Skip to main content
Component: TalkSDK - Unified voice and text chat integration Module: gaia.talk.sdk Import: from gaia.talk.sdk import TalkSDK, TalkConfig, TalkMode, TalkResponse

Overview

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

  1. Text Chat
    • Send text messages and receive complete responses
    • Streaming text generation support
    • Conversation history tracking (via AgentSDK)
    • Configurable max history length
  2. Voice Chat
    • Voice input via Whisper ASR
    • Voice output via TTS
    • Interactive voice sessions
    • Voice session lifecycle management
    • Callback support for voice input events
  3. Conversation Management
    • Automatic history tracking
    • History retrieval and formatting
    • History clearing
    • Max history length enforcement
  4. RAG Integration
    • Enable/disable RAG dynamically
    • Add documents to RAG index
    • Query documents during conversation
    • Support for PDF and text documents
  5. Configuration
    • Dynamic configuration updates
    • Model selection (local/Claude/ChatGPT)
    • Audio device configuration
    • TTS enable/disable
    • System prompt customization

Non-Functional Requirements

  1. Performance
    • Low latency for text responses
    • Efficient audio processing
    • Minimal overhead for history management
  2. Reliability
    • Graceful error handling
    • Automatic cleanup on shutdown
    • Session state management
  3. Usability
    • Simple API for common use cases
    • Convenience classes (SimpleTalk)
    • Clear error messages
    • Good logging support

API Specification

File Location

Public Interface

""" def init( self, system_prompt: Optional[str] = None, enable_tts: bool = True, assistant_name: str = “gaia”, ): """ Initialize SimpleTalk with minimal configuration. Args: system_prompt: Optional system prompt for the AI enable_tts: Whether to enable text-to-speech assistant_name: Name to use for the assistant """ pass async def ask(self, question: str) -> str: """ Ask a question and get a text response. Args: question: The question to ask Returns: The AI’s response as a string """ pass async def ask_stream(self, question: str): """ Ask a question and get a streaming response. Args: question: The question to ask Yields: Response chunks as they arrive """ pass async def voice_chat(self) -> None: """Start an interactive voice chat session.""" pass def clear_memory(self) -> None: """Clear the conversation memory.""" pass def get_conversation(self) -> list: """Get the conversation history in a readable format.""" pass

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 """ pass

Text 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