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