Nikita Makarov commited on
Commit
248f723
·
1 Parent(s): 9b6a0be
.gitignore CHANGED
@@ -4,42 +4,55 @@ __pycache__/
4
  *$py.class
5
  *.so
6
  .Python
7
- *.egg-info/
8
- dist/
9
- build/
10
-
11
- # Virtual environments
12
- .venv/
13
  venv/
14
  ENV/
15
-
16
- # Audio files (generated)
17
- audio/*.mp3
18
- audio/*.wav
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  # Logs
21
- logs/*.log
 
22
 
23
  # User data
24
  user_data.json
25
  user_memory.json
 
26
 
27
  # IDE
28
  .vscode/
29
  .idea/
30
  *.swp
31
  *.swo
 
32
 
33
  # OS
34
  .DS_Store
35
  Thumbs.db
36
 
37
- # Temporary files
38
- *.part
39
- *.tmp
40
-
41
- # ChromaDB
42
- chroma_db/
43
 
44
- # Music cache
45
- music_cache/
 
4
  *$py.class
5
  *.so
6
  .Python
7
+ env/
 
 
 
 
 
8
  venv/
9
  ENV/
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # Audio files
27
+ audio/
28
+ *.mp3
29
+ *.wav
30
+ *.mp4
31
+ *.part
32
 
33
  # Logs
34
+ logs/
35
+ *.log
36
 
37
  # User data
38
  user_data.json
39
  user_memory.json
40
+ music_cache/
41
 
42
  # IDE
43
  .vscode/
44
  .idea/
45
  *.swp
46
  *.swo
47
+ *~
48
 
49
  # OS
50
  .DS_Store
51
  Thumbs.db
52
 
53
+ # Environment
54
+ .env
55
+ .env.local
 
 
 
56
 
57
+ # Gradio
58
+ flagged/
DEPLOY_HF.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deploying to HuggingFace Spaces
2
+
3
+ ## Step-by-Step Guide
4
+
5
+ ### 1. Create a New Space
6
+
7
+ 1. Go to [HuggingFace Spaces](https://huggingface.co/spaces)
8
+ 2. Click "Create new Space"
9
+ 3. Fill in:
10
+ - **Space name**: `ai-radio` (or your preferred name)
11
+ - **SDK**: Select **Gradio**
12
+ - **Hardware**: CPU (or GPU if available)
13
+ - **Visibility**: Public or Private
14
+
15
+ ### 2. Configure Secrets
16
+
17
+ After creating the Space, go to **Settings → Secrets** and add:
18
+
19
+ | Secret Name | Value | Required |
20
+ |------------|-------|----------|
21
+ | `ELEVENLABS_API_KEY` | Your ElevenLabs API key | ✅ Yes |
22
+ | `NEBIUS_API_KEY` | Your Nebius API key | ✅ Yes |
23
+ | `LLAMAINDEX_API_KEY` | Your LlamaIndex API key | ⚠️ Optional |
24
+ | `OPENAI_API_KEY` | Your OpenAI API key (for embeddings fallback) | ⚠️ Optional |
25
+
26
+ ### 3. Push Your Code
27
+
28
+ You can either:
29
+
30
+ **Option A: Git Push**
31
+ ```bash
32
+ git remote add hf https://huggingface.co/spaces/<your-username>/<space-name>
33
+ git push hf main
34
+ ```
35
+
36
+ **Option B: Upload via Web UI**
37
+ - Go to your Space page
38
+ - Click "Files and versions"
39
+ - Upload all files from your local `ai_radio` directory
40
+
41
+ ### 4. Required Files
42
+
43
+ Make sure these files are in your Space repository:
44
+
45
+ - ✅ `app.py` - Entry point (already created)
46
+ - ✅ `requirements.txt` - Dependencies
47
+ - ✅ `README.md` - Space description
48
+ - ✅ `src/` - Source code directory
49
+ - ✅ `.gitignore` - Git ignore rules
50
+
51
+ ### 5. Verify Deployment
52
+
53
+ 1. Check the **Logs** tab in your Space
54
+ 2. Wait for the build to complete
55
+ 3. The app should be available at: `https://huggingface.co/spaces/<your-username>/<space-name>`
56
+
57
+ ## Troubleshooting
58
+
59
+ ### Build Fails
60
+ - Check that `requirements.txt` has all dependencies
61
+ - Verify Python version compatibility (3.9+)
62
+ - Check logs for specific error messages
63
+
64
+ ### App Doesn't Start
65
+ - Verify all required secrets are set
66
+ - Check that `app.py` is at the root level
67
+ - Ensure port is set to 7860 (HF Spaces default)
68
+
69
+ ### API Errors
70
+ - Double-check that API keys are correctly set as secrets
71
+ - Verify API keys are valid and have sufficient credits/quota
72
+
73
+ ## Notes
74
+
75
+ - The app uses port 7860 by default on HF Spaces (configured in `app.py`)
76
+ - Audio files are stored temporarily in `audio/` directory
77
+ - User data persists in `user_memory.json` and `user_data.json`
78
+ - Logs are available in the Space's Logs tab
79
+
README.md CHANGED
@@ -112,11 +112,33 @@ This app fulfills all requirements for **Track 2: MCP in Action**:
112
 
113
  ## 🚀 Getting Started
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  ### Prerequisites
116
 
117
  - Python 3.9+
118
  - Nebius API key (for GPT-OSS-120B LLM)
119
- - ElevenLabs API key (provided)
120
 
121
  ### Installation
122
 
@@ -131,9 +153,11 @@ cd ai_radio
131
  pip install -r requirements.txt
132
  ```
133
 
134
- 3. Set up your Nebius API key in `config.py`:
135
- ```python
136
- nebius_api_key: str = "your-nebius-api-key-here"
 
 
137
  ```
138
 
139
  4. Run the app:
@@ -141,11 +165,7 @@ nebius_api_key: str = "your-nebius-api-key-here"
141
  python run.py
142
  ```
143
 
144
- Or from the src directory:
145
- ```bash
146
- cd src
147
- python app.py
148
- ```
149
 
150
  5. Open your browser to `http://localhost:7871`
151
 
 
112
 
113
  ## 🚀 Getting Started
114
 
115
+ ### Option 1: Deploy to HuggingFace Spaces (Recommended) 🚀
116
+
117
+ **Quick Deploy:**
118
+
119
+ 1. **Create a new Space** on [HuggingFace Spaces](https://huggingface.co/spaces)
120
+ - SDK: **Gradio**
121
+ - Hardware: **CPU** (or GPU if available)
122
+
123
+ 2. **Configure Secrets** (Settings → Secrets):
124
+ - `ELEVENLABS_API_KEY` - Your ElevenLabs API key
125
+ - `NEBIUS_API_KEY` - Your Nebius API key (for GPT-OSS-120B)
126
+ - `LLAMAINDEX_API_KEY` - Optional, for LlamaIndex embeddings
127
+ - `OPENAI_API_KEY` - Optional, for OpenAI embeddings fallback
128
+
129
+ 3. **Push your code** to the Space repository
130
+
131
+ 4. **Access your Space** at `https://huggingface.co/spaces/<username>/<space-name>`
132
+
133
+ 📖 **Detailed deployment guide**: See [DEPLOY_HF.md](DEPLOY_HF.md)
134
+
135
+ ### Option 2: Local Installation
136
+
137
  ### Prerequisites
138
 
139
  - Python 3.9+
140
  - Nebius API key (for GPT-OSS-120B LLM)
141
+ - ElevenLabs API key
142
 
143
  ### Installation
144
 
 
153
  pip install -r requirements.txt
154
  ```
155
 
156
+ 3. Set up environment variables or edit `src/config.py`:
157
+ ```bash
158
+ export ELEVENLABS_API_KEY="your-key-here"
159
+ export NEBIUS_API_KEY="your-key-here"
160
+ export LLAMAINDEX_API_KEY="your-key-here"
161
  ```
162
 
163
  4. Run the app:
 
165
  python run.py
166
  ```
167
 
168
+ The app will be available at `http://localhost:7871`
 
 
 
 
169
 
170
  5. Open your browser to `http://localhost:7871`
171
 
README_HF_SPACES.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI Radio - HuggingFace Spaces Deployment
2
+
3
+ This is the deployment guide for hosting AI Radio on HuggingFace Spaces.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ 1. **Create a new Space** on HuggingFace Spaces
8
+ - Choose "Gradio" as the SDK
9
+ - Set the hardware to "CPU" (or "GPU" if available)
10
+
11
+ 2. **Configure Secrets** in your Space settings:
12
+ Go to Settings → Secrets and add the following:
13
+ - `ELEVENLABS_API_KEY` - Your ElevenLabs API key
14
+ - `NEBIUS_API_KEY` - Your Nebius API key (for GPT-OSS-120B)
15
+ - `LLAMAINDEX_API_KEY` - Your LlamaIndex API key (optional, for embeddings)
16
+ - `OPENAI_API_KEY` - Optional, for OpenAI embeddings fallback
17
+
18
+ 3. **Push your code** to the Space repository
19
+
20
+ ## 📁 File Structure
21
+
22
+ The Space expects:
23
+ - `app.py` - Entry point (already created)
24
+ - `requirements.txt` - Python dependencies (already exists)
25
+ - `src/` - Source code directory
26
+ - `README.md` - This file (will be displayed on Space)
27
+
28
+ ## 🔧 Configuration
29
+
30
+ API keys are loaded from environment variables (set as Secrets in HF Spaces):
31
+ - `ELEVENLABS_API_KEY` - Required for text-to-speech
32
+ - `NEBIUS_API_KEY` - Required for LLM (GPT-OSS-120B)
33
+ - `LLAMAINDEX_API_KEY` - Optional, for LlamaIndex embeddings
34
+ - `OPENAI_API_KEY` - Optional, for OpenAI embeddings fallback
35
+
36
+ ## 📝 Notes
37
+
38
+ - The app will run on port 7860 (HF Spaces default)
39
+ - Audio files are stored in `audio/` directory
40
+ - User data is stored in `user_memory.json` and `user_data.json`
41
+ - Logs are stored in `logs/` directory
42
+
43
+ ## 🐛 Troubleshooting
44
+
45
+ If the app doesn't start:
46
+ 1. Check that all required secrets are set
47
+ 2. Check the logs in the Space
48
+ 3. Ensure `requirements.txt` has all dependencies
49
+ 4. Verify that `app.py` is at the root level
50
+
SECRETS_SETUP.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🔐 Настройка Secrets для HuggingFace Spaces
2
+
3
+ ## Необходимые Secrets
4
+
5
+ Перейдите в **Settings → Secrets** вашего Space и добавьте следующие секреты:
6
+
7
+ ### Обязательные Secrets:
8
+
9
+ 1. **`ELEVENLABS_API_KEY`**
10
+ - Значение: Ваш API ключ от ElevenLabs
11
+ - Использование: Текст-в-речь (TTS)
12
+ - Где получить: https://elevenlabs.io/
13
+
14
+ 2. **`NEBIUS_API_KEY`**
15
+ - Значение: Ваш API ключ от Nebius
16
+ - Использование: LLM (GPT-OSS-120B) для генерации контента
17
+ - Где получить: https://nebius.com/
18
+
19
+ ### Опциональные Secrets:
20
+
21
+ 3. **`LLAMAINDEX_API_KEY`**
22
+ - Значение: Ваш API ключ от LlamaIndex
23
+ - Использование: Embeddings для RAG системы (если не используется локальный)
24
+ - Где получить: https://llamaindex.ai/
25
+ - Примечание: Если не указан, используется локальный sentence-transformers
26
+
27
+ 4. **`OPENAI_API_KEY`**
28
+ - Значение: Ваш API ключ от OpenAI
29
+ - Использование: Fallback для embeddings (если LlamaIndex недоступен)
30
+ - Где получить: https://platform.openai.com/
31
+ - Примечание: Опционально, используется только как fallback
32
+
33
+ ## Как добавить Secrets в HF Spaces:
34
+
35
+ 1. Откройте ваш Space: https://huggingface.co/spaces/MCP-1st-Birthday/AI-RADIO
36
+ 2. Перейдите в **Settings** (вкладка справа)
37
+ 3. Прокрутите до раздела **Secrets**
38
+ 4. Нажмите **"New secret"**
39
+ 5. Введите имя секрета (например, `ELEVENLABS_API_KEY`)
40
+ 6. Введите значение секрета
41
+ 7. Нажмите **"Add secret"**
42
+ 8. Повторите для всех необходимых секретов
43
+
44
+ ## Проверка:
45
+
46
+ После добавления всех секретов:
47
+ 1. Перейдите во вкладку **Logs**
48
+ 2. Дождитесь перезапуска Space
49
+ 3. Проверьте логи на наличие предупреждений о недостающих ключах
50
+
51
+ ## Важно:
52
+
53
+ - ✅ Все API ключи теперь читаются ТОЛЬКО из переменных окружения
54
+ - ✅ Никакие ключи не хранятся в коде
55
+ - ✅ Код безопасен для публичного репозитория
56
+ - ⚠️ Убедитесь, что все необходимые секреты добавлены перед запуском
57
+
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Entry point for HuggingFace Spaces deployment"""
3
+ import sys
4
+ import os
5
+
6
+ # Add src directory to Python path
7
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
8
+
9
+ # Import and run the app
10
+ from app import demo
11
+
12
+ if __name__ == "__main__":
13
+ demo.launch(
14
+ server_name="0.0.0.0",
15
+ server_port=7860, # HF Spaces default port
16
+ share=False
17
+ )
18
+
docs/ARCHITECTURE.md DELETED
@@ -1,424 +0,0 @@
1
- # 🏗️ AI Radio - Architecture Documentation
2
-
3
- ## System Overview
4
-
5
- AI Radio is built with a modular, agent-based architecture that demonstrates autonomous behavior, tool use via MCP servers, and intelligent personalization through RAG.
6
-
7
- ## 📐 Architecture Diagram
8
-
9
- ```
10
- ┌─────────────────────────────────────────────────────────────┐
11
- │ Gradio UI Layer │
12
- │ (Radio Player, Preferences, Stats, Controls) │
13
- └──────────────────────┬──────────────────────────────────────┘
14
-
15
- ┌──────────────────────▼──────────────────────────────────────┐
16
- │ Radio Agent │
17
- │ (Autonomous Planning, Reasoning, Execution) │
18
- │ │
19
- │ ┌─────────────────────────────────────────────────────┐ │
20
- │ │ Agent Core │ │
21
- │ │ • plan_radio_show() - Planning │ │
22
- │ │ • execute_segment() - Execution │ │
23
- │ │ • _generate_*() - Reasoning │ │
24
- │ └─────────────────────────────────────────────────────┘ │
25
- └──────┬──────────────┬──────────────┬──────────────┬─────────┘
26
- │ │ │ │
27
- │ │ │ │
28
- ┌──────▼──────┐ ┌─────▼─────┐ ┌─────▼─────┐ ┌─────▼─────┐
29
- │ Music │ │ News │ │ Podcast │ │ RAG │
30
- │ MCP Server │ │MCP Server │ │MCP Server │ │ System │
31
- │ │ │ │ │ │ │ │
32
- │ • search_ │ │ • fetch_ │ │ • get_ │ │• store_ │
33
- │ music │ │ news │ │ podcasts│ │ prefs │
34
- │ • get_ │ │ • get_ │ │ • get_ │ │• get_ │
35
- │ playlist │ │ personl │ │ personl │ │ recom │
36
- └─────────────┘ └───────────┘ └───────────┘ └─────┬─────┘
37
-
38
- ┌──────▼──────┐
39
- │ LlamaIndex │
40
- │Vector Store │
41
- └─────────────┘
42
- │ │
43
- ┌──────▼──────┐ ┌──────▼──────┐
44
- │ Gemini │ │ ElevenLabs │
45
- │ LLM │ │ TTS │
46
- │ │ │ │
47
- │ • Content │ │ • Voice │
48
- │ Gen │ │ Gen │
49
- │ • Host │ │ • Speech │
50
- │ Scripts │ │ Synth │
51
- └─────────────┘ └─────────────┘
52
- ```
53
-
54
- ## 🧩 Component Details
55
-
56
- ### 1. **Gradio UI Layer**
57
-
58
- **File**: `app.py`
59
-
60
- **Responsibilities**:
61
- - User interface for radio player
62
- - Preference collection
63
- - Statistics display
64
- - Playback controls
65
-
66
- **Key Features**:
67
- - Responsive design with custom CSS
68
- - Real-time updates
69
- - Audio player integration
70
- - Multi-tab layout
71
-
72
- ### 2. **Radio Agent (Autonomous Agent)**
73
-
74
- **File**: `radio_agent.py`
75
-
76
- **Responsibilities**:
77
- - **Planning**: Create personalized radio show plans
78
- - **Reasoning**: Make intelligent content decisions
79
- - **Execution**: Generate and deliver content
80
- - **Learning**: Store listening history
81
-
82
- **Agent Behaviors**:
83
-
84
- #### Planning
85
- ```python
86
- plan_radio_show(user_preferences, duration_minutes)
87
- ├── Load user preferences from RAG
88
- ├── Calculate segment distribution
89
- ├── Generate segment plan
90
- │ ├── Music segments (50%)
91
- │ ├── News segments (20%)
92
- │ ├── Podcast segments (20%)
93
- │ └── Story segments (10%)
94
- ├── Shuffle for variety
95
- └── Return structured plan
96
- ```
97
-
98
- #### Reasoning
99
- - Analyzes user mood and preferences
100
- - Selects appropriate content from MCP servers
101
- - Generates contextual commentary
102
- - Adapts to user feedback (via RAG)
103
-
104
- #### Execution
105
- - Executes each segment in sequence
106
- - Calls MCP servers for content
107
- - Generates TTS for host commentary
108
- - Logs to RAG system for learning
109
-
110
- ### 3. **MCP Servers (Tool Layer)**
111
-
112
- MCP (Model Context Protocol) servers provide structured, modular tools for the agent.
113
-
114
- #### Music MCP Server
115
- **File**: `mcp_servers/music_server.py`
116
-
117
- **Tools**:
118
- - `search_music(genre, mood, limit)`: Find music tracks
119
- - `get_personalized_playlist(user_preferences)`: Generate playlists
120
-
121
- **Features**:
122
- - Multi-genre support
123
- - Mood-based filtering
124
- - Demo tracks (expandable to real APIs)
125
-
126
- #### News MCP Server
127
- **File**: `mcp_servers/news_server.py`
128
-
129
- **Tools**:
130
- - `fetch_news(category, limit)`: Fetch latest news
131
- - `get_personalized_news(user_preferences)`: Curate news
132
-
133
- **Features**:
134
- - RSS feed integration
135
- - Multiple categories
136
- - Real-time updates
137
- - Fallback demo content
138
-
139
- #### Podcast MCP Server
140
- **File**: `mcp_servers/podcast_server.py`
141
-
142
- **Tools**:
143
- - `get_trending_podcasts(category, limit)`: Find podcasts
144
- - `get_personalized_podcasts(user_preferences)`: Recommend podcasts
145
-
146
- **Features**:
147
- - Category-based search
148
- - Ratings and metadata
149
- - Demo content (expandable)
150
-
151
- ### 4. **RAG System**
152
-
153
- **File**: `rag_system.py`
154
-
155
- **Powered by**: LlamaIndex + Gemini Embeddings
156
-
157
- **Responsibilities**:
158
- - Store user preferences
159
- - Track listening history
160
- - Generate recommendations
161
- - Provide context to agent
162
-
163
- **Data Storage**:
164
- ```json
165
- {
166
- "type": "preferences",
167
- "timestamp": "2025-11-27T...",
168
- "data": {
169
- "name": "User",
170
- "favorite_genres": ["pop", "rock"],
171
- "interests": ["technology"],
172
- "mood": "happy"
173
- }
174
- }
175
- ```
176
-
177
- **Vector Store**:
178
- - Uses Gemini embeddings
179
- - Semantic search over user data
180
- - Persistent storage in JSON
181
-
182
- ### 5. **TTS Service**
183
-
184
- **File**: `tts_service.py`
185
-
186
- **Powered by**: ElevenLabs
187
-
188
- **Responsibilities**:
189
- - Convert text to natural speech
190
- - Support multiple voices
191
- - Generate high-quality audio
192
- - Save audio files
193
-
194
- **Features**:
195
- - Streaming support
196
- - Voice selection
197
- - Error handling
198
- - File management
199
-
200
- ### 6. **Configuration**
201
-
202
- **File**: `config.py`
203
-
204
- **Contains**:
205
- - API keys (with environment variable support)
206
- - Radio station settings
207
- - Segment ratios
208
- - Voice configuration
209
-
210
- ## 🔄 Data Flow
211
-
212
- ### 1. User Sets Preferences
213
- ```
214
- User Input → Gradio UI → save_preferences()
215
-
216
- RAG System
217
-
218
- Store in Vector Index
219
- ```
220
-
221
- ### 2. Starting Radio
222
- ```
223
- Start Button → start_radio_stream()
224
-
225
- RadioAgent.plan_radio_show()
226
-
227
- ┌───────────┴───────────┐
228
- ↓ ↓
229
- Query RAG Use MCP Servers
230
- ↓ ↓
231
- Get Preferences Get Content
232
- ↓ ↓
233
- └───────────┬───────────┘
234
-
235
- Generate Show Plan
236
-
237
- Return Segments
238
- ```
239
-
240
- ### 3. Playing Segment
241
- ```
242
- play_next_segment()
243
-
244
- execute_segment()
245
-
246
- ┌────┴────┐
247
- ↓ ↓
248
- Generate Call MCP
249
- Text Server
250
- ↓ ↓
251
- └────┬────┘
252
-
253
- TTS Service
254
-
255
- Audio File
256
-
257
- Gradio Audio Player
258
-
259
- User Hears
260
- ```
261
-
262
- ### 4. Learning Loop
263
- ```
264
- User Listens → execute_segment()
265
-
266
- Store in RAG (history)
267
-
268
- Update Preferences
269
-
270
- Future Recommendations Improve
271
- ```
272
-
273
- ## 🎯 Autonomous Agent Behavior
274
-
275
- The RadioAgent demonstrates three key autonomous behaviors:
276
-
277
- ### 1. **Planning**
278
- - Analyzes user preferences and context
279
- - Creates a balanced, engaging show structure
280
- - Considers segment variety and flow
281
- - Adapts to show duration
282
-
283
- ### 2. **Reasoning**
284
- - Uses LLM to generate contextual content
285
- - Makes intelligent content selections
286
- - Balances user preferences with variety
287
- - Generates natural host commentary
288
-
289
- ### 3. **Execution**
290
- - Calls appropriate MCP tools
291
- - Generates TTS for speech
292
- - Manages playback flow
293
- - Logs for future learning
294
-
295
- ## 🔧 MCP Tool Integration
296
-
297
- All MCP servers follow a consistent pattern:
298
-
299
- ```python
300
- class MCPServer:
301
- def __init__(self):
302
- self.name = "server_name"
303
- self.description = "Server description"
304
-
305
- def tool_function(self, params):
306
- """Tool implementation"""
307
- return results
308
-
309
- def get_tools_definition(self):
310
- """Return MCP tool schema"""
311
- return [
312
- {
313
- "name": "tool_name",
314
- "description": "What it does",
315
- "parameters": { ... }
316
- }
317
- ]
318
- ```
319
-
320
- This standardization allows:
321
- - Easy tool discovery
322
- - Consistent invocation
323
- - Simple extension
324
- - Clear documentation
325
-
326
- ## 💡 Context Engineering
327
-
328
- The agent uses context engineering to:
329
-
330
- 1. **Personalize Content**:
331
- - Passes user preferences to all LLM calls
332
- - Includes mood and interests in prompts
333
- - Maintains conversation continuity
334
-
335
- 2. **Generate Natural Speech**:
336
- - Creates prompts that mimic radio DJ style
337
- - Ensures appropriate tone and energy
338
- - Keeps content concise for audio
339
-
340
- 3. **Adapt to User**:
341
- - Uses RAG to retrieve relevant history
342
- - Considers past feedback
343
- - Improves over time
344
-
345
- ## 🚀 Scalability Considerations
346
-
347
- ### Current Design
348
- - Demo content for quick deployment
349
- - In-memory vector store
350
- - Local file storage
351
-
352
- ### Production Ready
353
- - Replace demo content with real APIs:
354
- - Spotify/Apple Music API
355
- - NewsAPI.org
356
- - iTunes Podcast API
357
- - Use persistent vector store (Pinecone, Weaviate)
358
- - Cloud storage for audio files
359
- - Distributed architecture
360
-
361
- ## 📊 Performance
362
-
363
- ### Efficiency Features
364
- - **Lazy Loading**: TTS only generates when needed
365
- - **Caching**: Store generated audio
366
- - **Streaming**: Stream audio for large files
367
- - **Batching**: Process segments in batches
368
-
369
- ### Cost Optimization
370
- - **Conditional Generation**: Only generate TTS for host segments
371
- - **Reuse Content**: Cache common segments
372
- - **Efficient Prompts**: Minimize LLM token usage
373
- - **Smart Planning**: Balance content types
374
-
375
- ## 🔐 Security
376
-
377
- - API keys stored in config (can use env vars)
378
- - No user data sent to external services (except APIs)
379
- - Local storage of preferences
380
- - Sandboxed execution
381
-
382
- ## 🧪 Testing Strategy
383
-
384
- ### Unit Tests
385
- - Test each MCP server independently
386
- - Test RAG storage and retrieval
387
- - Test TTS generation
388
- - Test agent planning logic
389
-
390
- ### Integration Tests
391
- - Test full show generation
392
- - Test UI interactions
393
- - Test audio playback
394
- - Test preference persistence
395
-
396
- ### User Acceptance
397
- - Test with real users
398
- - Gather feedback on content quality
399
- - Measure engagement
400
- - Iterate on improvements
401
-
402
- ## 📈 Future Enhancements
403
-
404
- 1. **Multi-language Support**: TTS in multiple languages
405
- 2. **Live Streaming**: Real-time audio streaming
406
- 3. **Social Features**: Share shows with friends
407
- 4. **Advanced Personalization**: Deep learning recommendations
408
- 5. **Voice Commands**: Control radio with voice
409
- 6. **Mobile App**: Native mobile experience
410
- 7. **Offline Mode**: Download shows for offline listening
411
- 8. **Community Content**: User-generated segments
412
-
413
- ## 🎓 Learning Resources
414
-
415
- - [MCP Documentation](https://modelcontextprotocol.io/)
416
- - [Gradio Docs](https://www.gradio.app/docs)
417
- - [LlamaIndex Guide](https://docs.llamaindex.ai/)
418
- - [Gemini API](https://ai.google.dev/)
419
- - [ElevenLabs API](https://elevenlabs.io/docs)
420
-
421
- ---
422
-
423
- Built with ❤️ for the MCP 1st Birthday Competition
424
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/DEPLOYMENT.md DELETED
@@ -1,381 +0,0 @@
1
- # 🚀 AI Radio - Deployment Guide
2
-
3
- Complete guide for deploying AI Radio to HuggingFace Spaces for the MCP Competition.
4
-
5
- ## 📋 Pre-Deployment Checklist
6
-
7
- Before deploying, ensure you have:
8
- - ✅ All source files in the `ai_radio` folder
9
- - ✅ Google Gemini API key
10
- - ✅ HuggingFace account (free)
11
- - ✅ Tested the app locally
12
-
13
- ## 🌐 HuggingFace Spaces Deployment
14
-
15
- ### Method 1: Web Upload (Easiest)
16
-
17
- #### Step 1: Create Space
18
-
19
- 1. Go to https://huggingface.co/spaces
20
- 2. Click "Create new Space"
21
- 3. Fill in details:
22
- - **Owner**: Your username
23
- - **Space name**: `ai-radio` (or your choice)
24
- - **License**: MIT
25
- - **Select SDK**: Gradio
26
- - **SDK version**: 4.44.0
27
- - **Space hardware**: CPU basic (free tier)
28
- - **Visibility**: Public
29
- 4. Click "Create Space"
30
-
31
- #### Step 2: Prepare Files
32
-
33
- Ensure your folder has these files:
34
- ```
35
- ai_radio/
36
- ├── app.py # Main application
37
- ├── config.py # Configuration
38
- ├── requirements.txt # Dependencies
39
- ├── README.md # Project documentation
40
- ├── radio_agent.py # AI Agent
41
- ├── rag_system.py # RAG system
42
- ├── tts_service.py # Text-to-speech
43
- ├── demo_assets.py # Demo data
44
- ├── mcp_servers/
45
- │ ├── __init__.py
46
- │ ├── music_server.py
47
- │ ├── news_server.py
48
- │ └── podcast_server.py
49
- ├── .gitignore
50
- ├── LICENSE
51
- ├── QUICKSTART.md
52
- ├── SETUP_GUIDE.md
53
- └── ARCHITECTURE.md
54
- ```
55
-
56
- #### Step 3: Upload Files
57
-
58
- 1. In your new Space, click "Files" tab
59
- 2. Click "Add file" → "Upload files"
60
- 3. Drag and drop ALL files from the list above
61
- 4. Or upload folder by folder:
62
- - First, upload root files
63
- - Then create `mcp_servers` folder and upload its contents
64
- 5. Add commit message: "Initial deployment of AI Radio"
65
- 6. Click "Commit changes to main"
66
-
67
- #### Step 4: Configure Secrets
68
-
69
- 1. Go to "Settings" tab in your Space
70
- 2. Scroll to "Repository secrets"
71
- 3. Click "New secret"
72
- 4. Add your Gemini API key:
73
- - **Name**: `GOOGLE_API_KEY`
74
- - **Value**: Your actual Gemini API key
75
- - Click "Add"
76
-
77
- #### Step 5: Wait for Build
78
-
79
- 1. Go to "App" tab
80
- 2. HuggingFace will automatically:
81
- - Install dependencies from `requirements.txt`
82
- - Build the container
83
- - Start the app
84
- 3. Wait 3-5 minutes
85
- 4. Your app will be live!
86
-
87
- #### Step 6: Test Deployment
88
-
89
- 1. Once running, test the app:
90
- - Set preferences
91
- - Start radio
92
- - Check if audio plays
93
- - Verify all tabs work
94
- 2. If errors, check the "Logs" section
95
-
96
- ### Method 2: Git Push (Advanced)
97
-
98
- #### Prerequisites
99
- ```bash
100
- # Install git-lfs
101
- brew install git-lfs # macOS
102
- # or
103
- apt-get install git-lfs # Linux
104
-
105
- git lfs install
106
- ```
107
-
108
- #### Steps
109
-
110
- 1. **Clone your Space**:
111
- ```bash
112
- git clone https://huggingface.co/spaces/YOUR_USERNAME/ai-radio
113
- cd ai-radio
114
- ```
115
-
116
- 2. **Copy files**:
117
- ```bash
118
- # Copy all files from your local project
119
- cp -r ~/Desktop/ai_radio/* .
120
- ```
121
-
122
- 3. **Configure git** (if not already done):
123
- ```bash
124
- git config user.email "your.email@example.com"
125
- git config user.name "Your Name"
126
- ```
127
-
128
- 4. **Commit and push**:
129
- ```bash
130
- git add .
131
- git commit -m "Initial deployment of AI Radio for MCP Competition"
132
- git push
133
- ```
134
-
135
- 5. **Set secrets** via web interface (see Method 1, Step 4)
136
-
137
- ## 🏷️ Competition Tagging
138
-
139
- Your `README.md` already includes the correct tags for the competition:
140
-
141
- ```yaml
142
- tags:
143
- - mcp
144
- - mcp-in-action-track-consumer
145
- - hackathon
146
- ```
147
-
148
- This ensures your submission is properly categorized!
149
-
150
- ## 🔍 Verification
151
-
152
- After deployment, verify:
153
-
154
- ### ✅ App Functionality
155
- - [ ] App loads without errors
156
- - [ ] Can save preferences
157
- - [ ] Radio starts and plays
158
- - [ ] Audio generates (TTS works)
159
- - [ ] Stats page shows data
160
- - [ ] All tabs are accessible
161
-
162
- ### ✅ MCP Features
163
- - [ ] Music server provides tracks
164
- - [ ] News server fetches updates
165
- - [ ] Podcast server gives recommendations
166
- - [ ] Agent plans shows autonomously
167
- - [ ] RAG system stores preferences
168
-
169
- ### ✅ Competition Requirements
170
- - [ ] Tagged with `mcp-in-action-track-consumer`
171
- - [ ] README explains MCP usage
172
- - [ ] Demonstrates autonomous behavior
173
- - [ ] Uses MCP servers as tools
174
- - [ ] Gradio interface works
175
- - [ ] RAG system functional
176
-
177
- ## 🐛 Common Deployment Issues
178
-
179
- ### Issue 1: Dependencies Not Installing
180
-
181
- **Error**: `ModuleNotFoundError`
182
-
183
- **Solution**:
184
- - Ensure `requirements.txt` is in root directory
185
- - Check package names are correct
186
- - Try specifying versions more loosely:
187
- ```
188
- gradio>=4.44.0
189
- google-generativeai>=0.8.0
190
- ```
191
-
192
- ### Issue 2: Secrets Not Loading
193
-
194
- **Error**: `API key not found`
195
-
196
- **Solution**:
197
- - Verify secret name is exactly `GOOGLE_API_KEY`
198
- - Check secret is added to the Space (not repository)
199
- - Restart the Space after adding secrets
200
-
201
- ### Issue 3: Audio Not Playing
202
-
203
- **Error**: No audio output
204
-
205
- **Solutions**:
206
- - Check ElevenLabs API key in `config.py`
207
- - Verify TTS service initializes correctly
208
- - Check logs for ElevenLabs errors
209
- - Test with demo mode (without TTS)
210
-
211
- ### Issue 4: Out of Memory
212
-
213
- **Error**: Container crashes
214
-
215
- **Solution**:
216
- - Upgrade to better hardware tier (Settings → Hardware)
217
- - Optimize memory usage:
218
- - Reduce batch sizes
219
- - Clear old audio files
220
- - Use streaming instead of loading all at once
221
-
222
- ### Issue 5: Slow Performance
223
-
224
- **Symptoms**: App is sluggish
225
-
226
- **Solutions**:
227
- - Upgrade Space hardware
228
- - Implement caching for frequently used content
229
- - Reduce number of segments
230
- - Optimize LLM prompts
231
-
232
- ## 📊 Monitoring Your Space
233
-
234
- ### View Logs
235
- 1. Go to your Space
236
- 2. Click on the running app area
237
- 3. Look for "View Logs" or similar
238
- 4. Monitor for errors
239
-
240
- ### Check Usage
241
- 1. Settings → Usage
242
- 2. Monitor:
243
- - API calls
244
- - Memory usage
245
- - CPU usage
246
- - Storage
247
-
248
- ### Analytics
249
- 1. Settings → Analytics
250
- 2. See:
251
- - Number of visitors
252
- - Session duration
253
- - Popular features
254
-
255
- ## 🔄 Updating Your Space
256
-
257
- ### Quick Updates
258
- 1. Go to Files tab
259
- 2. Click on file to edit
260
- 3. Make changes
261
- 4. Commit
262
- 5. Space rebuilds automatically
263
-
264
- ### Batch Updates
265
- 1. Use git method to push multiple changes
266
- 2. Or upload files again via web interface
267
-
268
- ## 🎯 Competition Submission
269
-
270
- ### Final Steps
271
-
272
- 1. **Verify README**:
273
- - Has competition tags
274
- - Explains MCP integration
275
- - Includes demo instructions
276
- - Lists all features
277
-
278
- 2. **Test thoroughly**:
279
- - Try all features
280
- - Check error handling
281
- - Verify user experience
282
-
283
- 3. **Document**:
284
- - Clear setup instructions
285
- - Architecture explanation
286
- - MCP server details
287
-
288
- 4. **Share**:
289
- - Get the Space URL
290
- - Submit to competition
291
- - Share on social media!
292
-
293
- ### Submission Checklist
294
-
295
- - [ ] Space is public
296
- - [ ] App runs without errors
297
- - [ ] README has correct tags
298
- - [ ] All MCP features demonstrated
299
- - [ ] RAG system working
300
- - [ ] UI is polished
301
- - [ ] Documentation complete
302
-
303
- ## 🎨 Polish Your Space
304
-
305
- ### Custom Thumbnail
306
- 1. Create a 1200x400px image
307
- 2. Upload as `thumbnail.png`
308
- 3. It will show in Space preview
309
-
310
- ### Better Description
311
- Edit README to add:
312
- - Demo GIF/video
313
- - Feature highlights
314
- - Screenshots
315
- - Competition hashtags
316
-
317
- ### Social Media
318
- Share your Space:
319
- ```
320
- 🎵 Just built AI Radio for #MCP1stBirthday!
321
-
322
- Personalized radio with:
323
- 🤖 Autonomous AI agent
324
- 🎶 Smart music selection
325
- 📰 Custom news
326
- 🎙️ Podcast recommendations
327
-
328
- Try it: https://huggingface.co/spaces/YOUR_USERNAME/ai-radio
329
-
330
- #MCP #AI #Gradio #HuggingFace
331
- ```
332
-
333
- ## 📈 Optimization Tips
334
-
335
- ### For Free Tier
336
- - Use CPU efficiently
337
- - Cache generated content
338
- - Limit concurrent users
339
- - Optimize model calls
340
-
341
- ### For Better UX
342
- - Add loading indicators
343
- - Show progress bars
344
- - Provide helpful error messages
345
- - Add tooltips and hints
346
-
347
- ### For Demo
348
- - Preload sample data
349
- - Have demo preferences ready
350
- - Show example outputs
351
- - Guide first-time users
352
-
353
- ## 🏆 Making Your Submission Stand Out
354
-
355
- 1. **Demo Video**: Record a quick demo showing features
356
- 2. **Clear Documentation**: Make README super clear
357
- 3. **Polish UI**: Beautiful, intuitive interface
358
- 4. **Smooth Experience**: Test thoroughly, fix bugs
359
- 5. **Showcase MCP**: Clearly demonstrate MCP integration
360
- 6. **Highlight RAG**: Show how personalization works
361
- 7. **Agent Behavior**: Explain autonomous planning/reasoning
362
-
363
- ## 🎉 Launch!
364
-
365
- Once everything is ready:
366
-
367
- 1. ✅ Test one final time
368
- 2. ✅ Check all documentation
369
- 3. ✅ Verify tags are correct
370
- 4. ✅ Share your Space URL
371
- 5. ✅ Submit to competition
372
- 6. 🎊 Celebrate!
373
-
374
- Your AI Radio is now live and ready for the MCP Competition!
375
-
376
- ---
377
-
378
- **Good luck with your submission!** 🍀
379
-
380
- Made with ❤️ for MCP 1st Birthday Competition
381
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/GET_GEMINI_KEY.md DELETED
@@ -1,178 +0,0 @@
1
- # 🔑 How to Get Your Gemini API Key
2
-
3
- ## Why You Need It
4
-
5
- AI Radio uses Google's Gemini LLM to:
6
- - Generate radio host commentary
7
- - Create news scripts
8
- - Write stories and fun facts
9
- - Power the autonomous agent's reasoning
10
-
11
- **This is the ONLY key you need to add yourself!**
12
-
13
- ## 📝 Step-by-Step Guide
14
-
15
- ### Step 1: Go to Google AI Studio
16
-
17
- Open your browser and go to:
18
- ```
19
- https://makersuite.google.com/app/apikey
20
- ```
21
-
22
- Or Google search for: "Google AI Studio API key"
23
-
24
- ### Step 2: Sign In
25
-
26
- - Sign in with your Google account
27
- - Any Google account works (Gmail, workspace, etc.)
28
- - It's completely FREE!
29
-
30
- ### Step 3: Create API Key
31
-
32
- 1. Click the **"Create API Key"** button
33
- 2. Choose **"Create API key in new project"** (recommended)
34
- 3. Wait a few seconds for it to generate
35
- 4. Your API key will appear - it looks like:
36
- ```
37
- AIzaSyA1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q
38
- ```
39
-
40
- ### Step 4: Copy Your Key
41
-
42
- 1. Click the **copy icon** next to your key
43
- 2. Or manually select and copy the entire key
44
- 3. **Keep it safe!** Don't share publicly
45
-
46
- ### Step 5: Add to Config
47
-
48
- Open `config.py` in your editor and find this line:
49
-
50
- ```python
51
- google_api_key: str = ""
52
- ```
53
-
54
- Replace it with:
55
-
56
- ```python
57
- google_api_key: str = "AIzaSyA1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6Q"
58
- ```
59
-
60
- (Use your actual key, not the example above!)
61
-
62
- ### Step 6: Save and Test
63
-
64
- 1. Save the `config.py` file
65
- 2. Run the test script:
66
- ```bash
67
- python test_app.py
68
- ```
69
- 3. If you see "✅ Google API key present" - you're good to go!
70
-
71
- ## Alternative: Environment Variable
72
-
73
- Instead of editing `config.py`, you can set an environment variable:
74
-
75
- ### macOS/Linux:
76
- ```bash
77
- export GOOGLE_API_KEY="your-key-here"
78
- python app.py
79
- ```
80
-
81
- ### Windows (PowerShell):
82
- ```powershell
83
- $env:GOOGLE_API_KEY="your-key-here"
84
- python app.py
85
- ```
86
-
87
- ### Windows (CMD):
88
- ```cmd
89
- set GOOGLE_API_KEY=your-key-here
90
- python app.py
91
- ```
92
-
93
- ## 🔒 Security Tips
94
-
95
- 1. **Never commit API keys to git**
96
- - They're in `.gitignore` for safety
97
- - Config file with key won't be pushed
98
-
99
- 2. **Don't share publicly**
100
- - Don't post in forums, Discord, etc.
101
- - Don't include in screenshots
102
-
103
- 3. **Regenerate if exposed**
104
- - If you accidentally share it, regenerate in AI Studio
105
- - Old key will stop working
106
-
107
- 4. **Monitor usage**
108
- - Check Google AI Studio for usage stats
109
- - Free tier is generous (lots of requests)
110
-
111
- ## 🎁 Free Tier
112
-
113
- Gemini API free tier includes:
114
- - **60 requests per minute**
115
- - **1,500 requests per day**
116
- - Plenty for personal use and demos!
117
-
118
- No credit card required for free tier.
119
-
120
- ## ❓ Troubleshooting
121
-
122
- ### "API key not valid"
123
- - Make sure you copied the entire key
124
- - Check for extra spaces before/after
125
- - Verify it's the Gemini API key, not other Google API
126
-
127
- ### "Quota exceeded"
128
- - You've hit the free tier limit
129
- - Wait for the quota to reset (daily)
130
- - Or upgrade to paid tier in AI Studio
131
-
132
- ### "API not enabled"
133
- - Go to Google Cloud Console
134
- - Enable "Generative Language API"
135
- - Try again
136
-
137
- ### Still having issues?
138
- - Try creating a new API key
139
- - Check Google AI Studio status page
140
- - Make sure your Google account is active
141
-
142
- ## 🌐 For HuggingFace Deployment
143
-
144
- When deploying to HuggingFace Spaces:
145
-
146
- 1. **Don't include key in code**
147
- 2. Go to Space Settings → Secrets
148
- 3. Add secret:
149
- - Name: `GOOGLE_API_KEY`
150
- - Value: Your Gemini API key
151
- 4. App will load it automatically
152
-
153
- ## ✅ Verification
154
-
155
- Your key is working if:
156
- - ✅ Test script passes
157
- - ✅ Radio generates commentary
158
- - ✅ News scripts are created
159
- - ✅ Stories are generated
160
- - ✅ No "API key" errors in logs
161
-
162
- ## 🎉 You're All Set!
163
-
164
- Once you have your Gemini API key:
165
- 1. ✅ Add it to `config.py` or environment variable
166
- 2. ✅ Run `python test_app.py` to verify
167
- 3. ✅ Start the app with `python app.py`
168
- 4. 🎵 Enjoy your AI Radio!
169
-
170
- ---
171
-
172
- **Quick Links:**
173
- - [Google AI Studio](https://makersuite.google.com/app/apikey)
174
- - [Gemini API Docs](https://ai.google.dev/tutorials)
175
- - [Pricing Info](https://ai.google.dev/pricing)
176
-
177
- Need help? Check SETUP_GUIDE.md for more details!
178
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/INSTALL_FFMPEG.md DELETED
@@ -1,52 +0,0 @@
1
- # 🎵 Installing FFmpeg for Music Playback
2
-
3
- FFmpeg is required to download and convert YouTube audio for playback in the app.
4
-
5
- ## macOS Installation
6
-
7
- ```bash
8
- brew install ffmpeg
9
- ```
10
-
11
- ## Linux Installation
12
-
13
- ```bash
14
- # Ubuntu/Debian
15
- sudo apt-get update
16
- sudo apt-get install ffmpeg
17
-
18
- # Fedora/CentOS
19
- sudo dnf install ffmpeg
20
-
21
- # Arch Linux
22
- sudo pacman -S ffmpeg
23
- ```
24
-
25
- ## Windows Installation
26
-
27
- 1. Download from: https://ffmpeg.org/download.html
28
- 2. Extract to a folder (e.g., `C:\ffmpeg`)
29
- 3. Add to PATH:
30
- - System Properties → Environment Variables
31
- - Add `C:\ffmpeg\bin` to Path
32
-
33
- ## Verify Installation
34
-
35
- ```bash
36
- ffmpeg -version
37
- ```
38
-
39
- You should see version information if installed correctly.
40
-
41
- ## Alternative: Use YouTube Links
42
-
43
- If you can't install ffmpeg, the app will still work! It will:
44
- - Show track information
45
- - Provide YouTube links to listen
46
- - All other features work normally
47
- - Music just won't play directly in the app
48
-
49
- ## Note
50
-
51
- FFmpeg is only needed for downloading YouTube audio. All other features (host speech, news, podcasts, stories) work without it!
52
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/INSTALL_VOICE_INPUT.md DELETED
@@ -1,82 +0,0 @@
1
- # 🎤 Voice Input Installation Guide
2
-
3
- The voice input feature requires `pyaudio`, which needs the PortAudio library to be installed first.
4
-
5
- ## macOS Installation
6
-
7
- 1. **Install PortAudio using Homebrew:**
8
- ```bash
9
- brew install portaudio
10
- ```
11
-
12
- 2. **Install pyaudio:**
13
- ```bash
14
- pip install pyaudio
15
- ```
16
-
17
- ## Linux Installation
18
-
19
- 1. **Install PortAudio development libraries:**
20
- ```bash
21
- sudo apt-get update
22
- sudo apt-get install portaudio19-dev python3-pyaudio
23
- ```
24
-
25
- Or for other distributions:
26
- ```bash
27
- # Fedora/CentOS
28
- sudo dnf install portaudio-devel
29
-
30
- # Arch Linux
31
- sudo pacman -S portaudio
32
- ```
33
-
34
- 2. **Install pyaudio:**
35
- ```bash
36
- pip install pyaudio
37
- ```
38
-
39
- ## Windows Installation
40
-
41
- 1. **Download and install PortAudio:**
42
- - Download from: http://files.portaudio.com/download.html
43
- - Or use pre-built wheels:
44
- ```bash
45
- pip install pipwin
46
- pipwin install pyaudio
47
- ```
48
-
49
- ## Alternative: Use Text Input
50
-
51
- If you can't install pyaudio, you can still use the app! The voice input feature will be disabled, but you can:
52
- - Type your song requests in the preferences
53
- - Use the regular radio controls
54
- - All other features work without voice input
55
-
56
- ## Verify Installation
57
-
58
- After installing, test with:
59
- ```bash
60
- python -c "import speech_recognition as sr; print('✅ Speech recognition ready!')"
61
- python -c "import pyaudio; print('✅ PyAudio ready!')"
62
- ```
63
-
64
- ## Troubleshooting
65
-
66
- **Error: "portaudio.h not found"**
67
- - Make sure PortAudio is installed before pyaudio
68
- - On macOS, use Homebrew: `brew install portaudio`
69
-
70
- **Error: "No module named 'pyaudio'"**
71
- - Install pyaudio: `pip install pyaudio`
72
- - Make sure PortAudio is installed first
73
-
74
- **Microphone not detected**
75
- - Check microphone permissions in system settings
76
- - On macOS: System Settings → Privacy & Security → Microphone
77
- - Make sure your app has microphone access
78
-
79
- ## Note
80
-
81
- Voice input is **optional**. The app works perfectly without it - you just won't be able to request songs by voice. All other features (radio, music, news, etc.) work normally.
82
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/PROJECT_OVERVIEW.txt DELETED
@@ -1,356 +0,0 @@
1
- ================================================================================
2
- 🎵 AI RADIO - PROJECT COMPLETE! 🎵
3
- ================================================================================
4
-
5
- Congratulations! Your personalized AI Radio Station is ready for the
6
- MCP 1st Birthday Competition!
7
-
8
- ================================================================================
9
- 📦 WHAT YOU HAVE
10
- ================================================================================
11
-
12
- A complete, production-ready AI Radio application featuring:
13
-
14
- ✅ Autonomous AI Agent (planning, reasoning, execution)
15
- ✅ 3 MCP Servers (music, news, podcasts)
16
- ✅ RAG System (LlamaIndex) for personalization
17
- ✅ Beautiful Gradio UI (radio station theme)
18
- ✅ ElevenLabs TTS (natural voice)
19
- ✅ Google Gemini LLM (content generation)
20
- ✅ Comprehensive documentation
21
- ✅ Test suite
22
- ✅ HuggingFace deployment ready
23
-
24
- ================================================================================
25
- 📁 PROJECT STRUCTURE
26
- ================================================================================
27
-
28
- ai_radio/
29
- ├── 🚀 MAIN APPLICATION
30
- │ ├── app.py # Main Gradio app (run this!)
31
- │ ├── config.py # Configuration (ADD YOUR GEMINI KEY!)
32
- │ ├── radio_agent.py # Autonomous AI agent
33
- │ ├── rag_system.py # RAG system with LlamaIndex
34
- │ ├── tts_service.py # ElevenLabs TTS integration
35
- │ └── demo_assets.py # Sample data
36
-
37
- ├── 🔧 MCP SERVERS (Tools)
38
- │ ├── mcp_servers/
39
- │ │ ├── __init__.py
40
- │ │ ├── music_server.py # Music search & playlists
41
- │ │ ├── news_server.py # News fetching & curation
42
- │ │ └── podcast_server.py # Podcast recommendations
43
-
44
- ├── 📚 DOCUMENTATION
45
- │ ├── START_HERE.md # 👈 READ THIS FIRST!
46
- │ ├── README.md # Full project documentation
47
- │ ├── QUICKSTART.md # 5-minute setup guide
48
- │ ├── GET_GEMINI_KEY.md # How to get Gemini API key
49
- │ ├── SETUP_GUIDE.md # Detailed setup instructions
50
- │ ├── ARCHITECTURE.md # Technical architecture
51
- │ ├── DEPLOYMENT.md # HuggingFace deployment
52
- │ └── PROJECT_SUMMARY.md # Complete overview
53
-
54
- ├── 🧪 TESTING & CONFIG
55
- │ ├── test_app.py # Test suite (run before deploying!)
56
- │ ├── requirements.txt # Python dependencies
57
- │ ├── .gitignore # Git ignore rules
58
- │ └── LICENSE # MIT License
59
-
60
- └── 📄 THIS FILE
61
- └── PROJECT_OVERVIEW.txt # You are here!
62
-
63
- ================================================================================
64
- 🚀 GETTING STARTED (3 STEPS!)
65
- ================================================================================
66
-
67
- STEP 1: Get Gemini API Key (2 minutes)
68
- ---------------------------------------
69
- 1. Go to: https://makersuite.google.com/app/apikey
70
- 2. Sign in with Google (FREE!)
71
- 3. Click "Create API Key"
72
- 4. Copy the key
73
-
74
- 📖 See GET_GEMINI_KEY.md for detailed instructions
75
-
76
- STEP 2: Add Your Key (30 seconds)
77
- ----------------------------------
78
- Open config.py and find:
79
- google_api_key: str = ""
80
-
81
- Replace with:
82
- google_api_key: str = "your-gemini-key-here"
83
-
84
- STEP 3: Install & Run (3 minutes)
85
- ----------------------------------
86
- cd ~/Desktop/ai_radio
87
- pip install -r requirements.txt
88
- python test_app.py
89
- python app.py
90
-
91
- Open browser: http://localhost:7860
92
-
93
- 🎉 That's it! You're running!
94
-
95
- ================================================================================
96
- 🎮 USING YOUR AI RADIO
97
- ================================================================================
98
-
99
- 1. SET PREFERENCES
100
- - Go to "Your Preferences" tab
101
- - Enter name, genres, interests, mood
102
- - Click "Save Preferences"
103
-
104
- 2. START RADIO
105
- - Go to "Radio Player" tab
106
- - Click "▶️ Start Radio"
107
- - Listen to your personalized show!
108
-
109
- 3. CONTROLS
110
- - ⏭️ Next Segment - Skip to next
111
- - ⏹️ Stop - Pause radio
112
-
113
- 4. VIEW STATS
114
- - "Your Stats" tab shows listening history
115
- - RAG system learns from this!
116
-
117
- ================================================================================
118
- 🏆 MCP COMPETITION REQUIREMENTS
119
- ================================================================================
120
-
121
- TRACK: MCP in Action - Consumer Applications
122
- TAG: mcp-in-action-track-consumer
123
-
124
- REQUIREMENTS MET:
125
- ✅ Autonomous Agent Behavior
126
- • Planning: Creates balanced show plans
127
- • Reasoning: LLM-powered content decisions
128
- • Execution: Generates and delivers content
129
-
130
- ✅ MCP Servers as Tools
131
- • MusicMCPServer - Music search & playlists
132
- • NewsMCPServer - News fetching & curation
133
- • PodcastMCPServer - Podcast recommendations
134
-
135
- ✅ Gradio Application
136
- • Beautiful radio station UI
137
- • Real-time controls
138
- • Multi-tab interface
139
- • Responsive design
140
-
141
- ✅ Advanced Features (BONUS!)
142
- • RAG System - LlamaIndex personalization
143
- • Context Engineering - Mood-aware content
144
- • Learning System - Improves over time
145
-
146
- ================================================================================
147
- 🌐 DEPLOYING TO HUGGINGFACE
148
- ================================================================================
149
-
150
- QUICK DEPLOY (5 minutes):
151
-
152
- 1. Go to: https://huggingface.co/spaces
153
- 2. Click "New Space"
154
- - Name: ai-radio
155
- - SDK: Gradio
156
- - Visibility: Public
157
- 3. Upload all files from ai_radio/ folder
158
- 4. Settings → Secrets → Add:
159
- - Name: GOOGLE_API_KEY
160
- - Value: Your Gemini key
161
- 5. Wait for build (3-5 minutes)
162
- 6. Done! Share the link!
163
-
164
- 📖 See DEPLOYMENT.md for detailed instructions
165
-
166
- ================================================================================
167
- 🛠️ TECHNOLOGY STACK
168
- ================================================================================
169
-
170
- Frontend: Gradio 4.44.0
171
- LLM: Google Gemini Pro
172
- TTS: ElevenLabs
173
- RAG: LlamaIndex + Gemini Embeddings
174
- Protocol: MCP (Model Context Protocol)
175
- News: RSS Feeds (BBC, NYT, etc.)
176
- Language: Python 3.9+
177
-
178
- API Keys Included (Ready to Use):
179
- ✅ ElevenLabs: Already in config
180
- ✅ LlamaIndex: Already in config
181
- ⚠️ Gemini: YOU NEED TO ADD THIS!
182
-
183
- ================================================================================
184
- ✅ PRE-SUBMISSION CHECKLIST
185
- ================================================================================
186
-
187
- Before submitting to the competition:
188
-
189
- [ ] Gemini API key added to config.py
190
- [ ] Ran python test_app.py - all tests pass
191
- [ ] Tested locally - app runs without errors
192
- [ ] Can save preferences
193
- [ ] Radio starts and plays segments
194
- [ ] Audio generates (TTS works)
195
- [ ] All MCP servers working
196
- [ ] RAG system stores data
197
- [ ] Deployed to HuggingFace Spaces
198
- [ ] README.md has competition tags
199
- [ ] Tested deployed version
200
- [ ] Shared Space URL
201
-
202
- ================================================================================
203
- 📊 PROJECT STATISTICS
204
- ================================================================================
205
-
206
- Lines of Code: ~2,500+
207
- Python Files: 11 source files
208
- MCP Servers: 3 specialized tools
209
- Features: 10+ major features
210
- Documentation: 8 comprehensive guides
211
- Tests: 7 component tests
212
- Dependencies: 15 Python packages
213
- Ready to Deploy: ✅ YES!
214
-
215
- ================================================================================
216
- 🎨 CUSTOMIZATION OPTIONS
217
- ================================================================================
218
-
219
- Change Voice (config.py):
220
- elevenlabs_voice_id: str = "ErXwobaYiN019PkySvjV" # Antoni
221
-
222
- Adjust Music/News Ratio (config.py):
223
- music_ratio: float = 0.7 # More music
224
- news_ratio: float = 0.1 # Less news
225
-
226
- Station Name (config.py):
227
- station_name: str = "My Cool Radio 🎶"
228
-
229
- UI Colors (app.py):
230
- Edit custom_css variable to change gradients
231
-
232
- ================================================================================
233
- 🆘 TROUBLESHOOTING
234
- ================================================================================
235
-
236
- PROBLEM: "API key not valid"
237
- SOLUTION: Check you copied entire key from Google AI Studio
238
- See GET_GEMINI_KEY.md
239
-
240
- PROBLEM: "Module not found"
241
- SOLUTION: pip install -r requirements.txt --force-reinstall
242
-
243
- PROBLEM: "No audio playing"
244
- SOLUTION: ElevenLabs key is already in config.py
245
- Check internet connection
246
-
247
- PROBLEM: Tests failing
248
- SOLUTION: Ensure all dependencies installed
249
- Check Gemini API key is set correctly
250
-
251
- PROBLEM: Deployment issues
252
- SOLUTION: See DEPLOYMENT.md troubleshooting section
253
-
254
- ================================================================================
255
- 📚 DOCUMENTATION GUIDE
256
- ================================================================================
257
-
258
- WHERE TO START:
259
- 👉 START_HERE.md - Begin here!
260
-
261
- QUICK SETUP:
262
- 👉 QUICKSTART.md - Fast setup (5 min)
263
- 👉 GET_GEMINI_KEY.md - Get your API key
264
-
265
- DETAILED GUIDES:
266
- 👉 SETUP_GUIDE.md - Complete setup
267
- 👉 DEPLOYMENT.md - Deploy to HuggingFace
268
-
269
- TECHNICAL DETAILS:
270
- 👉 ARCHITECTURE.md - How it works
271
- 👉 PROJECT_SUMMARY.md - Complete overview
272
-
273
- MAIN DOCS:
274
- 👉 README.md - Project documentation
275
-
276
- ================================================================================
277
- 🎯 NEXT STEPS
278
- ================================================================================
279
-
280
- RIGHT NOW:
281
- 1. Read START_HERE.md
282
- 2. Get Gemini API key (see GET_GEMINI_KEY.md)
283
- 3. Add key to config.py
284
- 4. Run: python test_app.py
285
- 5. Run: python app.py
286
- 6. Test in browser: http://localhost:7860
287
-
288
- TODAY:
289
- 7. Try all features
290
- 8. Set preferences
291
- 9. Listen to personalized radio
292
- 10. Check stats page
293
-
294
- TOMORROW:
295
- 11. Deploy to HuggingFace (see DEPLOYMENT.md)
296
- 12. Test deployed version
297
- 13. Submit to MCP Competition
298
- 14. Share with friends!
299
-
300
- ================================================================================
301
- 🎉 YOU'RE ALL SET!
302
- ================================================================================
303
-
304
- Everything is ready to go! Your AI Radio is:
305
-
306
- ✅ Fully implemented
307
- ✅ Thoroughly documented
308
- ✅ Competition ready
309
- ✅ Deploy ready
310
- ✅ Production quality
311
-
312
- Just add your Gemini API key and you're ready to launch!
313
-
314
- Commands to run:
315
- cd ~/Desktop/ai_radio
316
- python test_app.py # Test everything
317
- python app.py # Start radio!
318
-
319
- Good luck with the MCP Competition! 🍀
320
-
321
- ================================================================================
322
- 📧 QUICK REFERENCE
323
- ================================================================================
324
-
325
- PROJECT NAME: AI Radio
326
- COMPETITION: MCP 1st Birthday
327
- TRACK: MCP in Action - Consumer
328
- TAG: mcp-in-action-track-consumer
329
- LICENSE: MIT
330
- LOCATION: ~/Desktop/ai_radio/
331
-
332
- KEY COMMANDS:
333
- Test: python test_app.py
334
- Run: python app.py
335
- Install: pip install -r requirements.txt
336
-
337
- KEY FILES:
338
- Main App: app.py
339
- Config: config.py (ADD GEMINI KEY HERE!)
340
- Agent: radio_agent.py
341
- RAG: rag_system.py
342
- Test: test_app.py
343
-
344
- IMPORTANT LINKS:
345
- Gemini Key: https://makersuite.google.com/app/apikey
346
- HF Spaces: https://huggingface.co/spaces
347
- Gemini Docs: https://ai.google.dev/
348
-
349
- ================================================================================
350
-
351
- Made with ❤️ for MCP 1st Birthday Competition
352
-
353
- 🎵 Enjoy your personalized AI Radio! 🎵
354
-
355
- ================================================================================
356
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/PROJECT_SUMMARY.md DELETED
@@ -1,315 +0,0 @@
1
- # 🎵 AI Radio - Project Summary
2
-
3
- ## 📦 What We Built
4
-
5
- **AI Radio** is a complete, production-ready personalized radio station application built for the MCP 1st Birthday Competition. It demonstrates autonomous AI agent behavior, MCP server integration, RAG-based personalization, and a beautiful Gradio interface.
6
-
7
- ## ✨ Key Features
8
-
9
- ### 🤖 Autonomous AI Agent
10
- The `RadioAgent` demonstrates three core autonomous behaviors:
11
-
12
- 1. **Planning** - Analyzes user preferences and creates balanced show plans
13
- 2. **Reasoning** - Makes intelligent content selections using LLM
14
- 3. **Execution** - Generates and delivers personalized content
15
-
16
- ### 🛠️ MCP Servers (Tools)
17
- Three specialized MCP servers provide modular functionality:
18
-
19
- - **MusicMCPServer** - Music search and playlist generation
20
- - **NewsMCPServer** - Real-time news fetching and curation
21
- - **PodcastMCPServer** - Podcast discovery and recommendations
22
-
23
- ### 💾 RAG System
24
- Powered by LlamaIndex:
25
- - Stores user preferences and listening history
26
- - Provides context-aware recommendations
27
- - Learns and improves over time
28
- - Semantic search over user data
29
-
30
- ### 🎨 Beautiful Gradio UI
31
- Modern radio station interface with:
32
- - Gradient color schemes
33
- - Real-time playback controls
34
- - Multiple themed tabs
35
- - Responsive design
36
- - Audio player integration
37
-
38
- ### 🔊 Voice Generation
39
- ElevenLabs TTS integration:
40
- - Natural-sounding AI radio host
41
- - High-quality voice synthesis
42
- - Multiple voice options
43
- - Streaming support
44
-
45
- ### 🧠 Advanced LLM Integration
46
- Google Gemini powers:
47
- - Dynamic host commentary
48
- - News script generation
49
- - Story creation
50
- - Personalized introductions
51
- - Context-aware responses
52
-
53
- ## 📁 Project Structure
54
-
55
- ```
56
- ai_radio/
57
- ├── app.py # Main Gradio application
58
- ├── config.py # Configuration and API keys
59
- ├── radio_agent.py # Autonomous AI agent
60
- ├── rag_system.py # RAG system with LlamaIndex
61
- ├── tts_service.py # ElevenLabs TTS integration
62
- ├── demo_assets.py # Sample data and demos
63
- ├── requirements.txt # Python dependencies
64
- ├── mcp_servers/ # MCP Server implementations
65
- │ ├── __init__.py
66
- │ ├── music_server.py # Music search and playlists
67
- │ ├── news_server.py # News fetching
68
- │ └── podcast_server.py # Podcast recommendations
69
- ├── README.md # Main documentation
70
- ├── QUICKSTART.md # 5-minute setup guide
71
- ├── SETUP_GUIDE.md # Detailed setup instructions
72
- ├── ARCHITECTURE.md # Technical architecture
73
- ├── DEPLOYMENT.md # HuggingFace deployment guide
74
- ├── .gitignore # Git ignore rules
75
- └── LICENSE # MIT License
76
- ```
77
-
78
- ## 🏆 Competition Requirements Met
79
-
80
- ### ✅ Track 2: MCP in Action
81
-
82
- | Requirement | Implementation | Status |
83
- |------------|----------------|--------|
84
- | Autonomous Agent Behavior | RadioAgent with planning, reasoning, execution | ✅ Complete |
85
- | MCP Servers as Tools | 3 specialized MCP servers | ✅ Complete |
86
- | Gradio App | Beautiful radio station UI | ✅ Complete |
87
- | Advanced Features (Bonus) | RAG system + Context Engineering | ✅ Complete |
88
-
89
- ### 🎯 Autonomous Behaviors Demonstrated
90
-
91
- 1. **Planning**:
92
- - Analyzes user preferences
93
- - Creates balanced show structure
94
- - Optimizes segment distribution
95
- - Considers variety and flow
96
-
97
- 2. **Reasoning**:
98
- - Uses RAG for context-aware decisions
99
- - Generates appropriate commentary
100
- - Selects relevant content
101
- - Adapts to user mood
102
-
103
- 3. **Execution**:
104
- - Calls MCP tools as needed
105
- - Generates TTS dynamically
106
- - Manages playback flow
107
- - Logs for learning
108
-
109
- ## 🔧 Technology Stack
110
-
111
- | Component | Technology | Purpose |
112
- |-----------|-----------|---------|
113
- | UI Framework | Gradio 4.44.0 | Interactive web interface |
114
- | LLM | Google Gemini Pro | Content generation & reasoning |
115
- | TTS | ElevenLabs | Voice synthesis |
116
- | RAG | LlamaIndex | Personalization & learning |
117
- | Embeddings | Gemini Embeddings | Vector search |
118
- | News | RSS Feeds | Real-time news |
119
- | Protocol | MCP | Structured tools |
120
-
121
- ## 🎮 User Experience Flow
122
-
123
- 1. **Onboarding**:
124
- ```
125
- User opens app → Sets preferences → Saves to RAG
126
- ```
127
-
128
- 2. **Planning**:
129
- ```
130
- User clicks Start → Agent queries RAG → Plans show → Returns segments
131
- ```
132
-
133
- 3. **Playback**:
134
- ```
135
- Play segment → Call MCP server → Generate TTS → Play audio
136
- ```
137
-
138
- 4. **Learning**:
139
- ```
140
- User listens → Log to RAG → Update preferences → Better recommendations
141
- ```
142
-
143
- ## 📊 Performance Characteristics
144
-
145
- ### Efficiency
146
- - **Low latency**: Segments generate in 2-5 seconds
147
- - **Streaming**: Audio streams for faster playback
148
- - **Caching**: Reuses generated content when possible
149
- - **Cost-effective**: Optimized API calls
150
-
151
- ### Scalability
152
- - **Modular design**: Easy to add new MCP servers
153
- - **Stateless segments**: Each segment independent
154
- - **Efficient storage**: JSON-based persistence
155
- - **API optimized**: Minimal token usage
156
-
157
- ## 🎨 UI Highlights
158
-
159
- ### Radio Player Tab
160
- - Prominent play controls
161
- - Now playing display
162
- - Progress indicator
163
- - Audio player with auto-play
164
- - Segment information display
165
-
166
- ### Preferences Tab
167
- - Intuitive form layout
168
- - Multi-select dropdowns
169
- - Instant save feedback
170
- - Visual confirmation
171
-
172
- ### Stats Tab
173
- - Listening history
174
- - Usage statistics
175
- - RAG-powered insights
176
- - One-click refresh
177
-
178
- ### About Tab
179
- - Feature overview
180
- - Technology stack
181
- - Competition info
182
- - Usage instructions
183
-
184
- ## 🔒 Security & Privacy
185
-
186
- - ✅ API keys in config (can use env vars)
187
- - ✅ Local data storage
188
- - ✅ No unnecessary data collection
189
- - ✅ User data stays on device
190
- - ✅ Secure API communication
191
-
192
- ## 📈 Future Enhancements
193
-
194
- ### Possible Extensions
195
- 1. Real music API integration (Spotify, Apple Music)
196
- 2. Live streaming capabilities
197
- 3. Social sharing features
198
- 4. Mobile app version
199
- 5. Offline mode
200
- 6. Voice commands
201
- 7. Multi-language support
202
- 8. Advanced analytics
203
-
204
- ## 📚 Documentation
205
-
206
- | Document | Purpose | Audience |
207
- |----------|---------|----------|
208
- | README.md | Project overview | All users |
209
- | QUICKSTART.md | 5-minute setup | New users |
210
- | SETUP_GUIDE.md | Detailed setup | All users |
211
- | ARCHITECTURE.md | Technical details | Developers |
212
- | DEPLOYMENT.md | HuggingFace deploy | Deployers |
213
- | PROJECT_SUMMARY.md | This file | Everyone |
214
-
215
- ## 🎯 What Makes This Special
216
-
217
- ### Innovation
218
- - **Personalized Radio**: First AI-powered personal radio station
219
- - **Autonomous Agent**: Fully self-managing show planning
220
- - **RAG Integration**: Learning system that improves over time
221
- - **MCP Protocol**: Demonstrates proper tool integration
222
-
223
- ### Quality
224
- - **Professional UI**: Beautiful, polished interface
225
- - **Comprehensive Docs**: Extensive documentation
226
- - **Error Handling**: Graceful fallbacks
227
- - **User Experience**: Intuitive, smooth interactions
228
-
229
- ### Completeness
230
- - **Full Stack**: End-to-end implementation
231
- - **Production Ready**: Can be deployed immediately
232
- - **Well Tested**: Robust error handling
233
- - **Documented**: Every component explained
234
-
235
- ## 🚀 Quick Start
236
-
237
- ```bash
238
- # 1. Install dependencies
239
- pip install -r requirements.txt
240
-
241
- # 2. Add Gemini API key to config.py
242
- # Edit config.py: google_api_key = "your-key"
243
-
244
- # 3. Run
245
- python app.py
246
-
247
- # 4. Open browser
248
- # http://localhost:7860
249
- ```
250
-
251
- ## 📊 Project Stats
252
-
253
- - **Files**: 15 source files
254
- - **Lines of Code**: ~2,500+
255
- - **MCP Servers**: 3 specialized tools
256
- - **Documentation Pages**: 6 comprehensive guides
257
- - **Features**: 10+ major features
258
- - **Dependencies**: 15 Python packages
259
- - **Development Time**: Optimized for quality
260
-
261
- ## 🎉 Success Criteria
262
-
263
- All checkboxes verified:
264
-
265
- - ✅ Autonomous agent with planning, reasoning, execution
266
- - ✅ MCP servers implemented as tools
267
- - ✅ Gradio app with beautiful UI
268
- - ✅ RAG system for personalization
269
- - ✅ Context engineering demonstrated
270
- - ✅ Production-ready code
271
- - ✅ Comprehensive documentation
272
- - ✅ Easy deployment process
273
- - ✅ Tagged for competition
274
- - ✅ Ready to submit!
275
-
276
- ## 🏅 Competition Highlights
277
-
278
- ### Why This Wins
279
-
280
- 1. **Complete Implementation**: Every requirement exceeded
281
- 2. **Beautiful UX**: Professional, polished interface
282
- 3. **Real Utility**: Actually useful application
283
- 4. **Technical Excellence**: Clean, modular architecture
284
- 5. **Great Documentation**: Easy to understand and deploy
285
- 6. **MCP Showcase**: Perfect demonstration of protocol
286
- 7. **RAG Integration**: Advanced personalization
287
- 8. **Production Ready**: Deploy immediately
288
-
289
- ## 📧 Next Steps
290
-
291
- 1. ✅ Add your Gemini API key to `config.py`
292
- 2. ✅ Test locally with `python app.py`
293
- 3. ✅ Deploy to HuggingFace Spaces
294
- 4. ✅ Submit to MCP Competition
295
- 5. 🎉 Share with the world!
296
-
297
- ## 🙏 Acknowledgments
298
-
299
- - **MCP Team** - For the amazing protocol
300
- - **Google** - For Gemini API
301
- - **ElevenLabs** - For TTS technology
302
- - **LlamaIndex** - For RAG capabilities
303
- - **Gradio** - For beautiful UI framework
304
- - **You** - For building this!
305
-
306
- ---
307
-
308
- ## 🎵 Enjoy Your AI Radio! 🎵
309
-
310
- **Track**: MCP in Action - Consumer Applications
311
- **Tag**: `mcp-in-action-track-consumer`
312
- **Status**: ✅ Ready for Competition
313
-
314
- Made with ❤️ for MCP 1st Birthday Competition
315
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/QUICKSTART.md DELETED
@@ -1,155 +0,0 @@
1
- # ⚡ AI Radio - Quick Start Guide
2
-
3
- Get your AI Radio up and running in 5 minutes!
4
-
5
- ## 🎯 What You Need
6
-
7
- 1. **Gemini API Key** - [Get it here](https://makersuite.google.com/app/apikey) (FREE)
8
- 2. Python 3.9+ installed
9
- 3. That's it! ElevenLabs and LlamaIndex keys are already included
10
-
11
- ## 🚀 3-Step Setup
12
-
13
- ### Step 1: Install Dependencies (2 minutes)
14
-
15
- ```bash
16
- cd ~/Desktop/ai_radio
17
- pip install -r requirements.txt
18
- ```
19
-
20
- ### Step 2: Add Your Gemini Key (30 seconds)
21
-
22
- Open `config.py` and add your key:
23
-
24
- ```python
25
- google_api_key: str = "paste-your-gemini-key-here"
26
- ```
27
-
28
- Or set environment variable:
29
- ```bash
30
- export GOOGLE_API_KEY="your-key-here"
31
- ```
32
-
33
- ### Step 3: Run! (10 seconds)
34
-
35
- ```bash
36
- python app.py
37
- ```
38
-
39
- Open: http://localhost:7860
40
-
41
- ## 🎵 First Use (1 minute)
42
-
43
- 1. Go to **"Your Preferences"** tab
44
- 2. Enter your name: `Your Name`
45
- 3. Pick genres: `pop`, `rock`
46
- 4. Pick interests: `technology`, `world`
47
- 5. Click **"Save Preferences"**
48
- 6. Go to **"Radio Player"** tab
49
- 7. Click **"▶️ Start Radio"**
50
- 8. Enjoy! 🎉
51
-
52
- ## ✅ What You Get
53
-
54
- - 🎵 **Personalized Music** from your favorite genres
55
- - 📰 **Latest News** on topics you care about
56
- - 🎙️ **Podcast Recommendations** matching your interests
57
- - 📖 **AI-Generated Stories** and fun facts
58
- - 🤖 **AI Radio Host** with natural voice
59
- - 💾 **Smart Learning** - gets better over time
60
-
61
- ## 🎮 Controls
62
-
63
- | Button | Action |
64
- |--------|--------|
65
- | ▶️ Start Radio | Begin your show |
66
- | ⏭️ Next Segment | Skip to next |
67
- | ⏹️ Stop | Pause playback |
68
-
69
- ## 📱 How It Works
70
-
71
- ```
72
- You → Set Preferences → AI Plans Show → Generates Content → Plays Audio
73
-
74
- Learns from your listening
75
-
76
- Better recommendations next time!
77
- ```
78
-
79
- ## 🔧 Troubleshooting
80
-
81
- **Can't hear audio?**
82
- - Check that ElevenLabs key is in `config.py`
83
- - Verify internet connection
84
-
85
- **Errors with Gemini?**
86
- - Double-check your API key
87
- - Make sure it's from Google AI Studio
88
-
89
- **News not loading?**
90
- - This is OK! Demo news will play instead
91
-
92
- ## 🌟 Pro Tips
93
-
94
- 1. **Try different moods** - Changes the music and tone
95
- 2. **Mix genres** - Get more variety in your show
96
- 3. **Check stats** - See what you've listened to
97
- 4. **Let it run** - Each segment is unique!
98
-
99
- ## 📊 Example Show
100
-
101
- A typical 30-minute show includes:
102
- - **Intro** (1 min) - Personal greeting
103
- - **Music** (15 min) - 5 tracks from your favorite genres
104
- - **News** (6 min) - Latest updates on your interests
105
- - **Podcasts** (6 min) - 3 podcast recommendations
106
- - **Stories** (3 min) - Interesting facts and tales
107
- - **Outro** (1 min) - Friendly goodbye
108
-
109
- ## 🚀 Deploy to HuggingFace (5 minutes)
110
-
111
- 1. Go to [HuggingFace Spaces](https://huggingface.co/spaces)
112
- 2. Click "New Space"
113
- 3. Choose Gradio SDK
114
- 4. Upload all files
115
- 5. Add `GOOGLE_API_KEY` in Settings → Secrets
116
- 6. Done! Share the link
117
-
118
- ## 🎨 Customize
119
-
120
- ### Change the Voice
121
- ```python
122
- # config.py
123
- elevenlabs_voice_id: str = "ErXwobaYiN019PkySvjV" # Antoni
124
- ```
125
-
126
- ### More Music, Less News
127
- ```python
128
- # config.py
129
- music_ratio: float = 0.7 # 70% music
130
- news_ratio: float = 0.1 # 10% news
131
- ```
132
-
133
- ### Different Station Name
134
- ```python
135
- # config.py
136
- station_name: str = "My Cool Radio 🎶"
137
- ```
138
-
139
- ## 🆘 Need Help?
140
-
141
- 1. Read [SETUP_GUIDE.md](SETUP_GUIDE.md) for detailed instructions
142
- 2. Check [ARCHITECTURE.md](ARCHITECTURE.md) for technical details
143
- 3. Review error messages carefully
144
- 4. Ensure all API keys are set correctly
145
-
146
- ## 🎉 You're Ready!
147
-
148
- That's it! You now have your own personalized AI radio station.
149
-
150
- **Enjoy the show!** 🎵📻🎶
151
-
152
- ---
153
-
154
- Made with ❤️ for MCP 1st Birthday Competition
155
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/SETUP_GUIDE.md DELETED
@@ -1,378 +0,0 @@
1
- # 🚀 AI Radio - Complete Setup Guide
2
-
3
- This guide will walk you through setting up AI Radio on your local machine or deploying it to HuggingFace Spaces.
4
-
5
- ## 📋 Prerequisites
6
-
7
- - Python 3.9 or higher
8
- - pip (Python package manager)
9
- - Google Gemini API key
10
- - (Optional) Git for version control
11
-
12
- ## 🔑 Getting API Keys
13
-
14
- ### 1. Google Gemini API Key (Required)
15
-
16
- 1. Go to [Google AI Studio](https://makersuite.google.com/app/apikey)
17
- 2. Sign in with your Google account
18
- 3. Click "Create API Key"
19
- 4. Copy your API key
20
- 5. Keep it safe - you'll need it later
21
-
22
- ### 2. ElevenLabs API Key (Already Provided)
23
-
24
- The ElevenLabs API key is already included in the configuration:
25
- ```
26
- sk_2dde999f3cedf21dff7ba4671ce27f292e48ea37d30c5e4a
27
- ```
28
-
29
- ### 3. LlamaIndex API Key (Already Provided)
30
-
31
- The LlamaIndex API key is already included:
32
- ```
33
- llx-WRsj0iehk2ZlSlNIenOLyyhO9X1yFT4CmJXpl0qk6hapFi01
34
- ```
35
-
36
- ## 💻 Local Installation
37
-
38
- ### Step 1: Clone the Repository
39
-
40
- ```bash
41
- # Navigate to your desired directory
42
- cd ~/Desktop
43
-
44
- # If you have the ai_radio folder already
45
- cd ai_radio
46
-
47
- # Otherwise, create it
48
- mkdir ai_radio
49
- cd ai_radio
50
- ```
51
-
52
- ### Step 2: Create Virtual Environment (Recommended)
53
-
54
- ```bash
55
- # Create virtual environment
56
- python -m venv venv
57
-
58
- # Activate it
59
- # On macOS/Linux:
60
- source venv/bin/activate
61
-
62
- # On Windows:
63
- venv\Scripts\activate
64
- ```
65
-
66
- ### Step 3: Install Dependencies
67
-
68
- ```bash
69
- pip install -r requirements.txt
70
- ```
71
-
72
- This will install:
73
- - gradio
74
- - google-generativeai
75
- - elevenlabs
76
- - llama-index
77
- - feedparser
78
- - and other dependencies
79
-
80
- ### Step 4: Configure API Keys
81
-
82
- Edit the `config.py` file and add your Gemini API key:
83
-
84
- ```python
85
- # Open config.py in your favorite editor
86
- nano config.py # or vim, code, etc.
87
-
88
- # Find this line:
89
- google_api_key: str = ""
90
-
91
- # Replace with your actual key:
92
- google_api_key: str = "your-gemini-api-key-here"
93
- ```
94
-
95
- Or set it as an environment variable:
96
-
97
- ```bash
98
- export GOOGLE_API_KEY="your-gemini-api-key-here"
99
- ```
100
-
101
- ### Step 5: Run the App
102
-
103
- ```bash
104
- python app.py
105
- ```
106
-
107
- You should see output like:
108
- ```
109
- Running on local URL: http://0.0.0.0:7860
110
-
111
- To create a public link, set `share=True` in `launch()`.
112
- ```
113
-
114
- ### Step 6: Open in Browser
115
-
116
- Open your browser and navigate to:
117
- ```
118
- http://localhost:7860
119
- ```
120
-
121
- You should see the AI Radio interface!
122
-
123
- ## 🎮 First-Time Usage
124
-
125
- ### 1. Set Your Preferences
126
-
127
- 1. Click on the **"Your Preferences"** tab
128
- 2. Fill in:
129
- - Your name (e.g., "Alex")
130
- - Current mood (e.g., "happy")
131
- - Favorite music genres (e.g., "pop", "rock")
132
- - News interests (e.g., "technology", "world")
133
- - Podcast interests (e.g., "technology")
134
- 3. Click **"Save Preferences"**
135
-
136
- You should see: ✅ Preferences saved!
137
-
138
- ### 2. Start Your Radio
139
-
140
- 1. Go to the **"Radio Player"** tab
141
- 2. Click **"▶️ Start Radio"**
142
- 3. Wait a moment for the agent to plan your show
143
- 4. Listen to your personalized radio!
144
-
145
- ### 3. Control Playback
146
-
147
- - **⏭️ Next Segment**: Skip to next segment
148
- - **⏹️ Stop**: Pause the radio
149
-
150
- ### 4. View Your Stats
151
-
152
- 1. Go to the **"Your Stats"** tab
153
- 2. Click **"🔄 Refresh Stats"**
154
- 3. See your listening history!
155
-
156
- ## 🌐 Deploying to HuggingFace Spaces
157
-
158
- ### Option 1: Using the Web Interface
159
-
160
- 1. **Create Account**
161
- - Go to [HuggingFace](https://huggingface.co)
162
- - Sign up or log in
163
-
164
- 2. **Create New Space**
165
- - Click your profile → "New Space"
166
- - Space name: `ai-radio`
167
- - License: MIT
168
- - Select SDK: **Gradio**
169
- - Visibility: Public
170
- - Click "Create Space"
171
-
172
- 3. **Upload Files**
173
- - Click "Files" tab
174
- - Click "Add file" → "Upload files"
175
- - Upload all files:
176
- - `app.py`
177
- - `config.py`
178
- - `requirements.txt`
179
- - `radio_agent.py`
180
- - `rag_system.py`
181
- - `tts_service.py`
182
- - `mcp_servers/` folder (all files)
183
- - `README.md`
184
- - Commit changes
185
-
186
- 4. **Set Secrets**
187
- - Go to "Settings" tab
188
- - Click "New secret"
189
- - Name: `GOOGLE_API_KEY`
190
- - Value: Your Gemini API key
191
- - Click "Add"
192
-
193
- 5. **Wait for Build**
194
- - HuggingFace will automatically build your space
195
- - Wait 2-3 minutes
196
- - Your app will be live!
197
-
198
- ### Option 2: Using Git (Advanced)
199
-
200
- ```bash
201
- # Install git-lfs
202
- git lfs install
203
-
204
- # Clone your space
205
- git clone https://huggingface.co/spaces/YOUR_USERNAME/ai-radio
206
- cd ai-radio
207
-
208
- # Copy all files
209
- cp -r ~/Desktop/ai_radio/* .
210
-
211
- # Add, commit, push
212
- git add .
213
- git commit -m "Initial commit of AI Radio"
214
- git push
215
- ```
216
-
217
- ## 🔧 Troubleshooting
218
-
219
- ### Issue: "ElevenLabs client not initialized"
220
-
221
- **Solution**: Check that the ElevenLabs API key is correctly set in `config.py`
222
-
223
- ### Issue: "Error generating speech"
224
-
225
- **Solutions**:
226
- 1. Verify ElevenLabs API key is valid
227
- 2. Check internet connection
228
- 3. Check API rate limits
229
-
230
- ### Issue: "Error fetching news"
231
-
232
- **Solution**: This is normal! The app will fall back to demo news. For real news:
233
- 1. Ensure internet connection
234
- 2. Some RSS feeds may be blocked - this is okay
235
-
236
- ### Issue: Gemini API errors
237
-
238
- **Solutions**:
239
- 1. Verify your API key is correct
240
- 2. Check you haven't exceeded quota
241
- 3. Make sure the key has Gemini API access enabled
242
-
243
- ### Issue: "Module not found"
244
-
245
- **Solution**: Reinstall dependencies:
246
- ```bash
247
- pip install -r requirements.txt --force-reinstall
248
- ```
249
-
250
- ### Issue: Port 7860 already in use
251
-
252
- **Solution**: Kill the existing process or use a different port:
253
- ```bash
254
- # Find process
255
- lsof -i :7860
256
-
257
- # Kill it
258
- kill -9 <PID>
259
-
260
- # Or change port in app.py:
261
- demo.launch(server_port=7861)
262
- ```
263
-
264
- ## 📱 Testing the App
265
-
266
- ### Test Checklist
267
-
268
- - [ ] Set preferences successfully
269
- - [ ] Start radio and hear intro
270
- - [ ] Music segment plays with commentary
271
- - [ ] News segment delivers news
272
- - [ ] Podcast segment gives recommendations
273
- - [ ] Story segment tells interesting story
274
- - [ ] Next button skips segments
275
- - [ ] Stop button pauses radio
276
- - [ ] Stats page shows listening history
277
- - [ ] Preferences persist between sessions
278
-
279
- ## 🎨 Customization
280
-
281
- ### Change Voice
282
-
283
- Edit `config.py`:
284
- ```python
285
- elevenlabs_voice_id: str = "ErXwobaYiN019PkySvjV" # Antoni voice
286
- ```
287
-
288
- Available voices:
289
- - `21m00Tcm4TlvDq8ikWAM` - Rachel (Default)
290
- - `ErXwobaYiN019PkySvjV` - Antoni
291
- - `MF3mGyEYCl7XYWbV9V6O` - Elli
292
-
293
- ### Change Segment Ratios
294
-
295
- Edit `config.py`:
296
- ```python
297
- music_ratio: float = 0.6 # 60% music (default 50%)
298
- news_ratio: float = 0.2 # 20% news
299
- podcast_ratio: float = 0.1 # 10% podcasts (default 20%)
300
- story_ratio: float = 0.1 # 10% stories
301
- ```
302
-
303
- ### Add Real Music API
304
-
305
- Edit `mcp_servers/music_server.py`:
306
- ```python
307
- def search_free_music(self, genre: str, mood: str, limit: int):
308
- # Add your API integration here
309
- # Example: Spotify, Apple Music, YouTube Music
310
- pass
311
- ```
312
-
313
- ### Customize UI Colors
314
-
315
- Edit `app.py` CSS:
316
- ```python
317
- custom_css = """
318
- #radio-header {
319
- background: linear-gradient(135deg, #your-color 0%, #your-color2 100%);
320
- }
321
- """
322
- ```
323
-
324
- ## 📊 Performance Tips
325
-
326
- ### Reduce Cost
327
-
328
- 1. **Use shorter segments**: Modify `duration_minutes` in planning
329
- 2. **Cache audio**: Reuse generated TTS
330
- 3. **Batch requests**: Generate multiple segments at once
331
-
332
- ### Improve Speed
333
-
334
- 1. **Preload content**: Fetch news/music in advance
335
- 2. **Parallel generation**: Generate TTS while planning next segment
336
- 3. **Optimize prompts**: Use shorter, more efficient prompts
337
-
338
- ## 🔒 Security Best Practices
339
-
340
- 1. **Never commit API keys** to public repos
341
- 2. **Use environment variables** for sensitive data
342
- 3. **Rotate keys regularly**
343
- 4. **Monitor API usage** to detect abuse
344
- 5. **Use secrets** in HuggingFace Spaces
345
-
346
- ## 📚 Additional Resources
347
-
348
- - [Gradio Documentation](https://www.gradio.app/docs)
349
- - [Gemini API Guide](https://ai.google.dev/tutorials)
350
- - [ElevenLabs API Docs](https://elevenlabs.io/docs)
351
- - [LlamaIndex Tutorials](https://docs.llamaindex.ai/)
352
- - [HuggingFace Spaces Guide](https://huggingface.co/docs/hub/spaces)
353
-
354
- ## 🆘 Getting Help
355
-
356
- If you encounter issues:
357
-
358
- 1. Check the troubleshooting section above
359
- 2. Review error messages carefully
360
- 3. Check API quotas and limits
361
- 4. Verify all dependencies are installed
362
- 5. Try running in a fresh virtual environment
363
-
364
- ## 🎉 Success!
365
-
366
- Once everything is working, you should have:
367
- - ✅ A running AI Radio station
368
- - ✅ Personalized content based on your preferences
369
- - ✅ Smooth playback with TTS
370
- - ✅ A beautiful Gradio interface
371
- - ✅ RAG-powered recommendations
372
-
373
- Enjoy your personalized AI Radio! 🎵
374
-
375
- ---
376
-
377
- Need help? Check the ARCHITECTURE.md for technical details!
378
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
docs/START_HERE.md DELETED
@@ -1,306 +0,0 @@
1
- # 🎵 AI Radio - START HERE! 🎵
2
-
3
- Welcome to your AI Radio project! This guide will get you up and running in minutes.
4
-
5
- ## 🎯 What You Have
6
-
7
- A complete, production-ready **personalized AI radio station** for the MCP 1st Birthday Competition!
8
-
9
- **Features:**
10
- - 🤖 Autonomous AI agent (planning, reasoning, execution)
11
- - 🎵 Personalized music from your favorite genres
12
- - 📰 Real-time news on topics you care about
13
- - 🎙️ Podcast recommendations
14
- - 📖 AI-generated stories
15
- - 🔊 Natural voice with ElevenLabs TTS
16
- - 💾 RAG system that learns your preferences
17
- - 🎨 Beautiful Gradio UI
18
-
19
- ## ⚡ Quick Start (5 Minutes)
20
-
21
- ### 1️⃣ Get Your Gemini API Key (2 minutes)
22
-
23
- This is the ONLY thing you need to do!
24
-
25
- 1. Go to: https://makersuite.google.com/app/apikey
26
- 2. Sign in with Google (it's FREE!)
27
- 3. Click "Create API Key"
28
- 4. Copy your key
29
-
30
- 📖 **Detailed guide**: See `GET_GEMINI_KEY.md`
31
-
32
- ### 2️⃣ Add Your Key (30 seconds)
33
-
34
- Open `config.py` and find this line:
35
-
36
- ```python
37
- google_api_key: str = ""
38
- ```
39
-
40
- Replace with your key:
41
-
42
- ```python
43
- google_api_key: str = "your-gemini-key-here"
44
- ```
45
-
46
- ### 3️⃣ Install Dependencies (2 minutes)
47
-
48
- ```bash
49
- cd ~/Desktop/ai_radio
50
- pip install -r requirements.txt
51
- ```
52
-
53
- ### 4️⃣ Test Everything (1 minute)
54
-
55
- ```bash
56
- python test_app.py
57
- ```
58
-
59
- You should see: "🎉 All tests passed!"
60
-
61
- ### 5️⃣ Run! (10 seconds)
62
-
63
- ```bash
64
- python app.py
65
- ```
66
-
67
- Open in browser: http://localhost:7860
68
-
69
- ## 🎮 Using AI Radio
70
-
71
- ### First Time Setup
72
-
73
- 1. Go to **"Your Preferences"** tab
74
- 2. Enter your details:
75
- - Name (e.g., "Alex")
76
- - Mood (e.g., "happy")
77
- - Favorite genres (e.g., pop, rock)
78
- - News interests (e.g., technology, world)
79
- - Podcast interests (e.g., technology)
80
- 3. Click **"Save Preferences"**
81
-
82
- ### Start Listening
83
-
84
- 1. Go to **"Radio Player"** tab
85
- 2. Click **"▶️ Start Radio"**
86
- 3. Enjoy your personalized show!
87
- 4. Use **⏭️ Next** to skip segments
88
- 5. Use **⏹️ Stop** to pause
89
-
90
- ### View Your Stats
91
-
92
- 1. Go to **"Your Stats"** tab
93
- 2. See your listening history
94
- 3. The RAG system learns from this!
95
-
96
- ## 📁 Project Files
97
-
98
- Here's what you have:
99
-
100
- | File | What It Does |
101
- |------|-------------|
102
- | `app.py` | Main Gradio app (run this!) |
103
- | `radio_agent.py` | Autonomous AI agent |
104
- | `rag_system.py` | Learning/personalization |
105
- | `tts_service.py` | Voice generation |
106
- | `mcp_servers/` | MCP tools (music, news, podcasts) |
107
- | `config.py` | Configuration (add your key here!) |
108
- | `test_app.py` | Test all components |
109
-
110
- **Documentation:**
111
- - `README.md` - Full project documentation
112
- - `QUICKSTART.md` - Fast setup guide
113
- - `SETUP_GUIDE.md` - Detailed instructions
114
- - `GET_GEMINI_KEY.md` - How to get API key
115
- - `ARCHITECTURE.md` - Technical details
116
- - `DEPLOYMENT.md` - Deploy to HuggingFace
117
- - `PROJECT_SUMMARY.md` - Complete overview
118
-
119
- ## 🚀 Deploy to HuggingFace (5 Minutes)
120
-
121
- ### Quick Deploy
122
-
123
- 1. Go to: https://huggingface.co/spaces
124
- 2. Create new Space (Gradio SDK)
125
- 3. Upload all files
126
- 4. Add `GOOGLE_API_KEY` in Settings → Secrets
127
- 5. Wait for build
128
- 6. Done! 🎉
129
-
130
- 📖 **Detailed guide**: See `DEPLOYMENT.md`
131
-
132
- ## ✅ Verification Checklist
133
-
134
- Before submitting to the competition:
135
-
136
- - [ ] Gemini API key added to config
137
- - [ ] `python test_app.py` passes all tests
138
- - [ ] App runs locally without errors
139
- - [ ] Can save preferences
140
- - [ ] Radio starts and plays
141
- - [ ] Audio generates (TTS works)
142
- - [ ] All MCP servers working
143
- - [ ] RAG system stores data
144
- - [ ] Deployed to HuggingFace Spaces
145
- - [ ] README has competition tags
146
-
147
- ## 🏆 Competition Info
148
-
149
- **Track**: MCP in Action - Consumer Applications
150
- **Tag**: `mcp-in-action-track-consumer`
151
-
152
- **Requirements Met:**
153
- - ✅ Autonomous agent (planning, reasoning, execution)
154
- - ✅ MCP servers as tools (3 specialized servers)
155
- - ✅ Gradio app (beautiful UI)
156
- - ✅ Advanced features (RAG + Context Engineering)
157
-
158
- ## 📚 Need Help?
159
-
160
- ### Common Issues
161
-
162
- **"API key not valid"**
163
- - Check you copied the entire key from Google AI Studio
164
- - See `GET_GEMINI_KEY.md`
165
-
166
- **"Module not found"**
167
- - Run: `pip install -r requirements.txt`
168
-
169
- **"No audio playing"**
170
- - Check ElevenLabs key in config.py
171
- - Key is already included!
172
-
173
- **Tests failing?**
174
- - Make sure all dependencies installed
175
- - Check Gemini API key is set
176
-
177
- ### Where to Look
178
-
179
- | Problem | Solution |
180
- |---------|----------|
181
- | Setup issues | `SETUP_GUIDE.md` |
182
- | API key help | `GET_GEMINI_KEY.md` |
183
- | Deployment | `DEPLOYMENT.md` |
184
- | How it works | `ARCHITECTURE.md` |
185
- | Quick fixes | This file! |
186
-
187
- ## 🎨 Customization
188
-
189
- ### Change the Voice
190
-
191
- Edit `config.py`:
192
- ```python
193
- elevenlabs_voice_id: str = "ErXwobaYiN019PkySvjV" # Antoni
194
- ```
195
-
196
- ### More Music, Less News
197
-
198
- Edit `config.py`:
199
- ```python
200
- music_ratio: float = 0.7 # 70% music
201
- news_ratio: float = 0.1 # 10% news
202
- ```
203
-
204
- ### Station Name
205
-
206
- Edit `config.py`:
207
- ```python
208
- station_name: str = "My Cool Radio 🎶"
209
- ```
210
-
211
- ## 🌟 Pro Tips
212
-
213
- 1. **Try different moods** - Affects music and commentary tone
214
- 2. **Mix multiple genres** - More variety in your show
215
- 3. **Let it run** - Each segment is unique!
216
- 4. **Check stats regularly** - See the RAG system learning
217
- 5. **Deploy to HF** - Share with friends!
218
-
219
- ## 📊 What Happens When You Run
220
-
221
- ```
222
- 1. You set preferences
223
-
224
- 2. RAG system stores them
225
-
226
- 3. Agent plans personalized show
227
-
228
- 4. MCP servers fetch content
229
-
230
- 5. Gemini generates commentary
231
-
232
- 6. ElevenLabs creates voice
233
-
234
- 7. You hear amazing radio!
235
-
236
- 8. System learns for next time
237
- ```
238
-
239
- ## 🎉 You're Ready!
240
-
241
- Everything is set up and ready to go. Just:
242
-
243
- 1. ✅ Add your Gemini API key to `config.py`
244
- 2. ✅ Run `python test_app.py`
245
- 3. ✅ Start with `python app.py`
246
- 4. 🎵 Enjoy!
247
-
248
- ## 🚢 Next Steps
249
-
250
- ### Today
251
- - [ ] Get Gemini API key
252
- - [ ] Test locally
253
- - [ ] Try all features
254
-
255
- ### Tomorrow
256
- - [ ] Deploy to HuggingFace
257
- - [ ] Share with friends
258
- - [ ] Submit to competition
259
-
260
- ### Optional
261
- - [ ] Customize UI colors
262
- - [ ] Add more genres
263
- - [ ] Tweak segment ratios
264
- - [ ] Create demo video
265
-
266
- ## 🙏 Thank You!
267
-
268
- Thank you for building AI Radio! This project demonstrates:
269
- - Autonomous AI agents
270
- - MCP protocol integration
271
- - RAG-based personalization
272
- - Beautiful UX design
273
-
274
- **Good luck with the MCP Competition!** 🍀
275
-
276
- ---
277
-
278
- ## 🆘 Still Stuck?
279
-
280
- If you're having issues:
281
-
282
- 1. Read the error message carefully
283
- 2. Check `SETUP_GUIDE.md` troubleshooting section
284
- 3. Run `python test_app.py` to diagnose
285
- 4. Verify all API keys are set
286
- 5. Make sure dependencies are installed
287
-
288
- ## 🎵 Let's Go!
289
-
290
- You're all set to create amazing personalized radio experiences!
291
-
292
- **Run this now:**
293
- ```bash
294
- python test_app.py
295
- python app.py
296
- ```
297
-
298
- **Open:** http://localhost:7860
299
-
300
- **Enjoy your AI Radio!** 🎉🎵📻
301
-
302
- ---
303
-
304
- Made with ❤️ for MCP 1st Birthday Competition
305
- Track: MCP in Action - Consumer Applications
306
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/app.py CHANGED
@@ -1961,10 +1961,13 @@ Your passphrase: **{passphrase}**
1961
  """)
1962
 
1963
  # Launch the app
 
1964
  if __name__ == "__main__":
 
 
1965
  demo.launch(
1966
  server_name="0.0.0.0",
1967
- server_port=7871,
1968
  share=False
1969
  )
1970
 
 
1961
  """)
1962
 
1963
  # Launch the app
1964
+ # Note: For HuggingFace Spaces, use app.py at root level instead
1965
  if __name__ == "__main__":
1966
+ import os
1967
+ port = int(os.getenv("PORT", 7871))
1968
  demo.launch(
1969
  server_name="0.0.0.0",
1970
+ server_port=port,
1971
  share=False
1972
  )
1973
 
src/config.py CHANGED
@@ -5,17 +5,13 @@ from pydantic import BaseModel
5
  class RadioConfig(BaseModel):
6
  """Configuration for the radio app"""
7
 
8
- # API Keys
9
- elevenlabs_api_key: str = "sk_d0a3622fe5acdf6c747236728ef193a3726c29bc943519d5"
10
- llamaindex_api_key: str = "llx-WRsj0iehk2ZlSlNIenOLyyhO9X1yFT4CmJXpl0qk6hapFi01"
11
- nebius_api_key: str = "v1.CmQKHHN0YXRpY2tleS1lMDB0eTkxeTdwY3lxNDk5OWcSIXNlcnZpY2VhY2NvdW50LWUwMGowemtmZWpqc2E3ZHF3aDIMCKb4oskGENS9j8MBOgwIpfu6lAcQgOqAhwNAAloDZTAw.AAAAAAAAAAGEI_L5sJCQ7XR93nSzvXCPO-J3-gHjqPiRqrvkrMLeDtd-70zGWB1-c8yovnX-q7yEc1dHOnA2L8FUa3Le6X8D"
 
 
12
  # Nebius OpenAI-compatible endpoint and model
13
- # See example usage:
14
- # client = OpenAI(
15
- # base_url="https://api.tokenfactory.nebius.com/v1/",
16
- # api_key=os.environ.get("NEBIUS_API_KEY")
17
- # )
18
- # model="openai/gpt-oss-120b"
19
  nebius_api_base: str = "https://api.tokenfactory.nebius.com/v1/" # Nebius OpenAI-compatible endpoint
20
  nebius_model: str = "openai/gpt-oss-120b" # GPT-OSS-120B model name from Nebius
21
 
@@ -33,16 +29,20 @@ class RadioConfig(BaseModel):
33
  story_ratio: float = 0.1
34
 
35
  def get_config() -> RadioConfig:
36
- """Get configuration with environment variable overrides"""
37
  config = RadioConfig()
38
 
39
- # Override with environment variables if available
40
- if api_key := os.getenv("ELEVENLABS_API_KEY"):
41
- config.elevenlabs_api_key = api_key
42
- if api_key := os.getenv("LLAMAINDEX_API_KEY"):
43
- config.llamaindex_api_key = api_key
44
- if api_key := os.getenv("NEBIUS_API_KEY"):
45
- config.nebius_api_key = api_key
 
 
 
 
46
 
47
  return config
48
 
 
5
  class RadioConfig(BaseModel):
6
  """Configuration for the radio app"""
7
 
8
+ # API Keys - MUST be set via environment variables (secrets in HF Spaces)
9
+ # These defaults are empty strings - will fail if not set via env vars
10
+ elevenlabs_api_key: str = ""
11
+ llamaindex_api_key: str = ""
12
+ nebius_api_key: str = ""
13
+
14
  # Nebius OpenAI-compatible endpoint and model
 
 
 
 
 
 
15
  nebius_api_base: str = "https://api.tokenfactory.nebius.com/v1/" # Nebius OpenAI-compatible endpoint
16
  nebius_model: str = "openai/gpt-oss-120b" # GPT-OSS-120B model name from Nebius
17
 
 
29
  story_ratio: float = 0.1
30
 
31
  def get_config() -> RadioConfig:
32
+ """Get configuration from environment variables (secrets in HF Spaces)"""
33
  config = RadioConfig()
34
 
35
+ # Read API keys from environment variables (required for HF Spaces)
36
+ # These should be set as Secrets in HuggingFace Spaces Settings
37
+ config.elevenlabs_api_key = os.getenv("ELEVENLABS_API_KEY", "")
38
+ config.llamaindex_api_key = os.getenv("LLAMAINDEX_API_KEY", "")
39
+ config.nebius_api_key = os.getenv("NEBIUS_API_KEY", "")
40
+
41
+ # Validate that required keys are set
42
+ if not config.elevenlabs_api_key:
43
+ print("⚠️ Warning: ELEVENLABS_API_KEY not set. TTS will not work.")
44
+ if not config.nebius_api_key:
45
+ print("⚠️ Warning: NEBIUS_API_KEY not set. LLM will not work.")
46
 
47
  return config
48