diff --git a/tools/perplexity/README.md b/tools/perplexity/README.md deleted file mode 100644 index 59628f17..00000000 --- a/tools/perplexity/README.md +++ /dev/null @@ -1,62 +0,0 @@ - -# Perplexity Tool Integration for Agents - -Use perplexity in your AI Agent to enrich it with data from the web. - -Full code example: - -```go -package main - -import ( - "context" - "fmt" - "os" - - "github.com/tmc/langchaingo/agents" - "github.com/tmc/langchaingo/callbacks" - "github.com/tmc/langchaingo/chains" - "github.com/tmc/langchaingo/llms/openai" - "github.com/tmc/langchaingo/tools" - "github.com/tmc/langchaingo/tools/perplexity" -) - -func main() { - if err := run(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func run() error { - llm, err := openai.New( - openai.WithModel("gpt-4o-mini"), - openai.WithCallback(callbacks.LogHandler{}), - ) - if err != nil { - return err - } - - perpl, err := perplexity.NewPerplexity(perplexity.ModelLlamaSonarSmall) - if err != nil { - return err - } - - agentTools := []tools.Tool{ - perpl, - } - - agent := agents.NewOneShotAgent(llm, - agentTools, - agents.WithMaxIterations(2), - ) - executor := agents.NewExecutor(agent) - - question := "what's the latest and best LLM on the market at the moment?" - answer, err := chains.Run(context.Background(), executor, question) - - fmt.Println(answer) - - return err -} -``` \ No newline at end of file diff --git a/tools/perplexity/doc.go b/tools/perplexity/doc.go new file mode 100644 index 00000000..368c465d --- /dev/null +++ b/tools/perplexity/doc.go @@ -0,0 +1,40 @@ +// 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.NewPerplexity( +// 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 +// agent := agents.NewOneShotAgent(llm, +// agentTools, +// agents.WithMaxIterations(2), +// ) +// executor := agents.NewExecutor(agent) +// +// answer, err := chains.Run(context.Background(), executor, "your question here") +package perplexity