Priyanshi Saxena commited on
Commit
a33b0e1
Β·
1 Parent(s): ea46ec8

docs: update README

Browse files
Files changed (1) hide show
  1. README.md +339 -83
README.md CHANGED
@@ -1,129 +1,385 @@
1
- # πŸš€ Web3 Research Co-Pilot
2
-
3
- AI-powered cryptocurrency research assistant with comprehensive Web3 data analysis capabilities.
4
-
5
- ## Features
 
 
 
 
 
6
 
7
- - **LangChain AI Agent**: Advanced query processing with Google Gemini
8
- - **Real-time Data**: CoinGecko, DeFiLlama, Etherscan integration
9
- - **Interactive UI**: Gradio-based chat interface with visualizations
10
- - **AIRAA Integration**: Research data forwarding to external platforms
11
- - **Production Ready**: Comprehensive error handling and async architecture
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- ## Quick Start
14
 
15
- ### 1. Environment Setup
16
 
17
  ```bash
18
- export GEMINI_API_KEY="your_gemini_api_key"
19
- export ETHERSCAN_API_KEY="your_etherscan_key" # Optional
20
- export COINGECKO_API_KEY="your_coingecko_key" # Optional
 
 
 
 
 
 
21
  ```
22
 
23
- ### 2. Installation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ```bash
26
- pip install -r requirements.txt
 
 
 
 
 
 
 
27
  ```
28
 
29
- ### 3. Launch
 
 
30
 
31
  ```bash
32
- python launch.py
33
  ```
34
 
35
- ## API Keys
36
-
37
- - **GEMINI_API_KEY** (Required): [Get from Google AI Studio](https://makersuite.google.com/app/apikey)
38
- - **ETHERSCAN_API_KEY** (Optional): [Get from Etherscan.io](https://etherscan.io/apis)
39
- - **COINGECKO_API_KEY** (Optional): [Get from CoinGecko](https://www.coingecko.com/en/api/pricing)
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- ## Architecture
42
 
43
  ```
44
- β”œβ”€β”€ app.py # Main Gradio application
45
- β”œβ”€β”€ src/
46
- β”‚ β”œβ”€β”€ agent/ # LangChain AI agent
47
- β”‚ β”œβ”€β”€ tools/ # Web3 data tools
48
- β”‚ β”œβ”€β”€ api/ # External integrations
49
- β”‚ └── utils/ # Configuration & utilities
50
- └── launch.py # Launch script
 
 
 
 
 
 
 
 
 
 
 
 
51
  ```
52
 
53
- ## Usage Examples
54
 
55
- - "What is the current price of Bitcoin?"
56
- - "Analyze Ethereum's DeFi ecosystem"
57
- - "Show me gas prices and network stats"
58
- - "Research the top DeFi protocols by TVL"
59
 
60
- ## Deployment
 
 
61
 
62
- Configured for HuggingFace Spaces with automatic dependency management.
63
 
64
- ---
 
 
 
 
 
65
 
66
- **Built with minimal, expert-level code and production-grade error handling.**
67
 
68
- ## Features
 
 
 
69
 
70
- - **Real-time Market Analysis**: CoinGecko, DeFiLlama, Etherscan integration
71
- - **AI Research Agent**: Powered by Google Gemini
72
- - **Interactive Interface**: Modern Gradio UI
73
- - **Data Visualization**: Price charts and market overviews
74
- - **AIRAA Integration**: Webhook support for external platforms
75
 
76
- ## Quick Start
 
 
 
77
 
78
- 1. **Clone and Setup**
79
- ```bash
80
- git clone <repository-url>
81
- cd web3-research-agent
82
- pip install -r requirements.txt
83
  ```
84
 
85
- 2. **Environment Configuration**
86
- ```bash
87
- cp .env.example .env
88
- # Edit .env with your API keys
89
  ```
90
 
91
- 3. **Run Application**
92
- ```bash
93
- python app.py
 
 
 
 
 
94
  ```
95
 
96
- ## Required API Keys
97
 
98
- - `GEMINI_API_KEY`: Google Gemini AI (required)
99
- - `ETHERSCAN_API_KEY`: Ethereum blockchain data
100
- - `COINGECKO_API_KEY`: Cryptocurrency market data (optional)
101
- - `AIRAA_WEBHOOK_URL`: External integration (optional)
 
 
102
 
103
- ## Deployment
104
 
105
- ### Docker
106
  ```bash
107
- docker build -t web3-research-agent .
108
- docker run -p 7860:7860 --env-file .env web3-research-agent
 
109
  ```
110
 
111
- ### Hugging Face Spaces
112
- Upload repository to HF Spaces with environment variables configured.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
- ## Architecture
 
 
 
 
 
115
 
116
- - **Agent**: LangChain-based research agent with memory
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
- ## Usage Examples
 
 
123
 
124
- - "Bitcoin price analysis and market sentiment"
125
- - "Top DeFi protocols by TVL"
126
- - "Ethereum gas prices and network stats"
127
- - "Compare BTC vs ETH performance"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
- Built with ❀️ for Web3 research
 
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
+ ![Web3 Research Co-Pilot](https://img.shields.io/badge/Web3-Research%20Co--Pilot-0066ff?style=for-the-badge)
19
+ ![Python](https://img.shields.io/badge/Python-3.11+-blue?style=for-the-badge&logo=python)
20
+ ![FastAPI](https://img.shields.io/badge/FastAPI-Latest-green?style=for-the-badge&logo=fastapi)
21
+ ![LangChain](https://img.shields.io/badge/LangChain-0.3.0-purple?style=for-the-badge)
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**