Spaces:
Sleeping
Sleeping
File size: 4,026 Bytes
15434c9 951bfef 15434c9 1684ac5 15434c9 d445f2a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
---
title: Web Research Agent
emoji: π
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "5.26.0"
app_file: app.py
pinned: false
python_version: "3.11"
---
# Web Research Agent
A powerful AI research assistant built with CrewAI that conducts comprehensive web research on any topic, providing factual, cited responses through a multi-agent approach.
## Overview
This application uses specialized AI agents working together to:
1. Refine search queries for optimal results
2. Search the web across multiple search engines
3. Analyze and verify content
4. Produce well-structured, factual responses with proper citations
## Setup Instructions
### Prerequisites
- Python 3.9+ (recommended: Python 3.11)
- API keys for:
- OpenAI (required)
- Brave Search (recommended)
- Tavily Search (optional)
### Installation
1. Clone the repository and navigate to the project directory:
```bash
git clone https://github.com/yourusername/web-research-agent.git
cd web-research-agent
```
2. Install required dependencies:
```bash
pip install -r requirements.txt
```
3. Create a `.env` file in the root directory with your API keys:
```
OPENAI_API_KEY=your_openai_api_key
BRAVE_API_KEY=your_brave_api_key
TAVILY_API_KEY=your_tavily_api_key
VERBOSE=False # Set to True for detailed logging
```
### Running the Application
Start the web interface:
```bash
python app.py
```
The application will be available at http://localhost:7860
## Common Issues & Troubleshooting
### Pydantic/CrewAI Compatibility Issues
If you encounter errors like:
```
AttributeError: 'property' object has no attribute 'model_fields'
```
Try the following fixes:
1. Update to the latest CrewAI version:
```bash
pip install -U crewai crewai-tools
```
2. If issues persist, temporarily modify the `tools/rate_limited_tool.py` file to fix compatibility with Pydantic.
### Search API Rate Limits
- Brave Search API has a free tier limit of 1 request per minute and 2,000 requests per month
- The application implements rate limiting to prevent API throttling
- Research queries may take several minutes to complete due to these limitations
### Gradio Interface Issues
If the interface fails to load or throws errors:
1. Try installing a specific Gradio version:
```bash
pip install gradio==4.26.0
```
2. Clear your browser cache to remove cached JavaScript files
3. Run the headless test script as an alternative:
```bash
python test.py "Your research question"
```
## Advanced Usage
### Command Line Operation
Test the research engine without the web interface:
```
python test.py "Your research query here"
```
### Environment Variables
- `OPENAI_API_KEY`: Required for language model access
- `BRAVE_API_KEY`: Recommended for web search functionality
- `TAVILY_API_KEY`: Optional alternative search engine
- `VERBOSE`: Set to True/False to control logging detail
## Deployment
This project can be deployed to Hugging Face Spaces for web access.
### Hugging Face Spaces Deployment
1. **Create a new Space on Hugging Face**
- Go to [Hugging Face Spaces](https://huggingface.co/spaces)
- Click "Create new Space"
- Choose a name and select "Gradio" as the SDK
- Set visibility as needed
2. **Configure Environment Variables**
- In Space settings, add required API keys as secrets
3. **Deploy Code**
```bash
git clone https://huggingface.co/spaces/your-username/your-space-name
cd your-space-name
cp -r /path/to/web-research-agent/* .
git add .
git commit -m "Initial deployment"
git push
```
### Security Notes
- Never commit your `.env` file or expose API keys
- Use repository secrets in Hugging Face Spaces
- Keep sensitive deployments private
## Development Structure
- `app.py`: Web interface and session management
- `research_engine.py`: Core research orchestration logic
- `agents.py`: Agent definitions and configurations
- `tools/`: Search and analysis tools
- `test.py`: Command-line testing utility |