Python API Reference¶
This page contains auto-generated API documentation for the Stimm Python modules, produced by mkdocstrings.
get_provider_constants_endpoint()
async
¶
Serve provider constants to JavaScript frontend
Source code in src/main.py
health_check()
¶
rag_preloading_health()
async
¶
Health check for RAG preloading status
Source code in src/main.py
sip_bridge_health()
async
¶
Health check for SIP Bridge status
Source code in src/main.py
sip_bridge_status()
async
¶
Detailed status of SIP Bridge
Source code in src/main.py
startup_event()
async
¶
Preload RAG models and initialize agent system at server startup
Source code in src/main.py
options: show_root_heading: true show_source: true
Stimm Service - Main service class for voice assistant functionality.
This service wraps the StimmEventLoop and provides a simple interface for managing stimm conversations.
StimmService
¶
Main stimm service class.
Provides a high-level interface for managing stimm interactions using the event-driven StimmEventLoop architecture.
Source code in src/services/agents/stimm_service.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
cleanup_all_sessions()
async
¶
close_session(conversation_id)
async
¶
Close a stimm session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
ID of the session to close |
required |
Source code in src/services/agents/stimm_service.py
create_session(conversation_id, session_id=None)
async
¶
Create a new stimm session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
Unique identifier for the conversation |
required |
session_id
|
str
|
Optional session identifier |
None
|
Returns:
| Type | Description |
|---|---|
StimmEventLoop
|
StimmEventLoop instance for the new session |
Source code in src/services/agents/stimm_service.py
get_active_sessions()
¶
Get information about all active sessions.
Returns:
| Type | Description |
|---|---|
Dict[str, Dict[str, Any]]
|
Dictionary mapping conversation IDs to session info |
Source code in src/services/agents/stimm_service.py
get_session_state(conversation_id)
¶
Get the current state of a session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
ID of the conversation |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
Dictionary with session state or None if session not found |
Source code in src/services/agents/stimm_service.py
process_audio(conversation_id, audio_chunk)
async
¶
Process audio chunk for a specific session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conversation_id
|
str
|
ID of the conversation |
required |
audio_chunk
|
bytes
|
Raw audio data bytes |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if processed successfully, False if session not found |
Source code in src/services/agents/stimm_service.py
register_event_handler(event_type, handler)
¶
Register an event handler for real-time updates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Type of event to handle |
required |
handler
|
Callable[[Dict[str, Any]], None]
|
Async function to call when event occurs |
required |
Source code in src/services/agents/stimm_service.py
unregister_event_handler(event_type)
¶
Unregister an event handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
str
|
Type of event to unregister |
required |
get_stimm_service(stt_service=None, chatbot_service=None, tts_service=None, vad_service=None, agent_id=None)
¶
Get or create the global stimm service instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stt_service
|
STT service instance |
None
|
|
chatbot_service
|
Chatbot service instance |
None
|
|
tts_service
|
TTS service instance |
None
|
|
vad_service
|
VAD service instance |
None
|
|
agent_id
|
str
|
Optional agent ID |
None
|
Returns:
| Type | Description |
|---|---|
StimmService
|
StimmService instance |
Source code in src/services/agents/stimm_service.py
options: show_root_heading: true show_source: true
RAG Service Core Logic
This module contains the core service logic for conversation management and document handling.
options: show_root_heading: true show_source: true
Language Model Service Module with Agent Support
LLMService
¶
Service for handling Language Model operations with agent support
Source code in src/services/llm/llm.py
__init__(agent_id=None, session_id=None)
¶
Initialize LLM Service with agent support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
Optional[UUID]
|
Specific agent ID to use (if None, uses default agent) |
None
|
session_id
|
Optional[str]
|
Session ID for agent resolution |
None
|
Source code in src/services/llm/llm.py
close()
async
¶
generate(prompt, **kwargs)
async
¶
Generate text using the configured LLM provider
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Input text prompt |
required |
**kwargs
|
Additional parameters for the provider |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Generated text |
Source code in src/services/llm/llm.py
generate_stream(prompt, **kwargs)
async
¶
Stream text generation using the configured LLM provider
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt
|
str
|
Input text prompt |
required |
**kwargs
|
Additional parameters for the provider |
{}
|
Yields:
| Name | Type | Description |
|---|---|---|
str |
AsyncIterator[str]
|
Generated text chunks |
Source code in src/services/llm/llm.py
options: show_root_heading: true show_source: true
Speech-to-Text Service Module
STTService
¶
Service for handling Speech-to-Text operations
Source code in src/services/stt/stt.py
transcribe_streaming(audio_generator)
async
¶
Transcribe from a streaming audio generator
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_generator
|
AsyncGenerator[bytes, None]
|
Async generator yielding audio chunks |
required |
Yields:
| Type | Description |
|---|---|
AsyncGenerator[Dict[str, Any], None]
|
Transcription results |
Source code in src/services/stt/stt.py
options: show_root_heading: true show_source: true
Text-to-Speech Service Module with provider-based streaming support.
TTSService
¶
Service for handling Text-to-Speech operations
Source code in src/services/tts/tts.py
stream_synthesis(text_generator)
async
¶
Stream synthesis using the configured provider.
Source code in src/services/tts/tts.py
options: show_root_heading: true show_source: true
Database models for stimm application.
Agent
¶
Bases: Base
Agent model representing a stimm configuration.
Source code in src/database/models.py
to_dict()
¶
Convert agent to dictionary for API responses.
Source code in src/database/models.py
AgentSession
¶
Bases: Base
Agent session model for runtime agent switching.
Source code in src/database/models.py
Document
¶
Bases: Base
Document model for tracking ingested documents in RAG configurations.
Source code in src/database/models.py
to_dict()
¶
Convert document to dictionary for API responses.
Source code in src/database/models.py
RagConfig
¶
Bases: Base
RAG configuration model representing a retrievable knowledge base.
Source code in src/database/models.py
to_dict()
¶
Convert RAG config to dictionary for API responses.
Source code in src/database/models.py
User
¶
Bases: Base
User model for future IAM support.
Source code in src/database/models.py
options: show_root_heading: true show_source: true
CLI Tool for testing voice agents from command line
clear_rooms(args)
async
¶
Delete all LiveKit rooms
Source code in src/cli/main.py
clear_sip_bridge(args)
async
¶
Clean all SIP bridge active rooms and processes
Source code in src/cli/main.py
get_base_url(args)
¶
list_agents(args)
async
¶
List all available agents
Source code in src/cli/main.py
list_rooms(args)
async
¶
List all LiveKit rooms
Source code in src/cli/main.py
main()
async
¶
parse_args()
¶
Parse command line arguments
Source code in src/cli/main.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
preprocess_argv()
¶
Preprocess argv to handle the ambiguous --http [URL] argument. If --http is followed by a URL (not a command/flag), convert it to --url URL. This allows supporting both '--http command' and '--http URL command'.
Source code in src/cli/main.py
run_chat_mode(args)
async
¶
run_talk_mode(args)
async
¶
Run agent in full audio mode via LiveKit
Source code in src/cli/main.py
test_echo_pipeline(args)
async
¶
Test LiveKit audio pipeline with echo server and client
Source code in src/cli/main.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
options: show_root_heading: true show_source: true