Building AI agents, atomically
More renaming & consistency
KennyVaneetveldeed34478210ce
diff --git a/atomic_agents/lib/tools/search/searx_tool.py b/atomic_agents/lib/tools/search/searxng_tool.pysimilarity index 100%rename from atomic_agents/lib/tools/search/searx_tool.pyrename to atomic_agents/lib/tools/search/searxng_tool.pydiff --git a/examples/deep_research_multi_agent/agents/info_refiner_agent.py b/examples/deep_research_multi_agent/agents/info_refiner_agent.pyindex 1f67ee0..16c6ae8 100644--- a/examples/deep_research_multi_agent/agents/info_refiner_agent.py+++ b/examples/deep_research_multi_agent/agents/info_refiner_agent.py@@ -3,7 +3,7 @@ from atomic_agents.agents.base_agent import BaseIOSchemaimport instructorimport openaifrom atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptInfo+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGeneratorclass RefineAnswerInputSchema(BaseIOSchema):question: str = Field(..., description='The question that was asked.')@@ -18,23 +18,21 @@ refine_answer_agent = BaseAgent(client=instructor.from_openai(openai.OpenAI()),model='gpt-3.5-turbo',system_prompt_generator=SystemPromptGenerator(- SystemPromptInfo(- background=[- "You are an intelligent answer refinement expert.",- "Your task is to expand and elaborate on an existing answer to a question using additional context from vector DB chunks."- ],- steps=[- "You will receive a question or instruction, the initial answer, and additional context from vector DB chunks.",- "Correct any inaccuracies and factual errors in the initial answer.",- "Expand and elaborate on the initial answer using the additional context to provide a more comprehensive and detailed response."- ],- output_instructions=[- "Ensure the refined answer is clear, concise, and well-structured.",- "Ensure the refined answer is directly relevant to the question and incorporates the additional context provided.",- "Add new information and details to make the final answer more elaborate and informative.",- "Do not make up any new information; only use the information present in the context."- ]- )+ background=[+ "You are an intelligent answer refinement expert.",+ "Your task is to expand and elaborate on an existing answer to a question using additional context from vector DB chunks."+ ],+ steps=[+ "You will receive a question or instruction, the initial answer, and additional context from vector DB chunks.",+ "Correct any inaccuracies and factual errors in the initial answer.",+ "Expand and elaborate on the initial answer using the additional context to provide a more comprehensive and detailed response."+ ],+ output_instructions=[+ "Ensure the refined answer is clear, concise, and well-structured.",+ "Ensure the refined answer is directly relevant to the question and incorporates the additional context provided.",+ "Add new information and details to make the final answer more elaborate and informative.",+ "Do not make up any new information; only use the information present in the context."+ ]),input_schema=RefineAnswerInputSchema,output_schema=RefineAnswerOutputSchemadiff --git a/examples/deep_research_multi_agent/agents/query_agent.py b/examples/deep_research_multi_agent/agents/query_agent.pyindex 8602289..7e06aa0 100644--- a/examples/deep_research_multi_agent/agents/query_agent.py+++ b/examples/deep_research_multi_agent/agents/query_agent.py@@ -1,8 +1,8 @@import instructorimport openaifrom atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfig-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptInfo-from atomic_agents.lib.tools.search.searx_tool import SearxNGTool+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator+from atomic_agents.lib.tools.search.searxng_tool import SearxNGToolclass QueryAgentInputSchema(BaseIOSchema):instruction: str = 'A detailed instruction or request to generate deep research queries for.'@@ -14,21 +14,19 @@ query_agent = BaseAgent(client=instructor.from_openai(openai.OpenAI()),model='gpt-3.5-turbo',system_prompt_generator=SystemPromptGenerator(- SystemPromptInfo(- background=[- "You are an intelligent query generation expert.",- "Your task is to generate a specified number of diverse and highly relevant queries based on a given instruction or request.",- "The queries should cover different aspects of the instruction to ensure comprehensive exploration."- ],- steps=[- "You will receive a detailed instruction or request and the number of queries to generate.",- "Generate the requested number of queries in a JSON format."- ],- output_instructions=[- "Ensure clarity and conciseness in each query.",- "Ensure each query is unique and as diverse as possible while remaining relevant to the instruction."- ]- )+ background=[+ "You are an intelligent query generation expert.",+ "Your task is to generate a specified number of diverse and highly relevant queries based on a given instruction or request.",+ "The queries should cover different aspects of the instruction to ensure comprehensive exploration."+ ],+ steps=[+ "You will receive a detailed instruction or request and the number of queries to generate.",+ "Generate the requested number of queries in a JSON format."+ ],+ output_instructions=[+ "Ensure clarity and conciseness in each query.",+ "Ensure each query is unique and as diverse as possible while remaining relevant to the instruction."+ ]),input_schema=QueryAgentInputSchema,output_schema=SearxNGTool.input_schemadiff --git a/examples/deep_research_multi_agent/agents/question_answering_agent.py b/examples/deep_research_multi_agent/agents/question_answering_agent.pyindex d02fc2e..2f5ab30 100644--- a/examples/deep_research_multi_agent/agents/question_answering_agent.py+++ b/examples/deep_research_multi_agent/agents/question_answering_agent.py@@ -2,7 +2,7 @@ import instructorimport openaifrom pydantic import BaseModel, Fieldfrom atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfig-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptInfo+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGeneratorclass AnswerAgentInputSchema(BaseIOSchema):question: str = Field(..., description='A question that needs to be answered based on the provided context.')@@ -16,20 +16,18 @@ answer_agent = BaseAgent(client=instructor.from_openai(openai.OpenAI()),model='gpt-3.5-turbo',system_prompt_generator=SystemPromptGenerator(- SystemPromptInfo(- background=[- "You are an intelligent answering expert.",- "Your task is to provide accurate and detailed answers to user questions based on the given context."- ],- steps=[- "You will receive a question and the context information.",- "Generate a detailed and accurate answer based on the context."- ],- output_instructions=[- "Ensure clarity and conciseness in each answer.",- "Ensure the answer is directly relevant to the question and context provided."- ]- )+ background=[+ "You are an intelligent answering expert.",+ "Your task is to provide accurate and detailed answers to user questions based on the given context."+ ],+ steps=[+ "You will receive a question and the context information.",+ "Generate a detailed and accurate answer based on the context."+ ],+ output_instructions=[+ "Ensure clarity and conciseness in each answer.",+ "Ensure the answer is directly relevant to the question and context provided."+ ]),input_schema=AnswerAgentInputSchema,output_schema=AnswerAgentOutputSchemadiff --git a/examples/deep_research_multi_agent/agents/top_urls_selector_agent.py b/examples/deep_research_multi_agent/agents/top_urls_selector_agent.pyindex 72236c0..371f483 100644--- a/examples/deep_research_multi_agent/agents/top_urls_selector_agent.py+++ b/examples/deep_research_multi_agent/agents/top_urls_selector_agent.py@@ -1,9 +1,9 @@from typing import Listimport instructorimport openai-from pydantic import BaseModel, Field, HttpUrl+from pydantic import Field, HttpUrlfrom atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfig-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptInfo+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGeneratorclass TopUrlsSelectorInputSchema(BaseIOSchema):user_input: str = Field(..., description='The user input or question.')@@ -18,20 +18,18 @@ top_urls_selector_agent = BaseAgent(client=instructor.from_openai(openai.OpenAI()),model='gpt-3.5-turbo',system_prompt_generator=SystemPromptGenerator(- SystemPromptInfo(- background=[- "You are an intelligent URL selection expert.",- "Your task is to select the best URLs from a list of search results that are most relevant to the user input or question."- ],- steps=[- "You will receive the user input or question, the list of search results, and the number of best URLs to select.",- "Analyze the search results and select the best URLs that are most relevant to the user input or question.",- ],- output_instructions=[- "Ensure each selected URL is highly relevant to the user input or question.",- "Ensure the selected URLs are diverse yet as relevant as possible."- ]- )+ background=[+ "You are an intelligent URL selection expert.",+ "Your task is to select the best URLs from a list of search results that are most relevant to the user input or question."+ ],+ steps=[+ "You will receive the user input or question, the list of search results, and the number of best URLs to select.",+ "Analyze the search results and select the best URLs that are most relevant to the user input or question.",+ ],+ output_instructions=[+ "Ensure each selected URL is highly relevant to the user input or question.",+ "Ensure the selected URLs are diverse yet as relevant as possible."+ ]),input_schema=TopUrlsSelectorInputSchema,output_schema=TopUrlsSelectorOutputSchemadiff --git a/examples/deep_research_multi_agent/main.py b/examples/deep_research_multi_agent/main.pyindex fb2d226..5df5d89 100644--- a/examples/deep_research_multi_agent/main.py+++ b/examples/deep_research_multi_agent/main.py@@ -5,7 +5,7 @@ from examples.deep_research_multi_agent.agents.top_urls_selector_agent import tofrom examples.deep_research_multi_agent.agents.info_refiner_agent import refine_answer_agentfrom examples.deep_research_multi_agent.providers import search_results_provider, vector_db_chunks_providerfrom examples.deep_research_multi_agent.in_memory_faiss import InMemFaiss-from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig+from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfigfrom rich.console import Consoleimport asynciodiff --git a/examples/mesop_example.py b/examples/mesop_example.pyindex ab31950..ce9a3bb 100644--- a/examples/mesop_example.py+++ b/examples/mesop_example.py@@ -16,29 +16,29 @@ import mesop.labs as melfrom dataclasses import fieldfrom atomic_agents.agents.tool_interface_agent import ToolInterfaceAgent, ToolInterfaceAgentConfig-from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig+from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfig# Initialize the console, client, and toolsconsole = Console()client = instructor.from_openai(openai.OpenAI())-def initialize_searx_tool():+def initialize_searxng_tool():base_url = os.getenv('SEARXNG_BASE_URL')config = SearxNGToolConfig(base_url=base_url, max_results=10)return SearxNGTool(config)-searx_tool = initialize_searx_tool()+searxng_tool = initialize_searxng_tool()-def initialize_agent(client, searx_tool):+def initialize_agent(client, searxng_tool):agent_config = ToolInterfaceAgentConfig(client=client,model='gpt-3.5-turbo',- tool_instance=searx_tool,+ tool_instance=searxng_tool,return_raw_output=False)return ToolInterfaceAgent(config=agent_config)-agent = initialize_agent(client, searx_tool)+agent = initialize_agent(client, searxng_tool)# Mesop state class@me.stateclassdiff --git a/examples/minimal_multi_agent_tool_use.py b/examples/minimal_multi_agent_tool_use.pyindex a097420..88d93c5 100644--- a/examples/minimal_multi_agent_tool_use.py+++ b/examples/minimal_multi_agent_tool_use.py@@ -6,15 +6,15 @@ from pydantic import create_modelfrom rich.console import Consolefrom atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfigfrom atomic_agents.agents.tool_interface_agent import ToolInterfaceAgent, ToolInterfaceAgentConfig-from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig+from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfigfrom atomic_agents.lib.tools.calculator_tool import CalculatorTool, CalculatorToolConfigconsole = Console()client = instructor.from_openai(openai.OpenAI())-searx_tool = SearxNGTool(SearxNGToolConfig(base_url=os.getenv('SEARXNG_BASE_URL'), max_results=10))+searxng_tool = SearxNGTool(SearxNGToolConfig(base_url=os.getenv('SEARXNG_BASE_URL'), max_results=10))calc_tool = CalculatorTool(CalculatorToolConfig())-search_agent_config = ToolInterfaceAgentConfig(client=client, model='gpt-3.5-turbo', tool_instance=searx_tool, return_raw_output=False)+search_agent_config = ToolInterfaceAgentConfig(client=client, model='gpt-3.5-turbo', tool_instance=searxng_tool, return_raw_output=False)calculator_agent_config = ToolInterfaceAgentConfig(client=client, model='gpt-3.5-turbo', tool_instance=calc_tool, return_raw_output=False)searx_agent = ToolInterfaceAgent(config=search_agent_config)calc_agent = ToolInterfaceAgent(config=calculator_agent_config)diff --git a/examples/notebooks/multi_agent_quickstart.ipynb b/examples/notebooks/multi_agent_quickstart.ipynbindex 8565f94..290cead 100644--- a/examples/notebooks/multi_agent_quickstart.ipynb+++ b/examples/notebooks/multi_agent_quickstart.ipynb@@ -67,7 +67,7 @@"from rich.console import Console\n","from atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfig\n","from atomic_agents.agents.tool_interface_agent import ToolInterfaceAgent, ToolInterfaceAgentConfig\n",- "from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig\n",+ "from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfig\n","from atomic_agents.lib.tools.calculator_tool import CalculatorTool, CalculatorToolConfig"]},@@ -93,7 +93,7 @@"client = instructor.from_openai(openai.OpenAI())\n","\n","# Initialize the SearxNG search tool\n",- "searx_tool = SearxNGTool(SearxNGToolConfig(base_url=os.getenv('SEARXNG_BASE_URL'), max_results=10))\n",+ "searxng_tool = SearxNGTool(SearxNGToolConfig(base_url=os.getenv('SEARXNG_BASE_URL'), max_results=10))\n","\n","# Initialize the calculator tool\n","calc_tool = CalculatorTool(CalculatorToolConfig())"@@ -115,7 +115,7 @@"outputs": [],"source": ["# Configure the search agent\n",- "search_agent_config = ToolInterfaceAgentConfig(client=client, model='gpt-3.5-turbo', tool_instance=searx_tool, return_raw_output=False)\n",+ "search_agent_config = ToolInterfaceAgentConfig(client=client, model='gpt-3.5-turbo', tool_instance=searxng_tool, return_raw_output=False)\n","\n","# Configure the calculator agent\n","calculator_agent_config = ToolInterfaceAgentConfig(client=client, model='gpt-3.5-turbo', tool_instance=calc_tool, return_raw_output=False)\n",diff --git a/examples/notebooks/what_is_atomic_agents.ipynb b/examples/notebooks/what_is_atomic_agents.ipynbindex 5834459..6e17cdc 100644--- a/examples/notebooks/what_is_atomic_agents.ipynb+++ b/examples/notebooks/what_is_atomic_agents.ipynb@@ -603,9 +603,9 @@"from rich.console import Console\n","\n","from atomic_agents.agents.tool_interface_agent import ToolInterfaceAgent, ToolInterfaceAgentConfig\n",- "from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig\n",+ "from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfig\n","\n",- "def initialize_searx_tool():\n",+ "def initialize_searxng_tool():\n"," \"\"\"\n"," Initialize the SearxNGTool with configuration.\n"," \"\"\"\n",@@ -613,14 +613,14 @@" config = SearxNGToolConfig(base_url=base_url, max_results=10)\n"," return SearxNGTool(config)\n","\n",- "def initialize_agent(client, searx_tool):\n",+ "def initialize_agent(client, searxng_tool):\n"," \"\"\"\n"," Initialize the ToolInterfaceAgent with the given client and SearxNGTool.\n"," \"\"\"\n"," agent_config = ToolInterfaceAgentConfig(\n"," client=client,\n"," model='gpt-3.5-turbo',\n",- " tool_instance=searx_tool,\n",+ " tool_instance=searxng_tool,\n"," return_raw_output=False\n"," )\n"," return ToolInterfaceAgent(config=agent_config)\n",@@ -632,8 +632,8 @@" base_url='http://localhost:1234/v1'\n"," )\n"," )\n",- " searx_tool = initialize_searx_tool()\n",- " agent = initialize_agent(client, searx_tool)\n",+ " searxng_tool = initialize_searxng_tool()\n",+ " agent = initialize_agent(client, searxng_tool)\n","\n"," console.print(\"ToolInterfaceAgent with SearxNGTool is ready.\")\n","\n",diff --git a/examples/product_finder.py b/examples/product_finder.pyindex 66f838e..8e8b464 100644--- a/examples/product_finder.py+++ b/examples/product_finder.py@@ -9,7 +9,7 @@ from rich.console import Consolefrom atomic_agents.lib.components.agent_memory import AgentMemoryfrom atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptInfofrom atomic_agents.agents.base_agent import BaseAgent, BaseAgentOutputSchema, BaseAgentConfig-from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig, SearxNGToolInputSchema+from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfig, SearxNGToolInputSchema# Configure logginglogging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')@@ -50,7 +50,7 @@ console = Console()client = instructor.from_openai(openai.OpenAI())# Initialize the SearxNGTool-searx_tool = SearxNGTool(SearxNGToolConfig(base_url=os.getenv('SEARXNG_BASE_URL'), max_results=5))+searxng_tool = SearxNGTool(SearxNGToolConfig(base_url=os.getenv('SEARXNG_BASE_URL'), max_results=5))# Define a custom response schemaclass OutputSchema(BaseModel):@@ -86,7 +86,7 @@ while True:logger.info(f'Chosen schema: {response.chosen_schema}')if isinstance(response.chosen_schema, SearxNGToolInputSchema):- search_results = searx_tool.run(response.chosen_schema)+ search_results = searxng_tool.run(response.chosen_schema)agent.memory.add_message('assistant', f'INTERNAL THOUGHT: I have found the following products: {search_results.results}\n\n I will now summarize the results for the user.')output = agent.run().chosen_schema.chat_messagediff --git a/examples/simple_web_search_agent.py b/examples/simple_web_search_agent.pyindex 92b012a..b4888b8 100644--- a/examples/simple_web_search_agent.py+++ b/examples/simple_web_search_agent.py@@ -5,9 +5,9 @@ import openaifrom rich.console import Consolefrom atomic_agents.agents.tool_interface_agent import ToolInterfaceAgent, ToolInterfaceAgentConfig-from atomic_agents.lib.tools.search.searx_tool import SearxNGTool, SearxNGToolConfig+from atomic_agents.lib.tools.search.searxng_tool import SearxNGTool, SearxNGToolConfig-def initialize_searx_tool():+def initialize_searxng_tool():"""Initialize the SearxNGTool with configuration."""@@ -15,14 +15,14 @@ def initialize_searx_tool():config = SearxNGToolConfig(base_url=base_url, max_results=10)return SearxNGTool(config)-def initialize_agent(client, searx_tool):+def initialize_agent(client, searxng_tool):"""Initialize the ToolInterfaceAgent with the given client and SearxNGTool."""agent_config = ToolInterfaceAgentConfig(client=client,model='gpt-3.5-turbo',- tool_instance=searx_tool,+ tool_instance=searxng_tool,return_raw_output=False)return ToolInterfaceAgent(config=agent_config)@@ -30,8 +30,8 @@ def initialize_agent(client, searx_tool):def main():console = Console()client = instructor.from_openai(openai.OpenAI())- searx_tool = initialize_searx_tool()- agent = initialize_agent(client, searx_tool)+ searxng_tool = initialize_searxng_tool()+ agent = initialize_agent(client, searxng_tool)console.print("ToolInterfaceAgent with SearxNGTool is ready.")diff --git a/examples/yelp_restaurant_finder.py b/examples/yelp_restaurant_finder.pyindex cb0d76f..692d6f4 100644--- a/examples/yelp_restaurant_finder.py+++ b/examples/yelp_restaurant_finder.py@@ -7,7 +7,7 @@ import openaifrom rich.console import Consolefrom atomic_agents.lib.components.agent_memory import AgentMemory-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptInfo+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGeneratorfrom atomic_agents.agents.base_agent import BaseAgent, BaseAgentOutputSchema, BaseAgentConfigfrom atomic_agents.lib.tools.yelp_restaurant_finder_tool import YelpSearchTool, YelpSearchToolConfig, YelpSearchToolInputSchema@@ -16,7 +16,7 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levellogger = logging.getLogger(__name__)# Define system prompt information including background, steps, and output instructions-system_prompt = SystemPromptInfo(+system_prompt_generator = SystemPromptGenerator(background=['This assistant is a restaurant finder AI designed to help users find the best restaurants based on their preferences by asking clarifying questions.',],@@ -34,9 +34,6 @@ system_prompt = SystemPromptInfo(])-# Initialize the system prompt generator with the defined system prompt and dynamic info providers-system_prompt_generator = SystemPromptGenerator(system_prompt)-# Initialize chat memory to store conversation historymemory = AgentMemory()# Define initial memory with a greeting message from the assistant