📖 You are viewing: User Guide - Learn how to build chat applicationsSee also: SDK Reference · API Specification
Source Code:
src/gaia/chat/sdk.py · src/gaia/rag/sdk.pyFirst time here? Complete the Setup guide first to install GAIA and its dependencies.
Quick Start
Core Classes
ChatConfig
Configure your chat session with these options:ChatResponse
Responses include text, history, and optional statistics:SimpleChat
SimpleChat
Lightweight wrapper for basic chat without complex configuration. Perfect for getting started quickly.
CLI Usage
Interactive Mode
Start a conversational chat session:Session Management
Session Management
/resume [id]- Resume a previous conversation (or list sessions if no id)/save- Save current conversation/sessions- List all saved sessions/reset- Clear conversation and start fresh
Other Commands
Other Commands
/helpor/?- Show help message/quit- Exit the chat session
Document Q&A: To work with documents, see the Document Q&A (RAG) section below for RAG-specific commands.
Single Query Mode
Execute one-shot queries:Python SDK Examples
Streaming Chat
Stream responses in real-time:streaming.py
Custom Assistant Name
Personalize your assistant:custom_assistant.py
Session Management
Manage multiple conversation contexts:sessions.py
Conversation History
Access and manage conversation history:history.py
Document Q&A (RAG)
RAG (Retrieval-Augmented Generation) enables chatting with PDF documents using semantic search and context retrieval.
Python SDK with RAG
CLI with RAG
- Single Document
- Multiple Documents
- One-shot Query
- Voice Mode
PDF Indexing Requirements: Processing PDFs with images requires a Vision Language Model (VLM). GAIA uses To see what models each agent requires:
Qwen3-VL-4B-Instruct-GGUF by default for extracting text from images in PDFs.To download all models needed for chat (including VLM):gaia download --listSee the CLI Reference for more download options.Interactive RAG Commands
When usinggaia chat with documents (via --index flag or /index command), additional commands become available:
Session Management
Session Management
Sessions preserve both your conversation history and indexed documents:
/resume [id]- Resume session with conversation and documents restored/save- Save session including indexed documents/sessions- List all saved sessions/reset- Clear conversation and start a new session (indexed documents are preserved)
Document Management
Document Management
/index <path>- Index a document or directory (enables RAG if needed)/watch <dir>- Watch directory for changes and auto-index new files/list- List all currently indexed documents/status- Show RAG system status (indexed files, chunks, memory usage)
Debug & Observability
Debug & Observability
/chunks <file>- View indexed chunks for a specific file/chunk <id>- View specific chunk by ID/test <query>- Test query retrieval with relevance scores/dump <file|#>- Export document and chunks to markdown/clear-cache- Clear RAG cache and force re-indexing/search-debug- Enable detailed search debugging output
RAG Configuration
Advanced RAG setup options:advanced_rag.py
RAG Debug Mode
Enable debug mode to see detailed retrieval information:Debug Information Includes
Debug Information Includes
- Search keys generated by the LLM
- Chunks found for each search
- Relevance scores
- Deduplication statistics
- Score distributions
Chunking Strategies
Structural Chunking
Default - Fast processing
LLM-Based Semantic
More accurate context
RAG Troubleshooting
Missing Dependencies
Missing Dependencies
Voice Mode: No Module Named 'pip'
Voice Mode: No Module Named 'pip'
If
gaia talk fails with “No module named ‘pip’”, install dependencies manually:PDF Issues
PDF Issues
- Ensure PDF has extractable text (not scanned images)
- Check file is not password-protected
- Verify file is not corrupted
Performance Tuning
Performance Tuning
API Reference
ChatSDK Core Methods
Messaging
send(message: str) -> ChatResponsesend_stream(message: str)
History
get_history() -> List[str]clear_history()get_formatted_history() -> List[Dict]
RAG (Document Q&A)
enable_rag(documents=None, **kwargs)disable_rag()add_document(path: str) -> bool
Configuration
update_config(**kwargs)get_stats() -> Dictdisplay_stats(stats=None)start_interactive_session()
SimpleChat Methods
ask(question: str) -> str- Ask question, get responseask_stream(question: str)- Ask question, stream responseclear_memory()- Clear conversation memoryget_conversation() -> List[Dict]- Get conversation history
ChatSession Methods
create_session(id, config=None, **kwargs) -> ChatSDK- Create new sessionget_session(id) -> ChatSDK- Get existing sessiondelete_session(id) -> bool- Delete sessionlist_sessions() -> List[str]- List all sessionsclear_all_sessions()- Delete all sessions
Utility Functions
quick_chat(message, system_prompt=None, model=None, assistant_name=None) -> strquick_chat_with_memory(messages, system_prompt=None, model=None, assistant_name=None) -> List[str]
Best Practices
Choose the Right Interface
SimpleChat for basic needs, ChatSDK for full features, ChatSession for multi-context appsMemory Management
Configure
max_history_length based on memory constraintsPerformance
Enable
show_stats=True during developmentError Handling
Wrap chat operations in try-catch blocks
Resource Cleanup
Clear sessions when done to free memory
Assistant Naming
Use meaningful names for distinct use cases
Next Steps
Voice Interaction
Add speech recognition and text-to-speech
CLI Reference
Explore all command-line options
Development Guide
Learn to build custom agents
API Server
Integrate via OpenAI-compatible API