From b9c5211557908b167a060397e7791266ff12d08e Mon Sep 17 00:00:00 2001 From: asiffarhankhan Date: Tue, 11 Mar 2025 00:31:04 +0530 Subject: [PATCH 1/2] Add search based tools using wikipedia, serper, serp, brave, exa, duckduckgo --- .gitignore | 1 + docs/tools/external/brave-search.py | 14 ++++++++++++++ docs/tools/external/duckduckgo-search.py | 7 +++++++ docs/tools/external/exa-search.py | 17 +++++++++++++++++ docs/tools/external/google-serper-search.py | 15 +++++++++++++++ docs/tools/external/serp-search.py | 7 +++++++ docs/tools/external/wikipedia-search.py | 7 +++++++ 7 files changed, 68 insertions(+) create mode 100644 docs/tools/external/brave-search.py create mode 100644 docs/tools/external/duckduckgo-search.py create mode 100644 docs/tools/external/exa-search.py create mode 100644 docs/tools/external/google-serper-search.py create mode 100644 docs/tools/external/serp-search.py create mode 100644 docs/tools/external/wikipedia-search.py diff --git a/.gitignore b/.gitignore index 40f48671..c2faff72 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +workspace.code-workspace .vscode crewai .cache diff --git a/docs/tools/external/brave-search.py b/docs/tools/external/brave-search.py new file mode 100644 index 00000000..9caedfb6 --- /dev/null +++ b/docs/tools/external/brave-search.py @@ -0,0 +1,14 @@ +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 on ways to boost lead generation through Linkedin", tools=[search_brave]) +editor_agent = Agent(instructions="Layout a plan to use Linkedin as a Lead Generator tool") +agents = PraisonAIAgents(agents=[data_agent, editor_agent]) +agents.start() diff --git a/docs/tools/external/duckduckgo-search.py b/docs/tools/external/duckduckgo-search.py new file mode 100644 index 00000000..2f5f9703 --- /dev/null +++ b/docs/tools/external/duckduckgo-search.py @@ -0,0 +1,7 @@ +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() diff --git a/docs/tools/external/exa-search.py b/docs/tools/external/exa-search.py new file mode 100644 index 00000000..70720cd3 --- /dev/null +++ b/docs/tools/external/exa-search.py @@ -0,0 +1,17 @@ +from praisonaiagents import Agent, PraisonAIAgents +from exa_py import Exa +import os + +exa = Exa(api_key=os.environ["EXA_API_KEY"]) + +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() diff --git a/docs/tools/external/google-serper-search.py b/docs/tools/external/google-serper-search.py new file mode 100644 index 00000000..bf2f492c --- /dev/null +++ b/docs/tools/external/google-serper-search.py @@ -0,0 +1,15 @@ +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') + +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() \ No newline at end of file diff --git a/docs/tools/external/serp-search.py b/docs/tools/external/serp-search.py new file mode 100644 index 00000000..27840c0f --- /dev/null +++ b/docs/tools/external/serp-search.py @@ -0,0 +1,7 @@ +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() \ No newline at end of file diff --git a/docs/tools/external/wikipedia-search.py b/docs/tools/external/wikipedia-search.py new file mode 100644 index 00000000..c6b541cf --- /dev/null +++ b/docs/tools/external/wikipedia-search.py @@ -0,0 +1,7 @@ +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() From 0a8fbc8948764f28cc31555b0adfbd10874d7d1a Mon Sep 17 00:00:00 2001 From: asiffarhankhan Date: Tue, 11 Mar 2025 00:37:40 +0530 Subject: [PATCH 2/2] Align .py files with existing .mdx files --- docs/tools/external/brave-search.py | 14 -------------- ...{duckduckgo-search.py => duckduckgo-search.mdx} | 2 ++ .../external/{exa-search.py => exa-search.mdx} | 2 ++ ...e-serper-search.py => google-serper-search.mdx} | 4 +++- .../external/{serp-search.py => serp-search.mdx} | 4 +++- .../{wikipedia-search.py => wikipedia-search.mdx} | 2 ++ 6 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 docs/tools/external/brave-search.py rename docs/tools/external/{duckduckgo-search.py => duckduckgo-search.mdx} (96%) rename docs/tools/external/{exa-search.py => exa-search.mdx} (98%) rename docs/tools/external/{google-serper-search.py => google-serper-search.mdx} (95%) rename docs/tools/external/{serp-search.py => serp-search.mdx} (92%) rename docs/tools/external/{wikipedia-search.py => wikipedia-search.mdx} (96%) diff --git a/docs/tools/external/brave-search.py b/docs/tools/external/brave-search.py deleted file mode 100644 index 9caedfb6..00000000 --- a/docs/tools/external/brave-search.py +++ /dev/null @@ -1,14 +0,0 @@ -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 on ways to boost lead generation through Linkedin", tools=[search_brave]) -editor_agent = Agent(instructions="Layout a plan to use Linkedin as a Lead Generator tool") -agents = PraisonAIAgents(agents=[data_agent, editor_agent]) -agents.start() diff --git a/docs/tools/external/duckduckgo-search.py b/docs/tools/external/duckduckgo-search.mdx similarity index 96% rename from docs/tools/external/duckduckgo-search.py rename to docs/tools/external/duckduckgo-search.mdx index 2f5f9703..0596ce31 100644 --- a/docs/tools/external/duckduckgo-search.py +++ b/docs/tools/external/duckduckgo-search.mdx @@ -1,3 +1,4 @@ +```python from praisonaiagents import Agent, PraisonAIAgents from praisonaiagents.tools import duckduckgo @@ -5,3 +6,4 @@ editor_agent = Agent(instructions="Write a scientifically researched outcome and findings about DNA Mutation") agents = PraisonAIAgents(agents=[data_agent, editor_agent]) agents.start() +``` \ No newline at end of file diff --git a/docs/tools/external/exa-search.py b/docs/tools/external/exa-search.mdx similarity index 98% rename from docs/tools/external/exa-search.py rename to docs/tools/external/exa-search.mdx index 70720cd3..badc9718 100644 --- a/docs/tools/external/exa-search.py +++ b/docs/tools/external/exa-search.mdx @@ -1,3 +1,4 @@ +```python from praisonaiagents import Agent, PraisonAIAgents from exa_py import Exa import os @@ -15,3 +16,4 @@ def search_and_contents(query: str): 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() +``` \ No newline at end of file diff --git a/docs/tools/external/google-serper-search.py b/docs/tools/external/google-serper-search.mdx similarity index 95% rename from docs/tools/external/google-serper-search.py rename to docs/tools/external/google-serper-search.mdx index bf2f492c..f10cdfb0 100644 --- a/docs/tools/external/google-serper-search.py +++ b/docs/tools/external/google-serper-search.mdx @@ -1,3 +1,4 @@ +```python from praisonaiagents import Agent, PraisonAIAgents from langchain_community.utilities import GoogleSerperAPIWrapper import os @@ -12,4 +13,5 @@ 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() \ No newline at end of file +agents.start() +``` \ No newline at end of file diff --git a/docs/tools/external/serp-search.py b/docs/tools/external/serp-search.mdx similarity index 92% rename from docs/tools/external/serp-search.py rename to docs/tools/external/serp-search.mdx index 27840c0f..83fc2fc4 100644 --- a/docs/tools/external/serp-search.py +++ b/docs/tools/external/serp-search.mdx @@ -1,7 +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() \ No newline at end of file +agents.start() +``` \ No newline at end of file diff --git a/docs/tools/external/wikipedia-search.py b/docs/tools/external/wikipedia-search.mdx similarity index 96% rename from docs/tools/external/wikipedia-search.py rename to docs/tools/external/wikipedia-search.mdx index c6b541cf..3759ede1 100644 --- a/docs/tools/external/wikipedia-search.py +++ b/docs/tools/external/wikipedia-search.mdx @@ -1,3 +1,4 @@ +```python from praisonaiagents import Agent, PraisonAIAgents from langchain_community.utilities import WikipediaAPIWrapper @@ -5,3 +6,4 @@ summarise_agent = Agent(instructions="Summarize the data into a well structured format") agents = PraisonAIAgents(agents=[data_agent, summarise_agent]) agents.start() +``` \ No newline at end of file