API Reference
Complete reference documentation for the Voxin framework. Find detailed information about classes, methods, configurations, and type definitions.
Agent Class
The core class for creating and managing AI agents:
agent.py
123456789101112131415161718
from voxin import Agentagent = Agent( name="Example Agent", model="gpt-4", # Base language model temperature=0.7, # Response creativity (0-1) max_tokens=150, # Maximum response length voice_config=voice_config, # Optional voice configuration behaviors=[], # Optional list of behaviors metadata={} # Optional metadata)# Available methodsawait agent.think(message) # Process message and generate responseawait agent.speak(text) # Convert text to speechawait agent.listen() # Start voice recognitionawait agent.stop() # Stop all processingawait agent.reset() # Reset agent state
Properties
name: str- Agent identifiermodel: str- Language model identifierbehaviors: List[Behavior]- Active behaviorsvoice_config: Optional[VoiceConfig]- Voice settingsstate: Dict[str, Any]- Current agent state
Voice Configuration
Configure voice synthesis and recognition settings:
voice_config.py
1234567891011
from voxin import VoiceConfigconfig = VoiceConfig( voice_id="clara-v1", # Voice identifier language="en-US", # Language code speaking_rate=1.0, # Speech rate (0.5-2.0) pitch=0.0, # Voice pitch (-10 to 10) volume_gain_db=0.0, # Volume adjustment sample_rate_hz=24000, # Audio sample rate audio_encoding="LINEAR16" # Audio encoding format)
Available Voices
English Voices
clara-v1- Professional femalejames-v1- Professional malesophie-v1- Young femalealex-v1- Young male
Other Languages
maria-v1- Spanish femalehans-v1- German maleyuki-v1- Japanese femaleli-v1- Chinese male
Behavior Interface
Base interface for implementing custom behaviors:
behavior.py
123456789101112131415161718
from voxin import Behaviorclass CustomBehavior(Behavior): async def on_message(self, message: str) -> None: """Handle incoming messages""" pass async def on_error(self, error: Exception) -> None: """Handle errors""" pass async def on_state_change(self, state: dict) -> None: """Handle state changes""" pass def get_state(self) -> dict: """Get behavior state""" return {}
Type Definitions
Core Types
Context- Interaction contextMessage- Communication unitState- Agent state typeEvent- System event type
Configuration Types
AgentConfig- Agent settingsVoiceConfig- Voice settingsBehaviorConfig- Behavior settingsSystemConfig- System settings
Error Handling
Exception Classes
VoxinError- Base error classConfigurationError- Invalid configurationConnectionError- Network issuesAuthenticationError- Invalid credentialsBehaviorError- Behavior-related issues