How pipecat-ai/gemini-multimodal-live-demo works
Main Components
• Client Application: Located in the "client" folder. This React/TypeScript front end handles UI components like ChatControls, ChatMessages, LiveMessages, and various utility UI and SVG components. It calls API methods (client.action(), client.connect()) and uses hooks (like useRTVIClientEvent) to manage events.
• API Backend / Server: Found under the "server" directory. It is a FastAPI backend with endpoints under "server/webapp/api" (e.g., bots.py, conversations.py).
• Bot Pipelines: Two major bot pipelines are implemented:
• HTTP single-turn pipeline (from bots/http/bot_pipeline.py) for one-off interactions.
• WebRTC connected multi-turn pipeline (from bots/webrtc/bot_pipeline.py) for ongoing sessions.
• Database Storage: The project uses a SQLite database (server/sesame.db) to persist conversation history, defined in common/models.py and managed by persistent_context.py.
• External Services: Integration with Gemini API for multimodal capabilities and potentially Daily API (for WebRTC specific functionality). These will be configured via environment variables (.env) and defined in configuration files (server/common/config.py).
Relationships and Interactions
• Clients initiate chat messages (HTTP or WebRTC) using UI components.
• For HTTP mode:
• The client sends a POST to the /api/bot/action endpoint.
• The HTTP pipeline (in bots/http/bot_pipeline.py) processes the message via the Pipecat SDK that calls the Gemini model.
• Responses get stored in SQLite.
• For WebRTC mode:
• The client calls client.connect() to initiate a connection.
• The server’s /connect endpoint (in server/webapp/api/bots.py) starts a persistent bot process via bot_launch() in bots/webrtc/bot.py.
• The WebRTC pipeline (in bots/webrtc/bot_pipeline.py) manages the session.
• The server handles backend logic (configuration, security, and session management) and interacts with the database.
Important Architectural Patterns and Design Principles
• Separation of Concerns: Clear division between client-side (front-end UI/UX) and server-side (backend APIs, bot pipelines, persistent storage).
• Modular Architecture: The server code splits functionality into discrete modules (bots, common, webapp), making it easier to extend or modify bot behavior.
• Dual Communication Patterns: A hybrid pattern implementing both HTTP RESTful endpoints for single-turn interactions and persistent WebRTC sessions for real-time, continuous engagement.
• Use of Pipelines: Both bot functionalities for HTTP and WebRTC are implemented as Pipecat pipelines, which encapsulate message processing and potentially enrich processing logic.
Relevant Technologies, Frameworks, and Libraries
• Client: React, Vite (bundler), TypeScript, tailwind CSS, and several custom UI components.
• Server: FastAPI (for API endpoints), Python (3.10 to 3.12), Uvicorn (for ASGI server), and SQLite as the database.
• Bot Pipelines and SDKs: Pipecat SDK is employed to manage actions and events; integration with Gemini Multimodal Live API adds AI capabilities, and Daily API can be optionally used for WebRTC functionalities.
Additional Recommendations
• Use annotations or callouts to reference key files (e.g., indicate that “server/common/config.py” holds the configuration or that “client/src/components/ClientPage.tsx” creates the RTVIClient).