Spaces:
Running
Running
Priyanshi Saxena
commited on
Commit
Β·
a33b0e1
1
Parent(s):
ea46ec8
docs: update README
Browse files
README.md
CHANGED
@@ -1,129 +1,385 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
##
|
14 |
|
15 |
-
###
|
16 |
|
17 |
```bash
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
```
|
22 |
|
23 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
```bash
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
```
|
28 |
|
29 |
-
|
|
|
|
|
30 |
|
31 |
```bash
|
32 |
-
python
|
33 |
```
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
##
|
42 |
|
43 |
```
|
44 |
-
|
45 |
-
βββ
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
```
|
52 |
|
53 |
-
##
|
54 |
|
55 |
-
|
56 |
-
- "Analyze Ethereum's DeFi ecosystem"
|
57 |
-
- "Show me gas prices and network stats"
|
58 |
-
- "Research the top DeFi protocols by TVL"
|
59 |
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
-
|
72 |
-
-
|
73 |
-
-
|
74 |
-
- **AIRAA Integration**: Webhook support for external platforms
|
75 |
|
76 |
-
|
|
|
|
|
|
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
```
|
84 |
|
85 |
-
|
86 |
-
```
|
87 |
-
|
88 |
-
# Edit .env with your API keys
|
89 |
```
|
90 |
|
91 |
-
|
92 |
-
```
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
94 |
```
|
95 |
|
96 |
-
##
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
|
|
|
|
102 |
|
103 |
-
|
104 |
|
105 |
-
### Docker
|
106 |
```bash
|
107 |
-
|
108 |
-
|
|
|
109 |
```
|
110 |
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
-
|
117 |
-
- **Tools**: Modular API integrations (CoinGecko, DeFiLlama, Etherscan)
|
118 |
-
- **UI**: Gradio interface with chat and visualization
|
119 |
-
- **Cache**: Optimized caching for API responses
|
120 |
-
- **Integration**: AIRAA webhook support
|
121 |
|
122 |
-
|
|
|
|
|
123 |
|
124 |
-
|
125 |
-
-
|
126 |
-
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
-
Built with β€οΈ for Web3
|
|
|
1 |
+
---
|
2 |
+
title: Web3 Research Co-Pilot
|
3 |
+
emoji: π
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
+
sdk: docker
|
7 |
+
sdk_version: "latest"
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
---
|
11 |
|
12 |
+
# Web3 Research Co-Pilot
|
13 |
+
|
14 |
+
A professional AI-powered cryptocurrency research assistant that provides real-time market analysis, DeFi intelligence, and blockchain insights through an elegant web interface.
|
15 |
+
|
16 |
+
π **Live Demo**: https://archcoder-web3-copilot.hf.space
|
17 |
+
|
18 |
+

|
19 |
+

|
20 |
+

|
21 |
+

|
22 |
+
|
23 |
+
## β¨ Features
|
24 |
+
|
25 |
+
- **AI-Powered Research**: Advanced LLM analysis using Google Gemini
|
26 |
+
- **Real-Time Data**: Live market data from CoinGecko, DeFiLlama, and Etherscan
|
27 |
+
- **Interactive Visualizations**: Dynamic charts and graphs powered by Plotly
|
28 |
+
- **Professional UI**: Minimalist, responsive web interface
|
29 |
+
- **Multi-Chain Support**: Ethereum, DeFi protocols, and Layer 2 solutions
|
30 |
+
- **Comprehensive Analytics**: Market trends, yield optimization, and risk assessment
|
31 |
+
|
32 |
+
## π Quick Start
|
33 |
+
|
34 |
+
### Prerequisites
|
35 |
+
|
36 |
+
- Python 3.11+
|
37 |
+
- Google Gemini API Key (required)
|
38 |
+
- Optional: CoinGecko API Key (for higher rate limits)
|
39 |
+
- Optional: Etherscan API Key (for blockchain data)
|
40 |
+
|
41 |
+
### Installation
|
42 |
+
|
43 |
+
1. **Clone the repository**
|
44 |
+
```bash
|
45 |
+
git clone https://github.com/Transcendental-Programmer/web3-research-agent.git
|
46 |
+
cd web3-research-agent
|
47 |
+
```
|
48 |
+
|
49 |
+
2. **Install dependencies**
|
50 |
+
```bash
|
51 |
+
pip install -r requirements.txt
|
52 |
+
```
|
53 |
+
|
54 |
+
3. **Set up environment variables**
|
55 |
+
|
56 |
+
Create a `.env` file in the project root:
|
57 |
+
```bash
|
58 |
+
cp .env.example .env
|
59 |
+
```
|
60 |
+
|
61 |
+
Edit `.env` with your API keys:
|
62 |
+
```properties
|
63 |
+
# Required
|
64 |
+
GEMINI_API_KEY=your_gemini_api_key_here
|
65 |
+
|
66 |
+
# Optional (for enhanced functionality)
|
67 |
+
COINGECKO_API_KEY=your_coingecko_api_key_here
|
68 |
+
ETHERSCAN_API_KEY=your_etherscan_api_key_here
|
69 |
+
```
|
70 |
+
|
71 |
+
4. **Run the application**
|
72 |
+
```bash
|
73 |
+
python app.py
|
74 |
+
```
|
75 |
+
|
76 |
+
5. **Access the interface**
|
77 |
+
- **Local Development**: http://localhost:7860
|
78 |
+
- **Production/Cloud**: Check your hosting platform's port forwarding
|
79 |
+
- **Docker**: http://localhost:7860
|
80 |
+
|
81 |
+
## π HuggingFace Spaces Deployment
|
82 |
+
|
83 |
+
This project is configured for HuggingFace Spaces deployment with Docker SDK.
|
84 |
+
|
85 |
+
### Quick Deploy to HF Spaces
|
86 |
+
|
87 |
+
1. **Fork/Clone this repository**
|
88 |
+
2. **Create a new HuggingFace Space**:
|
89 |
+
- Go to [HuggingFace Spaces](https://huggingface.co/spaces)
|
90 |
+
- Click "Create new Space"
|
91 |
+
- Choose "Docker" as the SDK
|
92 |
+
- Upload your repository files
|
93 |
+
|
94 |
+
3. **Configure Environment Variables**:
|
95 |
+
In your Space settings, add:
|
96 |
+
```
|
97 |
+
GEMINI_API_KEY=your_gemini_api_key
|
98 |
+
COINGECKO_API_KEY=your_coingecko_api_key
|
99 |
+
ETHERSCAN_API_KEY=your_etherscan_api_key
|
100 |
+
```
|
101 |
+
|
102 |
+
4. **Deploy via Git**:
|
103 |
+
```bash
|
104 |
+
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
105 |
+
git push hf main
|
106 |
+
```
|
107 |
+
|
108 |
+
### HF Spaces Configuration
|
109 |
+
|
110 |
+
The project includes a proper `README.md` header for HF Spaces:
|
111 |
+
```yaml
|
112 |
+
title: Web3 Research Co-Pilot
|
113 |
+
emoji: π
|
114 |
+
colorFrom: blue
|
115 |
+
colorTo: purple
|
116 |
+
sdk: docker
|
117 |
+
app_file: app.py
|
118 |
+
```
|
119 |
|
120 |
+
## π³ Docker Deployment
|
121 |
|
122 |
+
### Local Docker
|
123 |
|
124 |
```bash
|
125 |
+
# Build the image
|
126 |
+
docker build -t web3-research-copilot .
|
127 |
+
|
128 |
+
# Run the container
|
129 |
+
docker run -p 7860:7860 \
|
130 |
+
-e GEMINI_API_KEY=your_key_here \
|
131 |
+
-e COINGECKO_API_KEY=your_key_here \
|
132 |
+
-e ETHERSCAN_API_KEY=your_key_here \
|
133 |
+
web3-research-copilot
|
134 |
```
|
135 |
|
136 |
+
### HuggingFace Spaces
|
137 |
+
|
138 |
+
This project is optimized for HuggingFace Spaces deployment:
|
139 |
+
|
140 |
+
1. **Create a new Space**:
|
141 |
+
- Go to [HuggingFace Spaces](https://huggingface.co/spaces)
|
142 |
+
- Click "Create new Space"
|
143 |
+
- Choose "Docker" as the SDK
|
144 |
+
- Set visibility to "Public" or "Private"
|
145 |
+
|
146 |
+
2. **Configure Environment Variables**:
|
147 |
+
In your Space settings, add:
|
148 |
+
```
|
149 |
+
GEMINI_API_KEY=your_gemini_api_key
|
150 |
+
COINGECKO_API_KEY=your_coingecko_api_key
|
151 |
+
ETHERSCAN_API_KEY=your_etherscan_api_key
|
152 |
+
```
|
153 |
+
|
154 |
+
3. **Deploy**:
|
155 |
+
```bash
|
156 |
+
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
157 |
+
git push hf main
|
158 |
+
```
|
159 |
+
|
160 |
+
**Live Example**: https://archcoder-web3-copilot.hf.space
|
161 |
+
|
162 |
+
## π Development Setup
|
163 |
+
|
164 |
+
### Adding HuggingFace Remote
|
165 |
+
|
166 |
+
To deploy to your HuggingFace Space:
|
167 |
|
168 |
```bash
|
169 |
+
# Add HuggingFace remote
|
170 |
+
git remote add hf https://huggingface.co/spaces/ArchCoder/web3-copilot
|
171 |
+
|
172 |
+
# Or for your own space
|
173 |
+
git remote add hf https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
|
174 |
+
|
175 |
+
# Deploy to HF Spaces
|
176 |
+
git push hf main
|
177 |
```
|
178 |
|
179 |
+
## π Testing
|
180 |
+
|
181 |
+
Run the comprehensive test suite:
|
182 |
|
183 |
```bash
|
184 |
+
python test_suite.py
|
185 |
```
|
186 |
|
187 |
+
Expected output:
|
188 |
+
```
|
189 |
+
π Web3 Research Co-Pilot - Test Suite
|
190 |
+
==================================================
|
191 |
+
β
All imports successful
|
192 |
+
β
Configuration validated
|
193 |
+
β
Visualizations working
|
194 |
+
β
Tools initialized
|
195 |
+
β
Service functional
|
196 |
+
β
API endpoints healthy
|
197 |
+
β
Performance acceptable
|
198 |
+
|
199 |
+
Tests passed: 7/7
|
200 |
+
Success rate: 100.0%
|
201 |
+
π All tests passed!
|
202 |
+
```
|
203 |
|
204 |
+
## ποΈ Project Structure
|
205 |
|
206 |
```
|
207 |
+
web3-research-agent/
|
208 |
+
βββ app.py # Main FastAPI application
|
209 |
+
βββ requirements.txt # Python dependencies
|
210 |
+
βββ pyproject.toml # Project configuration
|
211 |
+
βββ uv.lock # Dependency lock file
|
212 |
+
βββ test_suite.py # Comprehensive test suite
|
213 |
+
βββ .env.example # Environment template
|
214 |
+
βββ src/ # Source code
|
215 |
+
β βββ __init__.py
|
216 |
+
β βββ research_agent.py # Main agent logic
|
217 |
+
β βββ enhanced_agent.py # Enhanced agent features
|
218 |
+
β βββ config.py # Configuration management
|
219 |
+
β βββ cache_manager.py # Response caching
|
220 |
+
β βββ api_clients.py # External API clients
|
221 |
+
β βββ defillama_client.py # DeFiLlama integration
|
222 |
+
β βββ news_aggregator.py # News and social data
|
223 |
+
β βββ portfolio_analyzer.py # Portfolio analysis
|
224 |
+
β βββ visualizations.py # Chart generation
|
225 |
+
βββ README.md # This file
|
226 |
```
|
227 |
|
228 |
+
## π§ Configuration
|
229 |
|
230 |
+
### Required Environment Variables
|
|
|
|
|
|
|
231 |
|
232 |
+
| Variable | Description | Required |
|
233 |
+
|----------|-------------|----------|
|
234 |
+
| `GEMINI_API_KEY` | Google Gemini API key for AI analysis | β
|
|
235 |
|
236 |
+
### Optional Environment Variables
|
237 |
|
238 |
+
| Variable | Description | Default |
|
239 |
+
|----------|-------------|---------|
|
240 |
+
| `COINGECKO_API_KEY` | CoinGecko API key for enhanced rate limits | None |
|
241 |
+
| `ETHERSCAN_API_KEY` | Etherscan API key for blockchain data | None |
|
242 |
+
| `AIRAA_WEBHOOK_URL` | AIRAA integration webhook URL | None |
|
243 |
+
| `AIRAA_API_KEY` | AIRAA API authentication key | None |
|
244 |
|
245 |
+
### Getting API Keys
|
246 |
|
247 |
+
1. **Google Gemini API**:
|
248 |
+
- Go to [Google AI Studio](https://aistudio.google.com/)
|
249 |
+
- Create a new API key
|
250 |
+
- Copy the key to your `.env` file
|
251 |
|
252 |
+
2. **CoinGecko API** (optional):
|
253 |
+
- Sign up at [CoinGecko](https://www.coingecko.com/api)
|
254 |
+
- Get your free API key
|
255 |
+
- Provides higher rate limits
|
|
|
256 |
|
257 |
+
3. **Etherscan API** (optional):
|
258 |
+
- Register at [Etherscan](https://etherscan.io/apis)
|
259 |
+
- Create a free API key
|
260 |
+
- Enables blockchain data queries
|
261 |
|
262 |
+
## π― Usage Examples
|
263 |
+
|
264 |
+
### Market Analysis
|
265 |
+
```
|
266 |
+
"Analyze Bitcoin price trends and institutional adoption patterns"
|
267 |
```
|
268 |
|
269 |
+
### DeFi Research
|
270 |
+
```
|
271 |
+
"Compare top DeFi protocols by TVL, yield, and risk metrics"
|
|
|
272 |
```
|
273 |
|
274 |
+
### Layer 2 Analysis
|
275 |
+
```
|
276 |
+
"Evaluate Ethereum Layer 2 scaling solutions and adoption metrics"
|
277 |
+
```
|
278 |
+
|
279 |
+
### Yield Optimization
|
280 |
+
```
|
281 |
+
"Identify optimal yield farming strategies across multiple chains"
|
282 |
```
|
283 |
|
284 |
+
## π API Endpoints
|
285 |
|
286 |
+
| Endpoint | Method | Description |
|
287 |
+
|----------|--------|-------------|
|
288 |
+
| `/` | GET | Web interface |
|
289 |
+
| `/status` | GET | System status and configuration |
|
290 |
+
| `/query` | POST | Process research queries |
|
291 |
+
| `/health` | GET | Health check |
|
292 |
|
293 |
+
### Query API Example
|
294 |
|
|
|
295 |
```bash
|
296 |
+
curl -X POST "http://localhost:7860/query" \
|
297 |
+
-H "Content-Type: application/json" \
|
298 |
+
-d '{"query": "What is the current Bitcoin price?"}'
|
299 |
```
|
300 |
|
301 |
+
## π Troubleshooting
|
302 |
+
|
303 |
+
### Port Access Issues
|
304 |
+
|
305 |
+
**Problem**: Can't access the app on http://localhost:7860 or http://0.0.0.0:7860
|
306 |
+
|
307 |
+
**Solutions**:
|
308 |
+
|
309 |
+
1. **Check if the app is running**:
|
310 |
+
```bash
|
311 |
+
ps aux | grep "python app.py"
|
312 |
+
```
|
313 |
+
|
314 |
+
2. **Verify port binding**:
|
315 |
+
```bash
|
316 |
+
netstat -tlnp | grep :7860
|
317 |
+
```
|
318 |
+
|
319 |
+
3. **For Development Environments (VS Code, etc.)**:
|
320 |
+
- Look for port forwarding notifications
|
321 |
+
- Check your IDE's "Ports" or "Forwarded Ports" tab
|
322 |
+
- Use the forwarded URL provided by your development environment
|
323 |
+
|
324 |
+
4. **For Cloud/Remote Environments**:
|
325 |
+
- The app binds to `0.0.0.0:7860` for external access
|
326 |
+
- Use your platform's provided URL (not localhost)
|
327 |
+
- Check firewall rules if on a VPS/server
|
328 |
|
329 |
+
5. **Local Network Access**:
|
330 |
+
```bash
|
331 |
+
# Find your local IP
|
332 |
+
hostname -I
|
333 |
+
# Access via: http://YOUR_IP:7860
|
334 |
+
```
|
335 |
|
336 |
+
### Common Issues
|
|
|
|
|
|
|
|
|
337 |
|
338 |
+
1. **"GEMINI_API_KEY not configured"**
|
339 |
+
- Ensure you've set the API key in your `.env` file
|
340 |
+
- Verify the key is valid and has proper permissions
|
341 |
|
342 |
+
2. **"Connection refused" on port 7860**
|
343 |
+
- Check if another process is using port 7860: `lsof -i :7860`
|
344 |
+
- Ensure the app started successfully: `python app.py`
|
345 |
+
|
346 |
+
3. **Import errors**
|
347 |
+
- Ensure all dependencies are installed: `pip install -r requirements.txt`
|
348 |
+
- Check Python version compatibility (3.11+)
|
349 |
+
|
350 |
+
4. **Slow visualization loading**
|
351 |
+
- Check your internet connection
|
352 |
+
- API rate limits may be affecting data retrieval
|
353 |
+
|
354 |
+
### Getting Help
|
355 |
+
|
356 |
+
- Check the test suite: `python test_suite.py`
|
357 |
+
- Review logs in the terminal output
|
358 |
+
- Verify API keys are configured correctly
|
359 |
+
- Open an issue on GitHub with error details
|
360 |
+
|
361 |
+
## π€ Contributing
|
362 |
+
|
363 |
+
1. Fork the repository
|
364 |
+
2. Create a feature branch
|
365 |
+
3. Make your changes
|
366 |
+
4. Add tests for new functionality
|
367 |
+
5. Run the test suite
|
368 |
+
6. Submit a pull request
|
369 |
+
|
370 |
+
## π License
|
371 |
+
|
372 |
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
373 |
+
|
374 |
+
## π Acknowledgments
|
375 |
+
|
376 |
+
- **Google Gemini** for AI capabilities
|
377 |
+
- **CoinGecko** for comprehensive market data
|
378 |
+
- **DeFiLlama** for DeFi protocol analytics
|
379 |
+
- **Etherscan** for blockchain data
|
380 |
+
- **FastAPI** for the web framework
|
381 |
+
- **Plotly** for interactive visualizations
|
382 |
+
|
383 |
+
---
|
384 |
|
385 |
+
**Built with β€οΈ for the Web3 community**
|