Test Git commited on
Commit
4e56990
·
1 Parent(s): e720bd2

feat: Final polish for hackathon submission

Browse files

- Add horizontal badges to frontend UI
- Update README with MCP tools, Phase 2 roadmap, and license
- Fix architecture diagrams (LR layout, contrast, syntax)
- Add footer with hackathon credits

Files changed (2) hide show
  1. README.md +231 -4
  2. app.py +85 -6
README.md CHANGED
@@ -29,10 +29,13 @@ tags:
29
  **An AI-powered interactive storybook that answers children's "Why?" questions with multimedia explanations.**
30
 
31
  [![Blaxel](https://img.shields.io/badge/Agent-Blaxel-purple)](https://blaxel.ai)
 
32
  [![Modal](https://img.shields.io/badge/Compute-Modal-green)](https://modal.com)
33
  [![Gemini](https://img.shields.io/badge/LLM-Gemini%202.5%20Pro-blue)](https://deepmind.google/technologies/gemini/)
34
  [![Hyperbolic](https://img.shields.io/badge/LLM-Llama%203.3-orange)](https://hyperbolic.xyz)
35
  [![Flux](https://img.shields.io/badge/Image-Flux.1-red)](https://blackforestlabs.ai/)
 
 
36
 
37
  ---
38
 
@@ -45,17 +48,27 @@ It answers questions like *"Why is the sky blue?"* or *"How do airplanes fly?"*
45
  2. 🎨 **An Illustration:** A beautiful, Pixar-style image generated by **Flux.1-schnell** on **Modal** GPUs.
46
  3. 🔊 **Narration:** A warm voice reading the story aloud using **OpenAI TTS** via a **Blaxel MCP Server**.
47
 
 
 
 
 
 
 
 
 
 
48
  ## 🚀 Features
49
 
50
  - **🌍 Multilingual:** Ask in English, Spanish, French, etc., and it responds in the same language!
51
  - **⚡ Real-time Hybrid Streaming:** Uses parallel execution to generate text, image, and audio simultaneously, reducing latency by 50%.
52
  - **👶 Age-Adaptive:** Adjusts the complexity of the story based on the child's age (3-12).
53
  - **🔊 Auto-Narration:** Automatically reads the story for younger children who can't read yet.
54
- - **🧠 Advanced Context Engineering:** The agent maintains conversation history and uses it to suggest relevant follow-up questions, creating a continuous learning journey.
 
55
 
56
  ## 🏗️ Architecture
57
 
58
- This project was built for the **Hugging Face & MCP Hackathon** (Celebrating 1 Year of Agents).
59
 
60
  It demonstrates a **Hybrid Architecture**:
61
  - **Frontend:** Gradio 6 (hosted here on Hugging Face Spaces).
@@ -63,6 +76,72 @@ It demonstrates a **Hybrid Architecture**:
63
  - **Tooling (MCP):** A Blaxel **Model Context Protocol (MCP)** server providing TTS capabilities.
64
  - **Heavy Compute:** [Modal](https://modal.com) running **Flux.1-schnell** on A100 GPUs for image generation.
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ### How it works:
67
  1. **User** asks a question in the Gradio UI.
68
  2. **Blaxel Agent** receives the request and prompts **Gemini**.
@@ -70,9 +149,66 @@ It demonstrates a **Hybrid Architecture**:
70
  4. **Agent Orchestrator** launches **3 parallel tasks** for maximum performance:
71
  - **Task A:** Calls **Modal** to generate the image (Flux.1).
72
  - **Task B:** Calls **MCP Server** to generate the audio narration.
73
- - **Task C:** Calls **Hyperbolic (Llama 3.3)** to generate related questions instantly.
74
  5. **Agent** streams all components back to the UI using Server-Sent Events (SSE) as they become available.
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  ## 🛠️ Technologies Used
77
 
78
  - **Blaxel:** For hosting the Agent and the MCP Server.
@@ -83,12 +219,103 @@ It demonstrates a **Hybrid Architecture**:
83
  - **Gradio:** For the kid-friendly user interface.
84
  - **FastAPI:** For the backend agent logic.
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  ## 🏆 Hackathon Tracks
87
 
88
  This project targets:
89
- - **Track 1: Building MCP:** We built a custom MCP server on Blaxel for audio generation.
90
  - **Track 2: MCP in Action:** We used the MCP server as a tool within a larger agentic workflow to build a consumer education app.
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  ---
93
 
94
  *Created with ❤️ by Silvestre-PO for the MCP's 1st Birthday.*
 
 
29
  **An AI-powered interactive storybook that answers children's "Why?" questions with multimedia explanations.**
30
 
31
  [![Blaxel](https://img.shields.io/badge/Agent-Blaxel-purple)](https://blaxel.ai)
32
+ [![Blaxel](https://img.shields.io/badge/MCP-Blaxel-purple)](https://blaxel.ai)
33
  [![Modal](https://img.shields.io/badge/Compute-Modal-green)](https://modal.com)
34
  [![Gemini](https://img.shields.io/badge/LLM-Gemini%202.5%20Pro-blue)](https://deepmind.google/technologies/gemini/)
35
  [![Hyperbolic](https://img.shields.io/badge/LLM-Llama%203.3-orange)](https://hyperbolic.xyz)
36
  [![Flux](https://img.shields.io/badge/Image-Flux.1-red)](https://blackforestlabs.ai/)
37
+ [![OpenAI](https://img.shields.io/badge/Audio-OpenAI%20TTS-green)](https://openai.com)
38
+ [![Gradio](https://img.shields.io/badge/Frontend-Gradio-orange)](https://gradio.app)
39
 
40
  ---
41
 
 
48
  2. 🎨 **An Illustration:** A beautiful, Pixar-style image generated by **Flux.1-schnell** on **Modal** GPUs.
49
  3. 🔊 **Narration:** A warm voice reading the story aloud using **OpenAI TTS** via a **Blaxel MCP Server**.
50
 
51
+ ## 🗣️ Sample Questions
52
+
53
+ Try asking these to see the magic happen:
54
+ - *"Why is the sky blue?"* (Classic physics)
55
+ - *"How do airplanes fly?"* (Engineering)
56
+ - *"Why do leaves change color in autumn?"* (Biology)
57
+ - *"Where does the sun go at night?"* (Astronomy)
58
+ - *"How do fish breathe underwater?"* (Marine biology)
59
+
60
  ## 🚀 Features
61
 
62
  - **🌍 Multilingual:** Ask in English, Spanish, French, etc., and it responds in the same language!
63
  - **⚡ Real-time Hybrid Streaming:** Uses parallel execution to generate text, image, and audio simultaneously, reducing latency by 50%.
64
  - **👶 Age-Adaptive:** Adjusts the complexity of the story based on the child's age (3-12).
65
  - **🔊 Auto-Narration:** Automatically reads the story for younger children who can't read yet.
66
+ - **🧠 Advanced Context Engineering:** Implements **Compaction** (summarization) and **Relevance Detection** to maintain a coherent conversation without context rot, following [Anthropic's best practices](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents).
67
+ - **🔒 Production-Ready Security:** Bearer token authentication, rate limiting (per-session + global), and built-in content safety filters.
68
 
69
  ## 🏗️ Architecture
70
 
71
+ This project was built for the **MCP's 1st Birthday Hackathon** (Celebrating 1 Year of MCP).
72
 
73
  It demonstrates a **Hybrid Architecture**:
74
  - **Frontend:** Gradio 6 (hosted here on Hugging Face Spaces).
 
76
  - **Tooling (MCP):** A Blaxel **Model Context Protocol (MCP)** server providing TTS capabilities.
77
  - **Heavy Compute:** [Modal](https://modal.com) running **Flux.1-schnell** on A100 GPUs for image generation.
78
 
79
+ ```mermaid
80
+ graph LR
81
+ %% Nodes with Icons
82
+ User([fa:fa-user User / Child])
83
+
84
+ subgraph Frontend_HF [Hugging Face Spaces]
85
+ Gradio[fa:fa-desktop Gradio UI]
86
+ end
87
+
88
+ subgraph Brain_Blaxel [Blaxel Cloud]
89
+ Agent[fa:fa-robot Blaxel Agent]
90
+ MCP[fa:fa-server MCP Server Host]
91
+ end
92
+
93
+ subgraph Text_Inference [Text Intelligence]
94
+ LLM_Story[fa:fa-book Story: Gemini 2.5 Pro]
95
+ LLM_Questions[fa:fa-bolt Questions: Hyperbolic]
96
+ end
97
+
98
+ subgraph Muscle_Modal [Modal.com]
99
+ Flux[fa:fa-image Image: Flux.1-schnell]
100
+ end
101
+
102
+ subgraph Audio_API [Audio Services]
103
+ TTS[fa:fa-headphones OpenAI Nova]
104
+ end
105
+
106
+ %% Data Flow
107
+ User -- "1. Ask" --> Gradio
108
+ Gradio -- "2. Request" --> Agent
109
+
110
+ Agent -- "3. Story" --> LLM_Story
111
+ LLM_Story -.-> Agent
112
+
113
+ %% Parallel Execution Flows
114
+ Agent -- "Task A" --> Flux
115
+ Flux -.-> Agent
116
+
117
+ Agent -- "Task B" --> MCP
118
+ MCP -- "TTS" --> TTS
119
+ TTS -.-> MCP
120
+ MCP -.-> Agent
121
+
122
+ Agent -- "Task C" --> LLM_Questions
123
+ LLM_Questions -.-> Agent
124
+
125
+ Agent -- "Stream" --> Gradio
126
+ Gradio -- "Show" --> User
127
+
128
+ %% Styling
129
+ classDef user fill:#fff,stroke:#333,stroke-width:2px,color:#000;
130
+ classDef frontend fill:#fff9c4,stroke:#fbc02d,stroke-width:2px,color:#000;
131
+ classDef blaxel fill:#e3f2fd,stroke:#2196f3,stroke-width:2px,color:#000;
132
+ classDef ai fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px,color:#000;
133
+ classDef modal fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;
134
+ classDef audio fill:#fbe9e7,stroke:#ff5722,stroke-width:2px,color:#000;
135
+ linkStyle default stroke:#000000
136
+
137
+ class User user;
138
+ class Gradio frontend;
139
+ class Agent,MCP blaxel;
140
+ class LLM_Story,LLM_Questions ai;
141
+ class Flux modal;
142
+ class TTS audio;
143
+ ```
144
+
145
  ### How it works:
146
  1. **User** asks a question in the Gradio UI.
147
  2. **Blaxel Agent** receives the request and prompts **Gemini**.
 
149
  4. **Agent Orchestrator** launches **3 parallel tasks** for maximum performance:
150
  - **Task A:** Calls **Modal** to generate the image (Flux.1).
151
  - **Task B:** Calls **MCP Server** to generate the audio narration.
152
+ - **Task C:** Calls **Hyperbolic (Llama 3.3)** to generate related questions instantly using **Compacted Context**.
153
  5. **Agent** streams all components back to the UI using Server-Sent Events (SSE) as they become available.
154
 
155
+ ### ⚙️ Workflow (Under the Hood)
156
+
157
+ ```mermaid
158
+ sequenceDiagram
159
+ participant User
160
+ participant Gradio as app.py<br/>(Gradio UI)
161
+ participant Agent as main.py<br/>(Blaxel Agent)
162
+ participant Gemini as Google Gemini<br/>(Storyteller)
163
+ participant Hyperbolic as Hyperbolic API<br/>(Questions)
164
+ participant Flux as Modal Flux<br/>(Image Gen)
165
+ participant MCP as server.py<br/>(MCP Server)
166
+ participant OpenAI as OpenAI API<br/>(TTS)
167
+
168
+ Note over User, Gradio: 1. Input
169
+ User->>Gradio: "Why do birds fly?" (Age: 5)
170
+
171
+ Note over Gradio, Agent: 2. Orchestration Request
172
+ Gradio->>Agent: POST /generate (SSE Stream)
173
+
174
+ Note over Agent, Gemini: 3. Story Generation
175
+ Agent->>Gemini: generate_content(prompt)
176
+ Gemini-->>Agent: { "story": "Birds have wings...", "image_prompt": "Bird flying..." }
177
+ Agent->>Gradio: Stream Story Text
178
+
179
+ Note over Agent, Flux: 4. PARALLEL EXECUTION START
180
+
181
+ par Task A: Image Generation
182
+ Agent->>Flux: generate_image.remote(prompt)
183
+ Flux-->>Agent: Image Bytes (PNG)
184
+ Agent->>Gradio: Stream Image (Base64)
185
+ and Task B: Audio Generation (via MCP)
186
+ Agent->>MCP: call_tool("narrate_text", text)
187
+ MCP->>OpenAI: audio.speech.create(text)
188
+ OpenAI-->>MCP: Audio Bytes (MP3)
189
+ MCP-->>Agent: Audio Base64
190
+ Agent->>Gradio: Stream Audio (Base64)
191
+ and Task C: Related Questions
192
+ Agent->>Hyperbolic: chat.completions.create(context_summary)
193
+ Hyperbolic-->>Agent: ["Question 1?", "Question 2?"]
194
+ Agent->>Gradio: Stream Related Questions
195
+ end
196
+
197
+ Note over Agent, Gradio: 5. Completion
198
+ Agent->>Gradio: Event: "completed"
199
+ Gradio->>User: Render Full Multimedia Story
200
+ ```
201
+
202
+ ### 🧠 Context Engineering (Bonus)
203
+
204
+ We implemented a custom `ConversationContext` class that applies **Context Engineering** principles:
205
+
206
+ 1. **Compaction:** Instead of feeding raw logs, we generate high-fidelity summaries of the conversation history. This allows **Hyperbolic** to understand the context without consuming excessive tokens.
207
+ 2. **Just-in-Time Relevance:** The agent analyzes the user's intent to decide whether to inject previous context (follow-up) or start fresh (new topic), preventing "Context Rot".
208
+ 3. **Parallel Contexts:** We maintain separate context windows for the Storyteller (Gemini) and the Question Generator (Hyperbolic), optimizing each for their specific role.
209
+
210
+ <!--[📄 Read our full Context Engineering Analysis](docs/context_engineering_analysis.md) -->
211
+
212
  ## 🛠️ Technologies Used
213
 
214
  - **Blaxel:** For hosting the Agent and the MCP Server.
 
219
  - **Gradio:** For the kid-friendly user interface.
220
  - **FastAPI:** For the backend agent logic.
221
 
222
+ ## 🔧 MCP Server Tools
223
+
224
+ Our custom MCP Server (`curiosity-tools`) exposes 2 tools via the Model Context Protocol:
225
+
226
+ ### 1. `narrate_text` ✅ **Actively Used**
227
+ ```python
228
+ def narrate_text(text: str, voice: str = "nova") -> str
229
+ ```
230
+ - **Purpose:** Generate audio narration using OpenAI TTS
231
+ - **Input:** Story text + voice selection
232
+ - **Output:** Base64-encoded MP3 audio
233
+ - **Usage:** Called by the agent for every story generation
234
+
235
+ ### 2. `generate_illustration` 📦 **Available**
236
+ ```python
237
+ def generate_illustration(prompt: str) -> str
238
+ ```
239
+ - **Purpose:** Generate illustrations using Modal Flux.1
240
+ - **Input:** Image description prompt
241
+ - **Output:** Base64-encoded PNG image
242
+ - **Note:** Available but bypassed in production (agent calls Modal directly for performance)
243
+
244
+ **Why the hybrid approach?**
245
+ - Audio generation is fast (~2s) → Safe to use via MCP
246
+ - Image generation can take 3-5 min on cold start → Direct Modal call prevents gateway timeouts
247
+
248
  ## 🏆 Hackathon Tracks
249
 
250
  This project targets:
251
+ - **Track 1: Building MCP:** We built a custom MCP server on Blaxel with 2 production-ready tools.
252
  - **Track 2: MCP in Action:** We used the MCP server as a tool within a larger agentic workflow to build a consumer education app.
253
 
254
+
255
+ ## 🚀 Phase 2: Roadmap & Future Enhancements
256
+
257
+ ### 📚 Content & Features
258
+ - **Interactive Quizzes:** Generate comprehension questions after each story
259
+ - **Story Collections:** Save favorite stories into personalized "books"
260
+ - **Parent Dashboard:** Track learning progress and topics explored
261
+ - **Collaborative Mode:** Multiple children can ask follow-up questions together
262
+ - **Video Narration:** Animated characters reading the story (Luma AI / Runway)
263
+
264
+ ### 🎨 UI/UX Enhancements
265
+ - **Kid-Friendly Design:**
266
+ - Animated mascot guide (friendly lion character)
267
+ - Colorful theme switcher (Rainbow, Ocean, Forest, Space)
268
+ - Larger fonts and touch-friendly buttons for tablets
269
+ - Celebration animations when stories complete (confetti, stars)
270
+ - **Reading Experience:**
271
+ - Page-flip animation for story transitions
272
+ - Highlight text as audio plays (karaoke mode)
273
+ - Adjustable reading speed and voice selection
274
+ - Dark mode for bedtime reading
275
+ - **Engagement Features:**
276
+ - Progress badges ("Curious Explorer", "Question Master")
277
+ - Story streak counter (days in a row)
278
+ - Share stories as beautiful PDFs or social cards
279
+ - Print-friendly storybook format
280
+
281
+ ### ⚡ Performance Optimizations
282
+ - **Smart Caching:** Cache frequently asked questions (Redis)
283
+ - **Predictive Pre-generation:** Start generating related questions while streaming the story
284
+ - **Edge Deployment:** Deploy MCP Server closer to users (Cloudflare Workers)
285
+ - **Model Quantization:** Use Flux.1-schnell quantized version for 2x faster image generation
286
+ - **Streaming Audio:** Stream TTS chunks instead of waiting for full audio
287
+
288
+ ### 🧠 AI Enhancements
289
+ - **Multi-Agent Storytelling:** Orchestrate specialized agents with distinct roles:
290
+ - **Writer Agent:** Crafts the narrative structure and plot
291
+ - **Educator Agent:** Ensures scientific accuracy and age-appropriateness
292
+ - **Illustrator Agent:** Designs visual concepts and composition
293
+ - **Editor Agent:** Reviews coherence and educational value
294
+ - **Coordinator Agent:** Manages workflow and quality control
295
+ - **Multi-modal Understanding:** Accept voice questions (Whisper API)
296
+ - **Visual Learning:** Generate diagrams for complex concepts (Mermaid/D2)
297
+ - **Adaptive Difficulty:** Fine-tune story complexity based on child's responses
298
+ - **Fact-Checking Layer:** Verify scientific accuracy with retrieval-augmented generation (RAG)
299
+ - **Emotion Detection:** Adjust tone based on child's engagement level
300
+
301
+ ### 🌍 Accessibility & Scale
302
+ - **Offline Mode:** Download stories for offline reading
303
+ - **Text-to-Sign Language:** Generate sign language videos (SignAll API)
304
+ - **Dyslexia-Friendly Mode:** OpenDyslexic font + adjustable spacing
305
+ - **Multi-platform:** Native iOS/Android apps (React Native)
306
+ - **Classroom Edition:** Teacher tools for group learning
307
+
308
+ ### 🔒 Safety & Compliance (Future)
309
+ - **Enhanced Content Filtering:** Multi-layer content moderation beyond Gemini's built-in filters
310
+ - **COPPA Compliance:** Privacy controls for children under 13
311
+ - **Parental Controls:** Approve topics, set time limits, review history
312
+ - **Audit Logs:** Comprehensive tracking of all AI-generated content
313
+
314
+ ## 📝 License
315
+
316
+ This project is licensed under the Apache License 2.0.
317
+
318
  ---
319
 
320
  *Created with ❤️ by Silvestre-PO for the MCP's 1st Birthday.*
321
+
app.py CHANGED
@@ -81,7 +81,7 @@ async def generate_storybook(question, age, session_id, progress=gr.Progress()):
81
  current_image = None
82
  current_audio = None
83
  related_questions = [] # Context Engineering
84
- status_msg = "🚀 Starting..."
85
 
86
  # Progress tracking
87
  progress(0, desc="Starting...")
@@ -233,11 +233,81 @@ label {
233
  }
234
  """
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  with gr.Blocks(title="🦁 Curiosity Storybook") as demo:
237
- gr.Markdown("# 🦁 Curiosity Storybook 🚀")
238
- gr.Markdown("### Ask me anything! I'll remember our conversation and suggest related questions. 📚✨💭")
239
- gr.Markdown("*Works in any language! Each conversation builds on previous questions.*")
 
 
 
 
 
 
 
 
 
 
240
 
 
 
 
 
241
  # Session state (invisible to user, persistent across interactions)
242
  session_state = gr.State(lambda: str(uuid.uuid4()))
243
 
@@ -245,7 +315,7 @@ with gr.Blocks(title="🦁 Curiosity Storybook") as demo:
245
  with gr.Column(scale=1):
246
  question_input = gr.Textbox(
247
  label="❓ What are you curious about?",
248
- placeholder="Why is the sky blue?\n¿Por qué brillan las estrellas?\nPourquoi les chats ronronnent?",
249
  lines=3,
250
  max_lines=5
251
  )
@@ -266,7 +336,7 @@ with gr.Blocks(title="🦁 Curiosity Storybook") as demo:
266
  )
267
 
268
  submit_btn = gr.Button("✨ Tell me a story! ✨", variant="primary", size="lg")
269
- status_output = gr.Markdown("🌟 Ready to explore! Ask me anything...")
270
 
271
  with gr.Column(scale=2):
272
  story_output = gr.Markdown(label="📖 Your Story")
@@ -291,6 +361,15 @@ with gr.Blocks(title="🦁 Curiosity Storybook") as demo:
291
  inputs=[question_input, age_slider],
292
  label="💡 Try these questions:"
293
  )
 
 
 
 
 
 
 
 
 
294
 
295
  # Event: Submit button click
296
  submit_btn.click(
 
81
  current_image = None
82
  current_audio = None
83
  related_questions = [] # Context Engineering
84
+ status_msg = "🚀 **Starting your magical story...**"
85
 
86
  # Progress tracking
87
  progress(0, desc="Starting...")
 
233
  }
234
  """
235
 
236
+ ''' with gr.Blocks(title="🦁 Curiosity Storybook") as demo:
237
+ gr.Markdown("""
238
+ # 🦁 Curiosity Storybook
239
+
240
+ [![Blaxel](https://img.shields.io/badge/Agent-Blaxel-purple)](https://blaxel.ai) [![Blaxel](https://img.shields.io/badge/MCP-Blaxel-purple)](https://blaxel.ai) [![Modal](https://img.shields.io/badge/Compute-Modal-green)](https://modal.com) [![Gemini](https://img.shields.io/badge/LLM-Gemini%202.5%20Pro-blue)](https://deepmind.google/technologies/gemini/) [![Hyperbolic](https://img.shields.io/badge/LLM-Llama%203.3-orange)](https://hyperbolic.xyz) [![Flux](https://img.shields.io/badge/Image-Flux.1-red)](https://blackforestlabs.ai/) [![OpenAI](https://img.shields.io/badge/Audio-OpenAI%20TTS-green)](https://openai.com) [![Gradio](https://img.shields.io/badge/Frontend-Gradio-orange)](https://gradio.app)
241
+
242
+ ### Ask me anything! I'll remember our conversation and suggest related questions. 📚✨💭
243
+ *Works in any language! Each conversation builds on previous questions.*
244
+ """) '''
245
+
246
+ # --- 1. Definición del Contenido y Estilos CSS ---
247
+
248
+ # A. CSS para Adaptabilidad: Permite el salto de línea (wrap)
249
+ COMPRESSION_CSS_ADAPTABLE = """
250
+ <style>
251
+ /* Clase para permitir que los elementos se envuelvan (wrap) naturalmente */
252
+ .compact-badges-adaptable {
253
+ padding: 0;
254
+ margin: 0;
255
+ }
256
+
257
+ /* Estilo para los enlaces (los badges) */
258
+ .compact-badges-adaptable a {
259
+ /* Es crucial que sean inline-block para que se alineen horizontalmente */
260
+ display: inline-block !important;
261
+ /* Margen entre badges: 4px horizontal, 5px vertical (para separar las filas) */
262
+ margin: 0px 4px 5px 0px !important;
263
+ padding: 0;
264
+ vertical-align: middle;
265
+ }
266
+ </style>
267
+ """
268
+
269
+ # B. Badges Convertidos a HTML Puro para garantizar la visualización
270
+ # Nota: La sintaxis es <a href="URL_DESTINO"><img src="URL_IMAGEN" alt="Texto" style="height: 20px;"></a>
271
+ BADGES_HTML_PURO = """
272
+ <a href="https://blaxel.ai"><img src="https://img.shields.io/badge/Agent-Blaxel-purple" alt="Blaxel Agent" style="height: 20px;"/></a>
273
+ <a href="https://blaxel.ai"><img src="https://img.shields.io/badge/MCP-Blaxel-purple" alt="Blaxel MCP" style="height: 20px;"/></a>
274
+ <a href="https://modal.com"><img src="https://img.shields.io/badge/Compute-Modal-green" alt="Modal Compute" style="height: 20px;"/></a>
275
+ <a href="https://deepmind.google/technologies/gemini/"><img src="https://img.shields.io/badge/LLM-Gemini%202.5%20Pro-blue" alt="Gemini LLM" style="height: 20px;"/></a>
276
+ <a href="https://hyperbolic.xyz"><img src="https://img.shields.io/badge/LLM-Llama%203.3-orange" alt="Llama LLM" style="height: 20px;"/></a>
277
+ <a href="https://blackforestlabs.ai/"><img src="https://img.shields.io/badge/Image-Flux.1-red" alt="Flux Image" style="height: 20px;"/></a>
278
+ <a href="https://openai.com"><img src="https://img.shields.io/badge/Audio-OpenAI%20TTS-green" alt="OpenAI Audio" style="height: 20px;"/></a>
279
+ <a href="https://gradio.app"><img src="https://img.shields.io/badge/Frontend-Gradio-orange" alt="Gradio Frontend" style="height: 20px;"/></a>
280
+ """
281
+
282
+ # C. Ensamblamos el contenido final que inyectaremos en gr.HTML
283
+ FULL_HTML_ADAPTABLE = f"""
284
+ {COMPRESSION_CSS_ADAPTABLE}
285
+ <div class="compact-badges-adaptable">
286
+ {BADGES_HTML_PURO}
287
+ </div>
288
+ """
289
+
290
+ # --- 2. Estructura Principal de Gradio ---
291
+
292
  with gr.Blocks(title="🦁 Curiosity Storybook") as demo:
293
+ gr.Markdown("""
294
+ # 🦁 Curiosity Storybook
295
+ """)
296
+
297
+ # Inyectamos el CSS y el contenido de los badges
298
+ gr.HTML(FULL_HTML_ADAPTABLE)
299
+
300
+ gr.Markdown("""
301
+ ---
302
+ ### Ask me anything! I'll remember our conversation and suggest related questions. 📚✨💭
303
+ *Works in any language! Each conversation builds on previous questions.*
304
+ """)
305
+
306
 
307
+
308
+
309
+
310
+
311
  # Session state (invisible to user, persistent across interactions)
312
  session_state = gr.State(lambda: str(uuid.uuid4()))
313
 
 
315
  with gr.Column(scale=1):
316
  question_input = gr.Textbox(
317
  label="❓ What are you curious about?",
318
+ placeholder="e.g., Why is the sky blue? 🌤️\n¿Por qué brillan las estrellas?\nPourquoi les chats ronronnent? 🐱",
319
  lines=3,
320
  max_lines=5
321
  )
 
336
  )
337
 
338
  submit_btn = gr.Button("✨ Tell me a story! ✨", variant="primary", size="lg")
339
+ status_output = gr.Markdown("🌟 **Ready to explore!** Ask me anything...")
340
 
341
  with gr.Column(scale=2):
342
  story_output = gr.Markdown(label="📖 Your Story")
 
361
  inputs=[question_input, age_slider],
362
  label="💡 Try these questions:"
363
  )
364
+
365
+ # Footer with credits
366
+ gr.Markdown("""
367
+ ---
368
+ ### 🏆 Built for MCP's 1st Birthday Hackathon
369
+
370
+
371
+ *Featuring Context Engineering with Compaction & Relevance Detection*
372
+ """)
373
 
374
  # Event: Submit button click
375
  submit_btn.click(