Skip to content

Commit

Permalink
Add Langchain external search tool examples for PraisonAI agents
Browse files Browse the repository at this point in the history
- Introduced example scripts for Brave Search, Google Trends, and SerpAPI
- Demonstrated multi-agent workflows using external search tools
- Added API key configuration instructions for each search tool
- Included examples of research and content generation agents using search capabilities
  • Loading branch information
MervinPraison committed Mar 10, 2025
1 parent 401c068 commit 65dab1b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/tools/langchain/brave-search.py
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()
18 changes: 18 additions & 0 deletions examples/tools/langchain/google-trends.py
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()
12 changes: 12 additions & 0 deletions examples/tools/langchain/serp-api.py
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()

0 comments on commit 65dab1b

Please sign in to comment.