-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #407 from MervinPraison/develop
Add Langchain external search tool examples for PraisonAI agents
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
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] | ||
) | ||
|
||
summarise_agent = Agent( | ||
instructions="Summarise findings from the research agent", | ||
) | ||
|
||
agents = PraisonAIAgents(agents=[research_agent, summarise_agent]) | ||
agents.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |