diff --git a/docs/mint.json b/docs/mint.json index 121a07d..b8ee030 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -206,6 +206,15 @@ "pages": [ "tools/tools", "tools/langchain_tools", + { + "group": "External Tools", + "icon": "subscript", + "pages": [ + "tools/external/serp-api", + "tools/external/brave-search", + "tools/external/google-trends" + ] + }, "tools/duckduckgo_tools", "tools/arxiv_tools", "tools/calculator_tools", diff --git a/docs/tools/external/brave-search.mdx b/docs/tools/external/brave-search.mdx new file mode 100644 index 0000000..76c20b0 --- /dev/null +++ b/docs/tools/external/brave-search.mdx @@ -0,0 +1,38 @@ +--- +title: "BraveSearch Tool" +description: "Guide for using the BraveSearch tool with PraisonAI agents." +icon: "magnifying-glass" +--- + +## Overview + +The BraveSearch tool is a tool that allows you to search the web using the BraveSearch API. + +```bash +pip install langchain-community google-search-results +``` + +```bash +export BRAVE_SEARCH_API=your_api_key_here +export OPENAI_API_KEY=your_api_key_here +``` + +```python +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() +``` + +Generate your BraveSearch API key from [BraveSearch](https://brave.com/search/api/) \ No newline at end of file diff --git a/docs/tools/external/google-trends.mdx b/docs/tools/external/google-trends.mdx index 36842c2..f14faae 100644 --- a/docs/tools/external/google-trends.mdx +++ b/docs/tools/external/google-trends.mdx @@ -1,29 +1,34 @@ +--- +title: "Google Trends Tool" +description: "Guide for using the Google Trends tool with PraisonAI agents." +icon: "arrow-trend-up" +--- +## Overview + +The Google Trends tool is a tool that allows you to search the web using the Google Trends API. + +```bash +pip install langchain-community google-search-results +``` + +```bash +export SERPAPI_API_KEY=your_api_key_here +``` ```python -import os -from langchain_community.tools.google_trends import GoogleTrendsQueryRun from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper from praisonaiagents import Agent, PraisonAIAgents -# Set your SerpApi API Key -os.environ["SERPAPI_API_KEY"] = "your_serpapi_key_here" - -# Initialize the Google Trends API Wrapper and Tool -google_trends_api_wrapper = GoogleTrendsAPIWrapper() -google_trends_tool = GoogleTrendsQueryRun(api_wrapper=google_trends_api_wrapper) - -# Define your agents with appropriate tools research_agent = Agent( instructions="Research trending topics related to AI", - tools=[google_trends_tool] + tools=[GoogleTrendsAPIWrapper] ) summarise_agent = Agent( instructions="Summarise findings from the research agent", ) -# Instantiate and start your PraisonAIAgents agents = PraisonAIAgents(agents=[research_agent, summarise_agent]) agents.start() ``` \ No newline at end of file diff --git a/docs/tools/external/serp-api.mdx b/docs/tools/external/serp-api.mdx new file mode 100644 index 0000000..93d2836 --- /dev/null +++ b/docs/tools/external/serp-api.mdx @@ -0,0 +1,26 @@ +--- +title: "SerpAPI Tool" +description: "Guide for using the SerpAPI tool with PraisonAI agents." +icon: "searchengin" +--- + +## Overview + +The SerpAPI tool is a tool that allows you to search the web using the SerpAPI. + +```bash +pip install langchain-community google-search-results +export SERPAPI_API_KEY=your_api_key_here +export OPENAI_API_KEY=your_api_key_here +``` + +```python +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() +``` \ No newline at end of file diff --git a/docs/tools/langchain_tools.mdx b/docs/tools/langchain_tools.mdx index 26d6e37..a9cf6bc 100644 --- a/docs/tools/langchain_tools.mdx +++ b/docs/tools/langchain_tools.mdx @@ -7,6 +7,217 @@ icon: "link-simple" ## Quick Start + + + + + First, install the required packages: + ```bash + pip install praisonaiagents langchain-community wikipedia youtube-search + ``` + + + + Set your OpenAI API key as an environment variable in your terminal: + ```bash + export OPENAI_API_KEY=your_api_key_here + ``` + + + + Create a new file `app.py` with the basic setup: + + ```python Single Tool +from praisonaiagents import Agent +from langchain_community.utilities import WikipediaAPIWrapper + +wiki_agent = Agent( + instructions="You are a wikipedia research Agent", + tools=[WikipediaAPIWrapper] +) + +wiki_agent.start("Research 'Artificial Intelligence' on Wikipedia") +``` + +```python Multiple Tools +from praisonaiagents import Agent, PraisonAIAgents +from langchain_community.utilities import WikipediaAPIWrapper +from langchain_community.tools import YouTubeSearchTool + +youtube_agent = Agent( + instructions="Search for information about 'AI advancements' on YouTube", + tools=[YouTubeSearchTool] +) + +wiki_agent = Agent( + instructions="Research 'Artificial Intelligence' on Wikipedia", + tools=[WikipediaAPIWrapper] +) + +agents = PraisonAIAgents(agents=[youtube_agent, wiki_agent]) +agents.start() +``` + + + + + Type this in your terminal to run your agents: + ```bash + python app.py + ``` + + + + + + + (Upcoming Feature) + Install the PraisonAI package: + ```bash + pip install "praisonai" + ``` + + + Set your OpenAI API key as an environment variable in your terminal: + ```bash + export OPENAI_API_KEY=your_api_key_here + ``` + + + Create a new file `agents.yaml` with the basic setup: +```yaml +framework: praisonai +process: sequential +roles: + researcher: + name: SearchAgent + role: Research Assistant + goal: Search for information from multiple sources + backstory: I am an AI assistant that can search YouTube and Wikipedia. + tools: + - youtube_search + - wikipedia + tasks: + search_task: + name: search_task + description: Search for information about 'AI advancements' on both YouTube and Wikipedia + expected_output: Combined information from YouTube videos and Wikipedia articles +``` + + + Type this in your terminal to run your agents: +```bash +praisonai agents.yaml +``` + + + + + + + **Requirements** + - Python 3.10 or higher + - OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys) + - LangChain compatible tools and utilities + + +## Understanding LangChain Integration + + + LangChain integration enables agents to: + - Use LangChain's extensive tool ecosystem + - Access various data sources and APIs + - Leverage pre-built utilities and wrappers + - Combine multiple tools in a single agent + - Extend agent capabilities with community tools + + +## Features + + + + Seamlessly use LangChain tools with PraisonAI agents. + + + Access various data sources through LangChain utilities. + + + Leverage the extensive LangChain community ecosystem. + + + Create and integrate custom LangChain tools. + + + +## LangChain Tools with Wrappers + + + - LangChain tools with wrappers can be directly used as Tools without modification. + - PraisonAI will automatically detect the tool and use it. + - Some exceptions apply where it doesn't work. + + +### Example Wrapper Usage + +```bash +pip install langchain-community google-search-results +export SERPAPI_API_KEY=your_api_key_here +export OPENAI_API_KEY=your_api_key_here +``` + +```python +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() +``` + +### Example without Wrapper Usage + +```bash +pip install langchain-community +export BRAVE_SEARCH_API=your_api_key_here +export OPENAI_API_KEY=your_api_key_here +``` + +```python +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() +``` + +## Next Steps + + + + Learn how to combine LangChain tools with agent memory + + + Create your own custom tools for agents + + + + + For optimal results, ensure all required dependencies are installed and API keys are properly configured for each tool. + + +## With More Detailed Instructions + @@ -164,56 +375,4 @@ praisonai agents.yaml - - - - **Requirements** - - Python 3.10 or higher - - OpenAI API key. Generate OpenAI API key [here](https://platform.openai.com/api-keys) - - LangChain compatible tools and utilities - - -## Understanding LangChain Integration - - - LangChain integration enables agents to: - - Use LangChain's extensive tool ecosystem - - Access various data sources and APIs - - Leverage pre-built utilities and wrappers - - Combine multiple tools in a single agent - - Extend agent capabilities with community tools - - -## Features - - - - Seamlessly use LangChain tools with PraisonAI agents. - - - Access various data sources through LangChain utilities. - - - Leverage the extensive LangChain community ecosystem. - - - Create and integrate custom LangChain tools. - - - - - -## Next Steps - - - - Learn how to combine LangChain tools with agent memory - - - Create your own custom tools for agents - - - - - For optimal results, ensure all required dependencies are installed and API keys are properly configured for each tool. - + \ No newline at end of file