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-agent
Install dependencies using Poetry:
poetry install --no-root
Set up environment variables: Create a
.env
file 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_here
Usage
Activate the Poetry shell:
poetry shell
Run the agent:
poetry run python main.py
Send 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.log
file.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?