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
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
Here’s a clean, professional **`README.md`** you can include in your Hugging Face Space or GitHub repo for your crypto AI agent:
|
| 2 |
+
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# 🪙 Crypto AI Agent (Gemini + LangChain)
|
| 6 |
+
|
| 7 |
+
This project is a simple **AI-powered crypto assistant** built using **Google’s Gemini model** and **LangChain**.
|
| 8 |
+
It can intelligently respond to prompts **and** fetch **real-time cryptocurrency prices** (like Bitcoin and Ethereum) using a live API.
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
## 🚀 Features
|
| 13 |
+
|
| 14 |
+
✅ **Conversational AI** — Powered by `ChatGoogleGenerativeAI` (Gemini).
|
| 15 |
+
✅ **Live Crypto Data** — Fetches real-time prices from the [CoinCap API](https://docs.coincap.io/).
|
| 16 |
+
✅ **LangChain Integration** — Uses LangChain’s latest tool architecture (`Tool`).
|
| 17 |
+
✅ **Simple Deployment** — Can run directly on **Hugging Face Spaces** or locally.
|
| 18 |
+
✅ **Extendable** — Easily add more tools, prompts, or custom logic.
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## 🧠 How It Works
|
| 23 |
+
|
| 24 |
+
1. The user gives a text input (e.g., “Check the Bitcoin price”).
|
| 25 |
+
2. The agent detects whether it should:
|
| 26 |
+
|
| 27 |
+
* Use a tool (like the `CryptoPriceChecker`), or
|
| 28 |
+
* Use the Gemini model to generate a conversational answer.
|
| 29 |
+
3. The result is printed or returned as a response.
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## 📂 Project Structure
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
crypto-ai-agent/
|
| 37 |
+
│
|
| 38 |
+
├── app.py # Main application code
|
| 39 |
+
├── requirements.txt # All Python dependencies
|
| 40 |
+
└── README.md # Project documentation
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
---
|
| 44 |
+
|
| 45 |
+
## 🧩 Installation
|
| 46 |
+
|
| 47 |
+
You can run this project locally or deploy it on Hugging Face.
|
| 48 |
+
|
| 49 |
+
### Option 1: Run Locally
|
| 50 |
+
|
| 51 |
+
```bash
|
| 52 |
+
# Clone the repository
|
| 53 |
+
git clone https://github.com/yourusername/crypto-ai-agent.git
|
| 54 |
+
cd crypto-ai-agent
|
| 55 |
+
|
| 56 |
+
# Install dependencies
|
| 57 |
+
pip install -r requirements.txt
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
### Option 2: Run in Google Colab
|
| 61 |
+
|
| 62 |
+
Simply upload `app.py` to your Colab environment and run:
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
!pip install -r requirements.txt
|
| 66 |
+
!python app.py
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
### Option 3: Deploy on Hugging Face Spaces
|
| 70 |
+
|
| 71 |
+
1. Create a new Space.
|
| 72 |
+
2. Choose **“Static / Python (Gradio)”** as your Space type.
|
| 73 |
+
3. Upload:
|
| 74 |
+
|
| 75 |
+
* `app.py`
|
| 76 |
+
* `requirements.txt`
|
| 77 |
+
* `README.md`
|
| 78 |
+
4. Add your **Google API key** in the Hugging Face **Secrets tab** as:
|
| 79 |
+
|
| 80 |
+
```
|
| 81 |
+
GOOGLE_API_KEY=your_api_key_here
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
---
|
| 85 |
+
|
| 86 |
+
## 🔧 Configuration
|
| 87 |
+
|
| 88 |
+
You’ll need a valid **Google Generative AI API key** (Gemini).
|
| 89 |
+
You can get one from [Google AI Studio](https://makersuite.google.com/app/apikey).
|
| 90 |
+
|
| 91 |
+
Once you have it, set it as an environment variable:
|
| 92 |
+
|
| 93 |
+
```bash
|
| 94 |
+
export GOOGLE_API_KEY="your_api_key_here"
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
Or, on Hugging Face, use the **“Repository Secrets”** feature.
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## 🧾 Example Usage
|
| 102 |
+
|
| 103 |
+
### In Python:
|
| 104 |
+
|
| 105 |
+
```python
|
| 106 |
+
from app import run_agent
|
| 107 |
+
|
| 108 |
+
print(run_agent("Check Bitcoin price"))
|
| 109 |
+
print(run_agent("What is blockchain?"))
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Output:
|
| 113 |
+
|
| 114 |
+
```
|
| 115 |
+
💰 BTC current price: $68,245.12
|
| 116 |
+
Blockchain is a distributed ledger technology that allows secure and transparent record-keeping.
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## 📦 Requirements
|
| 122 |
+
|
| 123 |
+
See [`requirements.txt`](requirements.txt):
|
| 124 |
+
|
| 125 |
+
```
|
| 126 |
+
langchain>=0.3.0
|
| 127 |
+
langchain-google-genai>=0.1.0
|
| 128 |
+
langchain-core>=0.3.0
|
| 129 |
+
requests>=2.31.0
|
| 130 |
+
python-dotenv>=1.0.0
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
## 🧩 Future Enhancements
|
| 136 |
+
|
| 137 |
+
* Add multiple crypto symbols (e.g., ADA, XRP, DOGE)
|
| 138 |
+
* Integrate trading signals or portfolio management
|
| 139 |
+
* Add Gradio interface for user input
|
| 140 |
+
* Deploy on Hugging Face Space with persistent logs
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## 👨💻 Author
|
| 145 |
+
|
| 146 |
+
**Ali Masood**
|
| 147 |
+
PhD in Artificial Intelligence | Founder, Zaytrics Pvt Ltd
|
| 148 |
+
🚀 Building world-class AI & blockchain solutions.
|
| 149 |
+
|
| 150 |
---
|
| 151 |
|
|
|