Skip to content

Commit f431347

Browse files
Merge pull request MervinPraison#407 from MervinPraison/develop
Add Langchain external search tool examples for PraisonAI agents
2 parents b40295e + e0725c1 commit f431347

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# pip install langchain-community
2+
# export BRAVE_SEARCH_API=your_api_key_here
3+
# export OPENAI_API_KEY=your_api_key_here
4+
5+
from praisonaiagents import Agent, PraisonAIAgents
6+
from langchain_community.tools import BraveSearch
7+
import os
8+
9+
def search_brave(query: str):
10+
"""Searches using BraveSearch and returns results."""
11+
api_key = os.environ['BRAVE_SEARCH_API']
12+
tool = BraveSearch.from_api_key(api_key=api_key, search_kwargs={"count": 3})
13+
return tool.run(query)
14+
15+
data_agent = Agent(instructions="Search about AI job trends in 2025", tools=[search_brave])
16+
editor_agent = Agent(instructions="Write a blog article")
17+
agents = PraisonAIAgents(agents=[data_agent, editor_agent])
18+
agents.start()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# pip install langchain-community google-search-results
2+
# export SERPAPI_API_KEY=your_api_key_here
3+
# export OPENAI_API_KEY=your_api_key_here
4+
5+
from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper
6+
from praisonaiagents import Agent, PraisonAIAgents
7+
8+
research_agent = Agent(
9+
instructions="Research trending topics related to AI",
10+
tools=[GoogleTrendsAPIWrapper]
11+
)
12+
13+
summarise_agent = Agent(
14+
instructions="Summarise findings from the research agent",
15+
)
16+
17+
agents = PraisonAIAgents(agents=[research_agent, summarise_agent])
18+
agents.start()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# pip install langchain-community google-search-results
2+
# export SERPAPI_API_KEY=your_api_key_here
3+
# export OPENAI_API_KEY=your_api_key_here
4+
5+
from praisonaiagents import Agent, PraisonAIAgents
6+
from langchain_community.utilities import SerpAPIWrapper
7+
8+
data_agent = Agent(instructions="Search about AI job trends in 2025", tools=[SerpAPIWrapper])
9+
editor_agent = Agent(instructions="Write a blog article")
10+
11+
agents = PraisonAIAgents(agents=[data_agent, editor_agent])
12+
agents.start()

0 commit comments

Comments
 (0)