Skip to content
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 search based tools using wikipedia, serper, serp, brave, exa, duckduckgo #412

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
workspace.code-workspace
.vscode
crewai
.cache
Expand Down
9 changes: 9 additions & 0 deletions docs/tools/external/duckduckgo-search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```python
from praisonaiagents import Agent, PraisonAIAgents
from praisonaiagents.tools import duckduckgo

data_agent = Agent(instructions="Search and Read Research Papers on DNA Mutation", tools=[duckduckgo])
editor_agent = Agent(instructions="Write a scientifically researched outcome and findings about DNA Mutation")
agents = PraisonAIAgents(agents=[data_agent, editor_agent])
agents.start()
```
19 changes: 19 additions & 0 deletions docs/tools/external/exa-search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```python
from praisonaiagents import Agent, PraisonAIAgents
from exa_py import Exa
import os

exa = Exa(api_key=os.environ["EXA_API_KEY"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

It's good to load the API key from the environment, but it's critical to handle the case where the EXA_API_KEY environment variable is not set. Without this, the program will crash. Consider adding a check to ensure the environment variable is set and provide a helpful error message if it's not.

exa_api_key = os.environ.get("EXA_API_KEY")
if not exa_api_key:
    raise ValueError("EXA_API_KEY environment variable not set.")
exa = Exa(api_key=exa_api_key)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asiffarhankhan there are few suggestions here. You could fix this may be in the next update. For now i will merge


def search_and_contents(query: str):
"""Search for webpages based on the query and retrieve their contents."""
# This combines two API endpoints: search and contents retrieval
return str(exa.search_and_contents(
query, use_autoprompt=False, num_results=5, text=True, highlights=True
))

data_agent = Agent(instructions="Find the latest jobs for Video Editor in New York at startups", tools=[search_and_contents])
editor_agent = Agent(instructions="Curate the available jobs at startups and their email for the candidate to apply based on his skills on Canva, Adobe Premiere Pro, and Adobe After Effects")
agents = PraisonAIAgents(agents=[data_agent, editor_agent], process='hierarchical')
agents.start()
```
17 changes: 17 additions & 0 deletions docs/tools/external/google-serper-search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```python
from praisonaiagents import Agent, PraisonAIAgents
from langchain_community.utilities import GoogleSerperAPIWrapper
import os
from dotenv import load_dotenv

load_dotenv()

os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There's an inconsistency in how the SERPER_API_KEY is being handled. You're setting it in os.environ but also getting it using os.getenv. It's better to stick to one approach. If you're using dotenv, you should only rely on os.getenv after calling load_dotenv().

# Load the environment variables
load_dotenv()

# Access the API key using os.getenv
os.environ['SERPER_API_KEY'] = os.getenv('SERPER_API_KEY')

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asiffarhankhan there are few suggestions here. You could fix this may be in the next update. For now i will merge


search = GoogleSerperAPIWrapper()

data_agent = Agent(instructions="Suggest me top 5 most visited websites for Dosa Recipe", tools=[search])
editor_agent = Agent(instructions="List out the websites with their url and a short description")
agents = PraisonAIAgents(agents=[data_agent, editor_agent])
agents.start()
```
9 changes: 9 additions & 0 deletions docs/tools/external/serp-search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```python
from praisonaiagents import Agent, PraisonAIAgents
from langchain_community.utilities import SerpAPIWrapper

data_agent = Agent(instructions="Search about decline of recruitment across various industries with the rise of AI", tools=[SerpAPIWrapper])
editor_agent = Agent(instructions="Write a blog article pointing out the jobs most at rish due to the rise of AI")
agents = PraisonAIAgents(agents=[data_agent, editor_agent])
agents.start()
```
9 changes: 9 additions & 0 deletions docs/tools/external/wikipedia-search.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```python
from praisonaiagents import Agent, PraisonAIAgents
from langchain_community.utilities import WikipediaAPIWrapper

data_agent = Agent(instructions="Gather all of Messi's record in LaLiga", tools=[WikipediaAPIWrapper])
summarise_agent = Agent(instructions="Summarize the data into a well structured format")
agents = PraisonAIAgents(agents=[data_agent, summarise_agent])
agents.start()
```
Loading