Documentation
¶
Overview ¶
Package perplexity provides integration with Perplexity AI's API for AI agents.
Perplexity AI functions as an AI-powered search engine that indexes, analyzes, and summarizes content from across the internet. This package allows you to integrate Perplexity's capabilities into your AI agents to enrich them with up-to-date web data.
Example usage:
llm, err := openai.New( openai.WithModel("gpt-4-mini"), openai.WithCallback(callbacks.LogHandler{}), ) if err != nil { return err } // Create a new Perplexity instance perpl, err := perplexity.New( perplexity.WithModel(perplexity.ModelLlamaSonarSmall), perplexity.WithAPIKey("your-api-key"), // Optional: defaults to PERPLEXITY_API_KEY env var ) if err != nil { return err } // Add Perplexity as a tool for your agent agentTools := []tools.Tool{ perpl, } // Create and use the agent toolAgent := agents.NewOneShotAgent(llm, agentTools, agents.WithMaxIterations(2), ) executor := agents.NewExecutor(toolAgent) answer, err := chains.Run(context.Background(), executor, "your question here")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model string
Model represents a Perplexity AI model type.
const ( // 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 Model = "llama-3.1-sonar-large-128k-online" // ModelLlamaSonarHuge is the huge version of the Llama Sonar model. ModelLlamaSonarHuge Model = "llama-3.1-sonar-huge-128k-online" )
Model pricing overview: https://docs.perplexity.ai/guides/pricing
type Option ¶
type Option func(*options)
Option is a function that modifies the options for the Perplexity AI tool.
func WithAPIKey ¶
WithAPIKey sets the API key for Perplexity AI.
type Tool ¶
Tool implements the Perplexity AI integration.
func (*Tool) Description ¶
Description returns a description of the Perplexity AI tool's capabilities.