Source Code:
src/gaia/talk/sdk.pyComponent: TalkSDK - Unified voice and text chat integration
Module:
gaia.talk.sdk
Import: from gaia.talk.sdk import TalkSDK, TalkConfig, TalkMode, TalkResponseOverview
TalkSDK provides a unified interface for integrating GAIA’s voice and text chat capabilities into applications. It combines AgentSDK for text generation with AudioClient for voice input/output, providing seamless voice and text interaction with conversation history management. Key Features:- Unified voice and text chat interface
- Conversation history management (via AgentSDK)
- Text-to-speech (TTS) output
- Speech-to-text (STT) input via Whisper
- RAG (Retrieval-Augmented Generation) support
- Multiple modes: text-only, voice-only, voice-and-text
- Support for local models and cloud APIs (Claude, ChatGPT)
Requirements
Functional Requirements
-
Text Chat
- Send text messages and receive complete responses
- Streaming text generation support
- Conversation history tracking (via AgentSDK)
- Configurable max history length
-
Voice Chat
- Voice input via Whisper ASR
- Voice output via TTS
- Interactive voice sessions
- Voice session lifecycle management
- Callback support for voice input events
-
Conversation Management
- Automatic history tracking
- History retrieval and formatting
- History clearing
- Max history length enforcement
-
RAG Integration
- Enable/disable RAG dynamically
- Add documents to RAG index
- Query documents during conversation
- Support for PDF and text documents
-
Configuration
- Dynamic configuration updates
- Model selection (local/Claude/ChatGPT)
- Audio device configuration
- TTS enable/disable
- System prompt customization
Non-Functional Requirements
-
Performance
- Low latency for text responses
- Efficient audio processing
- Minimal overhead for history management
-
Reliability
- Graceful error handling
- Automatic cleanup on shutdown
- Session state management
-
Usability
- Simple API for common use cases
- Convenience classes (SimpleTalk)
- Clear error messages
- Good logging support
API Specification
File Location
Public Interface
Convenience functions for one-off usage
async def quick_chat( message: str, system_prompt: Optional[str] = None, assistant_name: str = “gaia” ) -> str: """ Quick one-off text chat with conversation memory. Args: message: Message to send system_prompt: Optional system prompt assistant_name: Name to use for the assistant Returns: AI response """ pass async def quick_voice_chat( system_prompt: Optional[str] = None, assistant_name: str = “gaia” ) -> None: """ Quick one-off voice chat session with conversation memory. Args: system_prompt: Optional system prompt assistant_name: Name to use for the assistant """ passText Chat
Voice Session
Usage Examples
Example 1: Simple Text Chat
Example 2: Voice Chat with RAG
Example 3: SimpleTalk Interface
Testing Requirements
Unit Tests
File:tests/sdk/test_talk_sdk.py
Dependencies
Required Packages
Import Dependencies
Error Handling
Common Errors and Responses
Documentation Updates Required
docs/guides/talk.mdx
Add comprehensive TalkSDK documentation:TalkSDK Technical Specification