This repository contains the intelligent backend for Fable Lab, powered by Google ADK (Agent Development Kit) and Gemini 2.0 Flash Native Audio. It hosts specialized AI agents that drive the platform's content generation and real-time interaction capabilities.
This project defines two primary agent systems:
A sophisticated pipeline designed to generating high-quality, structured educational content. It uses a Teacher-Researcher-Designer workflow.
Architecture:
- Orchestrator: Parses user intent (Topic, Age Group, Scene Count) and coordinates the workflow.
- Librarian: Structures the lesson plan and pedagogy.
- Parallel Workers:
- Plotter: Writes the narrative story, defines characters, and generates consistent image prompts.
- ExperimentPipeline: A 5-step sub-chain to build p5.js simulations:
- Researcher: Reads p5.js documentation to find the best functions.
- ExperimentDesigner: Plans the interaction flow (Observe -> Explore -> Test).
- InteractionDesigner: Layouts the UI controls.
- CodeGenerator: Writes the actual p5.js code.
- Assembler: packages everything.
- Finisher: Validates output and signals completion to the frontend.
A high-speed, single-agent system optimized for the Gemini Multimodal Live API.
- Purpose: Enabling the "Voice Coding Playground" where users talk to build apps.
- Capabilities:
- Bidi-streaming (Native Audio in/out).
- Real-time tool calling (
create_experiment,evolve_experiment). - <100ms latency for conversational coding.
- Language: Python 3.10+
- Framework: Google ADK (Agent Development Kit)
- Models: Gemini 2.0 Flash (Preview & Live)
- Server: FastAPI / Uvicorn (for standard endpoints) & WebSockets (for Live API)
- Python 3.10 or higher
- A Google Cloud Project with Gemini API access
-
Navigate to the directory:
cd fable-lab-adk -
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Environment Setup: Create a
.envfile with your Google Cloud credentials and ADK configuration.GOOGLE_API_KEY=your_key_here GOOGLE_CLOUD_PROJECT=your_project_id
You can run the agents using the ADK CLI or directly via Python.
Run the Playground Agent (Live API):
# Serves the agent on port 8000/websocket
python main.pyRun the Generation Agent (Workflow):
# Typically triggered via API, but can be tested with ADK CLI
adk run fable_agent_p5fable-lab-adk/
├── fable_agent_p5/ # Multi-agent generation pipeline
│ ├── agent.py # Workflow definitions
│ ├── prompts/ # System instructions & p5.js docs
│ └── tools/ # Custom tools (Context7 docs, etc.)
├── playground_agent/ # Real-time voice agent
│ ├── agent.py # Single-agent configuration
│ └── tools/ # Experiment manipulation tools
├── requirements.txt # Dependencies
└── main.py # Entry point for backend server