Skip to content

Commit

Permalink
Comment should end in a period
Browse files Browse the repository at this point in the history
  • Loading branch information
sklinkert committed Jan 6, 2025
1 parent bbd85f1 commit a9d2531
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tools/perplexity/perplexity.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,50 @@ import (
"github.com/tmc/langchaingo/tools"
)

// Model represents a Perplexity AI model type
// Model represents a Perplexity AI model type.
type Model string

// Model pricing overview: https://docs.perplexity.ai/guides/pricing
const (
// ModelLlamaSonarSmall is the small version of the Llama Sonar model
// ModelLlamaSonarSmall is the small version of the Llama Sonar model.
ModelLlamaSonarSmall Model = "llama-3.1-sonar-small-128k-online"
// ModelLlamaSonarLarge is the large version of the Llama Sonar model
// ModelLlamaSonarLarge is the large version of the Llama Sonar model.
ModelLlamaSonarLarge Model = "llama-3.1-sonar-large-128k-online"
// ModelLlamaSonarHuge is the huge version of the Llama Sonar model
// ModelLlamaSonarHuge is the huge version of the Llama Sonar model.
ModelLlamaSonarHuge Model = "llama-3.1-sonar-huge-128k-online"
)

// Option is a function that modifies the options for the Perplexity AI tool
// Option is a function that modifies the options for the Perplexity AI tool.
type Option func(*options)

type options struct {
apiKey string
model Model
}

// WithAPIKey sets the API key for Perplexity AI
// WithAPIKey sets the API key for Perplexity AI.
func WithAPIKey(apiKey string) Option {
return func(o *options) {
o.apiKey = apiKey
}
}

// WithModel sets the model to be used by Perplexity AI
// WithModel sets the model to be used by Perplexity AI.
func WithModel(model Model) Option {
return func(o *options) {
o.model = model
}
}

// Tool implements the Perplexity AI integration
// Tool implements the Perplexity AI integration.
type Tool struct {
llm *openai.LLM
CallbacksHandler callbacks.Handler
}

var _ tools.Tool = (*Tool)(nil)

// New creates a new instance of the Perplexity AI tool with the given options
// New creates a new instance of the Perplexity AI tool with the given options.
func New(opts ...Option) (*Tool, error) {
options := &options{
apiKey: os.Getenv("PERPLEXITY_API_KEY"),
Expand Down Expand Up @@ -83,17 +83,17 @@ func New(opts ...Option) (*Tool, error) {
}, nil
}

// Name returns the name of the tool
// Name returns the name of the tool.
func (t *Tool) Name() string {
return "PerplexityAI"
}

// Description returns a description of the Perplexity AI tool's capabilities
// Description returns a description of the Perplexity AI tool's capabilities.
func (t *Tool) Description() string {
return "Perplexity AI has access to a wide range of information, as it functions as an AI-powered search engine that indexes, analyzes, and summarizes content from across the internet."
}

// Call executes a query against the Perplexity AI model and returns the response
// Call executes a query against the Perplexity AI model and returns the response.
func (t *Tool) Call(ctx context.Context, input string) (string, error) {
if t.CallbacksHandler != nil {
t.CallbacksHandler.HandleToolStart(ctx, input)
Expand Down

0 comments on commit a9d2531

Please sign in to comment.