Avatar System

System Overview

The Avatar System manages agent visual representation, voice configuration, and personality characteristics through a modular architecture built around three core components: Models, Manager, and Events.

Core Components

Models (core/avatar/models.py)

Avatar Class

Main configuration container for avatar properties:

@dataclass
class Avatar:
    id: str                    # Unique identifier
    name: str                  # Display name
    image_path: Path           # Static image asset path
    video_path: Optional[Path] # Optional video asset path
    voice_id: str             # ElevenLabs voice identifier
    accent_color: str         # UI theme color
    prompts: AvatarPrompts    # Personality configuration

AvatarPrompts Class

Container for different prompt types:

Manager (core/avatar/manager.py)

The AvatarManager class handles avatar state and transitions:

Key Methods:

  • _load_avatars(): Initializes avatars from configuration

  • set_current_avatar(avatar_id): Changes active avatar

  • get_current_avatar(): Returns active avatar instance

  • get_next_avatar_id(): Handles avatar rotation

  • get_prompt(prompt_type): Retrieves specific prompts

Properties:

  • current_voice_id: Active avatar's voice configuration

  • current_accent_color: Active avatar's UI theme color

Events (core/avatar/events.py)

Observer pattern implementation for avatar state changes:

Configuration (config/avatar_config.py)

Avatar definitions are stored in AVATAR_CONFIGS dictionary:

Integration Points

Voice System

  • Links to voice_id for audio generation

  • Manages voice characteristic changes during avatar switches

UI Integration

  • Provides accent_color for theming

  • Manages avatar visual assets

  • Handles transitions between avatars

Event Handling

  • Notifies system components of avatar changes

  • Manages state synchronization across the application

Usage Example

Error Handling

The system includes comprehensive error handling:

  • Configuration loading failures

  • Missing avatar assets

  • Observer notification errors

  • Invalid avatar ID handling

Last updated