Build & Monitor a Web Search Agent
A powerful web search agent built using SwarmZero framework that enables intelligent web searching capabilities.
Description
This agent utilizes the Tavily API for performing web searches and is built on top of the SwarmZero framework, providing enhanced search capabilities with AI-powered processing.
Prerequisites
Python 3.11 or higher
Poetry package manager
OpenAI API key
Installation
Clone the repository:
git clone https://github.com/swarmzero/examples.git
cd examples/agents/web-search-agentInstall dependencies using Poetry:
poetry install --no-rootSet up environment variables: Create a
.envfile in the root directory and add your API keys:
TAVILY_API_KEY=your_tavily_api_key_here
AGENTOPS_API_KEY=your_agentops_api_key_here
OPENAI_API_KEY=your_openai_api_key_hereUsage
Activate the Poetry shell:
poetry shellRun the agent:
poetry run python main.pySend a message to the agent:
curl -X 'POST' \
'http://localhost:8000/api/v1/chat' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'user_id=test_user' \
-F 'session_id=test_web_search_agent' \
-F 'chat_data={"messages":[{"role":"user","content":"what is swarmzero.ai about?"}]}'AgentOps will automatically capture the session:
View the auto-generated
agentops.logfile.See the AgentOps Dashboard
Dependencies
swarmzero: Main framework for agent developmentagentops: Agent operations and monitoringtavily-python: Web search API client
Learn more
Visit SwarmZero to learn more about the SwarmZero framework.
Last updated
Was this helpful?