AI Providers¶
AIProvider ¶
Bases: ABC
AI model provider for generating responses.
model_name
abstractmethod
property
¶
Model identifier (e.g. 'claude-sonnet-4-20250514', 'gpt-4o').
generate
abstractmethod
async
¶
Generate an AI response from the given context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
AIContext
|
Conversation context including messages, system prompt, temperature, and target channel capabilities. |
required |
Returns:
| Type | Description |
|---|---|
AIResponse
|
The AI response with content, usage stats, and optional |
AIResponse
|
tasks/observations. |
AIContext ¶
Bases: BaseModel
Context passed to AI provider for generation.
AIMessage ¶
Bases: BaseModel
A message in the AI conversation context.
AITextPart ¶
Bases: BaseModel
Text part of a multimodal message.
AIImagePart ¶
Bases: BaseModel
Image part of a multimodal message.
AITool ¶
Bases: BaseModel
Tool definition for function calling.
AIToolCall ¶
Bases: BaseModel
A tool call from the AI response.
AIResponse ¶
Bases: BaseModel
Response from an AI provider.
MockAIProvider ¶
Per-Room AI Configuration¶
AI channel settings can be overridden per-room using binding metadata:
# Default AI channel
ai = AIChannel("ai", provider=anthropic, system_prompt="Default assistant")
kit.register_channel(ai)
# Override per room
kit.attach_channel(room_id, "ai", metadata={
"system_prompt": "You are a customer support agent for Acme Corp.",
"temperature": 0.3, # More deterministic
"max_tokens": 2048,
})
Silent Observer Pattern (Meeting Notes)¶
# Attach AI as note-taker
kit.attach_channel(meeting_room_id, "ai", metadata={
"system_prompt": """You are a meeting note-taker.
Listen to the conversation silently.
When someone says 'meeting ended', compile and send a summary.""",
})
# Mute so AI listens but doesn't respond
await kit.mute(meeting_room_id, "ai")
# Later, unmute to let AI send summary
await kit.unmute(meeting_room_id, "ai")
Tools/Function Calling¶
Tools can be passed via binding metadata for function calling:
kit.attach_channel(room_id, "ai", metadata={
"tools": [
{
"name": "search_knowledge_base",
"description": "Search the company knowledge base",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"}
},
"required": ["query"]
}
}
]
})
Tool calls are returned in AIResponse.tool_calls:
response = await provider.generate(context)
for tool_call in response.tool_calls:
print(f"Tool: {tool_call.name}, Args: {tool_call.arguments}")
Gemini Provider¶
GeminiAIProvider ¶
GeminiConfig ¶
Bases: BaseModel
Google Gemini AI provider configuration.
Usage¶
from roomkit import GeminiAIProvider, GeminiConfig
config = GeminiConfig(api_key="your-api-key")
provider = GeminiAIProvider(config)
# Use with AIChannel
ai_channel = AIChannel("ai", provider=provider)
Install with: pip install roomkit[gemini]