-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Langchain external search tool examples for PraisonAI agents #407
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# pip install langchain-community | ||
# export BRAVE_SEARCH_API=your_api_key_here | ||
# export OPENAI_API_KEY=your_api_key_here | ||
|
||
from praisonaiagents import Agent, PraisonAIAgents | ||
from langchain_community.tools import BraveSearch | ||
import os | ||
|
||
def search_brave(query: str): | ||
"""Searches using BraveSearch and returns results.""" | ||
api_key = os.environ['BRAVE_SEARCH_API'] | ||
tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={"count": 3}) | ||
return tool.run(query) | ||
|
||
data_agent = Agent(instructions="Search about AI job trends in 2025", tools=[search_brave]) | ||
editor_agent = Agent(instructions="Write a blog article") | ||
agents = PraisonAIAgents(agents=[data_agent, editor_agent]) | ||
agents.start() |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||
# pip install langchain-community google-search-results | ||||||||||||||||||||||||||
# export SERPAPI_API_KEY=your_api_key_here | ||||||||||||||||||||||||||
# export OPENAI_API_KEY=your_api_key_here | ||||||||||||||||||||||||||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's good to include the installation and environment variable setup instructions, but it's missing instructions on how to obtain the
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper | ||||||||||||||||||||||||||
from praisonaiagents import Agent, PraisonAIAgents | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
research_agent = Agent( | ||||||||||||||||||||||||||
instructions="Research trending topics related to AI", | ||||||||||||||||||||||||||
tools=[GoogleTrendsAPIWrapper] | ||||||||||||||||||||||||||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with the other examples (
Suggested change
|
||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
summarise_agent = Agent( | ||||||||||||||||||||||||||
instructions="Summarise findings from the research agent", | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
agents = PraisonAIAgents(agents=[research_agent, summarise_agent]) | ||||||||||||||||||||||||||
agents.start() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# pip install langchain-community google-search-results | ||
# export SERPAPI_API_KEY=your_api_key_here | ||
# export OPENAI_API_KEY=your_api_key_here | ||
|
||
from praisonaiagents import Agent, PraisonAIAgents | ||
from langchain_community.utilities import SerpAPIWrapper | ||
|
||
data_agent = Agent(instructions="Search about AI job trends in 2025", tools=[SerpAPIWrapper]) | ||
editor_agent = Agent(instructions="Write a blog article") | ||
|
||
agents = PraisonAIAgents(agents=[data_agent, editor_agent]) | ||
agents.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling to check if the
BRAVE_SEARCH_API
environment variable is set. If it's not set, the program will crash. You can useos.getenv
with a default value or raise an exception with a helpful message.