From 12c6311cd50f4c69a771bbfd24318eaaef889b3a Mon Sep 17 00:00:00 2001 From: Harold Date: Sun, 2 Nov 2025 12:47:50 +0800 Subject: [PATCH 01/31] feat: backbone done --- main/live-agent-api/.gitignore | 45 + main/live-agent-api/.python-version | 1 + main/live-agent-api/Dockerfile | 33 + main/live-agent-api/config/__init__.py | 0 main/live-agent-api/config/settings.py | 85 ++ main/live-agent-api/docker-compose.yml | 61 ++ main/live-agent-api/env_example.txt | 19 + main/live-agent-api/main.py | 109 +++ main/live-agent-api/orm/__init__.py | 38 + main/live-agent-api/orm/agent/__init__.py | 11 + main/live-agent-api/orm/agent/model.py | 107 +++ main/live-agent-api/orm/agent/repository.py | 136 +++ main/live-agent-api/orm/base.py | 136 +++ main/live-agent-api/pyproject.toml | 32 + main/live-agent-api/router/__init__.py | 10 + main/live-agent-api/router/agent.py | 323 +++++++ main/live-agent-api/schemas/__init__.py | 28 + main/live-agent-api/schemas/agent.py | 277 ++++++ main/live-agent-api/services/__init__.py | 10 + main/live-agent-api/services/agent_service.py | 286 ++++++ main/live-agent-api/utils/__init__.py | 0 main/live-agent-api/utils/id_generator.py | 125 +++ main/live-agent-api/utils/response.py | 126 +++ main/live-agent-api/uv.lock | 908 ++++++++++++++++++ 24 files changed, 2906 insertions(+) create mode 100644 main/live-agent-api/.gitignore create mode 100644 main/live-agent-api/.python-version create mode 100644 main/live-agent-api/Dockerfile create mode 100644 main/live-agent-api/config/__init__.py create mode 100644 main/live-agent-api/config/settings.py create mode 100644 main/live-agent-api/docker-compose.yml create mode 100644 main/live-agent-api/env_example.txt create mode 100644 main/live-agent-api/main.py create mode 100644 main/live-agent-api/orm/__init__.py create mode 100644 main/live-agent-api/orm/agent/__init__.py create mode 100644 main/live-agent-api/orm/agent/model.py create mode 100644 main/live-agent-api/orm/agent/repository.py create mode 100644 main/live-agent-api/orm/base.py create mode 100644 main/live-agent-api/pyproject.toml create mode 100644 main/live-agent-api/router/__init__.py create mode 100644 main/live-agent-api/router/agent.py create mode 100644 main/live-agent-api/schemas/__init__.py create mode 100644 main/live-agent-api/schemas/agent.py create mode 100644 main/live-agent-api/services/__init__.py create mode 100644 main/live-agent-api/services/agent_service.py create mode 100644 main/live-agent-api/utils/__init__.py create mode 100644 main/live-agent-api/utils/id_generator.py create mode 100644 main/live-agent-api/utils/response.py create mode 100644 main/live-agent-api/uv.lock diff --git a/main/live-agent-api/.gitignore b/main/live-agent-api/.gitignore new file mode 100644 index 000000000..94bfd9467 --- /dev/null +++ b/main/live-agent-api/.gitignore @@ -0,0 +1,45 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +*.egg-info/ +dist/ +build/ +*.egg + +# Virtual Environment +venv/ +env/ +.venv/ + +# UV +.uv/ + +# Environment variables +.env + +# IDE +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log +logs/ + +# Database +*.db +*.sqlite +*.sqlite3 + +# Docker +docker-compose.override.yml + diff --git a/main/live-agent-api/.python-version b/main/live-agent-api/.python-version new file mode 100644 index 000000000..e4fba2183 --- /dev/null +++ b/main/live-agent-api/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/main/live-agent-api/Dockerfile b/main/live-agent-api/Dockerfile new file mode 100644 index 000000000..957050c37 --- /dev/null +++ b/main/live-agent-api/Dockerfile @@ -0,0 +1,33 @@ +# Live Agent Dashboard API Dockerfile + +FROM python:3.12-slim + +# Set working directory +WORKDIR /app + +# Install uv +RUN pip install --no-cache-dir uv + +# Copy project files +COPY pyproject.toml ./ +COPY main.py ./ +COPY config ./config +COPY models ./models +COPY schemas ./schemas +COPY router ./router +COPY services ./services +COPY utils ./utils + +# Install dependencies using uv +RUN uv pip install --system -r pyproject.toml + +# Expose port +EXPOSE 8080 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD python -c "import requests; requests.get('http://localhost:8080/health')" || exit 1 + +# Run application +CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] + diff --git a/main/live-agent-api/config/__init__.py b/main/live-agent-api/config/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/main/live-agent-api/config/settings.py b/main/live-agent-api/config/settings.py new file mode 100644 index 000000000..1482c607f --- /dev/null +++ b/main/live-agent-api/config/settings.py @@ -0,0 +1,85 @@ +""" +Application Configuration + +Centralized configuration management using Pydantic Settings. +Configuration values are loaded from environment variables. +""" + +import logging +from typing import Literal +from pydantic import Field, PostgresDsn +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class Settings(BaseSettings): + """Application settings loaded from environment variables""" + + # Application Configuration + app_env: Literal["development", "staging", "production"] = Field( + default="development", + description="Application environment" + ) + log_level: str = Field( + default="DEBUG", + description="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)" + ) + + # API Configuration + api_prefix: str = Field( + default="/api/v1", + description="API route prefix" + ) + + # Database Configuration + database_url: PostgresDsn = Field( + ..., + description="PostgreSQL database URL" + ) + + # OpenAI Configuration + openai_api_key: str = Field( + ..., + description="OpenAI API key for AI features" + ) + openai_model: str = Field( + default="gpt-4o", + description="OpenAI model to use for prompt generation" + ) + + # Snowflake ID Generator Configuration + instance_id: int = Field( + default=1, + ge=0, + le=1023, + description="Instance ID for Snowflake ID generator (0-1023)" + ) + + model_config = SettingsConfigDict( + env_file=".env", + env_file_encoding="utf-8", + case_sensitive=False, + extra="ignore" + ) + + def configure_logging(self) -> None: + """Configure application logging based on settings""" + log_level_map = { + "DEBUG": logging.DEBUG, + "INFO": logging.INFO, + "WARNING": logging.WARNING, + "ERROR": logging.ERROR, + "CRITICAL": logging.CRITICAL, + } + + level = log_level_map.get(self.log_level.upper(), logging.INFO) + + logging.basicConfig( + level=level, + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", + datefmt="%Y-%m-%d %H:%M:%S" + ) + + +# Global settings instance +settings = Settings() + diff --git a/main/live-agent-api/docker-compose.yml b/main/live-agent-api/docker-compose.yml new file mode 100644 index 000000000..8b4a70e5b --- /dev/null +++ b/main/live-agent-api/docker-compose.yml @@ -0,0 +1,61 @@ +version: '3.8' + +services: + # PostgreSQL Database + postgres: + image: postgres:16-alpine + container_name: live-agent-db + environment: + POSTGRES_DB: live_agent_db + POSTGRES_USER: live_agent + POSTGRES_PASSWORD: password + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U live_agent"] + interval: 10s + timeout: 5s + retries: 5 + networks: + - live-agent-network + + # Live Agent Dashboard API + api: + build: + context: . + dockerfile: Dockerfile + container_name: live-agent-api + environment: + # Database + DATABASE_URL: postgresql+asyncpg://live_agent:password@postgres:5432/live_agent_db + + # OpenAI (use your own API key) + OPENAI_API_KEY: ${OPENAI_API_KEY:-sk-your-api-key-here} + OPENAI_MODEL: ${OPENAI_MODEL:-gpt-4o} + + # Snowflake ID Generator + INSTANCE_ID: ${INSTANCE_ID:-1} + + # Application + APP_ENV: ${APP_ENV:-development} + LOG_LEVEL: ${LOG_LEVEL:-INFO} + API_PREFIX: /api/v1 + ports: + - "8080:8080" + depends_on: + postgres: + condition: service_healthy + networks: + - live-agent-network + restart: unless-stopped + +volumes: + postgres_data: + driver: local + +networks: + live-agent-network: + driver: bridge + diff --git a/main/live-agent-api/env_example.txt b/main/live-agent-api/env_example.txt new file mode 100644 index 000000000..b928b1947 --- /dev/null +++ b/main/live-agent-api/env_example.txt @@ -0,0 +1,19 @@ +# Copy this file to .env and fill in your values + +# Database Configuration +DATABASE_URL=postgresql+asyncpg://live_agent:password@localhost:5432/live_agent_db + +# OpenAI Configuration +OPENAI_API_KEY=sk-your-api-key-here +OPENAI_MODEL=gpt-4o + +# Snowflake ID Generator Configuration +# TODO: For production deployment, configure unique instance ID (0-1023) for each service instance +INSTANCE_ID=1 + +# Application Configuration +APP_ENV=development +LOG_LEVEL=DEBUG + +# API Configuration +API_PREFIX=/api/v1 diff --git a/main/live-agent-api/main.py b/main/live-agent-api/main.py new file mode 100644 index 000000000..123f2775a --- /dev/null +++ b/main/live-agent-api/main.py @@ -0,0 +1,109 @@ +""" +Live Agent Dashboard API + +FastAPI application entry point for the Live Agent configuration API. +""" + +import logging +from contextlib import asynccontextmanager +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware + +from config.settings import settings +from orm import init_database, close_database +from utils.id_generator import init_id_generator, close_id_generator +from router import agent_router + + +# Configure logging +settings.configure_logging() +logger = logging.getLogger(__name__) + + +@asynccontextmanager +async def lifespan(app: FastAPI): + """ + Application lifespan events handler + + Handles startup and shutdown operations. + """ + # Startup + logger.info("Starting Live Agent Dashboard API...") + + # Initialize ID generator + init_id_generator(instance_id=settings.instance_id) + logger.info(f"Initialized ID generator (instance={settings.instance_id})") + + # Initialize database + await init_database() + + logger.info(f"Application started in {settings.app_env} mode") + + yield + + # Shutdown + logger.info("Shutting down Live Agent Dashboard API...") + await close_database() + close_id_generator() + logger.info("Application shutdown complete") + + +# Create FastAPI application +app = FastAPI( + title="Live Agent Dashboard API", + description=( + "API service for managing voice assistant agents, devices, and bindings.\n\n" + "This API provides comprehensive endpoints for:\n" + "- Agent Management: Create, configure, and manage voice assistant agents\n" + "- Device Management: Register and manage physical devices\n" + "- Binding Management: Link agents to devices\n" + ), + version="0.1.0", + lifespan=lifespan, +) + +# Configure CORS +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], # TODO: Configure proper origins in production + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + + +# Include routers +app.include_router(agent_router, prefix=settings.api_prefix) + + +@app.get("/") +async def root(): + """Root endpoint - API health check""" + return { + "service": "Live Agent Dashboard API", + "version": "0.1.0", + "status": "running", + "environment": settings.app_env, + } + + +@app.get("/health") +async def health_check(): + """Health check endpoint""" + return { + "status": "healthy", + "environment": settings.app_env, + } + + +if __name__ == "__main__": + import uvicorn + + # Run with uvicorn + uvicorn.run( + "main:app", + host="0.0.0.0", + port=8080, + reload=settings.app_env == "development", + log_level=settings.log_level.lower(), + ) diff --git a/main/live-agent-api/orm/__init__.py b/main/live-agent-api/orm/__init__.py new file mode 100644 index 000000000..0718025d9 --- /dev/null +++ b/main/live-agent-api/orm/__init__.py @@ -0,0 +1,38 @@ +""" +ORM Layer + +Provides database models and data access for all entities. +Organized by business domain (agent, device, binding, etc.). +""" + +from orm.base import ( + Base, + get_db, + init_database, + close_database, +) + +from orm.agent import Agent, AgentRepository + +# Future imports: +# from orm.device import Device, DeviceRepository +# from orm.binding import Binding, BindingRepository + +__all__ = [ + # Base infrastructure + "Base", + "get_db", + "init_database", + "close_database", + + # Agent domain + "Agent", + "AgentRepository", + + # Future domains + # "Device", + # "DeviceRepository", + # "Binding", + # "BindingRepository", +] + diff --git a/main/live-agent-api/orm/agent/__init__.py b/main/live-agent-api/orm/agent/__init__.py new file mode 100644 index 000000000..841f84c35 --- /dev/null +++ b/main/live-agent-api/orm/agent/__init__.py @@ -0,0 +1,11 @@ +""" +Agent ORM Module + +Exports Agent model and repository for convenient importing. +""" + +from orm.agent.model import Agent +from orm.agent.repository import AgentRepository + +__all__ = ["Agent", "AgentRepository"] + diff --git a/main/live-agent-api/orm/agent/model.py b/main/live-agent-api/orm/agent/model.py new file mode 100644 index 000000000..84b22d267 --- /dev/null +++ b/main/live-agent-api/orm/agent/model.py @@ -0,0 +1,107 @@ +""" +Agent ORM Model + +Defines the Agent database table structure and basic data operations. +""" + +from datetime import datetime, timezone +from sqlalchemy import String, Text, DateTime +from sqlalchemy.orm import Mapped, mapped_column + +from orm.base import Base + + +class Agent(Base): + """ + Agent database model + + Represents a voice assistant agent with its configuration. + """ + __tablename__ = "agents" + + # Primary Key + id: Mapped[str] = mapped_column( + String(64), + primary_key=True, + comment="Agent unique ID (Snowflake ID)" + ) + + # Basic Information + name: Mapped[str] = mapped_column( + String(255), + nullable=False, + comment="Agent display name" + ) + + template: Mapped[str] = mapped_column( + String(100), + nullable=False, + default="blank", + comment="Agent template type (e.g., personal-assistant, blank)" + ) + + language: Mapped[str] = mapped_column( + String(10), + nullable=False, + default="en", + comment="Agent language code (e.g., en, zh)" + ) + + # Agent Configuration + first_message: Mapped[str] = mapped_column( + Text, + nullable=True, + comment="Agent's greeting message" + ) + + system_prompt: Mapped[str] = mapped_column( + Text, + nullable=True, + comment="System prompt for agent behavior" + ) + + wake_word: Mapped[str] = mapped_column( + String(50), + nullable=False, + default="PLAUD", + comment="Wake word to activate agent" + ) + + # Timestamps + created_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=False, + default=lambda: datetime.now(timezone.utc), + comment="Creation timestamp" + ) + + updated_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=False, + default=lambda: datetime.now(timezone.utc), + onupdate=lambda: datetime.now(timezone.utc), + comment="Last update timestamp" + ) + + def __repr__(self) -> str: + return f"" + + def to_dict(self) -> dict: + """ + Convert model to dictionary + + Returns: + Dictionary representation of the agent + """ + return { + "id": self.id, + "name": self.name, + "template": self.template, + "language": self.language, + "firstMessage": self.first_message, + "systemPrompt": self.system_prompt, + "wakeWord": self.wake_word, + "createdAt": self.created_at.isoformat() if self.created_at else None, + "updatedAt": self.updated_at.isoformat() if self.updated_at else None, + } + diff --git a/main/live-agent-api/orm/agent/repository.py b/main/live-agent-api/orm/agent/repository.py new file mode 100644 index 000000000..1b1ce8a64 --- /dev/null +++ b/main/live-agent-api/orm/agent/repository.py @@ -0,0 +1,136 @@ +""" +Agent Repository + +Data access layer for Agent entity. +Encapsulates all database operations for Agent. +""" + +from typing import Optional +from sqlalchemy import select, func, or_ +from sqlalchemy.ext.asyncio import AsyncSession + +from orm.agent.model import Agent + + +class AgentRepository: + """Repository for Agent data access operations""" + + def __init__(self, db: AsyncSession): + """ + Initialize repository with database session + + Args: + db: SQLAlchemy async session + """ + self.db = db + + async def find_by_id(self, agent_id: str) -> Optional[Agent]: + """ + Find agent by ID + + Args: + agent_id: Agent unique ID + + Returns: + Agent instance or None if not found + """ + stmt = select(Agent).where(Agent.id == agent_id) + result = await self.db.execute(stmt) + return result.scalar_one_or_none() + + async def find_all( + self, + search: Optional[str] = None, + page: int = 1, + page_size: int = 20, + sort_by: str = "created_at", + sort_order: str = "desc", + ) -> tuple[list[Agent], int]: + """ + Find all agents with filtering, pagination and sorting + + Args: + search: Search keyword (searches in name and system_prompt) + page: Page number (starting from 1) + page_size: Number of items per page + sort_by: Field to sort by + sort_order: Sort direction ('asc' or 'desc') + + Returns: + Tuple of (agents list, total count) + """ + # Build base query + stmt = select(Agent) + + # Apply search filter + if search: + search_pattern = f"%{search}%" + stmt = stmt.where( + or_( + Agent.name.ilike(search_pattern), + Agent.system_prompt.ilike(search_pattern), + ) + ) + + # Get total count + count_stmt = select(func.count()).select_from(stmt.subquery()) + total_result = await self.db.execute(count_stmt) + total = total_result.scalar_one() + + # Apply sorting + sort_column = getattr(Agent, sort_by, Agent.created_at) + if sort_order == "desc": + stmt = stmt.order_by(sort_column.desc()) + else: + stmt = stmt.order_by(sort_column.asc()) + + # Apply pagination + offset = (page - 1) * page_size + stmt = stmt.offset(offset).limit(page_size) + + # Execute query + result = await self.db.execute(stmt) + agents = list(result.scalars().all()) + + return agents, total + + async def save(self, agent: Agent) -> Agent: + """ + Save or update agent + + Args: + agent: Agent instance to save + + Returns: + Saved agent instance + """ + self.db.add(agent) + await self.db.flush() + await self.db.refresh(agent) + return agent + + async def delete(self, agent: Agent) -> None: + """ + Delete agent + + Args: + agent: Agent instance to delete + """ + await self.db.delete(agent) + await self.db.flush() + + async def exists(self, agent_id: str) -> bool: + """ + Check if agent exists + + Args: + agent_id: Agent unique ID + + Returns: + True if agent exists, False otherwise + """ + stmt = select(func.count()).where(Agent.id == agent_id) + result = await self.db.execute(stmt) + count = result.scalar_one() + return count > 0 + diff --git a/main/live-agent-api/orm/base.py b/main/live-agent-api/orm/base.py new file mode 100644 index 000000000..529cbb51a --- /dev/null +++ b/main/live-agent-api/orm/base.py @@ -0,0 +1,136 @@ +""" +ORM Base Infrastructure + +Database configuration and utilities for SQLAlchemy ORM. +Provides the declarative base, engine management, and session handling. +""" + +import logging +from typing import AsyncGenerator +from sqlalchemy.ext.asyncio import ( + create_async_engine, + AsyncSession, + async_sessionmaker, + AsyncEngine +) +from sqlalchemy.orm import declarative_base + +from config.settings import settings + +logger = logging.getLogger(__name__) + +# SQLAlchemy declarative base for all ORM models +Base = declarative_base() + +# Global instances +_engine: AsyncEngine | None = None +_async_session_maker: async_sessionmaker[AsyncSession] | None = None + + +def get_engine() -> AsyncEngine: + """ + Get or create the global async database engine + + Returns: + Async SQLAlchemy engine instance + """ + global _engine + + if _engine is None: + logger.info("Creating database engine") + _engine = create_async_engine( + str(settings.database_url), + echo=settings.app_env == "development", + pool_size=10, + max_overflow=20, + pool_pre_ping=True, + ) + + return _engine + + +def get_session_maker() -> async_sessionmaker[AsyncSession]: + """ + Get or create the global async session maker + + Returns: + Async session maker instance + """ + global _async_session_maker + + if _async_session_maker is None: + engine = get_engine() + _async_session_maker = async_sessionmaker( + engine, + class_=AsyncSession, + expire_on_commit=False, + autocommit=False, + autoflush=False, + ) + + return _async_session_maker + + +async def get_db() -> AsyncGenerator[AsyncSession, None]: + """ + FastAPI dependency function to get database session + + Yields: + Async database session + + Example: + ```python + @router.get("/items") + async def get_items(db: AsyncSession = Depends(get_db)): + result = await db.execute(select(Item)) + return result.scalars().all() + ``` + """ + session_maker = get_session_maker() + async with session_maker() as session: + try: + yield session + await session.commit() + except Exception: + await session.rollback() + raise + finally: + await session.close() + + +async def init_database() -> None: + """ + Initialize database tables + + Creates all tables defined in SQLAlchemy models. + Should be called once during application startup in lifespan. + """ + engine = get_engine() + + logger.info("Initializing database tables...") + async with engine.begin() as conn: + # Import all models to ensure they are registered with Base + from orm.agent import Agent # noqa: F401 + # Future: from orm.device import Device + # Future: from orm.binding import Binding + + # Create all tables + await conn.run_sync(Base.metadata.create_all) + + logger.info("Database tables initialized successfully") + + +async def close_database() -> None: + """ + Close database connections + + Should be called during application shutdown in lifespan. + """ + global _engine + + if _engine is not None: + logger.info("Closing database connections...") + await _engine.dispose() + _engine = None + logger.info("Database connections closed") + diff --git a/main/live-agent-api/pyproject.toml b/main/live-agent-api/pyproject.toml new file mode 100644 index 000000000..196dea78d --- /dev/null +++ b/main/live-agent-api/pyproject.toml @@ -0,0 +1,32 @@ +[project] +name = "live-agent-api" +version = "0.1.0" +description = "Live Agent Dashboard API - Agent configuration and management service" +requires-python = ">=3.12" +dependencies = [ + "fastapi>=0.115.0", + "uvicorn[standard]>=0.32.0", + "sqlalchemy>=2.0.36", + "asyncpg>=0.30.0", + "pydantic>=2.9.0", + "pydantic-settings>=2.6.0", + "openai>=1.54.0", + "python-dotenv>=1.0.0", + "httpx>=0.27.0", + "snowflake-id>=1.0.2", +] + +[dependency-groups] +dev = [ + "pytest>=8.3.0", + "pytest-asyncio>=0.24.0", + "black>=24.10.0", + "ruff>=0.7.0", +] + +[tool.hatch.build.targets.wheel] +packages = ["config", "models", "schemas", "router", "services", "utils"] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" diff --git a/main/live-agent-api/router/__init__.py b/main/live-agent-api/router/__init__.py new file mode 100644 index 000000000..5181e0caf --- /dev/null +++ b/main/live-agent-api/router/__init__.py @@ -0,0 +1,10 @@ +""" +API Routers + +FastAPI route handlers for all API endpoints. +""" + +from router.agent import router as agent_router + +__all__ = ["agent_router"] + diff --git a/main/live-agent-api/router/agent.py b/main/live-agent-api/router/agent.py new file mode 100644 index 000000000..943633cd8 --- /dev/null +++ b/main/live-agent-api/router/agent.py @@ -0,0 +1,323 @@ +""" +Agent Router + +API endpoints for Agent management. +""" + +import logging +from typing import Annotated +from fastapi import APIRouter, Depends, HTTPException, Query +from sqlalchemy.ext.asyncio import AsyncSession + +from orm import get_db +from services.agent_service import AgentService, get_agent_service +from schemas.agent import ( + AgentCreate, + AgentUpdate, + AgentDuplicate, + AgentResponse, + AgentListQuery, + GeneratePromptRequest, + GeneratePromptResponse, +) +from utils.response import ( + ApiResponse, + success_response, + error_response, + paginated_response, +) + + +logger = logging.getLogger(__name__) + +router = APIRouter(prefix="/agent", tags=["agent"]) + + +@router.get("/") +async def get_agent_list( + search: Annotated[str | None, Query(description="Search keyword")] = None, + page: Annotated[int, Query(ge=1, description="Page number")] = 1, + pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 20, + sortBy: Annotated[str, Query(alias="sortBy", description="Sort field")] = "createdAt", + sortOrder: Annotated[str, Query(alias="sortOrder", pattern="^(asc|desc)$", description="Sort order")] = "desc", + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get Agent list with search, pagination and sorting + + - **search**: Search keyword (searches in name and system prompt) + - **page**: Page number (starting from 1) + - **pageSize**: Number of items per page (1-100) + - **sortBy**: Field to sort by (default: createdAt) + - **sortOrder**: Sort order - asc or desc (default: desc) + + Returns paginated list of agents with total count. + """ + try: + # Create query object + query = AgentListQuery( + search=search, + page=page, + page_size=pageSize, + sort_by=sortBy, + sort_order=sortOrder, + ) + + # Get service + service = get_agent_service(db) + + # Get agents + agents, total = await service.get_agent_list(query) + + # Convert to response format + agent_responses = [ + AgentResponse.model_validate(agent) for agent in agents + ] + + # Create paginated response + pagination_data = paginated_response( + items=agent_responses, + total=total, + page=page, + page_size=pageSize, + ) + + return success_response(data=pagination_data) + + except Exception as e: + logger.error(f"Error getting agent list: {str(e)}") + return error_response( + message=f"Failed to get agent list: {str(e)}", + code=500 + ) + + +@router.get("/{agent_id}") +async def get_agent_detail( + agent_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get Agent details by ID + + - **agent_id**: Agent unique ID + + Returns detailed agent information. + """ + try: + service = get_agent_service(db) + agent = await service.get_agent_by_id(agent_id) + + if not agent: + return error_response( + message=f"Agent not found: {agent_id}", + code=404 + ) + + agent_response = AgentResponse.model_validate(agent) + return success_response(data=agent_response) + + except Exception as e: + logger.error(f"Error getting agent detail: {str(e)}") + return error_response( + message=f"Failed to get agent detail: {str(e)}", + code=500 + ) + + +@router.post("/") +async def create_agent( + agent_data: AgentCreate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Create a new Agent + + Request body: + - **name**: Agent display name (required) + - **template**: Agent template type (default: blank) + - **language**: Language code, e.g., en, zh (default: en) + - **firstMessage**: Greeting message (optional) + - **systemPrompt**: System prompt for behavior (optional) + - **wakeWord**: Wake word to activate agent (default: PLAUD) + + Returns the created agent with generated ID. + """ + try: + service = get_agent_service(db) + agent = await service.create_agent(agent_data) + + agent_response = AgentResponse.model_validate(agent) + return success_response( + data=agent_response, + message="Agent created successfully", + code=201 + ) + + except Exception as e: + logger.error(f"Error creating agent: {str(e)}") + return error_response( + message=f"Failed to create agent: {str(e)}", + code=500 + ) + + +@router.put("/{agent_id}") +async def update_agent( + agent_id: str, + agent_data: AgentUpdate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Update Agent configuration + + - **agent_id**: Agent unique ID + + Request body (all fields optional): + - **name**: Agent display name + - **language**: Language code + - **firstMessage**: Greeting message + - **systemPrompt**: System prompt for behavior + - **wakeWord**: Wake word to activate agent + + Returns the updated agent information. + """ + try: + service = get_agent_service(db) + agent = await service.update_agent(agent_id, agent_data) + + if not agent: + return error_response( + message=f"Agent not found: {agent_id}", + code=404 + ) + + agent_response = AgentResponse.model_validate(agent) + return success_response( + data=agent_response, + message="Agent updated successfully" + ) + + except Exception as e: + logger.error(f"Error updating agent: {str(e)}") + return error_response( + message=f"Failed to update agent: {str(e)}", + code=500 + ) + + +@router.delete("/{agent_id}") +async def delete_agent( + agent_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Delete an Agent + + - **agent_id**: Agent unique ID + + Deletes the agent if no binding relationships exist. + Returns success message if deleted. + """ + try: + service = get_agent_service(db) + deleted = await service.delete_agent(agent_id) + + if not deleted: + return error_response( + message=f"Agent not found: {agent_id}", + code=404 + ) + + return success_response( + data={"id": agent_id}, + message="Agent deleted successfully" + ) + + except Exception as e: + logger.error(f"Error deleting agent: {str(e)}") + return error_response( + message=f"Failed to delete agent: {str(e)}", + code=500 + ) + + +@router.post("/{agent_id}/duplicate") +async def duplicate_agent( + agent_id: str, + duplicate_data: AgentDuplicate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Duplicate an existing Agent + + - **agent_id**: Source agent ID to duplicate + + Request body: + - **name**: Name for the duplicated agent (required) + + Creates a copy of the agent with a new ID and name. + Returns the newly created agent. + """ + try: + service = get_agent_service(db) + new_agent = await service.duplicate_agent( + agent_id, + duplicate_data.name + ) + + if not new_agent: + return error_response( + message=f"Source agent not found: {agent_id}", + code=404 + ) + + agent_response = AgentResponse.model_validate(new_agent) + return success_response( + data=agent_response, + message="Agent duplicated successfully", + code=201 + ) + + except Exception as e: + logger.error(f"Error duplicating agent: {str(e)}") + return error_response( + message=f"Failed to duplicate agent: {str(e)}", + code=500 + ) + + +@router.post("/generate-prompt") +async def generate_system_prompt( + request: GeneratePromptRequest, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Generate system prompt using AI + + Request body: + - **description**: Description of the agent's purpose (required) + + Uses OpenAI to generate a professional system prompt based on the description. + Returns the generated prompt. + """ + try: + service = get_agent_service(db) + generated_prompt = await service.generate_system_prompt(request) + + response_data = GeneratePromptResponse( + systemPrompt=generated_prompt + ) + + return success_response( + data=response_data, + message="System prompt generated successfully" + ) + + except Exception as e: + logger.error(f"Error generating prompt: {str(e)}") + return error_response( + message=f"Failed to generate prompt: {str(e)}", + code=500 + ) + diff --git a/main/live-agent-api/schemas/__init__.py b/main/live-agent-api/schemas/__init__.py new file mode 100644 index 000000000..a0d65e62d --- /dev/null +++ b/main/live-agent-api/schemas/__init__.py @@ -0,0 +1,28 @@ +""" +API Schemas + +Pydantic models for request/response validation. +""" + +from schemas.agent import ( + AgentBase, + AgentCreate, + AgentUpdate, + AgentDuplicate, + AgentResponse, + AgentListQuery, + GeneratePromptRequest, + GeneratePromptResponse, +) + +__all__ = [ + "AgentBase", + "AgentCreate", + "AgentUpdate", + "AgentDuplicate", + "AgentResponse", + "AgentListQuery", + "GeneratePromptRequest", + "GeneratePromptResponse", +] + diff --git a/main/live-agent-api/schemas/agent.py b/main/live-agent-api/schemas/agent.py new file mode 100644 index 000000000..90c94f291 --- /dev/null +++ b/main/live-agent-api/schemas/agent.py @@ -0,0 +1,277 @@ +""" +Agent Schemas + +Pydantic models for Agent API request/response validation. +""" + +from datetime import datetime +from typing import Optional +from pydantic import BaseModel, Field, field_validator + + +class AgentBase(BaseModel): + """Base schema for Agent with common fields""" + + name: str = Field( + ..., + min_length=1, + max_length=255, + description="Agent display name" + ) + template: str = Field( + default="blank", + max_length=100, + description="Agent template type" + ) + language: str = Field( + default="en", + max_length=10, + description="Agent language code (e.g., en, zh)" + ) + first_message: Optional[str] = Field( + None, + alias="firstMessage", + description="Agent's greeting message" + ) + system_prompt: Optional[str] = Field( + None, + alias="systemPrompt", + description="System prompt for agent behavior" + ) + wake_word: str = Field( + default="PLAUD", + alias="wakeWord", + max_length=50, + description="Wake word to activate agent" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "name": "My Assistant", + "template": "personal-assistant", + "language": "en", + "firstMessage": "Hello! How can I help you today?", + "systemPrompt": "You are a helpful assistant.", + "wakeWord": "PLAUD" + } + } + } + + +class AgentCreate(AgentBase): + """Schema for creating a new Agent""" + + @field_validator('name') + @classmethod + def validate_name(cls, v: str) -> str: + """Validate and clean agent name""" + v = v.strip() + if not v: + raise ValueError("Agent name cannot be empty") + return v + + @field_validator('language') + @classmethod + def validate_language(cls, v: str) -> str: + """Validate language code""" + v = v.lower().strip() + # Basic validation for common language codes + if len(v) < 2 or len(v) > 10: + raise ValueError("Invalid language code") + return v + + +class AgentUpdate(BaseModel): + """Schema for updating an Agent (all fields optional)""" + + name: Optional[str] = Field( + None, + min_length=1, + max_length=255, + description="Agent display name" + ) + language: Optional[str] = Field( + None, + max_length=10, + description="Agent language code" + ) + first_message: Optional[str] = Field( + None, + alias="firstMessage", + description="Agent's greeting message" + ) + system_prompt: Optional[str] = Field( + None, + alias="systemPrompt", + description="System prompt for agent behavior" + ) + wake_word: Optional[str] = Field( + None, + alias="wakeWord", + max_length=50, + description="Wake word to activate agent" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "name": "Updated Agent Name", + "language": "zh", + "firstMessage": "你好!有什么可以帮助你的吗?", + "systemPrompt": "You are a helpful Chinese assistant.", + "wakeWord": "小助手" + } + } + } + + @field_validator('name') + @classmethod + def validate_name(cls, v: Optional[str]) -> Optional[str]: + """Validate and clean agent name""" + if v is not None: + v = v.strip() + if not v: + raise ValueError("Agent name cannot be empty") + return v + + @field_validator('language') + @classmethod + def validate_language(cls, v: Optional[str]) -> Optional[str]: + """Validate language code""" + if v is not None: + v = v.lower().strip() + if len(v) < 2 or len(v) > 10: + raise ValueError("Invalid language code") + return v + + +class AgentDuplicate(BaseModel): + """Schema for duplicating an Agent""" + + name: str = Field( + ..., + min_length=1, + max_length=255, + description="Name for the duplicated agent" + ) + + model_config = { + "json_schema_extra": { + "example": { + "name": "Copy of My Agent" + } + } + } + + +class AgentResponse(AgentBase): + """Schema for Agent response""" + + id: str = Field(..., description="Agent unique ID") + created_at: datetime = Field( + ..., + alias="createdAt", + description="Creation timestamp" + ) + updated_at: datetime = Field( + ..., + alias="updatedAt", + description="Last update timestamp" + ) + + model_config = { + "populate_by_name": True, + "from_attributes": True, + "json_schema_extra": { + "example": { + "id": "1234567890", + "name": "My Assistant", + "template": "personal-assistant", + "language": "en", + "firstMessage": "Hello! How can I help you today?", + "systemPrompt": "You are a helpful assistant.", + "wakeWord": "PLAUD", + "createdAt": "2024-01-01T00:00:00", + "updatedAt": "2024-01-01T00:00:00" + } + } + } + + +class AgentListQuery(BaseModel): + """Schema for Agent list query parameters""" + + search: Optional[str] = Field( + None, + max_length=255, + description="Search keyword" + ) + page: int = Field( + default=1, + ge=1, + description="Page number" + ) + page_size: int = Field( + default=20, + alias="pageSize", + ge=1, + le=100, + description="Number of items per page" + ) + sort_by: str = Field( + default="createdAt", + alias="sortBy", + description="Sort field" + ) + sort_order: str = Field( + default="desc", + alias="sortOrder", + pattern="^(asc|desc)$", + description="Sort order (asc or desc)" + ) + + model_config = { + "populate_by_name": True + } + + +class GeneratePromptRequest(BaseModel): + """Schema for generating system prompt""" + + description: str = Field( + ..., + min_length=1, + max_length=1000, + description="Description of the agent's purpose" + ) + + model_config = { + "json_schema_extra": { + "example": { + "description": "a customer support agent for PLAUD" + } + } + } + + +class GeneratePromptResponse(BaseModel): + """Schema for generated system prompt response""" + + system_prompt: str = Field( + ..., + alias="systemPrompt", + description="Generated system prompt" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "systemPrompt": "You are a professional customer support agent for PLAUD..." + } + } + } + diff --git a/main/live-agent-api/services/__init__.py b/main/live-agent-api/services/__init__.py new file mode 100644 index 000000000..ebd26cead --- /dev/null +++ b/main/live-agent-api/services/__init__.py @@ -0,0 +1,10 @@ +""" +Business Logic Services + +Service layer for handling business logic. +""" + +from services.agent_service import AgentService, get_agent_service + +__all__ = ["AgentService", "get_agent_service"] + diff --git a/main/live-agent-api/services/agent_service.py b/main/live-agent-api/services/agent_service.py new file mode 100644 index 000000000..472582fab --- /dev/null +++ b/main/live-agent-api/services/agent_service.py @@ -0,0 +1,286 @@ +""" +Agent Service + +Business logic layer for Agent operations. +Uses Repository pattern for data access. +""" + +import logging +from typing import Optional +from datetime import datetime, timezone +from sqlalchemy.ext.asyncio import AsyncSession +from openai import AsyncOpenAI + +from orm.agent import Agent, AgentRepository +from schemas.agent import ( + AgentCreate, + AgentUpdate, + AgentListQuery, + GeneratePromptRequest, +) +from utils.id_generator import generate_id +from config.settings import settings + + +logger = logging.getLogger(__name__) + + +class AgentService: + """Service class for Agent business logic""" + + def __init__(self, db: AsyncSession): + """ + Initialize Agent service + + Args: + db: Database session + """ + self.repo = AgentRepository(db) + self.openai_client = AsyncOpenAI(api_key=settings.openai_api_key) + + async def get_agent_list( + self, + query: AgentListQuery + ) -> tuple[list[Agent], int]: + """ + Get paginated list of agents with optional search + + Args: + query: Query parameters for filtering and pagination + + Returns: + Tuple of (agents list, total count) + """ + agents, total = await self.repo.find_all( + search=query.search, + page=query.page, + page_size=query.page_size, + sort_by=query.sort_by, + sort_order=query.sort_order, + ) + + logger.info( + f"Retrieved {len(agents)} agents (page {query.page}, total {total})" + ) + + return agents, total + + async def get_agent_by_id(self, agent_id: str) -> Optional[Agent]: + """ + Get agent by ID + + Args: + agent_id: Agent unique ID + + Returns: + Agent instance or None if not found + """ + agent = await self.repo.find_by_id(agent_id) + + if agent: + logger.info(f"Retrieved agent: {agent_id}") + else: + logger.warning(f"Agent not found: {agent_id}") + + return agent + + async def create_agent(self, agent_data: AgentCreate) -> Agent: + """ + Create a new agent + + Args: + agent_data: Agent creation data + + Returns: + Created agent instance + """ + # Business logic: Generate unique ID + agent_id = generate_id() + + # Business logic: Create agent instance + agent = Agent( + id=agent_id, + name=agent_data.name, + template=agent_data.template, + language=agent_data.language, + first_message=agent_data.first_message, + system_prompt=agent_data.system_prompt, + wake_word=agent_data.wake_word, + ) + + # Persist to database + agent = await self.repo.save(agent) + + logger.info(f"Created agent: {agent_id} ({agent.name})") + + return agent + + async def update_agent( + self, + agent_id: str, + agent_data: AgentUpdate + ) -> Optional[Agent]: + """ + Update agent configuration + + Args: + agent_id: Agent unique ID + agent_data: Agent update data + + Returns: + Updated agent instance or None if not found + """ + # Get existing agent + agent = await self.repo.find_by_id(agent_id) + if not agent: + return None + + # Business logic: Update fields + update_data = agent_data.model_dump(exclude_unset=True) + for field, value in update_data.items(): + # Convert camelCase to snake_case + db_field = field.replace("firstMessage", "first_message") + db_field = db_field.replace("systemPrompt", "system_prompt") + db_field = db_field.replace("wakeWord", "wake_word") + + if hasattr(agent, db_field): + setattr(agent, db_field, value) + + # Business logic: Update timestamp + agent.updated_at = datetime.now(timezone.utc) + + # Persist changes + agent = await self.repo.save(agent) + + logger.info(f"Updated agent: {agent_id}") + + return agent + + async def delete_agent(self, agent_id: str) -> bool: + """ + Delete an agent + + Args: + agent_id: Agent unique ID + + Returns: + True if deleted, False if not found + """ + agent = await self.repo.find_by_id(agent_id) + if not agent: + return False + + # TODO: Business logic - Check for binding relationships + # For now, just delete the agent + # In production, should check if agent has bindings and handle accordingly + + await self.repo.delete(agent) + + logger.info(f"Deleted agent: {agent_id}") + + return True + + async def duplicate_agent( + self, + agent_id: str, + new_name: str + ) -> Optional[Agent]: + """ + Duplicate an existing agent + + Args: + agent_id: Source agent ID + new_name: Name for the duplicated agent + + Returns: + New agent instance or None if source not found + """ + # Get source agent + source_agent = await self.repo.find_by_id(agent_id) + if not source_agent: + return None + + # Business logic: Create duplicate with new ID and name + new_id = generate_id() + duplicate_agent = Agent( + id=new_id, + name=new_name, + template=source_agent.template, + language=source_agent.language, + first_message=source_agent.first_message, + system_prompt=source_agent.system_prompt, + wake_word=source_agent.wake_word, + ) + + # Persist to database + duplicate_agent = await self.repo.save(duplicate_agent) + + logger.info( + f"Duplicated agent {agent_id} to {new_id} ({new_name})" + ) + + return duplicate_agent + + async def generate_system_prompt( + self, + request: GeneratePromptRequest + ) -> str: + """ + Generate system prompt using AI + + Args: + request: Prompt generation request with description + + Returns: + Generated system prompt + """ + logger.info(f"Generating prompt for: {request.description}") + + try: + response = await self.openai_client.chat.completions.create( + model=settings.openai_model, + messages=[ + { + "role": "system", + "content": ( + "You are an AI assistant that helps create system prompts " + "for voice assistant agents. Generate a clear, concise, " + "and professional system prompt based on the user's description. " + "The prompt should define the agent's role, capabilities, " + "and behavior guidelines." + ) + }, + { + "role": "user", + "content": ( + f"Create a system prompt for {request.description}. " + f"The prompt should be suitable for a voice assistant agent." + ) + } + ], + temperature=0.7, + max_tokens=500, + ) + + generated_prompt = response.choices[0].message.content.strip() + + logger.info("Successfully generated system prompt") + + return generated_prompt + + except Exception as e: + logger.error(f"Error generating prompt: {str(e)}") + raise + + +def get_agent_service(db: AsyncSession) -> AgentService: + """ + Dependency function to get Agent service + + Args: + db: Database session + + Returns: + AgentService instance + """ + return AgentService(db) diff --git a/main/live-agent-api/utils/__init__.py b/main/live-agent-api/utils/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/main/live-agent-api/utils/id_generator.py b/main/live-agent-api/utils/id_generator.py new file mode 100644 index 000000000..f1095b2fb --- /dev/null +++ b/main/live-agent-api/utils/id_generator.py @@ -0,0 +1,125 @@ +""" +Snowflake ID Generator + +Wrapper around the snowflake-id library for generating distributed unique IDs. +Uses Twitter's Snowflake algorithm to generate 64-bit IDs. +""" + +from typing import Optional +from snowflake import SnowflakeGenerator + +import logging + +logger = logging.getLogger(__name__) + +# Global ID generator instance +_id_generator: Optional[SnowflakeGenerator] = None + + +def get_id_generator() -> SnowflakeGenerator: + """ + Get the global ID generator instance + + Returns: + Snowflake ID generator instance + + Raises: + RuntimeError: If generator is not initialized + """ + global _id_generator + + if _id_generator is None: + raise RuntimeError( + "ID generator not initialized. " + "Call init_id_generator() in application lifespan." + ) + + return _id_generator + + +def generate_id() -> str: + """ + Generate a unique Snowflake ID as string + + Returns: + Unique ID as string + """ + generator = get_id_generator() + return str(next(generator)) + + +def generate_id_int() -> int: + """ + Generate a unique Snowflake ID as integer + + Returns: + Unique 64-bit integer ID + """ + generator = get_id_generator() + return next(generator) + + +def init_id_generator(instance_id: int = 1) -> None: + """ + Initialize global Snowflake ID generator + + Should be called once during application startup in lifespan. + + Args: + instance_id: Unique instance ID for this service (0-1023) + In production, this should be: + - Stored in a distributed configuration center (e.g., etcd, Consul) + - Automatically assigned when service instances start + - Managed by orchestration system (e.g., Kubernetes StatefulSet) + + Raises: + ValueError: If instance_id is out of valid range + """ + global _id_generator + + # Already initialized + if _id_generator is not None: + logger.warning("ID generator already initialized, skipping") + return + + # Validate instance_id + if instance_id < 0 or instance_id > 1023: + raise ValueError( + f"Instance ID must be between 0 and 1023, got {instance_id}" + ) + + _id_generator = SnowflakeGenerator(instance_id) + logger.info(f"ID generator initialized with instance_id={instance_id}") + + +def close_id_generator() -> None: + """ + Close and cleanup ID generator + + Optional cleanup function for application shutdown. + """ + global _id_generator + + if _id_generator is not None: + logger.info("Closing ID generator...") + _id_generator = None + logger.info("ID generator closed") + + +if __name__ == "__main__": + # Test ID generation + print("Testing Snowflake ID Generator") + print("=" * 50) + + # Initialize with instance ID 1 + init_id_generator(instance_id=1) + + print("\nGenerating 10 sample IDs:") + for i in range(10): + id_str = generate_id() + print(f" {i+1:2d}. {id_str}") + + print("\nAll IDs generated successfully!") + + # Cleanup + close_id_generator() diff --git a/main/live-agent-api/utils/response.py b/main/live-agent-api/utils/response.py new file mode 100644 index 000000000..2a4fbf257 --- /dev/null +++ b/main/live-agent-api/utils/response.py @@ -0,0 +1,126 @@ +""" +API Response Wrapper + +Provides standardized response format for all API endpoints. +""" + +from typing import Any, Optional, TypeVar, Generic +from pydantic import BaseModel, Field + + +T = TypeVar('T') + + +class ApiResponse(BaseModel, Generic[T]): + """ + Standard API response format + + Attributes: + code: HTTP status code + message: Response message + data: Response data payload + """ + code: int = Field(..., description="HTTP status code") + message: str = Field(..., description="Response message") + data: Optional[T] = Field(None, description="Response data") + + class Config: + json_schema_extra = { + "example": { + "code": 200, + "message": "success", + "data": {"id": "123", "name": "Example"} + } + } + + +class PaginatedResponse(BaseModel, Generic[T]): + """ + Paginated list response format + + Attributes: + total: Total number of items + page: Current page number + pageSize: Number of items per page + items: List of items + """ + total: int = Field(..., description="Total number of items") + page: int = Field(..., description="Current page number") + pageSize: int = Field(..., alias="pageSize", description="Number of items per page") + items: list[T] = Field(..., description="List of items") + + class Config: + populate_by_name = True + json_schema_extra = { + "example": { + "total": 100, + "page": 1, + "pageSize": 20, + "items": [] + } + } + + +def success_response( + data: Any = None, + message: str = "success", + code: int = 200 +) -> ApiResponse: + """ + Create a success response + + Args: + data: Response data payload + message: Success message + code: HTTP status code + + Returns: + Standardized success response + """ + return ApiResponse(code=code, message=message, data=data) + + +def error_response( + message: str, + code: int = 400, + data: Any = None +) -> ApiResponse: + """ + Create an error response + + Args: + message: Error message + code: HTTP status code + data: Additional error data + + Returns: + Standardized error response + """ + return ApiResponse(code=code, message=message, data=data) + + +def paginated_response( + items: list[Any], + total: int, + page: int, + page_size: int +) -> PaginatedResponse: + """ + Create a paginated response + + Args: + items: List of items + total: Total number of items + page: Current page number + page_size: Number of items per page + + Returns: + Paginated response + """ + return PaginatedResponse( + total=total, + page=page, + pageSize=page_size, + items=items + ) + diff --git a/main/live-agent-api/uv.lock b/main/live-agent-api/uv.lock new file mode 100644 index 000000000..cf2d518d2 --- /dev/null +++ b/main/live-agent-api/uv.lock @@ -0,0 +1,908 @@ +version = 1 +revision = 3 +requires-python = ">=3.12" + +[[package]] +name = "annotated-doc" +version = "0.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/a6/dc46877b911e40c00d395771ea710d5e77b6de7bacd5fdcd78d70cc5a48f/annotated_doc-0.0.3.tar.gz", hash = "sha256:e18370014c70187422c33e945053ff4c286f453a984eba84d0dbfa0c935adeda", size = 5535, upload-time = "2025-10-24T14:57:10.718Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/02/b7/cf592cb5de5cb3bade3357f8d2cf42bf103bbe39f459824b4939fd212911/annotated_doc-0.0.3-py3-none-any.whl", hash = "sha256:348ec6664a76f1fd3be81f43dffbee4c7e8ce931ba71ec67cc7f4ade7fbbb580", size = 5488, upload-time = "2025-10-24T14:57:09.462Z" }, +] + +[[package]] +name = "annotated-types" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, +] + +[[package]] +name = "anyio" +version = "4.11.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "sniffio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c6/78/7d432127c41b50bccba979505f272c16cbcadcc33645d5fa3a738110ae75/anyio-4.11.0.tar.gz", hash = "sha256:82a8d0b81e318cc5ce71a5f1f8b5c4e63619620b63141ef8c995fa0db95a57c4", size = 219094, upload-time = "2025-09-23T09:19:12.58Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/15/b3/9b1a8074496371342ec1e796a96f99c82c945a339cd81a8e73de28b4cf9e/anyio-4.11.0-py3-none-any.whl", hash = "sha256:0287e96f4d26d4149305414d4e3bc32f0dcd0862365a4bddea19d7a1ec38c4fc", size = 109097, upload-time = "2025-09-23T09:19:10.601Z" }, +] + +[[package]] +name = "asyncpg" +version = "0.30.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/2f/4c/7c991e080e106d854809030d8584e15b2e996e26f16aee6d757e387bc17d/asyncpg-0.30.0.tar.gz", hash = "sha256:c551e9928ab6707602f44811817f82ba3c446e018bfe1d3abecc8ba5f3eac851", size = 957746, upload-time = "2024-10-20T00:30:41.127Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4b/64/9d3e887bb7b01535fdbc45fbd5f0a8447539833b97ee69ecdbb7a79d0cb4/asyncpg-0.30.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c902a60b52e506d38d7e80e0dd5399f657220f24635fee368117b8b5fce1142e", size = 673162, upload-time = "2024-10-20T00:29:41.88Z" }, + { url = "https://files.pythonhosted.org/packages/6e/eb/8b236663f06984f212a087b3e849731f917ab80f84450e943900e8ca4052/asyncpg-0.30.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:aca1548e43bbb9f0f627a04666fedaca23db0a31a84136ad1f868cb15deb6e3a", size = 637025, upload-time = "2024-10-20T00:29:43.352Z" }, + { url = "https://files.pythonhosted.org/packages/cc/57/2dc240bb263d58786cfaa60920779af6e8d32da63ab9ffc09f8312bd7a14/asyncpg-0.30.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c2a2ef565400234a633da0eafdce27e843836256d40705d83ab7ec42074efb3", size = 3496243, upload-time = "2024-10-20T00:29:44.922Z" }, + { url = "https://files.pythonhosted.org/packages/f4/40/0ae9d061d278b10713ea9021ef6b703ec44698fe32178715a501ac696c6b/asyncpg-0.30.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1292b84ee06ac8a2ad8e51c7475aa309245874b61333d97411aab835c4a2f737", size = 3575059, upload-time = "2024-10-20T00:29:46.891Z" }, + { url = "https://files.pythonhosted.org/packages/c3/75/d6b895a35a2c6506952247640178e5f768eeb28b2e20299b6a6f1d743ba0/asyncpg-0.30.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:0f5712350388d0cd0615caec629ad53c81e506b1abaaf8d14c93f54b35e3595a", size = 3473596, upload-time = "2024-10-20T00:29:49.201Z" }, + { url = "https://files.pythonhosted.org/packages/c8/e7/3693392d3e168ab0aebb2d361431375bd22ffc7b4a586a0fc060d519fae7/asyncpg-0.30.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:db9891e2d76e6f425746c5d2da01921e9a16b5a71a1c905b13f30e12a257c4af", size = 3641632, upload-time = "2024-10-20T00:29:50.768Z" }, + { url = "https://files.pythonhosted.org/packages/32/ea/15670cea95745bba3f0352341db55f506a820b21c619ee66b7d12ea7867d/asyncpg-0.30.0-cp312-cp312-win32.whl", hash = "sha256:68d71a1be3d83d0570049cd1654a9bdfe506e794ecc98ad0873304a9f35e411e", size = 560186, upload-time = "2024-10-20T00:29:52.394Z" }, + { url = "https://files.pythonhosted.org/packages/7e/6b/fe1fad5cee79ca5f5c27aed7bd95baee529c1bf8a387435c8ba4fe53d5c1/asyncpg-0.30.0-cp312-cp312-win_amd64.whl", hash = "sha256:9a0292c6af5c500523949155ec17b7fe01a00ace33b68a476d6b5059f9630305", size = 621064, upload-time = "2024-10-20T00:29:53.757Z" }, + { url = "https://files.pythonhosted.org/packages/3a/22/e20602e1218dc07692acf70d5b902be820168d6282e69ef0d3cb920dc36f/asyncpg-0.30.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:05b185ebb8083c8568ea8a40e896d5f7af4b8554b64d7719c0eaa1eb5a5c3a70", size = 670373, upload-time = "2024-10-20T00:29:55.165Z" }, + { url = "https://files.pythonhosted.org/packages/3d/b3/0cf269a9d647852a95c06eb00b815d0b95a4eb4b55aa2d6ba680971733b9/asyncpg-0.30.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c47806b1a8cbb0a0db896f4cd34d89942effe353a5035c62734ab13b9f938da3", size = 634745, upload-time = "2024-10-20T00:29:57.14Z" }, + { url = "https://files.pythonhosted.org/packages/8e/6d/a4f31bf358ce8491d2a31bfe0d7bcf25269e80481e49de4d8616c4295a34/asyncpg-0.30.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b6fde867a74e8c76c71e2f64f80c64c0f3163e687f1763cfaf21633ec24ec33", size = 3512103, upload-time = "2024-10-20T00:29:58.499Z" }, + { url = "https://files.pythonhosted.org/packages/96/19/139227a6e67f407b9c386cb594d9628c6c78c9024f26df87c912fabd4368/asyncpg-0.30.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46973045b567972128a27d40001124fbc821c87a6cade040cfcd4fa8a30bcdc4", size = 3592471, upload-time = "2024-10-20T00:30:00.354Z" }, + { url = "https://files.pythonhosted.org/packages/67/e4/ab3ca38f628f53f0fd28d3ff20edff1c975dd1cb22482e0061916b4b9a74/asyncpg-0.30.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9110df111cabc2ed81aad2f35394a00cadf4f2e0635603db6ebbd0fc896f46a4", size = 3496253, upload-time = "2024-10-20T00:30:02.794Z" }, + { url = "https://files.pythonhosted.org/packages/ef/5f/0bf65511d4eeac3a1f41c54034a492515a707c6edbc642174ae79034d3ba/asyncpg-0.30.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:04ff0785ae7eed6cc138e73fc67b8e51d54ee7a3ce9b63666ce55a0bf095f7ba", size = 3662720, upload-time = "2024-10-20T00:30:04.501Z" }, + { url = "https://files.pythonhosted.org/packages/e7/31/1513d5a6412b98052c3ed9158d783b1e09d0910f51fbe0e05f56cc370bc4/asyncpg-0.30.0-cp313-cp313-win32.whl", hash = "sha256:ae374585f51c2b444510cdf3595b97ece4f233fde739aa14b50e0d64e8a7a590", size = 560404, upload-time = "2024-10-20T00:30:06.537Z" }, + { url = "https://files.pythonhosted.org/packages/c8/a4/cec76b3389c4c5ff66301cd100fe88c318563ec8a520e0b2e792b5b84972/asyncpg-0.30.0-cp313-cp313-win_amd64.whl", hash = "sha256:f59b430b8e27557c3fb9869222559f7417ced18688375825f8f12302c34e915e", size = 621623, upload-time = "2024-10-20T00:30:09.024Z" }, +] + +[[package]] +name = "black" +version = "25.9.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "mypy-extensions" }, + { name = "packaging" }, + { name = "pathspec" }, + { name = "platformdirs" }, + { name = "pytokens" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/4b/43/20b5c90612d7bdb2bdbcceeb53d588acca3bb8f0e4c5d5c751a2c8fdd55a/black-25.9.0.tar.gz", hash = "sha256:0474bca9a0dd1b51791fcc507a4e02078a1c63f6d4e4ae5544b9848c7adfb619", size = 648393, upload-time = "2025-09-19T00:27:37.758Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/8e/319cfe6c82f7e2d5bfb4d3353c6cc85b523d677ff59edc61fdb9ee275234/black-25.9.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1b9dc70c21ef8b43248f1d86aedd2aaf75ae110b958a7909ad8463c4aa0880b0", size = 1742012, upload-time = "2025-09-19T00:33:08.678Z" }, + { url = "https://files.pythonhosted.org/packages/94/cc/f562fe5d0a40cd2a4e6ae3f685e4c36e365b1f7e494af99c26ff7f28117f/black-25.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8e46eecf65a095fa62e53245ae2795c90bdecabd53b50c448d0a8bcd0d2e74c4", size = 1581421, upload-time = "2025-09-19T00:35:25.937Z" }, + { url = "https://files.pythonhosted.org/packages/84/67/6db6dff1ebc8965fd7661498aea0da5d7301074b85bba8606a28f47ede4d/black-25.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9101ee58ddc2442199a25cb648d46ba22cd580b00ca4b44234a324e3ec7a0f7e", size = 1655619, upload-time = "2025-09-19T00:30:49.241Z" }, + { url = "https://files.pythonhosted.org/packages/10/10/3faef9aa2a730306cf469d76f7f155a8cc1f66e74781298df0ba31f8b4c8/black-25.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:77e7060a00c5ec4b3367c55f39cf9b06e68965a4f2e61cecacd6d0d9b7ec945a", size = 1342481, upload-time = "2025-09-19T00:31:29.625Z" }, + { url = "https://files.pythonhosted.org/packages/48/99/3acfea65f5e79f45472c45f87ec13037b506522719cd9d4ac86484ff51ac/black-25.9.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0172a012f725b792c358d57fe7b6b6e8e67375dd157f64fa7a3097b3ed3e2175", size = 1742165, upload-time = "2025-09-19T00:34:10.402Z" }, + { url = "https://files.pythonhosted.org/packages/3a/18/799285282c8236a79f25d590f0222dbd6850e14b060dfaa3e720241fd772/black-25.9.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3bec74ee60f8dfef564b573a96b8930f7b6a538e846123d5ad77ba14a8d7a64f", size = 1581259, upload-time = "2025-09-19T00:32:49.685Z" }, + { url = "https://files.pythonhosted.org/packages/f1/ce/883ec4b6303acdeca93ee06b7622f1fa383c6b3765294824165d49b1a86b/black-25.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b756fc75871cb1bcac5499552d771822fd9db5a2bb8db2a7247936ca48f39831", size = 1655583, upload-time = "2025-09-19T00:30:44.505Z" }, + { url = "https://files.pythonhosted.org/packages/21/17/5c253aa80a0639ccc427a5c7144534b661505ae2b5a10b77ebe13fa25334/black-25.9.0-cp313-cp313-win_amd64.whl", hash = "sha256:846d58e3ce7879ec1ffe816bb9df6d006cd9590515ed5d17db14e17666b2b357", size = 1343428, upload-time = "2025-09-19T00:32:13.839Z" }, + { url = "https://files.pythonhosted.org/packages/1b/46/863c90dcd3f9d41b109b7f19032ae0db021f0b2a81482ba0a1e28c84de86/black-25.9.0-py3-none-any.whl", hash = "sha256:474b34c1342cdc157d307b56c4c65bce916480c4a8f6551fdc6bf9b486a7c4ae", size = 203363, upload-time = "2025-09-19T00:27:35.724Z" }, +] + +[[package]] +name = "certifi" +version = "2025.10.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4c/5b/b6ce21586237c77ce67d01dc5507039d444b630dd76611bbca2d8e5dcd91/certifi-2025.10.5.tar.gz", hash = "sha256:47c09d31ccf2acf0be3f701ea53595ee7e0b8fa08801c6624be771df09ae7b43", size = 164519, upload-time = "2025-10-05T04:12:15.808Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e4/37/af0d2ef3967ac0d6113837b44a4f0bfe1328c2b9763bd5b1744520e5cfed/certifi-2025.10.5-py3-none-any.whl", hash = "sha256:0f212c2744a9bb6de0c56639a6f68afe01ecd92d91f14ae897c4fe7bbeeef0de", size = 163286, upload-time = "2025-10-05T04:12:14.03Z" }, +] + +[[package]] +name = "click" +version = "8.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/46/61/de6cd827efad202d7057d93e0fed9294b96952e188f7384832791c7b2254/click-8.3.0.tar.gz", hash = "sha256:e7b8232224eba16f4ebe410c25ced9f7875cb5f3263ffc93cc3e8da705e229c4", size = 276943, upload-time = "2025-09-18T17:32:23.696Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/db/d3/9dcc0f5797f070ec8edf30fbadfb200e71d9db6b84d211e3b2085a7589a0/click-8.3.0-py3-none-any.whl", hash = "sha256:9b9f285302c6e3064f4330c05f05b81945b2a39544279343e6e7c5f27a9baddc", size = 107295, upload-time = "2025-09-18T17:32:22.42Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "distro" +version = "1.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, +] + +[[package]] +name = "fastapi" +version = "0.120.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-doc" }, + { name = "pydantic" }, + { name = "starlette" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3f/3a/0bf90d5189d7f62dc2bd0523899629ca59b58ff4290d631cd3bb5c8889d4/fastapi-0.120.4.tar.gz", hash = "sha256:2d856bc847893ca4d77896d4504ffdec0fb04312b705065fca9104428eca3868", size = 339716, upload-time = "2025-10-31T18:37:28.81Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ed/47/14a76b926edc3957c8a8258423db789d3fa925d2fed800102fce58959413/fastapi-0.120.4-py3-none-any.whl", hash = "sha256:9bdf192308676480d3593e10fd05094e56d6fdc7d9283db26053d8104d5f82a0", size = 108235, upload-time = "2025-10-31T18:37:27.038Z" }, +] + +[[package]] +name = "greenlet" +version = "3.2.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/03/b8/704d753a5a45507a7aab61f18db9509302ed3d0a27ac7e0359ec2905b1a6/greenlet-3.2.4.tar.gz", hash = "sha256:0dca0d95ff849f9a364385f36ab49f50065d76964944638be9691e1832e9f86d", size = 188260, upload-time = "2025-08-07T13:24:33.51Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/44/69/9b804adb5fd0671f367781560eb5eb586c4d495277c93bde4307b9e28068/greenlet-3.2.4-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:3b67ca49f54cede0186854a008109d6ee71f66bd57bb36abd6d0a0267b540cdd", size = 274079, upload-time = "2025-08-07T13:15:45.033Z" }, + { url = "https://files.pythonhosted.org/packages/46/e9/d2a80c99f19a153eff70bc451ab78615583b8dac0754cfb942223d2c1a0d/greenlet-3.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddf9164e7a5b08e9d22511526865780a576f19ddd00d62f8a665949327fde8bb", size = 640997, upload-time = "2025-08-07T13:42:56.234Z" }, + { url = "https://files.pythonhosted.org/packages/3b/16/035dcfcc48715ccd345f3a93183267167cdd162ad123cd93067d86f27ce4/greenlet-3.2.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f28588772bb5fb869a8eb331374ec06f24a83a9c25bfa1f38b6993afe9c1e968", size = 655185, upload-time = "2025-08-07T13:45:27.624Z" }, + { url = "https://files.pythonhosted.org/packages/31/da/0386695eef69ffae1ad726881571dfe28b41970173947e7c558d9998de0f/greenlet-3.2.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:5c9320971821a7cb77cfab8d956fa8e39cd07ca44b6070db358ceb7f8797c8c9", size = 649926, upload-time = "2025-08-07T13:53:15.251Z" }, + { url = "https://files.pythonhosted.org/packages/68/88/69bf19fd4dc19981928ceacbc5fd4bb6bc2215d53199e367832e98d1d8fe/greenlet-3.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c60a6d84229b271d44b70fb6e5fa23781abb5d742af7b808ae3f6efd7c9c60f6", size = 651839, upload-time = "2025-08-07T13:18:30.281Z" }, + { url = "https://files.pythonhosted.org/packages/19/0d/6660d55f7373b2ff8152401a83e02084956da23ae58cddbfb0b330978fe9/greenlet-3.2.4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b3812d8d0c9579967815af437d96623f45c0f2ae5f04e366de62a12d83a8fb0", size = 607586, upload-time = "2025-08-07T13:18:28.544Z" }, + { url = "https://files.pythonhosted.org/packages/8e/1a/c953fdedd22d81ee4629afbb38d2f9d71e37d23caace44775a3a969147d4/greenlet-3.2.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:abbf57b5a870d30c4675928c37278493044d7c14378350b3aa5d484fa65575f0", size = 1123281, upload-time = "2025-08-07T13:42:39.858Z" }, + { url = "https://files.pythonhosted.org/packages/3f/c7/12381b18e21aef2c6bd3a636da1088b888b97b7a0362fac2e4de92405f97/greenlet-3.2.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:20fb936b4652b6e307b8f347665e2c615540d4b42b3b4c8a321d8286da7e520f", size = 1151142, upload-time = "2025-08-07T13:18:22.981Z" }, + { url = "https://files.pythonhosted.org/packages/e9/08/b0814846b79399e585f974bbeebf5580fbe59e258ea7be64d9dfb253c84f/greenlet-3.2.4-cp312-cp312-win_amd64.whl", hash = "sha256:a7d4e128405eea3814a12cc2605e0e6aedb4035bf32697f72deca74de4105e02", size = 299899, upload-time = "2025-08-07T13:38:53.448Z" }, + { url = "https://files.pythonhosted.org/packages/49/e8/58c7f85958bda41dafea50497cbd59738c5c43dbbea5ee83d651234398f4/greenlet-3.2.4-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:1a921e542453fe531144e91e1feedf12e07351b1cf6c9e8a3325ea600a715a31", size = 272814, upload-time = "2025-08-07T13:15:50.011Z" }, + { url = "https://files.pythonhosted.org/packages/62/dd/b9f59862e9e257a16e4e610480cfffd29e3fae018a68c2332090b53aac3d/greenlet-3.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd3c8e693bff0fff6ba55f140bf390fa92c994083f838fece0f63be121334945", size = 641073, upload-time = "2025-08-07T13:42:57.23Z" }, + { url = "https://files.pythonhosted.org/packages/f7/0b/bc13f787394920b23073ca3b6c4a7a21396301ed75a655bcb47196b50e6e/greenlet-3.2.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:710638eb93b1fa52823aa91bf75326f9ecdfd5e0466f00789246a5280f4ba0fc", size = 655191, upload-time = "2025-08-07T13:45:29.752Z" }, + { url = "https://files.pythonhosted.org/packages/f2/d6/6adde57d1345a8d0f14d31e4ab9c23cfe8e2cd39c3baf7674b4b0338d266/greenlet-3.2.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:c5111ccdc9c88f423426df3fd1811bfc40ed66264d35aa373420a34377efc98a", size = 649516, upload-time = "2025-08-07T13:53:16.314Z" }, + { url = "https://files.pythonhosted.org/packages/7f/3b/3a3328a788d4a473889a2d403199932be55b1b0060f4ddd96ee7cdfcad10/greenlet-3.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d76383238584e9711e20ebe14db6c88ddcedc1829a9ad31a584389463b5aa504", size = 652169, upload-time = "2025-08-07T13:18:32.861Z" }, + { url = "https://files.pythonhosted.org/packages/ee/43/3cecdc0349359e1a527cbf2e3e28e5f8f06d3343aaf82ca13437a9aa290f/greenlet-3.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23768528f2911bcd7e475210822ffb5254ed10d71f4028387e5a99b4c6699671", size = 610497, upload-time = "2025-08-07T13:18:31.636Z" }, + { url = "https://files.pythonhosted.org/packages/b8/19/06b6cf5d604e2c382a6f31cafafd6f33d5dea706f4db7bdab184bad2b21d/greenlet-3.2.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:00fadb3fedccc447f517ee0d3fd8fe49eae949e1cd0f6a611818f4f6fb7dc83b", size = 1121662, upload-time = "2025-08-07T13:42:41.117Z" }, + { url = "https://files.pythonhosted.org/packages/a2/15/0d5e4e1a66fab130d98168fe984c509249c833c1a3c16806b90f253ce7b9/greenlet-3.2.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:d25c5091190f2dc0eaa3f950252122edbbadbb682aa7b1ef2f8af0f8c0afefae", size = 1149210, upload-time = "2025-08-07T13:18:24.072Z" }, + { url = "https://files.pythonhosted.org/packages/0b/55/2321e43595e6801e105fcfdee02b34c0f996eb71e6ddffca6b10b7e1d771/greenlet-3.2.4-cp313-cp313-win_amd64.whl", hash = "sha256:554b03b6e73aaabec3745364d6239e9e012d64c68ccd0b8430c64ccc14939a8b", size = 299685, upload-time = "2025-08-07T13:24:38.824Z" }, + { url = "https://files.pythonhosted.org/packages/22/5c/85273fd7cc388285632b0498dbbab97596e04b154933dfe0f3e68156c68c/greenlet-3.2.4-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:49a30d5fda2507ae77be16479bdb62a660fa51b1eb4928b524975b3bde77b3c0", size = 273586, upload-time = "2025-08-07T13:16:08.004Z" }, + { url = "https://files.pythonhosted.org/packages/d1/75/10aeeaa3da9332c2e761e4c50d4c3556c21113ee3f0afa2cf5769946f7a3/greenlet-3.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:299fd615cd8fc86267b47597123e3f43ad79c9d8a22bebdce535e53550763e2f", size = 686346, upload-time = "2025-08-07T13:42:59.944Z" }, + { url = "https://files.pythonhosted.org/packages/c0/aa/687d6b12ffb505a4447567d1f3abea23bd20e73a5bed63871178e0831b7a/greenlet-3.2.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:c17b6b34111ea72fc5a4e4beec9711d2226285f0386ea83477cbb97c30a3f3a5", size = 699218, upload-time = "2025-08-07T13:45:30.969Z" }, + { url = "https://files.pythonhosted.org/packages/dc/8b/29aae55436521f1d6f8ff4e12fb676f3400de7fcf27fccd1d4d17fd8fecd/greenlet-3.2.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b4a1870c51720687af7fa3e7cda6d08d801dae660f75a76f3845b642b4da6ee1", size = 694659, upload-time = "2025-08-07T13:53:17.759Z" }, + { url = "https://files.pythonhosted.org/packages/92/2e/ea25914b1ebfde93b6fc4ff46d6864564fba59024e928bdc7de475affc25/greenlet-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:061dc4cf2c34852b052a8620d40f36324554bc192be474b9e9770e8c042fd735", size = 695355, upload-time = "2025-08-07T13:18:34.517Z" }, + { url = "https://files.pythonhosted.org/packages/72/60/fc56c62046ec17f6b0d3060564562c64c862948c9d4bc8aa807cf5bd74f4/greenlet-3.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44358b9bf66c8576a9f57a590d5f5d6e72fa4228b763d0e43fee6d3b06d3a337", size = 657512, upload-time = "2025-08-07T13:18:33.969Z" }, + { url = "https://files.pythonhosted.org/packages/e3/a5/6ddab2b4c112be95601c13428db1d8b6608a8b6039816f2ba09c346c08fc/greenlet-3.2.4-cp314-cp314-win_amd64.whl", hash = "sha256:e37ab26028f12dbb0ff65f29a8d3d44a765c61e729647bf2ddfbbed621726f01", size = 303425, upload-time = "2025-08-07T13:32:27.59Z" }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, +] + +[[package]] +name = "httptools" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b5/46/120a669232c7bdedb9d52d4aeae7e6c7dfe151e99dc70802e2fc7a5e1993/httptools-0.7.1.tar.gz", hash = "sha256:abd72556974f8e7c74a259655924a717a2365b236c882c3f6f8a45fe94703ac9", size = 258961, upload-time = "2025-10-10T03:55:08.559Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/53/7f/403e5d787dc4942316e515e949b0c8a013d84078a915910e9f391ba9b3ed/httptools-0.7.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:38e0c83a2ea9746ebbd643bdfb521b9aa4a91703e2cd705c20443405d2fd16a5", size = 206280, upload-time = "2025-10-10T03:54:39.274Z" }, + { url = "https://files.pythonhosted.org/packages/2a/0d/7f3fd28e2ce311ccc998c388dd1c53b18120fda3b70ebb022b135dc9839b/httptools-0.7.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f25bbaf1235e27704f1a7b86cd3304eabc04f569c828101d94a0e605ef7205a5", size = 110004, upload-time = "2025-10-10T03:54:40.403Z" }, + { url = "https://files.pythonhosted.org/packages/84/a6/b3965e1e146ef5762870bbe76117876ceba51a201e18cc31f5703e454596/httptools-0.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:2c15f37ef679ab9ecc06bfc4e6e8628c32a8e4b305459de7cf6785acd57e4d03", size = 517655, upload-time = "2025-10-10T03:54:41.347Z" }, + { url = "https://files.pythonhosted.org/packages/11/7d/71fee6f1844e6fa378f2eddde6c3e41ce3a1fb4b2d81118dd544e3441ec0/httptools-0.7.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7fe6e96090df46b36ccfaf746f03034e5ab723162bc51b0a4cf58305324036f2", size = 511440, upload-time = "2025-10-10T03:54:42.452Z" }, + { url = "https://files.pythonhosted.org/packages/22/a5/079d216712a4f3ffa24af4a0381b108aa9c45b7a5cc6eb141f81726b1823/httptools-0.7.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f72fdbae2dbc6e68b8239defb48e6a5937b12218e6ffc2c7846cc37befa84362", size = 495186, upload-time = "2025-10-10T03:54:43.937Z" }, + { url = "https://files.pythonhosted.org/packages/e9/9e/025ad7b65278745dee3bd0ebf9314934c4592560878308a6121f7f812084/httptools-0.7.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e99c7b90a29fd82fea9ef57943d501a16f3404d7b9ee81799d41639bdaae412c", size = 499192, upload-time = "2025-10-10T03:54:45.003Z" }, + { url = "https://files.pythonhosted.org/packages/6d/de/40a8f202b987d43afc4d54689600ff03ce65680ede2f31df348d7f368b8f/httptools-0.7.1-cp312-cp312-win_amd64.whl", hash = "sha256:3e14f530fefa7499334a79b0cf7e7cd2992870eb893526fb097d51b4f2d0f321", size = 86694, upload-time = "2025-10-10T03:54:45.923Z" }, + { url = "https://files.pythonhosted.org/packages/09/8f/c77b1fcbfd262d422f12da02feb0d218fa228d52485b77b953832105bb90/httptools-0.7.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:6babce6cfa2a99545c60bfef8bee0cc0545413cb0018f617c8059a30ad985de3", size = 202889, upload-time = "2025-10-10T03:54:47.089Z" }, + { url = "https://files.pythonhosted.org/packages/0a/1a/22887f53602feaa066354867bc49a68fc295c2293433177ee90870a7d517/httptools-0.7.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:601b7628de7504077dd3dcb3791c6b8694bbd967148a6d1f01806509254fb1ca", size = 108180, upload-time = "2025-10-10T03:54:48.052Z" }, + { url = "https://files.pythonhosted.org/packages/32/6a/6aaa91937f0010d288d3d124ca2946d48d60c3a5ee7ca62afe870e3ea011/httptools-0.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:04c6c0e6c5fb0739c5b8a9eb046d298650a0ff38cf42537fc372b28dc7e4472c", size = 478596, upload-time = "2025-10-10T03:54:48.919Z" }, + { url = "https://files.pythonhosted.org/packages/6d/70/023d7ce117993107be88d2cbca566a7c1323ccbaf0af7eabf2064fe356f6/httptools-0.7.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:69d4f9705c405ae3ee83d6a12283dc9feba8cc6aaec671b412917e644ab4fa66", size = 473268, upload-time = "2025-10-10T03:54:49.993Z" }, + { url = "https://files.pythonhosted.org/packages/32/4d/9dd616c38da088e3f436e9a616e1d0cc66544b8cdac405cc4e81c8679fc7/httptools-0.7.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:44c8f4347d4b31269c8a9205d8a5ee2df5322b09bbbd30f8f862185bb6b05346", size = 455517, upload-time = "2025-10-10T03:54:51.066Z" }, + { url = "https://files.pythonhosted.org/packages/1d/3a/a6c595c310b7df958e739aae88724e24f9246a514d909547778d776799be/httptools-0.7.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:465275d76db4d554918aba40bf1cbebe324670f3dfc979eaffaa5d108e2ed650", size = 458337, upload-time = "2025-10-10T03:54:52.196Z" }, + { url = "https://files.pythonhosted.org/packages/fd/82/88e8d6d2c51edc1cc391b6e044c6c435b6aebe97b1abc33db1b0b24cd582/httptools-0.7.1-cp313-cp313-win_amd64.whl", hash = "sha256:322d00c2068d125bd570f7bf78b2d367dad02b919d8581d7476d8b75b294e3e6", size = 85743, upload-time = "2025-10-10T03:54:53.448Z" }, + { url = "https://files.pythonhosted.org/packages/34/50/9d095fcbb6de2d523e027a2f304d4551855c2f46e0b82befd718b8b20056/httptools-0.7.1-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:c08fe65728b8d70b6923ce31e3956f859d5e1e8548e6f22ec520a962c6757270", size = 203619, upload-time = "2025-10-10T03:54:54.321Z" }, + { url = "https://files.pythonhosted.org/packages/07/f0/89720dc5139ae54b03f861b5e2c55a37dba9a5da7d51e1e824a1f343627f/httptools-0.7.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:7aea2e3c3953521c3c51106ee11487a910d45586e351202474d45472db7d72d3", size = 108714, upload-time = "2025-10-10T03:54:55.163Z" }, + { url = "https://files.pythonhosted.org/packages/b3/cb/eea88506f191fb552c11787c23f9a405f4c7b0c5799bf73f2249cd4f5228/httptools-0.7.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:0e68b8582f4ea9166be62926077a3334064d422cf08ab87d8b74664f8e9058e1", size = 472909, upload-time = "2025-10-10T03:54:56.056Z" }, + { url = "https://files.pythonhosted.org/packages/e0/4a/a548bdfae6369c0d078bab5769f7b66f17f1bfaa6fa28f81d6be6959066b/httptools-0.7.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:df091cf961a3be783d6aebae963cc9b71e00d57fa6f149025075217bc6a55a7b", size = 470831, upload-time = "2025-10-10T03:54:57.219Z" }, + { url = "https://files.pythonhosted.org/packages/4d/31/14df99e1c43bd132eec921c2e7e11cda7852f65619bc0fc5bdc2d0cb126c/httptools-0.7.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f084813239e1eb403ddacd06a30de3d3e09a9b76e7894dcda2b22f8a726e9c60", size = 452631, upload-time = "2025-10-10T03:54:58.219Z" }, + { url = "https://files.pythonhosted.org/packages/22/d2/b7e131f7be8d854d48cb6d048113c30f9a46dca0c9a8b08fcb3fcd588cdc/httptools-0.7.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:7347714368fb2b335e9063bc2b96f2f87a9ceffcd9758ac295f8bbcd3ffbc0ca", size = 452910, upload-time = "2025-10-10T03:54:59.366Z" }, + { url = "https://files.pythonhosted.org/packages/53/cf/878f3b91e4e6e011eff6d1fa9ca39f7eb17d19c9d7971b04873734112f30/httptools-0.7.1-cp314-cp314-win_amd64.whl", hash = "sha256:cfabda2a5bb85aa2a904ce06d974a3f30fb36cc63d7feaddec05d2050acede96", size = 88205, upload-time = "2025-10-10T03:55:00.389Z" }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, +] + +[[package]] +name = "idna" +version = "3.11" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, +] + +[[package]] +name = "jiter" +version = "0.11.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a3/68/0357982493a7b20925aece061f7fb7a2678e3b232f8d73a6edb7e5304443/jiter-0.11.1.tar.gz", hash = "sha256:849dcfc76481c0ea0099391235b7ca97d7279e0fa4c86005457ac7c88e8b76dc", size = 168385, upload-time = "2025-10-17T11:31:15.186Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/15/8b/318e8af2c904a9d29af91f78c1e18f0592e189bbdb8a462902d31fe20682/jiter-0.11.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:c92148eec91052538ce6823dfca9525f5cfc8b622d7f07e9891a280f61b8c96c", size = 305655, upload-time = "2025-10-17T11:29:18.859Z" }, + { url = "https://files.pythonhosted.org/packages/f7/29/6c7de6b5d6e511d9e736312c0c9bfcee8f9b6bef68182a08b1d78767e627/jiter-0.11.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ecd4da91b5415f183a6be8f7158d127bdd9e6a3174138293c0d48d6ea2f2009d", size = 315645, upload-time = "2025-10-17T11:29:20.889Z" }, + { url = "https://files.pythonhosted.org/packages/ac/5f/ef9e5675511ee0eb7f98dd8c90509e1f7743dbb7c350071acae87b0145f3/jiter-0.11.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7e3ac25c00b9275684d47aa42febaa90a9958e19fd1726c4ecf755fbe5e553b", size = 348003, upload-time = "2025-10-17T11:29:22.712Z" }, + { url = "https://files.pythonhosted.org/packages/56/1b/abe8c4021010b0a320d3c62682769b700fb66f92c6db02d1a1381b3db025/jiter-0.11.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:57d7305c0a841858f866cd459cd9303f73883fb5e097257f3d4a3920722c69d4", size = 365122, upload-time = "2025-10-17T11:29:24.408Z" }, + { url = "https://files.pythonhosted.org/packages/2a/2d/4a18013939a4f24432f805fbd5a19893e64650b933edb057cd405275a538/jiter-0.11.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e86fa10e117dce22c547f31dd6d2a9a222707d54853d8de4e9a2279d2c97f239", size = 488360, upload-time = "2025-10-17T11:29:25.724Z" }, + { url = "https://files.pythonhosted.org/packages/f0/77/38124f5d02ac4131f0dfbcfd1a19a0fac305fa2c005bc4f9f0736914a1a4/jiter-0.11.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ae5ef1d48aec7e01ee8420155d901bb1d192998fa811a65ebb82c043ee186711", size = 376884, upload-time = "2025-10-17T11:29:27.056Z" }, + { url = "https://files.pythonhosted.org/packages/7b/43/59fdc2f6267959b71dd23ce0bd8d4aeaf55566aa435a5d00f53d53c7eb24/jiter-0.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb68e7bf65c990531ad8715e57d50195daf7c8e6f1509e617b4e692af1108939", size = 358827, upload-time = "2025-10-17T11:29:28.698Z" }, + { url = "https://files.pythonhosted.org/packages/7d/d0/b3cc20ff5340775ea3bbaa0d665518eddecd4266ba7244c9cb480c0c82ec/jiter-0.11.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43b30c8154ded5845fa454ef954ee67bfccce629b2dea7d01f795b42bc2bda54", size = 385171, upload-time = "2025-10-17T11:29:30.078Z" }, + { url = "https://files.pythonhosted.org/packages/d2/bc/94dd1f3a61f4dc236f787a097360ec061ceeebebf4ea120b924d91391b10/jiter-0.11.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:586cafbd9dd1f3ce6a22b4a085eaa6be578e47ba9b18e198d4333e598a91db2d", size = 518359, upload-time = "2025-10-17T11:29:31.464Z" }, + { url = "https://files.pythonhosted.org/packages/7e/8c/12ee132bd67e25c75f542c227f5762491b9a316b0dad8e929c95076f773c/jiter-0.11.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:677cc2517d437a83bb30019fd4cf7cad74b465914c56ecac3440d597ac135250", size = 509205, upload-time = "2025-10-17T11:29:32.895Z" }, + { url = "https://files.pythonhosted.org/packages/39/d5/9de848928ce341d463c7e7273fce90ea6d0ea4343cd761f451860fa16b59/jiter-0.11.1-cp312-cp312-win32.whl", hash = "sha256:fa992af648fcee2b850a3286a35f62bbbaeddbb6dbda19a00d8fbc846a947b6e", size = 205448, upload-time = "2025-10-17T11:29:34.217Z" }, + { url = "https://files.pythonhosted.org/packages/ee/b0/8002d78637e05009f5e3fb5288f9d57d65715c33b5d6aa20fd57670feef5/jiter-0.11.1-cp312-cp312-win_amd64.whl", hash = "sha256:88b5cae9fa51efeb3d4bd4e52bfd4c85ccc9cac44282e2a9640893a042ba4d87", size = 204285, upload-time = "2025-10-17T11:29:35.446Z" }, + { url = "https://files.pythonhosted.org/packages/9f/a2/bb24d5587e4dff17ff796716542f663deee337358006a80c8af43ddc11e5/jiter-0.11.1-cp312-cp312-win_arm64.whl", hash = "sha256:9a6cae1ab335551917f882f2c3c1efe7617b71b4c02381e4382a8fc80a02588c", size = 188712, upload-time = "2025-10-17T11:29:37.027Z" }, + { url = "https://files.pythonhosted.org/packages/7c/4b/e4dd3c76424fad02a601d570f4f2a8438daea47ba081201a721a903d3f4c/jiter-0.11.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:71b6a920a5550f057d49d0e8bcc60945a8da998019e83f01adf110e226267663", size = 305272, upload-time = "2025-10-17T11:29:39.249Z" }, + { url = "https://files.pythonhosted.org/packages/67/83/2cd3ad5364191130f4de80eacc907f693723beaab11a46c7d155b07a092c/jiter-0.11.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0b3de72e925388453a5171be83379549300db01284f04d2a6f244d1d8de36f94", size = 314038, upload-time = "2025-10-17T11:29:40.563Z" }, + { url = "https://files.pythonhosted.org/packages/d3/3c/8e67d9ba524e97d2f04c8f406f8769a23205026b13b0938d16646d6e2d3e/jiter-0.11.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc19dd65a2bd3d9c044c5b4ebf657ca1e6003a97c0fc10f555aa4f7fb9821c00", size = 345977, upload-time = "2025-10-17T11:29:42.009Z" }, + { url = "https://files.pythonhosted.org/packages/8d/a5/489ce64d992c29bccbffabb13961bbb0435e890d7f2d266d1f3df5e917d2/jiter-0.11.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d58faaa936743cd1464540562f60b7ce4fd927e695e8bc31b3da5b914baa9abd", size = 364503, upload-time = "2025-10-17T11:29:43.459Z" }, + { url = "https://files.pythonhosted.org/packages/d4/c0/e321dd83ee231d05c8fe4b1a12caf1f0e8c7a949bf4724d58397104f10f2/jiter-0.11.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:902640c3103625317291cb73773413b4d71847cdf9383ba65528745ff89f1d14", size = 487092, upload-time = "2025-10-17T11:29:44.835Z" }, + { url = "https://files.pythonhosted.org/packages/f9/5e/8f24ec49c8d37bd37f34ec0112e0b1a3b4b5a7b456c8efff1df5e189ad43/jiter-0.11.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:30405f726e4c2ed487b176c09f8b877a957f535d60c1bf194abb8dadedb5836f", size = 376328, upload-time = "2025-10-17T11:29:46.175Z" }, + { url = "https://files.pythonhosted.org/packages/7f/70/ded107620e809327cf7050727e17ccfa79d6385a771b7fe38fb31318ef00/jiter-0.11.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3217f61728b0baadd2551844870f65219ac4a1285d5e1a4abddff3d51fdabe96", size = 356632, upload-time = "2025-10-17T11:29:47.454Z" }, + { url = "https://files.pythonhosted.org/packages/19/53/c26f7251613f6a9079275ee43c89b8a973a95ff27532c421abc2a87afb04/jiter-0.11.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b1364cc90c03a8196f35f396f84029f12abe925415049204446db86598c8b72c", size = 384358, upload-time = "2025-10-17T11:29:49.377Z" }, + { url = "https://files.pythonhosted.org/packages/84/16/e0f2cc61e9c4d0b62f6c1bd9b9781d878a427656f88293e2a5335fa8ff07/jiter-0.11.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:53a54bf8e873820ab186b2dca9f6c3303f00d65ae5e7b7d6bda1b95aa472d646", size = 517279, upload-time = "2025-10-17T11:29:50.968Z" }, + { url = "https://files.pythonhosted.org/packages/60/5c/4cd095eaee68961bca3081acbe7c89e12ae24a5dae5fd5d2a13e01ed2542/jiter-0.11.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7e29aca023627b0e0c2392d4248f6414d566ff3974fa08ff2ac8dbb96dfee92a", size = 508276, upload-time = "2025-10-17T11:29:52.619Z" }, + { url = "https://files.pythonhosted.org/packages/4f/25/f459240e69b0e09a7706d96ce203ad615ca36b0fe832308d2b7123abf2d0/jiter-0.11.1-cp313-cp313-win32.whl", hash = "sha256:f153e31d8bca11363751e875c0a70b3d25160ecbaee7b51e457f14498fb39d8b", size = 205593, upload-time = "2025-10-17T11:29:53.938Z" }, + { url = "https://files.pythonhosted.org/packages/7c/16/461bafe22bae79bab74e217a09c907481a46d520c36b7b9fe71ee8c9e983/jiter-0.11.1-cp313-cp313-win_amd64.whl", hash = "sha256:f773f84080b667c69c4ea0403fc67bb08b07e2b7ce1ef335dea5868451e60fed", size = 203518, upload-time = "2025-10-17T11:29:55.216Z" }, + { url = "https://files.pythonhosted.org/packages/7b/72/c45de6e320edb4fa165b7b1a414193b3cae302dd82da2169d315dcc78b44/jiter-0.11.1-cp313-cp313-win_arm64.whl", hash = "sha256:635ecd45c04e4c340d2187bcb1cea204c7cc9d32c1364d251564bf42e0e39c2d", size = 188062, upload-time = "2025-10-17T11:29:56.631Z" }, + { url = "https://files.pythonhosted.org/packages/65/9b/4a57922437ca8753ef823f434c2dec5028b237d84fa320f06a3ba1aec6e8/jiter-0.11.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:d892b184da4d94d94ddb4031296931c74ec8b325513a541ebfd6dfb9ae89904b", size = 313814, upload-time = "2025-10-17T11:29:58.509Z" }, + { url = "https://files.pythonhosted.org/packages/76/50/62a0683dadca25490a4bedc6a88d59de9af2a3406dd5a576009a73a1d392/jiter-0.11.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aa22c223a3041dacb2fcd37c70dfd648b44662b4a48e242592f95bda5ab09d58", size = 344987, upload-time = "2025-10-17T11:30:00.208Z" }, + { url = "https://files.pythonhosted.org/packages/da/00/2355dbfcbf6cdeaddfdca18287f0f38ae49446bb6378e4a5971e9356fc8a/jiter-0.11.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:330e8e6a11ad4980cd66a0f4a3e0e2e0f646c911ce047014f984841924729789", size = 356399, upload-time = "2025-10-17T11:30:02.084Z" }, + { url = "https://files.pythonhosted.org/packages/c9/07/c2bd748d578fa933d894a55bff33f983bc27f75fc4e491b354bef7b78012/jiter-0.11.1-cp313-cp313t-win_amd64.whl", hash = "sha256:09e2e386ebf298547ca3a3704b729471f7ec666c2906c5c26c1a915ea24741ec", size = 203289, upload-time = "2025-10-17T11:30:03.656Z" }, + { url = "https://files.pythonhosted.org/packages/e6/ee/ace64a853a1acbd318eb0ca167bad1cf5ee037207504b83a868a5849747b/jiter-0.11.1-cp313-cp313t-win_arm64.whl", hash = "sha256:fe4a431c291157e11cee7c34627990ea75e8d153894365a3bc84b7a959d23ca8", size = 188284, upload-time = "2025-10-17T11:30:05.046Z" }, + { url = "https://files.pythonhosted.org/packages/8d/00/d6006d069e7b076e4c66af90656b63da9481954f290d5eca8c715f4bf125/jiter-0.11.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:0fa1f70da7a8a9713ff8e5f75ec3f90c0c870be6d526aa95e7c906f6a1c8c676", size = 304624, upload-time = "2025-10-17T11:30:06.678Z" }, + { url = "https://files.pythonhosted.org/packages/fc/45/4a0e31eb996b9ccfddbae4d3017b46f358a599ccf2e19fbffa5e531bd304/jiter-0.11.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:569ee559e5046a42feb6828c55307cf20fe43308e3ae0d8e9e4f8d8634d99944", size = 315042, upload-time = "2025-10-17T11:30:08.87Z" }, + { url = "https://files.pythonhosted.org/packages/e7/91/22f5746f5159a28c76acdc0778801f3c1181799aab196dbea2d29e064968/jiter-0.11.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f69955fa1d92e81987f092b233f0be49d4c937da107b7f7dcf56306f1d3fcce9", size = 346357, upload-time = "2025-10-17T11:30:10.222Z" }, + { url = "https://files.pythonhosted.org/packages/f5/4f/57620857d4e1dc75c8ff4856c90cb6c135e61bff9b4ebfb5dc86814e82d7/jiter-0.11.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:090f4c9d4a825e0fcbd0a2647c9a88a0f366b75654d982d95a9590745ff0c48d", size = 365057, upload-time = "2025-10-17T11:30:11.585Z" }, + { url = "https://files.pythonhosted.org/packages/ce/34/caf7f9cc8ae0a5bb25a5440cc76c7452d264d1b36701b90fdadd28fe08ec/jiter-0.11.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bbf3d8cedf9e9d825233e0dcac28ff15c47b7c5512fdfe2e25fd5bbb6e6b0cee", size = 487086, upload-time = "2025-10-17T11:30:13.052Z" }, + { url = "https://files.pythonhosted.org/packages/50/17/85b5857c329d533d433fedf98804ebec696004a1f88cabad202b2ddc55cf/jiter-0.11.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2aa9b1958f9c30d3d1a558b75f0626733c60eb9b7774a86b34d88060be1e67fe", size = 376083, upload-time = "2025-10-17T11:30:14.416Z" }, + { url = "https://files.pythonhosted.org/packages/85/d3/2d9f973f828226e6faebdef034097a2918077ea776fb4d88489949024787/jiter-0.11.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e42d1ca16590b768c5e7d723055acd2633908baacb3628dd430842e2e035aa90", size = 357825, upload-time = "2025-10-17T11:30:15.765Z" }, + { url = "https://files.pythonhosted.org/packages/f4/55/848d4dabf2c2c236a05468c315c2cb9dc736c5915e65449ccecdba22fb6f/jiter-0.11.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5db4c2486a023820b701a17aec9c5a6173c5ba4393f26662f032f2de9c848b0f", size = 383933, upload-time = "2025-10-17T11:30:17.34Z" }, + { url = "https://files.pythonhosted.org/packages/0b/6c/204c95a4fbb0e26dfa7776c8ef4a878d0c0b215868011cc904bf44f707e2/jiter-0.11.1-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:4573b78777ccfac954859a6eff45cbd9d281d80c8af049d0f1a3d9fc323d5c3a", size = 517118, upload-time = "2025-10-17T11:30:18.684Z" }, + { url = "https://files.pythonhosted.org/packages/88/25/09956644ea5a2b1e7a2a0f665cb69a973b28f4621fa61fc0c0f06ff40a31/jiter-0.11.1-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:7593ac6f40831d7961cb67633c39b9fef6689a211d7919e958f45710504f52d3", size = 508194, upload-time = "2025-10-17T11:30:20.719Z" }, + { url = "https://files.pythonhosted.org/packages/09/49/4d1657355d7f5c9e783083a03a3f07d5858efa6916a7d9634d07db1c23bd/jiter-0.11.1-cp314-cp314-win32.whl", hash = "sha256:87202ec6ff9626ff5f9351507def98fcf0df60e9a146308e8ab221432228f4ea", size = 203961, upload-time = "2025-10-17T11:30:22.073Z" }, + { url = "https://files.pythonhosted.org/packages/76/bd/f063bd5cc2712e7ca3cf6beda50894418fc0cfeb3f6ff45a12d87af25996/jiter-0.11.1-cp314-cp314-win_amd64.whl", hash = "sha256:a5dd268f6531a182c89d0dd9a3f8848e86e92dfff4201b77a18e6b98aa59798c", size = 202804, upload-time = "2025-10-17T11:30:23.452Z" }, + { url = "https://files.pythonhosted.org/packages/52/ca/4d84193dfafef1020bf0bedd5e1a8d0e89cb67c54b8519040effc694964b/jiter-0.11.1-cp314-cp314-win_arm64.whl", hash = "sha256:5d761f863f912a44748a21b5c4979c04252588ded8d1d2760976d2e42cd8d991", size = 188001, upload-time = "2025-10-17T11:30:24.915Z" }, + { url = "https://files.pythonhosted.org/packages/d5/fa/3b05e5c9d32efc770a8510eeb0b071c42ae93a5b576fd91cee9af91689a1/jiter-0.11.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2cc5a3965285ddc33e0cab933e96b640bc9ba5940cea27ebbbf6695e72d6511c", size = 312561, upload-time = "2025-10-17T11:30:26.742Z" }, + { url = "https://files.pythonhosted.org/packages/50/d3/335822eb216154ddb79a130cbdce88fdf5c3e2b43dc5dba1fd95c485aaf5/jiter-0.11.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b572b3636a784c2768b2342f36a23078c8d3aa6d8a30745398b1bab58a6f1a8", size = 344551, upload-time = "2025-10-17T11:30:28.252Z" }, + { url = "https://files.pythonhosted.org/packages/31/6d/a0bed13676b1398f9b3ba61f32569f20a3ff270291161100956a577b2dd3/jiter-0.11.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ad93e3d67a981f96596d65d2298fe8d1aa649deb5374a2fb6a434410ee11915e", size = 363051, upload-time = "2025-10-17T11:30:30.009Z" }, + { url = "https://files.pythonhosted.org/packages/a4/03/313eda04aa08545a5a04ed5876e52f49ab76a4d98e54578896ca3e16313e/jiter-0.11.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a83097ce379e202dcc3fe3fc71a16d523d1ee9192c8e4e854158f96b3efe3f2f", size = 485897, upload-time = "2025-10-17T11:30:31.429Z" }, + { url = "https://files.pythonhosted.org/packages/5f/13/a1011b9d325e40b53b1b96a17c010b8646013417f3902f97a86325b19299/jiter-0.11.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7042c51e7fbeca65631eb0c332f90c0c082eab04334e7ccc28a8588e8e2804d9", size = 375224, upload-time = "2025-10-17T11:30:33.18Z" }, + { url = "https://files.pythonhosted.org/packages/92/da/1b45026b19dd39b419e917165ff0ea629dbb95f374a3a13d2df95e40a6ac/jiter-0.11.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0a68d679c0e47649a61df591660507608adc2652442de7ec8276538ac46abe08", size = 356606, upload-time = "2025-10-17T11:30:34.572Z" }, + { url = "https://files.pythonhosted.org/packages/7a/0c/9acb0e54d6a8ba59ce923a180ebe824b4e00e80e56cefde86cc8e0a948be/jiter-0.11.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a1b0da75dbf4b6ec0b3c9e604d1ee8beaf15bc046fff7180f7d89e3cdbd3bb51", size = 384003, upload-time = "2025-10-17T11:30:35.987Z" }, + { url = "https://files.pythonhosted.org/packages/3f/2b/e5a5fe09d6da2145e4eed651e2ce37f3c0cf8016e48b1d302e21fb1628b7/jiter-0.11.1-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:69dd514bf0fa31c62147d6002e5ca2b3e7ef5894f5ac6f0a19752385f4e89437", size = 516946, upload-time = "2025-10-17T11:30:37.425Z" }, + { url = "https://files.pythonhosted.org/packages/5f/fe/db936e16e0228d48eb81f9934e8327e9fde5185e84f02174fcd22a01be87/jiter-0.11.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:bb31ac0b339efa24c0ca606febd8b77ef11c58d09af1b5f2be4c99e907b11111", size = 507614, upload-time = "2025-10-17T11:30:38.977Z" }, + { url = "https://files.pythonhosted.org/packages/86/db/c4438e8febfb303486d13c6b72f5eb71cf851e300a0c1f0b4140018dd31f/jiter-0.11.1-cp314-cp314t-win32.whl", hash = "sha256:b2ce0d6156a1d3ad41da3eec63b17e03e296b78b0e0da660876fccfada86d2f7", size = 204043, upload-time = "2025-10-17T11:30:40.308Z" }, + { url = "https://files.pythonhosted.org/packages/36/59/81badb169212f30f47f817dfaabf965bc9b8204fed906fab58104ee541f9/jiter-0.11.1-cp314-cp314t-win_amd64.whl", hash = "sha256:f4db07d127b54c4a2d43b4cf05ff0193e4f73e0dd90c74037e16df0b29f666e1", size = 204046, upload-time = "2025-10-17T11:30:41.692Z" }, + { url = "https://files.pythonhosted.org/packages/dd/01/43f7b4eb61db3e565574c4c5714685d042fb652f9eef7e5a3de6aafa943a/jiter-0.11.1-cp314-cp314t-win_arm64.whl", hash = "sha256:28e4fdf2d7ebfc935523e50d1efa3970043cfaa161674fe66f9642409d001dfe", size = 188069, upload-time = "2025-10-17T11:30:43.23Z" }, + { url = "https://files.pythonhosted.org/packages/a6/bc/950dd7f170c6394b6fdd73f989d9e729bd98907bcc4430ef080a72d06b77/jiter-0.11.1-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:0d4d6993edc83cf75e8c6828a8d6ce40a09ee87e38c7bfba6924f39e1337e21d", size = 302626, upload-time = "2025-10-17T11:31:09.645Z" }, + { url = "https://files.pythonhosted.org/packages/3a/65/43d7971ca82ee100b7b9b520573eeef7eabc0a45d490168ebb9a9b5bb8b2/jiter-0.11.1-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:f78d151c83a87a6cf5461d5ee55bc730dd9ae227377ac6f115b922989b95f838", size = 297034, upload-time = "2025-10-17T11:31:10.975Z" }, + { url = "https://files.pythonhosted.org/packages/19/4c/000e1e0c0c67e96557a279f8969487ea2732d6c7311698819f977abae837/jiter-0.11.1-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9022974781155cd5521d5cb10997a03ee5e31e8454c9d999dcdccd253f2353f", size = 337328, upload-time = "2025-10-17T11:31:12.399Z" }, + { url = "https://files.pythonhosted.org/packages/d9/71/71408b02c6133153336d29fa3ba53000f1e1a3f78bb2fc2d1a1865d2e743/jiter-0.11.1-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18c77aaa9117510d5bdc6a946baf21b1f0cfa58ef04d31c8d016f206f2118960", size = 343697, upload-time = "2025-10-17T11:31:13.773Z" }, +] + +[[package]] +name = "live-agent-api" +version = "0.1.0" +source = { editable = "." } +dependencies = [ + { name = "asyncpg" }, + { name = "fastapi" }, + { name = "httpx" }, + { name = "openai" }, + { name = "pydantic" }, + { name = "pydantic-settings" }, + { name = "python-dotenv" }, + { name = "snowflake-id" }, + { name = "sqlalchemy" }, + { name = "uvicorn", extra = ["standard"] }, +] + +[package.dev-dependencies] +dev = [ + { name = "black" }, + { name = "pytest" }, + { name = "pytest-asyncio" }, + { name = "ruff" }, +] + +[package.metadata] +requires-dist = [ + { name = "asyncpg", specifier = ">=0.30.0" }, + { name = "fastapi", specifier = ">=0.115.0" }, + { name = "httpx", specifier = ">=0.27.0" }, + { name = "openai", specifier = ">=1.54.0" }, + { name = "pydantic", specifier = ">=2.9.0" }, + { name = "pydantic-settings", specifier = ">=2.6.0" }, + { name = "python-dotenv", specifier = ">=1.0.0" }, + { name = "snowflake-id", specifier = ">=1.0.2" }, + { name = "sqlalchemy", specifier = ">=2.0.36" }, + { name = "uvicorn", extras = ["standard"], specifier = ">=0.32.0" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "black", specifier = ">=24.10.0" }, + { name = "pytest", specifier = ">=8.3.0" }, + { name = "pytest-asyncio", specifier = ">=0.24.0" }, + { name = "ruff", specifier = ">=0.7.0" }, +] + +[[package]] +name = "mypy-extensions" +version = "1.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, +] + +[[package]] +name = "openai" +version = "2.6.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "distro" }, + { name = "httpx" }, + { name = "jiter" }, + { name = "pydantic" }, + { name = "sniffio" }, + { name = "tqdm" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c4/44/303deb97be7c1c9b53118b52825cbd1557aeeff510f3a52566b1fa66f6a2/openai-2.6.1.tar.gz", hash = "sha256:27ae704d190615fca0c0fc2b796a38f8b5879645a3a52c9c453b23f97141bb49", size = 593043, upload-time = "2025-10-24T13:29:52.79Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/15/0e/331df43df633e6105ff9cf45e0ce57762bd126a45ac16b25a43f6738d8a2/openai-2.6.1-py3-none-any.whl", hash = "sha256:904e4b5254a8416746a2f05649594fa41b19d799843cd134dac86167e094edef", size = 1005551, upload-time = "2025-10-24T13:29:50.973Z" }, +] + +[[package]] +name = "packaging" +version = "25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, +] + +[[package]] +name = "pathspec" +version = "0.12.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ca/bc/f35b8446f4531a7cb215605d100cd88b7ac6f44ab3fc94870c120ab3adbf/pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712", size = 51043, upload-time = "2023-12-10T22:30:45Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cc/20/ff623b09d963f88bfde16306a54e12ee5ea43e9b597108672ff3a408aad6/pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", size = 31191, upload-time = "2023-12-10T22:30:43.14Z" }, +] + +[[package]] +name = "platformdirs" +version = "4.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/61/33/9611380c2bdb1225fdef633e2a9610622310fed35ab11dac9620972ee088/platformdirs-4.5.0.tar.gz", hash = "sha256:70ddccdd7c99fc5942e9fc25636a8b34d04c24b335100223152c2803e4063312", size = 21632, upload-time = "2025-10-08T17:44:48.791Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/73/cb/ac7874b3e5d58441674fb70742e6c374b28b0c7cb988d37d991cde47166c/platformdirs-4.5.0-py3-none-any.whl", hash = "sha256:e578a81bb873cbb89a41fcc904c7ef523cc18284b7e3b3ccf06aca1403b7ebd3", size = 18651, upload-time = "2025-10-08T17:44:47.223Z" }, +] + +[[package]] +name = "pluggy" +version = "1.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, +] + +[[package]] +name = "pydantic" +version = "2.12.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f3/1e/4f0a3233767010308f2fd6bd0814597e3f63f1dc98304a9112b8759df4ff/pydantic-2.12.3.tar.gz", hash = "sha256:1da1c82b0fc140bb0103bc1441ffe062154c8d38491189751ee00fd8ca65ce74", size = 819383, upload-time = "2025-10-17T15:04:21.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a1/6b/83661fa77dcefa195ad5f8cd9af3d1a7450fd57cc883ad04d65446ac2029/pydantic-2.12.3-py3-none-any.whl", hash = "sha256:6986454a854bc3bc6e5443e1369e06a3a456af9d339eda45510f517d9ea5c6bf", size = 462431, upload-time = "2025-10-17T15:04:19.346Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.41.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/18/d0944e8eaaa3efd0a91b0f1fc537d3be55ad35091b6a87638211ba691964/pydantic_core-2.41.4.tar.gz", hash = "sha256:70e47929a9d4a1905a67e4b687d5946026390568a8e952b92824118063cee4d5", size = 457557, upload-time = "2025-10-14T10:23:47.909Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e9/81/d3b3e95929c4369d30b2a66a91db63c8ed0a98381ae55a45da2cd1cc1288/pydantic_core-2.41.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:ab06d77e053d660a6faaf04894446df7b0a7e7aba70c2797465a0a1af00fc887", size = 2099043, upload-time = "2025-10-14T10:20:28.561Z" }, + { url = "https://files.pythonhosted.org/packages/58/da/46fdac49e6717e3a94fc9201403e08d9d61aa7a770fab6190b8740749047/pydantic_core-2.41.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c53ff33e603a9c1179a9364b0a24694f183717b2e0da2b5ad43c316c956901b2", size = 1910699, upload-time = "2025-10-14T10:20:30.217Z" }, + { url = "https://files.pythonhosted.org/packages/1e/63/4d948f1b9dd8e991a5a98b77dd66c74641f5f2e5225fee37994b2e07d391/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:304c54176af2c143bd181d82e77c15c41cbacea8872a2225dd37e6544dce9999", size = 1952121, upload-time = "2025-10-14T10:20:32.246Z" }, + { url = "https://files.pythonhosted.org/packages/b2/a7/e5fc60a6f781fc634ecaa9ecc3c20171d238794cef69ae0af79ac11b89d7/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:025ba34a4cf4fb32f917d5d188ab5e702223d3ba603be4d8aca2f82bede432a4", size = 2041590, upload-time = "2025-10-14T10:20:34.332Z" }, + { url = "https://files.pythonhosted.org/packages/70/69/dce747b1d21d59e85af433428978a1893c6f8a7068fa2bb4a927fba7a5ff/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b9f5f30c402ed58f90c70e12eff65547d3ab74685ffe8283c719e6bead8ef53f", size = 2219869, upload-time = "2025-10-14T10:20:35.965Z" }, + { url = "https://files.pythonhosted.org/packages/83/6a/c070e30e295403bf29c4df1cb781317b6a9bac7cd07b8d3acc94d501a63c/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dd96e5d15385d301733113bcaa324c8bcf111275b7675a9c6e88bfb19fc05e3b", size = 2345169, upload-time = "2025-10-14T10:20:37.627Z" }, + { url = "https://files.pythonhosted.org/packages/f0/83/06d001f8043c336baea7fd202a9ac7ad71f87e1c55d8112c50b745c40324/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:98f348cbb44fae6e9653c1055db7e29de67ea6a9ca03a5fa2c2e11a47cff0e47", size = 2070165, upload-time = "2025-10-14T10:20:39.246Z" }, + { url = "https://files.pythonhosted.org/packages/14/0a/e567c2883588dd12bcbc110232d892cf385356f7c8a9910311ac997ab715/pydantic_core-2.41.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ec22626a2d14620a83ca583c6f5a4080fa3155282718b6055c2ea48d3ef35970", size = 2189067, upload-time = "2025-10-14T10:20:41.015Z" }, + { url = "https://files.pythonhosted.org/packages/f4/1d/3d9fca34273ba03c9b1c5289f7618bc4bd09c3ad2289b5420481aa051a99/pydantic_core-2.41.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3a95d4590b1f1a43bf33ca6d647b990a88f4a3824a8c4572c708f0b45a5290ed", size = 2132997, upload-time = "2025-10-14T10:20:43.106Z" }, + { url = "https://files.pythonhosted.org/packages/52/70/d702ef7a6cd41a8afc61f3554922b3ed8d19dd54c3bd4bdbfe332e610827/pydantic_core-2.41.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:f9672ab4d398e1b602feadcffcdd3af44d5f5e6ddc15bc7d15d376d47e8e19f8", size = 2307187, upload-time = "2025-10-14T10:20:44.849Z" }, + { url = "https://files.pythonhosted.org/packages/68/4c/c06be6e27545d08b802127914156f38d10ca287a9e8489342793de8aae3c/pydantic_core-2.41.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:84d8854db5f55fead3b579f04bda9a36461dab0730c5d570e1526483e7bb8431", size = 2305204, upload-time = "2025-10-14T10:20:46.781Z" }, + { url = "https://files.pythonhosted.org/packages/b0/e5/35ae4919bcd9f18603419e23c5eaf32750224a89d41a8df1a3704b69f77e/pydantic_core-2.41.4-cp312-cp312-win32.whl", hash = "sha256:9be1c01adb2ecc4e464392c36d17f97e9110fbbc906bcbe1c943b5b87a74aabd", size = 1972536, upload-time = "2025-10-14T10:20:48.39Z" }, + { url = "https://files.pythonhosted.org/packages/1e/c2/49c5bb6d2a49eb2ee3647a93e3dae7080c6409a8a7558b075027644e879c/pydantic_core-2.41.4-cp312-cp312-win_amd64.whl", hash = "sha256:d682cf1d22bab22a5be08539dca3d1593488a99998f9f412137bc323179067ff", size = 2031132, upload-time = "2025-10-14T10:20:50.421Z" }, + { url = "https://files.pythonhosted.org/packages/06/23/936343dbcba6eec93f73e95eb346810fc732f71ba27967b287b66f7b7097/pydantic_core-2.41.4-cp312-cp312-win_arm64.whl", hash = "sha256:833eebfd75a26d17470b58768c1834dfc90141b7afc6eb0429c21fc5a21dcfb8", size = 1969483, upload-time = "2025-10-14T10:20:52.35Z" }, + { url = "https://files.pythonhosted.org/packages/13/d0/c20adabd181a029a970738dfe23710b52a31f1258f591874fcdec7359845/pydantic_core-2.41.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:85e050ad9e5f6fe1004eec65c914332e52f429bc0ae12d6fa2092407a462c746", size = 2105688, upload-time = "2025-10-14T10:20:54.448Z" }, + { url = "https://files.pythonhosted.org/packages/00/b6/0ce5c03cec5ae94cca220dfecddc453c077d71363b98a4bbdb3c0b22c783/pydantic_core-2.41.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e7393f1d64792763a48924ba31d1e44c2cfbc05e3b1c2c9abb4ceeadd912cced", size = 1910807, upload-time = "2025-10-14T10:20:56.115Z" }, + { url = "https://files.pythonhosted.org/packages/68/3e/800d3d02c8beb0b5c069c870cbb83799d085debf43499c897bb4b4aaff0d/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94dab0940b0d1fb28bcab847adf887c66a27a40291eedf0b473be58761c9799a", size = 1956669, upload-time = "2025-10-14T10:20:57.874Z" }, + { url = "https://files.pythonhosted.org/packages/60/a4/24271cc71a17f64589be49ab8bd0751f6a0a03046c690df60989f2f95c2c/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:de7c42f897e689ee6f9e93c4bec72b99ae3b32a2ade1c7e4798e690ff5246e02", size = 2051629, upload-time = "2025-10-14T10:21:00.006Z" }, + { url = "https://files.pythonhosted.org/packages/68/de/45af3ca2f175d91b96bfb62e1f2d2f1f9f3b14a734afe0bfeff079f78181/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:664b3199193262277b8b3cd1e754fb07f2c6023289c815a1e1e8fb415cb247b1", size = 2224049, upload-time = "2025-10-14T10:21:01.801Z" }, + { url = "https://files.pythonhosted.org/packages/af/8f/ae4e1ff84672bf869d0a77af24fd78387850e9497753c432875066b5d622/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d95b253b88f7d308b1c0b417c4624f44553ba4762816f94e6986819b9c273fb2", size = 2342409, upload-time = "2025-10-14T10:21:03.556Z" }, + { url = "https://files.pythonhosted.org/packages/18/62/273dd70b0026a085c7b74b000394e1ef95719ea579c76ea2f0cc8893736d/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1351f5bbdbbabc689727cb91649a00cb9ee7203e0a6e54e9f5ba9e22e384b84", size = 2069635, upload-time = "2025-10-14T10:21:05.385Z" }, + { url = "https://files.pythonhosted.org/packages/30/03/cf485fff699b4cdaea469bc481719d3e49f023241b4abb656f8d422189fc/pydantic_core-2.41.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1affa4798520b148d7182da0615d648e752de4ab1a9566b7471bc803d88a062d", size = 2194284, upload-time = "2025-10-14T10:21:07.122Z" }, + { url = "https://files.pythonhosted.org/packages/f9/7e/c8e713db32405dfd97211f2fc0a15d6bf8adb7640f3d18544c1f39526619/pydantic_core-2.41.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:7b74e18052fea4aa8dea2fb7dbc23d15439695da6cbe6cfc1b694af1115df09d", size = 2137566, upload-time = "2025-10-14T10:21:08.981Z" }, + { url = "https://files.pythonhosted.org/packages/04/f7/db71fd4cdccc8b75990f79ccafbbd66757e19f6d5ee724a6252414483fb4/pydantic_core-2.41.4-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:285b643d75c0e30abda9dc1077395624f314a37e3c09ca402d4015ef5979f1a2", size = 2316809, upload-time = "2025-10-14T10:21:10.805Z" }, + { url = "https://files.pythonhosted.org/packages/76/63/a54973ddb945f1bca56742b48b144d85c9fc22f819ddeb9f861c249d5464/pydantic_core-2.41.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:f52679ff4218d713b3b33f88c89ccbf3a5c2c12ba665fb80ccc4192b4608dbab", size = 2311119, upload-time = "2025-10-14T10:21:12.583Z" }, + { url = "https://files.pythonhosted.org/packages/f8/03/5d12891e93c19218af74843a27e32b94922195ded2386f7b55382f904d2f/pydantic_core-2.41.4-cp313-cp313-win32.whl", hash = "sha256:ecde6dedd6fff127c273c76821bb754d793be1024bc33314a120f83a3c69460c", size = 1981398, upload-time = "2025-10-14T10:21:14.584Z" }, + { url = "https://files.pythonhosted.org/packages/be/d8/fd0de71f39db91135b7a26996160de71c073d8635edfce8b3c3681be0d6d/pydantic_core-2.41.4-cp313-cp313-win_amd64.whl", hash = "sha256:d081a1f3800f05409ed868ebb2d74ac39dd0c1ff6c035b5162356d76030736d4", size = 2030735, upload-time = "2025-10-14T10:21:16.432Z" }, + { url = "https://files.pythonhosted.org/packages/72/86/c99921c1cf6650023c08bfab6fe2d7057a5142628ef7ccfa9921f2dda1d5/pydantic_core-2.41.4-cp313-cp313-win_arm64.whl", hash = "sha256:f8e49c9c364a7edcbe2a310f12733aad95b022495ef2a8d653f645e5d20c1564", size = 1973209, upload-time = "2025-10-14T10:21:18.213Z" }, + { url = "https://files.pythonhosted.org/packages/36/0d/b5706cacb70a8414396efdda3d72ae0542e050b591119e458e2490baf035/pydantic_core-2.41.4-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ed97fd56a561f5eb5706cebe94f1ad7c13b84d98312a05546f2ad036bafe87f4", size = 1877324, upload-time = "2025-10-14T10:21:20.363Z" }, + { url = "https://files.pythonhosted.org/packages/de/2d/cba1fa02cfdea72dfb3a9babb067c83b9dff0bbcb198368e000a6b756ea7/pydantic_core-2.41.4-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a870c307bf1ee91fc58a9a61338ff780d01bfae45922624816878dce784095d2", size = 1884515, upload-time = "2025-10-14T10:21:22.339Z" }, + { url = "https://files.pythonhosted.org/packages/07/ea/3df927c4384ed9b503c9cc2d076cf983b4f2adb0c754578dfb1245c51e46/pydantic_core-2.41.4-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d25e97bc1f5f8f7985bdc2335ef9e73843bb561eb1fa6831fdfc295c1c2061cf", size = 2042819, upload-time = "2025-10-14T10:21:26.683Z" }, + { url = "https://files.pythonhosted.org/packages/6a/ee/df8e871f07074250270a3b1b82aad4cd0026b588acd5d7d3eb2fcb1471a3/pydantic_core-2.41.4-cp313-cp313t-win_amd64.whl", hash = "sha256:d405d14bea042f166512add3091c1af40437c2e7f86988f3915fabd27b1e9cd2", size = 1995866, upload-time = "2025-10-14T10:21:28.951Z" }, + { url = "https://files.pythonhosted.org/packages/fc/de/b20f4ab954d6d399499c33ec4fafc46d9551e11dc1858fb7f5dca0748ceb/pydantic_core-2.41.4-cp313-cp313t-win_arm64.whl", hash = "sha256:19f3684868309db5263a11bace3c45d93f6f24afa2ffe75a647583df22a2ff89", size = 1970034, upload-time = "2025-10-14T10:21:30.869Z" }, + { url = "https://files.pythonhosted.org/packages/54/28/d3325da57d413b9819365546eb9a6e8b7cbd9373d9380efd5f74326143e6/pydantic_core-2.41.4-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:e9205d97ed08a82ebb9a307e92914bb30e18cdf6f6b12ca4bedadb1588a0bfe1", size = 2102022, upload-time = "2025-10-14T10:21:32.809Z" }, + { url = "https://files.pythonhosted.org/packages/9e/24/b58a1bc0d834bf1acc4361e61233ee217169a42efbdc15a60296e13ce438/pydantic_core-2.41.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:82df1f432b37d832709fbcc0e24394bba04a01b6ecf1ee87578145c19cde12ac", size = 1905495, upload-time = "2025-10-14T10:21:34.812Z" }, + { url = "https://files.pythonhosted.org/packages/fb/a4/71f759cc41b7043e8ecdaab81b985a9b6cad7cec077e0b92cff8b71ecf6b/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc3b4cc4539e055cfa39a3763c939f9d409eb40e85813257dcd761985a108554", size = 1956131, upload-time = "2025-10-14T10:21:36.924Z" }, + { url = "https://files.pythonhosted.org/packages/b0/64/1e79ac7aa51f1eec7c4cda8cbe456d5d09f05fdd68b32776d72168d54275/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b1eb1754fce47c63d2ff57fdb88c351a6c0150995890088b33767a10218eaa4e", size = 2052236, upload-time = "2025-10-14T10:21:38.927Z" }, + { url = "https://files.pythonhosted.org/packages/e9/e3/a3ffc363bd4287b80f1d43dc1c28ba64831f8dfc237d6fec8f2661138d48/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e6ab5ab30ef325b443f379ddb575a34969c333004fca5a1daa0133a6ffaad616", size = 2223573, upload-time = "2025-10-14T10:21:41.574Z" }, + { url = "https://files.pythonhosted.org/packages/28/27/78814089b4d2e684a9088ede3790763c64693c3d1408ddc0a248bc789126/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:31a41030b1d9ca497634092b46481b937ff9397a86f9f51bd41c4767b6fc04af", size = 2342467, upload-time = "2025-10-14T10:21:44.018Z" }, + { url = "https://files.pythonhosted.org/packages/92/97/4de0e2a1159cb85ad737e03306717637842c88c7fd6d97973172fb183149/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a44ac1738591472c3d020f61c6df1e4015180d6262ebd39bf2aeb52571b60f12", size = 2063754, upload-time = "2025-10-14T10:21:46.466Z" }, + { url = "https://files.pythonhosted.org/packages/0f/50/8cb90ce4b9efcf7ae78130afeb99fd1c86125ccdf9906ef64b9d42f37c25/pydantic_core-2.41.4-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d72f2b5e6e82ab8f94ea7d0d42f83c487dc159c5240d8f83beae684472864e2d", size = 2196754, upload-time = "2025-10-14T10:21:48.486Z" }, + { url = "https://files.pythonhosted.org/packages/34/3b/ccdc77af9cd5082723574a1cc1bcae7a6acacc829d7c0a06201f7886a109/pydantic_core-2.41.4-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:c4d1e854aaf044487d31143f541f7aafe7b482ae72a022c664b2de2e466ed0ad", size = 2137115, upload-time = "2025-10-14T10:21:50.63Z" }, + { url = "https://files.pythonhosted.org/packages/ca/ba/e7c7a02651a8f7c52dc2cff2b64a30c313e3b57c7d93703cecea76c09b71/pydantic_core-2.41.4-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:b568af94267729d76e6ee5ececda4e283d07bbb28e8148bb17adad93d025d25a", size = 2317400, upload-time = "2025-10-14T10:21:52.959Z" }, + { url = "https://files.pythonhosted.org/packages/2c/ba/6c533a4ee8aec6b812c643c49bb3bd88d3f01e3cebe451bb85512d37f00f/pydantic_core-2.41.4-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:6d55fb8b1e8929b341cc313a81a26e0d48aa3b519c1dbaadec3a6a2b4fcad025", size = 2312070, upload-time = "2025-10-14T10:21:55.419Z" }, + { url = "https://files.pythonhosted.org/packages/22/ae/f10524fcc0ab8d7f96cf9a74c880243576fd3e72bd8ce4f81e43d22bcab7/pydantic_core-2.41.4-cp314-cp314-win32.whl", hash = "sha256:5b66584e549e2e32a1398df11da2e0a7eff45d5c2d9db9d5667c5e6ac764d77e", size = 1982277, upload-time = "2025-10-14T10:21:57.474Z" }, + { url = "https://files.pythonhosted.org/packages/b4/dc/e5aa27aea1ad4638f0c3fb41132f7eb583bd7420ee63204e2d4333a3bbf9/pydantic_core-2.41.4-cp314-cp314-win_amd64.whl", hash = "sha256:557a0aab88664cc552285316809cab897716a372afaf8efdbef756f8b890e894", size = 2024608, upload-time = "2025-10-14T10:21:59.557Z" }, + { url = "https://files.pythonhosted.org/packages/3e/61/51d89cc2612bd147198e120a13f150afbf0bcb4615cddb049ab10b81b79e/pydantic_core-2.41.4-cp314-cp314-win_arm64.whl", hash = "sha256:3f1ea6f48a045745d0d9f325989d8abd3f1eaf47dd00485912d1a3a63c623a8d", size = 1967614, upload-time = "2025-10-14T10:22:01.847Z" }, + { url = "https://files.pythonhosted.org/packages/0d/c2/472f2e31b95eff099961fa050c376ab7156a81da194f9edb9f710f68787b/pydantic_core-2.41.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:6c1fe4c5404c448b13188dd8bd2ebc2bdd7e6727fa61ff481bcc2cca894018da", size = 1876904, upload-time = "2025-10-14T10:22:04.062Z" }, + { url = "https://files.pythonhosted.org/packages/4a/07/ea8eeb91173807ecdae4f4a5f4b150a520085b35454350fc219ba79e66a3/pydantic_core-2.41.4-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:523e7da4d43b113bf8e7b49fa4ec0c35bf4fe66b2230bfc5c13cc498f12c6c3e", size = 1882538, upload-time = "2025-10-14T10:22:06.39Z" }, + { url = "https://files.pythonhosted.org/packages/1e/29/b53a9ca6cd366bfc928823679c6a76c7a4c69f8201c0ba7903ad18ebae2f/pydantic_core-2.41.4-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5729225de81fb65b70fdb1907fcf08c75d498f4a6f15af005aabb1fdadc19dfa", size = 2041183, upload-time = "2025-10-14T10:22:08.812Z" }, + { url = "https://files.pythonhosted.org/packages/c7/3d/f8c1a371ceebcaf94d6dd2d77c6cf4b1c078e13a5837aee83f760b4f7cfd/pydantic_core-2.41.4-cp314-cp314t-win_amd64.whl", hash = "sha256:de2cfbb09e88f0f795fd90cf955858fc2c691df65b1f21f0aa00b99f3fbc661d", size = 1993542, upload-time = "2025-10-14T10:22:11.332Z" }, + { url = "https://files.pythonhosted.org/packages/8a/ac/9fc61b4f9d079482a290afe8d206b8f490e9fd32d4fc03ed4fc698214e01/pydantic_core-2.41.4-cp314-cp314t-win_arm64.whl", hash = "sha256:d34f950ae05a83e0ede899c595f312ca976023ea1db100cd5aa188f7005e3ab0", size = 1973897, upload-time = "2025-10-14T10:22:13.444Z" }, + { url = "https://files.pythonhosted.org/packages/c4/48/ae937e5a831b7c0dc646b2ef788c27cd003894882415300ed21927c21efa/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:4f5d640aeebb438517150fdeec097739614421900e4a08db4a3ef38898798537", size = 2112087, upload-time = "2025-10-14T10:22:56.818Z" }, + { url = "https://files.pythonhosted.org/packages/5e/db/6db8073e3d32dae017da7e0d16a9ecb897d0a4d92e00634916e486097961/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:4a9ab037b71927babc6d9e7fc01aea9e66dc2a4a34dff06ef0724a4049629f94", size = 1920387, upload-time = "2025-10-14T10:22:59.342Z" }, + { url = "https://files.pythonhosted.org/packages/0d/c1/dd3542d072fcc336030d66834872f0328727e3b8de289c662faa04aa270e/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e4dab9484ec605c3016df9ad4fd4f9a390bc5d816a3b10c6550f8424bb80b18c", size = 1951495, upload-time = "2025-10-14T10:23:02.089Z" }, + { url = "https://files.pythonhosted.org/packages/2b/c6/db8d13a1f8ab3f1eb08c88bd00fd62d44311e3456d1e85c0e59e0a0376e7/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd8a5028425820731d8c6c098ab642d7b8b999758e24acae03ed38a66eca8335", size = 2139008, upload-time = "2025-10-14T10:23:04.539Z" }, +] + +[[package]] +name = "pydantic-settings" +version = "2.11.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/20/c5/dbbc27b814c71676593d1c3f718e6cd7d4f00652cefa24b75f7aa3efb25e/pydantic_settings-2.11.0.tar.gz", hash = "sha256:d0e87a1c7d33593beb7194adb8470fc426e95ba02af83a0f23474a04c9a08180", size = 188394, upload-time = "2025-09-24T14:19:11.764Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/83/d6/887a1ff844e64aa823fb4905978d882a633cfe295c32eacad582b78a7d8b/pydantic_settings-2.11.0-py3-none-any.whl", hash = "sha256:fe2cea3413b9530d10f3a5875adffb17ada5c1e1bab0b2885546d7310415207c", size = 48608, upload-time = "2025-09-24T14:19:10.015Z" }, +] + +[[package]] +name = "pygments" +version = "2.19.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, +] + +[[package]] +name = "pytest" +version = "8.4.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a3/5c/00a0e072241553e1a7496d638deababa67c5058571567b92a7eaa258397c/pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01", size = 1519618, upload-time = "2025-09-04T14:34:22.711Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a8/a4/20da314d277121d6534b3a980b29035dcd51e6744bd79075a6ce8fa4eb8d/pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79", size = 365750, upload-time = "2025-09-04T14:34:20.226Z" }, +] + +[[package]] +name = "pytest-asyncio" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/42/86/9e3c5f48f7b7b638b216e4b9e645f54d199d7abbbab7a64a13b4e12ba10f/pytest_asyncio-1.2.0.tar.gz", hash = "sha256:c609a64a2a8768462d0c99811ddb8bd2583c33fd33cf7f21af1c142e824ffb57", size = 50119, upload-time = "2025-09-12T07:33:53.816Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/93/2fa34714b7a4ae72f2f8dad66ba17dd9a2c793220719e736dda28b7aec27/pytest_asyncio-1.2.0-py3-none-any.whl", hash = "sha256:8e17ae5e46d8e7efe51ab6494dd2010f4ca8dae51652aa3c8d55acf50bfb2e99", size = 15095, upload-time = "2025-09-12T07:33:52.639Z" }, +] + +[[package]] +name = "python-dotenv" +version = "1.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" }, +] + +[[package]] +name = "pytokens" +version = "0.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d4/c2/dbadcdddb412a267585459142bfd7cc241e6276db69339353ae6e241ab2b/pytokens-0.2.0.tar.gz", hash = "sha256:532d6421364e5869ea57a9523bf385f02586d4662acbcc0342afd69511b4dd43", size = 15368, upload-time = "2025-10-15T08:02:42.738Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/89/5a/c269ea6b348b6f2c32686635df89f32dbe05df1088dd4579302a6f8f99af/pytokens-0.2.0-py3-none-any.whl", hash = "sha256:74d4b318c67f4295c13782ddd9abcb7e297ec5630ad060eb90abf7ebbefe59f8", size = 12038, upload-time = "2025-10-15T08:02:41.694Z" }, +] + +[[package]] +name = "pyyaml" +version = "6.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" }, + { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" }, + { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" }, + { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" }, + { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" }, + { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" }, + { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" }, + { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" }, + { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" }, + { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" }, + { url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" }, + { url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" }, + { url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" }, + { url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" }, + { url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" }, + { url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" }, + { url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" }, + { url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" }, + { url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" }, + { url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" }, + { url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" }, + { url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" }, + { url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" }, + { url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" }, + { url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" }, + { url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" }, + { url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" }, + { url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" }, + { url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" }, + { url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" }, + { url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" }, + { url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" }, + { url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" }, + { url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" }, + { url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" }, + { url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" }, + { url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" }, + { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, +] + +[[package]] +name = "ruff" +version = "0.14.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/75/62/50b7727004dfe361104dfbf898c45a9a2fdfad8c72c04ae62900224d6ecf/ruff-0.14.3.tar.gz", hash = "sha256:4ff876d2ab2b161b6de0aa1f5bd714e8e9b4033dc122ee006925fbacc4f62153", size = 5558687, upload-time = "2025-10-31T00:26:26.878Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ce/8e/0c10ff1ea5d4360ab8bfca4cb2c9d979101a391f3e79d2616c9bf348cd26/ruff-0.14.3-py3-none-linux_armv6l.whl", hash = "sha256:876b21e6c824f519446715c1342b8e60f97f93264012de9d8d10314f8a79c371", size = 12535613, upload-time = "2025-10-31T00:25:44.302Z" }, + { url = "https://files.pythonhosted.org/packages/d3/c8/6724f4634c1daf52409fbf13fefda64aa9c8f81e44727a378b7b73dc590b/ruff-0.14.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b6fd8c79b457bedd2abf2702b9b472147cd860ed7855c73a5247fa55c9117654", size = 12855812, upload-time = "2025-10-31T00:25:47.793Z" }, + { url = "https://files.pythonhosted.org/packages/de/03/db1bce591d55fd5f8a08bb02517fa0b5097b2ccabd4ea1ee29aa72b67d96/ruff-0.14.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:71ff6edca490c308f083156938c0c1a66907151263c4abdcb588602c6e696a14", size = 11944026, upload-time = "2025-10-31T00:25:49.657Z" }, + { url = "https://files.pythonhosted.org/packages/0b/75/4f8dbd48e03272715d12c87dc4fcaaf21b913f0affa5f12a4e9c6f8a0582/ruff-0.14.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:786ee3ce6139772ff9272aaf43296d975c0217ee1b97538a98171bf0d21f87ed", size = 12356818, upload-time = "2025-10-31T00:25:51.949Z" }, + { url = "https://files.pythonhosted.org/packages/ec/9b/506ec5b140c11d44a9a4f284ea7c14ebf6f8b01e6e8917734a3325bff787/ruff-0.14.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cd6291d0061811c52b8e392f946889916757610d45d004e41140d81fb6cd5ddc", size = 12336745, upload-time = "2025-10-31T00:25:54.248Z" }, + { url = "https://files.pythonhosted.org/packages/c7/e1/c560d254048c147f35e7f8131d30bc1f63a008ac61595cf3078a3e93533d/ruff-0.14.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a497ec0c3d2c88561b6d90f9c29f5ae68221ac00d471f306fa21fa4264ce5fcd", size = 13101684, upload-time = "2025-10-31T00:25:56.253Z" }, + { url = "https://files.pythonhosted.org/packages/a5/32/e310133f8af5cd11f8cc30f52522a3ebccc5ea5bff4b492f94faceaca7a8/ruff-0.14.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:e231e1be58fc568950a04fbe6887c8e4b85310e7889727e2b81db205c45059eb", size = 14535000, upload-time = "2025-10-31T00:25:58.397Z" }, + { url = "https://files.pythonhosted.org/packages/a2/a1/7b0470a22158c6d8501eabc5e9b6043c99bede40fa1994cadf6b5c2a61c7/ruff-0.14.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:469e35872a09c0e45fecf48dd960bfbce056b5db2d5e6b50eca329b4f853ae20", size = 14156450, upload-time = "2025-10-31T00:26:00.889Z" }, + { url = "https://files.pythonhosted.org/packages/0a/96/24bfd9d1a7f532b560dcee1a87096332e461354d3882124219bcaff65c09/ruff-0.14.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d6bc90307c469cb9d28b7cfad90aaa600b10d67c6e22026869f585e1e8a2db0", size = 13568414, upload-time = "2025-10-31T00:26:03.291Z" }, + { url = "https://files.pythonhosted.org/packages/a7/e7/138b883f0dfe4ad5b76b58bf4ae675f4d2176ac2b24bdd81b4d966b28c61/ruff-0.14.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e2f8a0bbcffcfd895df39c9a4ecd59bb80dca03dc43f7fb63e647ed176b741e", size = 13315293, upload-time = "2025-10-31T00:26:05.708Z" }, + { url = "https://files.pythonhosted.org/packages/33/f4/c09bb898be97b2eb18476b7c950df8815ef14cf956074177e9fbd40b7719/ruff-0.14.3-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:678fdd7c7d2d94851597c23ee6336d25f9930b460b55f8598e011b57c74fd8c5", size = 13539444, upload-time = "2025-10-31T00:26:08.09Z" }, + { url = "https://files.pythonhosted.org/packages/9c/aa/b30a1db25fc6128b1dd6ff0741fa4abf969ded161599d07ca7edd0739cc0/ruff-0.14.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1ec1ac071e7e37e0221d2f2dbaf90897a988c531a8592a6a5959f0603a1ecf5e", size = 12252581, upload-time = "2025-10-31T00:26:10.297Z" }, + { url = "https://files.pythonhosted.org/packages/da/13/21096308f384d796ffe3f2960b17054110a9c3828d223ca540c2b7cc670b/ruff-0.14.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:afcdc4b5335ef440d19e7df9e8ae2ad9f749352190e96d481dc501b753f0733e", size = 12307503, upload-time = "2025-10-31T00:26:12.646Z" }, + { url = "https://files.pythonhosted.org/packages/cb/cc/a350bac23f03b7dbcde3c81b154706e80c6f16b06ff1ce28ed07dc7b07b0/ruff-0.14.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:7bfc42f81862749a7136267a343990f865e71fe2f99cf8d2958f684d23ce3dfa", size = 12675457, upload-time = "2025-10-31T00:26:15.044Z" }, + { url = "https://files.pythonhosted.org/packages/cb/76/46346029fa2f2078826bc88ef7167e8c198e58fe3126636e52f77488cbba/ruff-0.14.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a65e448cfd7e9c59fae8cf37f9221585d3354febaad9a07f29158af1528e165f", size = 13403980, upload-time = "2025-10-31T00:26:17.81Z" }, + { url = "https://files.pythonhosted.org/packages/9f/a4/35f1ef68c4e7b236d4a5204e3669efdeefaef21f0ff6a456792b3d8be438/ruff-0.14.3-py3-none-win32.whl", hash = "sha256:f3d91857d023ba93e14ed2d462ab62c3428f9bbf2b4fbac50a03ca66d31991f7", size = 12500045, upload-time = "2025-10-31T00:26:20.503Z" }, + { url = "https://files.pythonhosted.org/packages/03/15/51960ae340823c9859fb60c63301d977308735403e2134e17d1d2858c7fb/ruff-0.14.3-py3-none-win_amd64.whl", hash = "sha256:d7b7006ac0756306db212fd37116cce2bd307e1e109375e1c6c106002df0ae5f", size = 13594005, upload-time = "2025-10-31T00:26:22.533Z" }, + { url = "https://files.pythonhosted.org/packages/b7/73/4de6579bac8e979fca0a77e54dec1f1e011a0d268165eb8a9bc0982a6564/ruff-0.14.3-py3-none-win_arm64.whl", hash = "sha256:26eb477ede6d399d898791d01961e16b86f02bc2486d0d1a7a9bb2379d055dc1", size = 12590017, upload-time = "2025-10-31T00:26:24.52Z" }, +] + +[[package]] +name = "sniffio" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" }, +] + +[[package]] +name = "snowflake-id" +version = "1.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7a/d0/91bd3d2e54ea849e8c4e73681ef75c1c93f37a8c9f0627b1553522267e08/snowflake_id-1.0.2.tar.gz", hash = "sha256:4a4cd49508599aaa16488311f4b9121e9ac3bac57edff3e9f71b1d79086dbfe8", size = 4497, upload-time = "2024-04-17T13:36:05.552Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/a4/ee0bdba1d1e98db21166381559d0061d752bbf66af2dd1cbbe4c2afdc4fa/snowflake_id-1.0.2-py3-none-any.whl", hash = "sha256:c3142752ed334b9d4632739a704461d13e97aa6fa71b65d5329829b4b5cc058c", size = 4795, upload-time = "2024-04-17T13:36:03.898Z" }, +] + +[[package]] +name = "sqlalchemy" +version = "2.0.44" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f0/f2/840d7b9496825333f532d2e3976b8eadbf52034178aac53630d09fe6e1ef/sqlalchemy-2.0.44.tar.gz", hash = "sha256:0ae7454e1ab1d780aee69fd2aae7d6b8670a581d8847f2d1e0f7ddfbf47e5a22", size = 9819830, upload-time = "2025-10-10T14:39:12.935Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/c4/59c7c9b068e6813c898b771204aad36683c96318ed12d4233e1b18762164/sqlalchemy-2.0.44-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:72fea91746b5890f9e5e0997f16cbf3d53550580d76355ba2d998311b17b2250", size = 2139675, upload-time = "2025-10-10T16:03:31.064Z" }, + { url = "https://files.pythonhosted.org/packages/d6/ae/eeb0920537a6f9c5a3708e4a5fc55af25900216bdb4847ec29cfddf3bf3a/sqlalchemy-2.0.44-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:585c0c852a891450edbb1eaca8648408a3cc125f18cf433941fa6babcc359e29", size = 2127726, upload-time = "2025-10-10T16:03:35.934Z" }, + { url = "https://files.pythonhosted.org/packages/d8/d5/2ebbabe0379418eda8041c06b0b551f213576bfe4c2f09d77c06c07c8cc5/sqlalchemy-2.0.44-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b94843a102efa9ac68a7a30cd46df3ff1ed9c658100d30a725d10d9c60a2f44", size = 3327603, upload-time = "2025-10-10T15:35:28.322Z" }, + { url = "https://files.pythonhosted.org/packages/45/e5/5aa65852dadc24b7d8ae75b7efb8d19303ed6ac93482e60c44a585930ea5/sqlalchemy-2.0.44-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:119dc41e7a7defcefc57189cfa0e61b1bf9c228211aba432b53fb71ef367fda1", size = 3337842, upload-time = "2025-10-10T15:43:45.431Z" }, + { url = "https://files.pythonhosted.org/packages/41/92/648f1afd3f20b71e880ca797a960f638d39d243e233a7082c93093c22378/sqlalchemy-2.0.44-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:0765e318ee9179b3718c4fd7ba35c434f4dd20332fbc6857a5e8df17719c24d7", size = 3264558, upload-time = "2025-10-10T15:35:29.93Z" }, + { url = "https://files.pythonhosted.org/packages/40/cf/e27d7ee61a10f74b17740918e23cbc5bc62011b48282170dc4c66da8ec0f/sqlalchemy-2.0.44-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2e7b5b079055e02d06a4308d0481658e4f06bc7ef211567edc8f7d5dce52018d", size = 3301570, upload-time = "2025-10-10T15:43:48.407Z" }, + { url = "https://files.pythonhosted.org/packages/3b/3d/3116a9a7b63e780fb402799b6da227435be878b6846b192f076d2f838654/sqlalchemy-2.0.44-cp312-cp312-win32.whl", hash = "sha256:846541e58b9a81cce7dee8329f352c318de25aa2f2bbe1e31587eb1f057448b4", size = 2103447, upload-time = "2025-10-10T15:03:21.678Z" }, + { url = "https://files.pythonhosted.org/packages/25/83/24690e9dfc241e6ab062df82cc0df7f4231c79ba98b273fa496fb3dd78ed/sqlalchemy-2.0.44-cp312-cp312-win_amd64.whl", hash = "sha256:7cbcb47fd66ab294703e1644f78971f6f2f1126424d2b300678f419aa73c7b6e", size = 2130912, upload-time = "2025-10-10T15:03:24.656Z" }, + { url = "https://files.pythonhosted.org/packages/45/d3/c67077a2249fdb455246e6853166360054c331db4613cda3e31ab1cadbef/sqlalchemy-2.0.44-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ff486e183d151e51b1d694c7aa1695747599bb00b9f5f604092b54b74c64a8e1", size = 2135479, upload-time = "2025-10-10T16:03:37.671Z" }, + { url = "https://files.pythonhosted.org/packages/2b/91/eabd0688330d6fd114f5f12c4f89b0d02929f525e6bf7ff80aa17ca802af/sqlalchemy-2.0.44-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0b1af8392eb27b372ddb783b317dea0f650241cea5bd29199b22235299ca2e45", size = 2123212, upload-time = "2025-10-10T16:03:41.755Z" }, + { url = "https://files.pythonhosted.org/packages/b0/bb/43e246cfe0e81c018076a16036d9b548c4cc649de241fa27d8d9ca6f85ab/sqlalchemy-2.0.44-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2b61188657e3a2b9ac4e8f04d6cf8e51046e28175f79464c67f2fd35bceb0976", size = 3255353, upload-time = "2025-10-10T15:35:31.221Z" }, + { url = "https://files.pythonhosted.org/packages/b9/96/c6105ed9a880abe346b64d3b6ddef269ddfcab04f7f3d90a0bf3c5a88e82/sqlalchemy-2.0.44-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b87e7b91a5d5973dda5f00cd61ef72ad75a1db73a386b62877d4875a8840959c", size = 3260222, upload-time = "2025-10-10T15:43:50.124Z" }, + { url = "https://files.pythonhosted.org/packages/44/16/1857e35a47155b5ad927272fee81ae49d398959cb749edca6eaa399b582f/sqlalchemy-2.0.44-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:15f3326f7f0b2bfe406ee562e17f43f36e16167af99c4c0df61db668de20002d", size = 3189614, upload-time = "2025-10-10T15:35:32.578Z" }, + { url = "https://files.pythonhosted.org/packages/88/ee/4afb39a8ee4fc786e2d716c20ab87b5b1fb33d4ac4129a1aaa574ae8a585/sqlalchemy-2.0.44-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1e77faf6ff919aa8cd63f1c4e561cac1d9a454a191bb864d5dd5e545935e5a40", size = 3226248, upload-time = "2025-10-10T15:43:51.862Z" }, + { url = "https://files.pythonhosted.org/packages/32/d5/0e66097fc64fa266f29a7963296b40a80d6a997b7ac13806183700676f86/sqlalchemy-2.0.44-cp313-cp313-win32.whl", hash = "sha256:ee51625c2d51f8baadf2829fae817ad0b66b140573939dd69284d2ba3553ae73", size = 2101275, upload-time = "2025-10-10T15:03:26.096Z" }, + { url = "https://files.pythonhosted.org/packages/03/51/665617fe4f8c6450f42a6d8d69243f9420f5677395572c2fe9d21b493b7b/sqlalchemy-2.0.44-cp313-cp313-win_amd64.whl", hash = "sha256:c1c80faaee1a6c3428cecf40d16a2365bcf56c424c92c2b6f0f9ad204b899e9e", size = 2127901, upload-time = "2025-10-10T15:03:27.548Z" }, + { url = "https://files.pythonhosted.org/packages/9c/5e/6a29fa884d9fb7ddadf6b69490a9d45fded3b38541713010dad16b77d015/sqlalchemy-2.0.44-py3-none-any.whl", hash = "sha256:19de7ca1246fbef9f9d1bff8f1ab25641569df226364a0e40457dc5457c54b05", size = 1928718, upload-time = "2025-10-10T15:29:45.32Z" }, +] + +[[package]] +name = "starlette" +version = "0.49.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/de/1a/608df0b10b53b0beb96a37854ee05864d182ddd4b1156a22f1ad3860425a/starlette-0.49.3.tar.gz", hash = "sha256:1c14546f299b5901a1ea0e34410575bc33bbd741377a10484a54445588d00284", size = 2655031, upload-time = "2025-11-01T15:12:26.13Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a3/e0/021c772d6a662f43b63044ab481dc6ac7592447605b5b35a957785363122/starlette-0.49.3-py3-none-any.whl", hash = "sha256:b579b99715fdc2980cf88c8ec96d3bf1ce16f5a8051a7c2b84ef9b1cdecaea2f", size = 74340, upload-time = "2025-11-01T15:12:24.387Z" }, +] + +[[package]] +name = "tqdm" +version = "4.67.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a8/4b/29b4ef32e036bb34e4ab51796dd745cdba7ed47ad142a9f4a1eb8e0c744d/tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2", size = 169737, upload-time = "2024-11-24T20:12:22.481Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d0/30/dc54f88dd4a2b5dc8a0279bdd7270e735851848b762aeb1c1184ed1f6b14/tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2", size = 78540, upload-time = "2024-11-24T20:12:19.698Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" }, +] + +[[package]] +name = "uvicorn" +version = "0.38.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cb/ce/f06b84e2697fef4688ca63bdb2fdf113ca0a3be33f94488f2cadb690b0cf/uvicorn-0.38.0.tar.gz", hash = "sha256:fd97093bdd120a2609fc0d3afe931d4d4ad688b6e75f0f929fde1bc36fe0e91d", size = 80605, upload-time = "2025-10-18T13:46:44.63Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl", hash = "sha256:48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02", size = 68109, upload-time = "2025-10-18T13:46:42.958Z" }, +] + +[package.optional-dependencies] +standard = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "httptools" }, + { name = "python-dotenv" }, + { name = "pyyaml" }, + { name = "uvloop", marker = "platform_python_implementation != 'PyPy' and sys_platform != 'cygwin' and sys_platform != 'win32'" }, + { name = "watchfiles" }, + { name = "websockets" }, +] + +[[package]] +name = "uvloop" +version = "0.22.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/06/f0/18d39dbd1971d6d62c4629cc7fa67f74821b0dc1f5a77af43719de7936a7/uvloop-0.22.1.tar.gz", hash = "sha256:6c84bae345b9147082b17371e3dd5d42775bddce91f885499017f4607fdaf39f", size = 2443250, upload-time = "2025-10-16T22:17:19.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3d/ff/7f72e8170be527b4977b033239a83a68d5c881cc4775fca255c677f7ac5d/uvloop-0.22.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:fe94b4564e865d968414598eea1a6de60adba0c040ba4ed05ac1300de402cd42", size = 1359936, upload-time = "2025-10-16T22:16:29.436Z" }, + { url = "https://files.pythonhosted.org/packages/c3/c6/e5d433f88fd54d81ef4be58b2b7b0cea13c442454a1db703a1eea0db1a59/uvloop-0.22.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:51eb9bd88391483410daad430813d982010f9c9c89512321f5b60e2cddbdddd6", size = 752769, upload-time = "2025-10-16T22:16:30.493Z" }, + { url = "https://files.pythonhosted.org/packages/24/68/a6ac446820273e71aa762fa21cdcc09861edd3536ff47c5cd3b7afb10eeb/uvloop-0.22.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:700e674a166ca5778255e0e1dc4e9d79ab2acc57b9171b79e65feba7184b3370", size = 4317413, upload-time = "2025-10-16T22:16:31.644Z" }, + { url = "https://files.pythonhosted.org/packages/5f/6f/e62b4dfc7ad6518e7eff2516f680d02a0f6eb62c0c212e152ca708a0085e/uvloop-0.22.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b5b1ac819a3f946d3b2ee07f09149578ae76066d70b44df3fa990add49a82e4", size = 4426307, upload-time = "2025-10-16T22:16:32.917Z" }, + { url = "https://files.pythonhosted.org/packages/90/60/97362554ac21e20e81bcef1150cb2a7e4ffdaf8ea1e5b2e8bf7a053caa18/uvloop-0.22.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e047cc068570bac9866237739607d1313b9253c3051ad84738cbb095be0537b2", size = 4131970, upload-time = "2025-10-16T22:16:34.015Z" }, + { url = "https://files.pythonhosted.org/packages/99/39/6b3f7d234ba3964c428a6e40006340f53ba37993f46ed6e111c6e9141d18/uvloop-0.22.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:512fec6815e2dd45161054592441ef76c830eddaad55c8aa30952e6fe1ed07c0", size = 4296343, upload-time = "2025-10-16T22:16:35.149Z" }, + { url = "https://files.pythonhosted.org/packages/89/8c/182a2a593195bfd39842ea68ebc084e20c850806117213f5a299dfc513d9/uvloop-0.22.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:561577354eb94200d75aca23fbde86ee11be36b00e52a4eaf8f50fb0c86b7705", size = 1358611, upload-time = "2025-10-16T22:16:36.833Z" }, + { url = "https://files.pythonhosted.org/packages/d2/14/e301ee96a6dc95224b6f1162cd3312f6d1217be3907b79173b06785f2fe7/uvloop-0.22.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1cdf5192ab3e674ca26da2eada35b288d2fa49fdd0f357a19f0e7c4e7d5077c8", size = 751811, upload-time = "2025-10-16T22:16:38.275Z" }, + { url = "https://files.pythonhosted.org/packages/b7/02/654426ce265ac19e2980bfd9ea6590ca96a56f10c76e63801a2df01c0486/uvloop-0.22.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e2ea3d6190a2968f4a14a23019d3b16870dd2190cd69c8180f7c632d21de68d", size = 4288562, upload-time = "2025-10-16T22:16:39.375Z" }, + { url = "https://files.pythonhosted.org/packages/15/c0/0be24758891ef825f2065cd5db8741aaddabe3e248ee6acc5e8a80f04005/uvloop-0.22.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0530a5fbad9c9e4ee3f2b33b148c6a64d47bbad8000ea63704fa8260f4cf728e", size = 4366890, upload-time = "2025-10-16T22:16:40.547Z" }, + { url = "https://files.pythonhosted.org/packages/d2/53/8369e5219a5855869bcee5f4d317f6da0e2c669aecf0ef7d371e3d084449/uvloop-0.22.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bc5ef13bbc10b5335792360623cc378d52d7e62c2de64660616478c32cd0598e", size = 4119472, upload-time = "2025-10-16T22:16:41.694Z" }, + { url = "https://files.pythonhosted.org/packages/f8/ba/d69adbe699b768f6b29a5eec7b47dd610bd17a69de51b251126a801369ea/uvloop-0.22.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1f38ec5e3f18c8a10ded09742f7fb8de0108796eb673f30ce7762ce1b8550cad", size = 4239051, upload-time = "2025-10-16T22:16:43.224Z" }, + { url = "https://files.pythonhosted.org/packages/90/cd/b62bdeaa429758aee8de8b00ac0dd26593a9de93d302bff3d21439e9791d/uvloop-0.22.1-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:3879b88423ec7e97cd4eba2a443aa26ed4e59b45e6b76aabf13fe2f27023a142", size = 1362067, upload-time = "2025-10-16T22:16:44.503Z" }, + { url = "https://files.pythonhosted.org/packages/0d/f8/a132124dfda0777e489ca86732e85e69afcd1ff7686647000050ba670689/uvloop-0.22.1-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:4baa86acedf1d62115c1dc6ad1e17134476688f08c6efd8a2ab076e815665c74", size = 752423, upload-time = "2025-10-16T22:16:45.968Z" }, + { url = "https://files.pythonhosted.org/packages/a3/94/94af78c156f88da4b3a733773ad5ba0b164393e357cc4bd0ab2e2677a7d6/uvloop-0.22.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:297c27d8003520596236bdb2335e6b3f649480bd09e00d1e3a99144b691d2a35", size = 4272437, upload-time = "2025-10-16T22:16:47.451Z" }, + { url = "https://files.pythonhosted.org/packages/b5/35/60249e9fd07b32c665192cec7af29e06c7cd96fa1d08b84f012a56a0b38e/uvloop-0.22.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c1955d5a1dd43198244d47664a5858082a3239766a839b2102a269aaff7a4e25", size = 4292101, upload-time = "2025-10-16T22:16:49.318Z" }, + { url = "https://files.pythonhosted.org/packages/02/62/67d382dfcb25d0a98ce73c11ed1a6fba5037a1a1d533dcbb7cab033a2636/uvloop-0.22.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:b31dc2fccbd42adc73bc4e7cdbae4fc5086cf378979e53ca5d0301838c5682c6", size = 4114158, upload-time = "2025-10-16T22:16:50.517Z" }, + { url = "https://files.pythonhosted.org/packages/f0/7a/f1171b4a882a5d13c8b7576f348acfe6074d72eaf52cccef752f748d4a9f/uvloop-0.22.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:93f617675b2d03af4e72a5333ef89450dfaa5321303ede6e67ba9c9d26878079", size = 4177360, upload-time = "2025-10-16T22:16:52.646Z" }, + { url = "https://files.pythonhosted.org/packages/79/7b/b01414f31546caf0919da80ad57cbfe24c56b151d12af68cee1b04922ca8/uvloop-0.22.1-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:37554f70528f60cad66945b885eb01f1bb514f132d92b6eeed1c90fd54ed6289", size = 1454790, upload-time = "2025-10-16T22:16:54.355Z" }, + { url = "https://files.pythonhosted.org/packages/d4/31/0bb232318dd838cad3fa8fb0c68c8b40e1145b32025581975e18b11fab40/uvloop-0.22.1-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:b76324e2dc033a0b2f435f33eb88ff9913c156ef78e153fb210e03c13da746b3", size = 796783, upload-time = "2025-10-16T22:16:55.906Z" }, + { url = "https://files.pythonhosted.org/packages/42/38/c9b09f3271a7a723a5de69f8e237ab8e7803183131bc57c890db0b6bb872/uvloop-0.22.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:badb4d8e58ee08dad957002027830d5c3b06aea446a6a3744483c2b3b745345c", size = 4647548, upload-time = "2025-10-16T22:16:57.008Z" }, + { url = "https://files.pythonhosted.org/packages/c1/37/945b4ca0ac27e3dc4952642d4c900edd030b3da6c9634875af6e13ae80e5/uvloop-0.22.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b91328c72635f6f9e0282e4a57da7470c7350ab1c9f48546c0f2866205349d21", size = 4467065, upload-time = "2025-10-16T22:16:58.206Z" }, + { url = "https://files.pythonhosted.org/packages/97/cc/48d232f33d60e2e2e0b42f4e73455b146b76ebe216487e862700457fbf3c/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:daf620c2995d193449393d6c62131b3fbd40a63bf7b307a1527856ace637fe88", size = 4328384, upload-time = "2025-10-16T22:16:59.36Z" }, + { url = "https://files.pythonhosted.org/packages/e4/16/c1fd27e9549f3c4baf1dc9c20c456cd2f822dbf8de9f463824b0c0357e06/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6cde23eeda1a25c75b2e07d39970f3374105d5eafbaab2a4482be82f272d5a5e", size = 4296730, upload-time = "2025-10-16T22:17:00.744Z" }, +] + +[[package]] +name = "watchfiles" +version = "1.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c2/c9/8869df9b2a2d6c59d79220a4db37679e74f807c559ffe5265e08b227a210/watchfiles-1.1.1.tar.gz", hash = "sha256:a173cb5c16c4f40ab19cecf48a534c409f7ea983ab8fed0741304a1c0a31b3f2", size = 94440, upload-time = "2025-10-14T15:06:21.08Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/74/d5/f039e7e3c639d9b1d09b07ea412a6806d38123f0508e5f9b48a87b0a76cc/watchfiles-1.1.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:8c89f9f2f740a6b7dcc753140dd5e1ab9215966f7a3530d0c0705c83b401bd7d", size = 404745, upload-time = "2025-10-14T15:04:46.731Z" }, + { url = "https://files.pythonhosted.org/packages/a5/96/a881a13aa1349827490dab2d363c8039527060cfcc2c92cc6d13d1b1049e/watchfiles-1.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bd404be08018c37350f0d6e34676bd1e2889990117a2b90070b3007f172d0610", size = 391769, upload-time = "2025-10-14T15:04:48.003Z" }, + { url = "https://files.pythonhosted.org/packages/4b/5b/d3b460364aeb8da471c1989238ea0e56bec24b6042a68046adf3d9ddb01c/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8526e8f916bb5b9a0a777c8317c23ce65de259422bba5b31325a6fa6029d33af", size = 449374, upload-time = "2025-10-14T15:04:49.179Z" }, + { url = "https://files.pythonhosted.org/packages/b9/44/5769cb62d4ed055cb17417c0a109a92f007114a4e07f30812a73a4efdb11/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2edc3553362b1c38d9f06242416a5d8e9fe235c204a4072e988ce2e5bb1f69f6", size = 459485, upload-time = "2025-10-14T15:04:50.155Z" }, + { url = "https://files.pythonhosted.org/packages/19/0c/286b6301ded2eccd4ffd0041a1b726afda999926cf720aab63adb68a1e36/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:30f7da3fb3f2844259cba4720c3fc7138eb0f7b659c38f3bfa65084c7fc7abce", size = 488813, upload-time = "2025-10-14T15:04:51.059Z" }, + { url = "https://files.pythonhosted.org/packages/c7/2b/8530ed41112dd4a22f4dcfdb5ccf6a1baad1ff6eed8dc5a5f09e7e8c41c7/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f8979280bdafff686ba5e4d8f97840f929a87ed9cdf133cbbd42f7766774d2aa", size = 594816, upload-time = "2025-10-14T15:04:52.031Z" }, + { url = "https://files.pythonhosted.org/packages/ce/d2/f5f9fb49489f184f18470d4f99f4e862a4b3e9ac2865688eb2099e3d837a/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dcc5c24523771db3a294c77d94771abcfcb82a0e0ee8efd910c37c59ec1b31bb", size = 475186, upload-time = "2025-10-14T15:04:53.064Z" }, + { url = "https://files.pythonhosted.org/packages/cf/68/5707da262a119fb06fbe214d82dd1fe4a6f4af32d2d14de368d0349eb52a/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1db5d7ae38ff20153d542460752ff397fcf5c96090c1230803713cf3147a6803", size = 456812, upload-time = "2025-10-14T15:04:55.174Z" }, + { url = "https://files.pythonhosted.org/packages/66/ab/3cbb8756323e8f9b6f9acb9ef4ec26d42b2109bce830cc1f3468df20511d/watchfiles-1.1.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:28475ddbde92df1874b6c5c8aaeb24ad5be47a11f87cde5a28ef3835932e3e94", size = 630196, upload-time = "2025-10-14T15:04:56.22Z" }, + { url = "https://files.pythonhosted.org/packages/78/46/7152ec29b8335f80167928944a94955015a345440f524d2dfe63fc2f437b/watchfiles-1.1.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:36193ed342f5b9842edd3532729a2ad55c4160ffcfa3700e0d54be496b70dd43", size = 622657, upload-time = "2025-10-14T15:04:57.521Z" }, + { url = "https://files.pythonhosted.org/packages/0a/bf/95895e78dd75efe9a7f31733607f384b42eb5feb54bd2eb6ed57cc2e94f4/watchfiles-1.1.1-cp312-cp312-win32.whl", hash = "sha256:859e43a1951717cc8de7f4c77674a6d389b106361585951d9e69572823f311d9", size = 272042, upload-time = "2025-10-14T15:04:59.046Z" }, + { url = "https://files.pythonhosted.org/packages/87/0a/90eb755f568de2688cb220171c4191df932232c20946966c27a59c400850/watchfiles-1.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:91d4c9a823a8c987cce8fa2690923b069966dabb196dd8d137ea2cede885fde9", size = 288410, upload-time = "2025-10-14T15:05:00.081Z" }, + { url = "https://files.pythonhosted.org/packages/36/76/f322701530586922fbd6723c4f91ace21364924822a8772c549483abed13/watchfiles-1.1.1-cp312-cp312-win_arm64.whl", hash = "sha256:a625815d4a2bdca61953dbba5a39d60164451ef34c88d751f6c368c3ea73d404", size = 278209, upload-time = "2025-10-14T15:05:01.168Z" }, + { url = "https://files.pythonhosted.org/packages/bb/f4/f750b29225fe77139f7ae5de89d4949f5a99f934c65a1f1c0b248f26f747/watchfiles-1.1.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:130e4876309e8686a5e37dba7d5e9bc77e6ed908266996ca26572437a5271e18", size = 404321, upload-time = "2025-10-14T15:05:02.063Z" }, + { url = "https://files.pythonhosted.org/packages/2b/f9/f07a295cde762644aa4c4bb0f88921d2d141af45e735b965fb2e87858328/watchfiles-1.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5f3bde70f157f84ece3765b42b4a52c6ac1a50334903c6eaf765362f6ccca88a", size = 391783, upload-time = "2025-10-14T15:05:03.052Z" }, + { url = "https://files.pythonhosted.org/packages/bc/11/fc2502457e0bea39a5c958d86d2cb69e407a4d00b85735ca724bfa6e0d1a/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:14e0b1fe858430fc0251737ef3824c54027bedb8c37c38114488b8e131cf8219", size = 449279, upload-time = "2025-10-14T15:05:04.004Z" }, + { url = "https://files.pythonhosted.org/packages/e3/1f/d66bc15ea0b728df3ed96a539c777acfcad0eb78555ad9efcaa1274688f0/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f27db948078f3823a6bb3b465180db8ebecf26dd5dae6f6180bd87383b6b4428", size = 459405, upload-time = "2025-10-14T15:05:04.942Z" }, + { url = "https://files.pythonhosted.org/packages/be/90/9f4a65c0aec3ccf032703e6db02d89a157462fbb2cf20dd415128251cac0/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:059098c3a429f62fc98e8ec62b982230ef2c8df68c79e826e37b895bc359a9c0", size = 488976, upload-time = "2025-10-14T15:05:05.905Z" }, + { url = "https://files.pythonhosted.org/packages/37/57/ee347af605d867f712be7029bb94c8c071732a4b44792e3176fa3c612d39/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bfb5862016acc9b869bb57284e6cb35fdf8e22fe59f7548858e2f971d045f150", size = 595506, upload-time = "2025-10-14T15:05:06.906Z" }, + { url = "https://files.pythonhosted.org/packages/a8/78/cc5ab0b86c122047f75e8fc471c67a04dee395daf847d3e59381996c8707/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:319b27255aacd9923b8a276bb14d21a5f7ff82564c744235fc5eae58d95422ae", size = 474936, upload-time = "2025-10-14T15:05:07.906Z" }, + { url = "https://files.pythonhosted.org/packages/62/da/def65b170a3815af7bd40a3e7010bf6ab53089ef1b75d05dd5385b87cf08/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c755367e51db90e75b19454b680903631d41f9e3607fbd941d296a020c2d752d", size = 456147, upload-time = "2025-10-14T15:05:09.138Z" }, + { url = "https://files.pythonhosted.org/packages/57/99/da6573ba71166e82d288d4df0839128004c67d2778d3b566c138695f5c0b/watchfiles-1.1.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:c22c776292a23bfc7237a98f791b9ad3144b02116ff10d820829ce62dff46d0b", size = 630007, upload-time = "2025-10-14T15:05:10.117Z" }, + { url = "https://files.pythonhosted.org/packages/a8/51/7439c4dd39511368849eb1e53279cd3454b4a4dbace80bab88feeb83c6b5/watchfiles-1.1.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:3a476189be23c3686bc2f4321dd501cb329c0a0469e77b7b534ee10129ae6374", size = 622280, upload-time = "2025-10-14T15:05:11.146Z" }, + { url = "https://files.pythonhosted.org/packages/95/9c/8ed97d4bba5db6fdcdb2b298d3898f2dd5c20f6b73aee04eabe56c59677e/watchfiles-1.1.1-cp313-cp313-win32.whl", hash = "sha256:bf0a91bfb5574a2f7fc223cf95eeea79abfefa404bf1ea5e339c0c1560ae99a0", size = 272056, upload-time = "2025-10-14T15:05:12.156Z" }, + { url = "https://files.pythonhosted.org/packages/1f/f3/c14e28429f744a260d8ceae18bf58c1d5fa56b50d006a7a9f80e1882cb0d/watchfiles-1.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:52e06553899e11e8074503c8e716d574adeeb7e68913115c4b3653c53f9bae42", size = 288162, upload-time = "2025-10-14T15:05:13.208Z" }, + { url = "https://files.pythonhosted.org/packages/dc/61/fe0e56c40d5cd29523e398d31153218718c5786b5e636d9ae8ae79453d27/watchfiles-1.1.1-cp313-cp313-win_arm64.whl", hash = "sha256:ac3cc5759570cd02662b15fbcd9d917f7ecd47efe0d6b40474eafd246f91ea18", size = 277909, upload-time = "2025-10-14T15:05:14.49Z" }, + { url = "https://files.pythonhosted.org/packages/79/42/e0a7d749626f1e28c7108a99fb9bf524b501bbbeb9b261ceecde644d5a07/watchfiles-1.1.1-cp313-cp313t-macosx_10_12_x86_64.whl", hash = "sha256:563b116874a9a7ce6f96f87cd0b94f7faf92d08d0021e837796f0a14318ef8da", size = 403389, upload-time = "2025-10-14T15:05:15.777Z" }, + { url = "https://files.pythonhosted.org/packages/15/49/08732f90ce0fbbc13913f9f215c689cfc9ced345fb1bcd8829a50007cc8d/watchfiles-1.1.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:3ad9fe1dae4ab4212d8c91e80b832425e24f421703b5a42ef2e4a1e215aff051", size = 389964, upload-time = "2025-10-14T15:05:16.85Z" }, + { url = "https://files.pythonhosted.org/packages/27/0d/7c315d4bd5f2538910491a0393c56bf70d333d51bc5b34bee8e68e8cea19/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ce70f96a46b894b36eba678f153f052967a0d06d5b5a19b336ab0dbbd029f73e", size = 448114, upload-time = "2025-10-14T15:05:17.876Z" }, + { url = "https://files.pythonhosted.org/packages/c3/24/9e096de47a4d11bc4df41e9d1e61776393eac4cb6eb11b3e23315b78b2cc/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cb467c999c2eff23a6417e58d75e5828716f42ed8289fe6b77a7e5a91036ca70", size = 460264, upload-time = "2025-10-14T15:05:18.962Z" }, + { url = "https://files.pythonhosted.org/packages/cc/0f/e8dea6375f1d3ba5fcb0b3583e2b493e77379834c74fd5a22d66d85d6540/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:836398932192dae4146c8f6f737d74baeac8b70ce14831a239bdb1ca882fc261", size = 487877, upload-time = "2025-10-14T15:05:20.094Z" }, + { url = "https://files.pythonhosted.org/packages/ac/5b/df24cfc6424a12deb41503b64d42fbea6b8cb357ec62ca84a5a3476f654a/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:743185e7372b7bc7c389e1badcc606931a827112fbbd37f14c537320fca08620", size = 595176, upload-time = "2025-10-14T15:05:21.134Z" }, + { url = "https://files.pythonhosted.org/packages/8f/b5/853b6757f7347de4e9b37e8cc3289283fb983cba1ab4d2d7144694871d9c/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:afaeff7696e0ad9f02cbb8f56365ff4686ab205fcf9c4c5b6fdfaaa16549dd04", size = 473577, upload-time = "2025-10-14T15:05:22.306Z" }, + { url = "https://files.pythonhosted.org/packages/e1/f7/0a4467be0a56e80447c8529c9fce5b38eab4f513cb3d9bf82e7392a5696b/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3f7eb7da0eb23aa2ba036d4f616d46906013a68caf61b7fdbe42fc8b25132e77", size = 455425, upload-time = "2025-10-14T15:05:23.348Z" }, + { url = "https://files.pythonhosted.org/packages/8e/e0/82583485ea00137ddf69bc84a2db88bd92ab4a6e3c405e5fb878ead8d0e7/watchfiles-1.1.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:831a62658609f0e5c64178211c942ace999517f5770fe9436be4c2faeba0c0ef", size = 628826, upload-time = "2025-10-14T15:05:24.398Z" }, + { url = "https://files.pythonhosted.org/packages/28/9a/a785356fccf9fae84c0cc90570f11702ae9571036fb25932f1242c82191c/watchfiles-1.1.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:f9a2ae5c91cecc9edd47e041a930490c31c3afb1f5e6d71de3dc671bfaca02bf", size = 622208, upload-time = "2025-10-14T15:05:25.45Z" }, + { url = "https://files.pythonhosted.org/packages/c3/f4/0872229324ef69b2c3edec35e84bd57a1289e7d3fe74588048ed8947a323/watchfiles-1.1.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:d1715143123baeeaeadec0528bb7441103979a1d5f6fd0e1f915383fea7ea6d5", size = 404315, upload-time = "2025-10-14T15:05:26.501Z" }, + { url = "https://files.pythonhosted.org/packages/7b/22/16d5331eaed1cb107b873f6ae1b69e9ced582fcf0c59a50cd84f403b1c32/watchfiles-1.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:39574d6370c4579d7f5d0ad940ce5b20db0e4117444e39b6d8f99db5676c52fd", size = 390869, upload-time = "2025-10-14T15:05:27.649Z" }, + { url = "https://files.pythonhosted.org/packages/b2/7e/5643bfff5acb6539b18483128fdc0ef2cccc94a5b8fbda130c823e8ed636/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7365b92c2e69ee952902e8f70f3ba6360d0d596d9299d55d7d386df84b6941fb", size = 449919, upload-time = "2025-10-14T15:05:28.701Z" }, + { url = "https://files.pythonhosted.org/packages/51/2e/c410993ba5025a9f9357c376f48976ef0e1b1aefb73b97a5ae01a5972755/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bfff9740c69c0e4ed32416f013f3c45e2ae42ccedd1167ef2d805c000b6c71a5", size = 460845, upload-time = "2025-10-14T15:05:30.064Z" }, + { url = "https://files.pythonhosted.org/packages/8e/a4/2df3b404469122e8680f0fcd06079317e48db58a2da2950fb45020947734/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b27cf2eb1dda37b2089e3907d8ea92922b673c0c427886d4edc6b94d8dfe5db3", size = 489027, upload-time = "2025-10-14T15:05:31.064Z" }, + { url = "https://files.pythonhosted.org/packages/ea/84/4587ba5b1f267167ee715b7f66e6382cca6938e0a4b870adad93e44747e6/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:526e86aced14a65a5b0ec50827c745597c782ff46b571dbfe46192ab9e0b3c33", size = 595615, upload-time = "2025-10-14T15:05:32.074Z" }, + { url = "https://files.pythonhosted.org/packages/6a/0f/c6988c91d06e93cd0bb3d4a808bcf32375ca1904609835c3031799e3ecae/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:04e78dd0b6352db95507fd8cb46f39d185cf8c74e4cf1e4fbad1d3df96faf510", size = 474836, upload-time = "2025-10-14T15:05:33.209Z" }, + { url = "https://files.pythonhosted.org/packages/b4/36/ded8aebea91919485b7bbabbd14f5f359326cb5ec218cd67074d1e426d74/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5c85794a4cfa094714fb9c08d4a218375b2b95b8ed1666e8677c349906246c05", size = 455099, upload-time = "2025-10-14T15:05:34.189Z" }, + { url = "https://files.pythonhosted.org/packages/98/e0/8c9bdba88af756a2fce230dd365fab2baf927ba42cd47521ee7498fd5211/watchfiles-1.1.1-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:74d5012b7630714b66be7b7b7a78855ef7ad58e8650c73afc4c076a1f480a8d6", size = 630626, upload-time = "2025-10-14T15:05:35.216Z" }, + { url = "https://files.pythonhosted.org/packages/2a/84/a95db05354bf2d19e438520d92a8ca475e578c647f78f53197f5a2f17aaf/watchfiles-1.1.1-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:8fbe85cb3201c7d380d3d0b90e63d520f15d6afe217165d7f98c9c649654db81", size = 622519, upload-time = "2025-10-14T15:05:36.259Z" }, + { url = "https://files.pythonhosted.org/packages/1d/ce/d8acdc8de545de995c339be67711e474c77d643555a9bb74a9334252bd55/watchfiles-1.1.1-cp314-cp314-win32.whl", hash = "sha256:3fa0b59c92278b5a7800d3ee7733da9d096d4aabcfabb9a928918bd276ef9b9b", size = 272078, upload-time = "2025-10-14T15:05:37.63Z" }, + { url = "https://files.pythonhosted.org/packages/c4/c9/a74487f72d0451524be827e8edec251da0cc1fcf111646a511ae752e1a3d/watchfiles-1.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:c2047d0b6cea13b3316bdbafbfa0c4228ae593d995030fda39089d36e64fc03a", size = 287664, upload-time = "2025-10-14T15:05:38.95Z" }, + { url = "https://files.pythonhosted.org/packages/df/b8/8ac000702cdd496cdce998c6f4ee0ca1f15977bba51bdf07d872ebdfc34c/watchfiles-1.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:842178b126593addc05acf6fce960d28bc5fae7afbaa2c6c1b3a7b9460e5be02", size = 277154, upload-time = "2025-10-14T15:05:39.954Z" }, + { url = "https://files.pythonhosted.org/packages/47/a8/e3af2184707c29f0f14b1963c0aace6529f9d1b8582d5b99f31bbf42f59e/watchfiles-1.1.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:88863fbbc1a7312972f1c511f202eb30866370ebb8493aef2812b9ff28156a21", size = 403820, upload-time = "2025-10-14T15:05:40.932Z" }, + { url = "https://files.pythonhosted.org/packages/c0/ec/e47e307c2f4bd75f9f9e8afbe3876679b18e1bcec449beca132a1c5ffb2d/watchfiles-1.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:55c7475190662e202c08c6c0f4d9e345a29367438cf8e8037f3155e10a88d5a5", size = 390510, upload-time = "2025-10-14T15:05:41.945Z" }, + { url = "https://files.pythonhosted.org/packages/d5/a0/ad235642118090f66e7b2f18fd5c42082418404a79205cdfca50b6309c13/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f53fa183d53a1d7a8852277c92b967ae99c2d4dcee2bfacff8868e6e30b15f7", size = 448408, upload-time = "2025-10-14T15:05:43.385Z" }, + { url = "https://files.pythonhosted.org/packages/df/85/97fa10fd5ff3332ae17e7e40e20784e419e28521549780869f1413742e9d/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6aae418a8b323732fa89721d86f39ec8f092fc2af67f4217a2b07fd3e93c6101", size = 458968, upload-time = "2025-10-14T15:05:44.404Z" }, + { url = "https://files.pythonhosted.org/packages/47/c2/9059c2e8966ea5ce678166617a7f75ecba6164375f3b288e50a40dc6d489/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f096076119da54a6080e8920cbdaac3dbee667eb91dcc5e5b78840b87415bd44", size = 488096, upload-time = "2025-10-14T15:05:45.398Z" }, + { url = "https://files.pythonhosted.org/packages/94/44/d90a9ec8ac309bc26db808a13e7bfc0e4e78b6fc051078a554e132e80160/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:00485f441d183717038ed2e887a7c868154f216877653121068107b227a2f64c", size = 596040, upload-time = "2025-10-14T15:05:46.502Z" }, + { url = "https://files.pythonhosted.org/packages/95/68/4e3479b20ca305cfc561db3ed207a8a1c745ee32bf24f2026a129d0ddb6e/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a55f3e9e493158d7bfdb60a1165035f1cf7d320914e7b7ea83fe22c6023b58fc", size = 473847, upload-time = "2025-10-14T15:05:47.484Z" }, + { url = "https://files.pythonhosted.org/packages/4f/55/2af26693fd15165c4ff7857e38330e1b61ab8c37d15dc79118cdba115b7a/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c91ed27800188c2ae96d16e3149f199d62f86c7af5f5f4d2c61a3ed8cd3666c", size = 455072, upload-time = "2025-10-14T15:05:48.928Z" }, + { url = "https://files.pythonhosted.org/packages/66/1d/d0d200b10c9311ec25d2273f8aad8c3ef7cc7ea11808022501811208a750/watchfiles-1.1.1-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:311ff15a0bae3714ffb603e6ba6dbfba4065ab60865d15a6ec544133bdb21099", size = 629104, upload-time = "2025-10-14T15:05:49.908Z" }, + { url = "https://files.pythonhosted.org/packages/e3/bd/fa9bb053192491b3867ba07d2343d9f2252e00811567d30ae8d0f78136fe/watchfiles-1.1.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:a916a2932da8f8ab582f242c065f5c81bed3462849ca79ee357dd9551b0e9b01", size = 622112, upload-time = "2025-10-14T15:05:50.941Z" }, +] + +[[package]] +name = "websockets" +version = "15.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/e6/26d09fab466b7ca9c7737474c52be4f76a40301b08362eb2dbc19dcc16c1/websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee", size = 177016, upload-time = "2025-03-05T20:03:41.606Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/6b/4545a0d843594f5d0771e86463606a3988b5a09ca5123136f8a76580dd63/websockets-15.0.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3e90baa811a5d73f3ca0bcbf32064d663ed81318ab225ee4f427ad4e26e5aff3", size = 175437, upload-time = "2025-03-05T20:02:16.706Z" }, + { url = "https://files.pythonhosted.org/packages/f4/71/809a0f5f6a06522af902e0f2ea2757f71ead94610010cf570ab5c98e99ed/websockets-15.0.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:592f1a9fe869c778694f0aa806ba0374e97648ab57936f092fd9d87f8bc03665", size = 173096, upload-time = "2025-03-05T20:02:18.832Z" }, + { url = "https://files.pythonhosted.org/packages/3d/69/1a681dd6f02180916f116894181eab8b2e25b31e484c5d0eae637ec01f7c/websockets-15.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0701bc3cfcb9164d04a14b149fd74be7347a530ad3bbf15ab2c678a2cd3dd9a2", size = 173332, upload-time = "2025-03-05T20:02:20.187Z" }, + { url = "https://files.pythonhosted.org/packages/a6/02/0073b3952f5bce97eafbb35757f8d0d54812b6174ed8dd952aa08429bcc3/websockets-15.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8b56bdcdb4505c8078cb6c7157d9811a85790f2f2b3632c7d1462ab5783d215", size = 183152, upload-time = "2025-03-05T20:02:22.286Z" }, + { url = "https://files.pythonhosted.org/packages/74/45/c205c8480eafd114b428284840da0b1be9ffd0e4f87338dc95dc6ff961a1/websockets-15.0.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0af68c55afbd5f07986df82831c7bff04846928ea8d1fd7f30052638788bc9b5", size = 182096, upload-time = "2025-03-05T20:02:24.368Z" }, + { url = "https://files.pythonhosted.org/packages/14/8f/aa61f528fba38578ec553c145857a181384c72b98156f858ca5c8e82d9d3/websockets-15.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64dee438fed052b52e4f98f76c5790513235efaa1ef7f3f2192c392cd7c91b65", size = 182523, upload-time = "2025-03-05T20:02:25.669Z" }, + { url = "https://files.pythonhosted.org/packages/ec/6d/0267396610add5bc0d0d3e77f546d4cd287200804fe02323797de77dbce9/websockets-15.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d5f6b181bb38171a8ad1d6aa58a67a6aa9d4b38d0f8c5f496b9e42561dfc62fe", size = 182790, upload-time = "2025-03-05T20:02:26.99Z" }, + { url = "https://files.pythonhosted.org/packages/02/05/c68c5adbf679cf610ae2f74a9b871ae84564462955d991178f95a1ddb7dd/websockets-15.0.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:5d54b09eba2bada6011aea5375542a157637b91029687eb4fdb2dab11059c1b4", size = 182165, upload-time = "2025-03-05T20:02:30.291Z" }, + { url = "https://files.pythonhosted.org/packages/29/93/bb672df7b2f5faac89761cb5fa34f5cec45a4026c383a4b5761c6cea5c16/websockets-15.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3be571a8b5afed347da347bfcf27ba12b069d9d7f42cb8c7028b5e98bbb12597", size = 182160, upload-time = "2025-03-05T20:02:31.634Z" }, + { url = "https://files.pythonhosted.org/packages/ff/83/de1f7709376dc3ca9b7eeb4b9a07b4526b14876b6d372a4dc62312bebee0/websockets-15.0.1-cp312-cp312-win32.whl", hash = "sha256:c338ffa0520bdb12fbc527265235639fb76e7bc7faafbb93f6ba80d9c06578a9", size = 176395, upload-time = "2025-03-05T20:02:33.017Z" }, + { url = "https://files.pythonhosted.org/packages/7d/71/abf2ebc3bbfa40f391ce1428c7168fb20582d0ff57019b69ea20fa698043/websockets-15.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:fcd5cf9e305d7b8338754470cf69cf81f420459dbae8a3b40cee57417f4614a7", size = 176841, upload-time = "2025-03-05T20:02:34.498Z" }, + { url = "https://files.pythonhosted.org/packages/cb/9f/51f0cf64471a9d2b4d0fc6c534f323b664e7095640c34562f5182e5a7195/websockets-15.0.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ee443ef070bb3b6ed74514f5efaa37a252af57c90eb33b956d35c8e9c10a1931", size = 175440, upload-time = "2025-03-05T20:02:36.695Z" }, + { url = "https://files.pythonhosted.org/packages/8a/05/aa116ec9943c718905997412c5989f7ed671bc0188ee2ba89520e8765d7b/websockets-15.0.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5a939de6b7b4e18ca683218320fc67ea886038265fd1ed30173f5ce3f8e85675", size = 173098, upload-time = "2025-03-05T20:02:37.985Z" }, + { url = "https://files.pythonhosted.org/packages/ff/0b/33cef55ff24f2d92924923c99926dcce78e7bd922d649467f0eda8368923/websockets-15.0.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:746ee8dba912cd6fc889a8147168991d50ed70447bf18bcda7039f7d2e3d9151", size = 173329, upload-time = "2025-03-05T20:02:39.298Z" }, + { url = "https://files.pythonhosted.org/packages/31/1d/063b25dcc01faa8fada1469bdf769de3768b7044eac9d41f734fd7b6ad6d/websockets-15.0.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:595b6c3969023ecf9041b2936ac3827e4623bfa3ccf007575f04c5a6aa318c22", size = 183111, upload-time = "2025-03-05T20:02:40.595Z" }, + { url = "https://files.pythonhosted.org/packages/93/53/9a87ee494a51bf63e4ec9241c1ccc4f7c2f45fff85d5bde2ff74fcb68b9e/websockets-15.0.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3c714d2fc58b5ca3e285461a4cc0c9a66bd0e24c5da9911e30158286c9b5be7f", size = 182054, upload-time = "2025-03-05T20:02:41.926Z" }, + { url = "https://files.pythonhosted.org/packages/ff/b2/83a6ddf56cdcbad4e3d841fcc55d6ba7d19aeb89c50f24dd7e859ec0805f/websockets-15.0.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f3c1e2ab208db911594ae5b4f79addeb3501604a165019dd221c0bdcabe4db8", size = 182496, upload-time = "2025-03-05T20:02:43.304Z" }, + { url = "https://files.pythonhosted.org/packages/98/41/e7038944ed0abf34c45aa4635ba28136f06052e08fc2168520bb8b25149f/websockets-15.0.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:229cf1d3ca6c1804400b0a9790dc66528e08a6a1feec0d5040e8b9eb14422375", size = 182829, upload-time = "2025-03-05T20:02:48.812Z" }, + { url = "https://files.pythonhosted.org/packages/e0/17/de15b6158680c7623c6ef0db361da965ab25d813ae54fcfeae2e5b9ef910/websockets-15.0.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:756c56e867a90fb00177d530dca4b097dd753cde348448a1012ed6c5131f8b7d", size = 182217, upload-time = "2025-03-05T20:02:50.14Z" }, + { url = "https://files.pythonhosted.org/packages/33/2b/1f168cb6041853eef0362fb9554c3824367c5560cbdaad89ac40f8c2edfc/websockets-15.0.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:558d023b3df0bffe50a04e710bc87742de35060580a293c2a984299ed83bc4e4", size = 182195, upload-time = "2025-03-05T20:02:51.561Z" }, + { url = "https://files.pythonhosted.org/packages/86/eb/20b6cdf273913d0ad05a6a14aed4b9a85591c18a987a3d47f20fa13dcc47/websockets-15.0.1-cp313-cp313-win32.whl", hash = "sha256:ba9e56e8ceeeedb2e080147ba85ffcd5cd0711b89576b83784d8605a7df455fa", size = 176393, upload-time = "2025-03-05T20:02:53.814Z" }, + { url = "https://files.pythonhosted.org/packages/1b/6c/c65773d6cab416a64d191d6ee8a8b1c68a09970ea6909d16965d26bfed1e/websockets-15.0.1-cp313-cp313-win_amd64.whl", hash = "sha256:e09473f095a819042ecb2ab9465aee615bd9c2028e4ef7d933600a8401c79561", size = 176837, upload-time = "2025-03-05T20:02:55.237Z" }, + { url = "https://files.pythonhosted.org/packages/fa/a8/5b41e0da817d64113292ab1f8247140aac61cbf6cfd085d6a0fa77f4984f/websockets-15.0.1-py3-none-any.whl", hash = "sha256:f7a866fbc1e97b5c617ee4116daaa09b722101d4a3c170c787450ba409f9736f", size = 169743, upload-time = "2025-03-05T20:03:39.41Z" }, +] From f052047d65d3149f06599242fd628220e97daa04 Mon Sep 17 00:00:00 2001 From: pany-05 Date: Thu, 30 Oct 2025 15:10:19 +0800 Subject: [PATCH 02/31] [feature] update system prompt --- main/xiaozhi-server/config.yaml | 17 + main/xiaozhi-server/core/connection.py | 117 +++- .../core/providers/llm/openai/openai.py | 239 ++++++- .../core/providers/memory/mem0ai/mem0ai.py | 35 + .../memory/mem_local_short/mem_local_short.py | 55 ++ .../core/providers/tts/elevenlabs/tts.py | 626 ++++++++++++++++++ .../core/providers/tts/stream_adapter.py | 263 ++++++++ main/xiaozhi-server/core/roles/__init__.py | 14 + .../core/roles/data/default.yaml | 38 ++ .../core/roles/data/hospital_assistant.yaml | 66 ++ main/xiaozhi-server/core/roles/factory.py | 70 ++ .../xiaozhi-server/core/roles/local_loader.py | 108 +++ main/xiaozhi-server/core/roles/models.py | 39 ++ .../core/roles/prompts/__init__.py | 5 + .../core/roles/prompts/builder.py | 213 ++++++ .../core/roles/prompts/languages/en.md | 5 + .../core/roles/prompts/languages/zh.md | 6 + .../xiaozhi-server/core/roles/prompts/role.md | 41 ++ .../core/roles/prompts/user_persona.md | 14 + main/xiaozhi-server/core/tokenize/__init__.py | 28 + .../core/tokenize/_basic_sent.py | 79 +++ main/xiaozhi-server/core/utils/dialogue.py | 6 +- .../core/utils/prompt_manager.py | 97 ++- main/xiaozhi-server/core/websocket_server.py | 9 + 24 files changed, 2084 insertions(+), 106 deletions(-) create mode 100644 main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py create mode 100644 main/xiaozhi-server/core/providers/tts/stream_adapter.py create mode 100644 main/xiaozhi-server/core/roles/__init__.py create mode 100644 main/xiaozhi-server/core/roles/data/default.yaml create mode 100644 main/xiaozhi-server/core/roles/data/hospital_assistant.yaml create mode 100644 main/xiaozhi-server/core/roles/factory.py create mode 100644 main/xiaozhi-server/core/roles/local_loader.py create mode 100644 main/xiaozhi-server/core/roles/models.py create mode 100644 main/xiaozhi-server/core/roles/prompts/__init__.py create mode 100644 main/xiaozhi-server/core/roles/prompts/builder.py create mode 100644 main/xiaozhi-server/core/roles/prompts/languages/en.md create mode 100644 main/xiaozhi-server/core/roles/prompts/languages/zh.md create mode 100644 main/xiaozhi-server/core/roles/prompts/role.md create mode 100644 main/xiaozhi-server/core/roles/prompts/user_persona.md create mode 100644 main/xiaozhi-server/core/tokenize/__init__.py create mode 100644 main/xiaozhi-server/core/tokenize/_basic_sent.py diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 248be252e..90e9edb38 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -182,6 +182,23 @@ prompt: | # 默认系统提示词模板文件 prompt_template: agent-base-prompt.txt +# Role 配置 +# 指定要加载的 role 配置文件(位于 core/roles/data/目录) +# 如果不指定或加载失败,将使用 prompt 字段的内容作为 profile +role_id: hospital_assistant + +# 时区配置(用于系统提示词中的时间显示) +# 支持的时区格式:Asia/Shanghai, America/New_York, Europe/London 等 +# 默认:Asia/Shanghai +# 注意:如果 role 配置文件中指定了 timezone,将优先使用 role 配置中的值 +timezone: Asia/Shanghai + +# 语言配置(用于系统提示词中的语言特定提示) +# 支持:zh(中文)、en(英文) +# 默认:zh +# 注意:如果 role 配置文件中指定了 language,将优先使用 role 配置中的值 +language: zh + # 结束语prompt end_prompt: enable: true # 是否开启结束语 diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 92043e9bd..9dc15fcd2 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -439,11 +439,28 @@ class ConnectionHandler: self.logger.bind(tag=TAG).error(f"实例化组件失败: {e}") def _init_prompt_enhancement(self): + """初始化并更新系统提示词""" # 更新上下文信息 self.prompt_manager.update_context_info(self, self.client_ip) + + # 获取用户画像(如果 Memory 模块已初始化) + user_persona = None + if self.memory and hasattr(self.memory, 'get_user_persona'): + try: + user_persona = self.memory.get_user_persona() + if user_persona: + self.logger.bind(tag=TAG).debug(f"获取到用户画像,长度: {len(user_persona)}") + except Exception as e: + self.logger.bind(tag=TAG).warning(f"获取用户画像失败: {e}") + + # 构建增强的系统提示词 enhanced_prompt = self.prompt_manager.build_enhanced_prompt( - self.config["prompt"], self.device_id, self.client_ip + self.config["prompt"], + self.device_id, + self.client_ip, + user_persona=user_persona, ) + if enhanced_prompt: self.change_system_prompt(enhanced_prompt) self.logger.bind(tag=TAG).info("系统提示词已增强更新") @@ -753,24 +770,97 @@ class ConnectionHandler: ) memory_str = future.result() + # 获取对话历史 + dialogue_history = self.dialogue.get_llm_dialogue_with_memory( + memory_str, self.config.get("voiceprint", {}) + ) + if self.intent_type == "function_call" and functions is not None: # 使用支持functions的streaming接口 - llm_responses = self.llm.response_with_functions( - self.session_id, - self.dialogue.get_llm_dialogue_with_memory( - memory_str, self.config.get("voiceprint", {}) - ), - functions=functions, + # response_with_functions 是异步生成器,使用队列在线程间传递 + response_queue = queue.Queue() + stop_flag = threading.Event() + + async def consume_async_generator(): + try: + async_gen = self.llm.response_with_functions( + self.session_id, + dialogue_history, + functions=functions, + ) + async for item in async_gen: + if stop_flag.is_set(): + break + response_queue.put(item) + response_queue.put(None) # 结束标记 + except Exception as e: + self.logger.bind(tag=TAG).error(f"异步生成器消费出错: {e}", exc_info=True) + response_queue.put(None) + response_queue.put(("ERROR", str(e))) + + asyncio.run_coroutine_threadsafe( + consume_async_generator(), self.loop ) + + # 从队列中获取响应 + def get_responses(): + while True: + try: + item = response_queue.get(timeout=300) # 5分钟超时 + if item is None: + break + if isinstance(item, tuple) and item[0] == "ERROR": + raise Exception(item[1]) + yield item + except queue.Empty: + self.logger.bind(tag=TAG).warning("等待 LLM 响应超时") + stop_flag.set() + break + + llm_responses = get_responses() else: - llm_responses = self.llm.response( - self.session_id, - self.dialogue.get_llm_dialogue_with_memory( - memory_str, self.config.get("voiceprint", {}) - ), + # response 也是异步生成器,使用队列在线程间传递 + response_queue = queue.Queue() + stop_flag = threading.Event() + + async def consume_async_generator(): + try: + async_gen = self.llm.response( + self.session_id, + dialogue_history, + ) + async for item in async_gen: + if stop_flag.is_set(): + break + response_queue.put(item) + response_queue.put(None) # 结束标记 + except Exception as e: + self.logger.bind(tag=TAG).error(f"异步生成器消费出错: {e}", exc_info=True) + response_queue.put(None) + response_queue.put(("ERROR", str(e))) + + asyncio.run_coroutine_threadsafe( + consume_async_generator(), self.loop ) + + # 从队列中获取响应 + def get_responses(): + while True: + try: + item = response_queue.get(timeout=300) # 5分钟超时 + if item is None: + break + if isinstance(item, tuple) and item[0] == "ERROR": + raise Exception(item[1]) + yield item + except queue.Empty: + self.logger.bind(tag=TAG).warning("等待 LLM 响应超时") + stop_flag.set() + break + + llm_responses = get_responses() except Exception as e: - self.logger.bind(tag=TAG).error(f"LLM 处理出错 {query}: {e}") + self.logger.bind(tag=TAG).error(f"LLM 处理出错 {query}: {e}", exc_info=True) return None # 处理流式响应 @@ -781,6 +871,7 @@ class ConnectionHandler: content_arguments = "" self.client_abort = False emotion_flag = True + for response in llm_responses: if self.client_abort: break diff --git a/main/xiaozhi-server/core/providers/llm/openai/openai.py b/main/xiaozhi-server/core/providers/llm/openai/openai.py index 5c85c6478..18548e4c2 100644 --- a/main/xiaozhi-server/core/providers/llm/openai/openai.py +++ b/main/xiaozhi-server/core/providers/llm/openai/openai.py @@ -49,33 +49,39 @@ class LLMProvider(LLMProviderBase): self.client = openai.OpenAI(api_key=self.api_key, base_url=self.base_url, timeout=httpx.Timeout(self.timeout)) def response(self, session_id, dialogue, **kwargs): + """ + 同步流式响应方法 + 注意:保持同步以兼容基类和其他 LLM 提供商 + """ try: - responses = self.client.chat.completions.create( + # Create streaming response + # 注意:ChatGLM 等服务可能不支持 responses.create API,改用标准的 chat.completions.create + stream = self.client.chat.completions.create( model=self.model_name, messages=dialogue, stream=True, max_tokens=kwargs.get("max_tokens", self.max_tokens), temperature=kwargs.get("temperature", self.temperature), top_p=kwargs.get("top_p", self.top_p), - frequency_penalty=kwargs.get( - "frequency_penalty", self.frequency_penalty - ), + frequency_penalty=kwargs.get("frequency_penalty", self.frequency_penalty), ) - + is_active = True - for chunk in responses: + + for chunk in stream: try: - # 检查是否存在有效的choice且content不为空 - delta = ( - chunk.choices[0].delta - if getattr(chunk, "choices", None) - else None - ) - content = delta.content if hasattr(delta, "content") else "" - except IndexError: - content = "" - if content: - # 处理标签跨多个chunk的情况 + # Handle response choices + if not hasattr(chunk, "choices") or not chunk.choices: + continue + + delta = chunk.choices[0].delta + content = getattr(delta, "content", None) + + if content is None: + continue + + # Handle thinking tags (for reasoning models like o1) + # Filter out content between ... if "" in content: is_active = False content = content.split("")[0] @@ -84,31 +90,192 @@ class LLMProvider(LLMProviderBase): content = content.split("")[-1] if is_active: yield content + + except (IndexError, AttributeError) as e: + continue + except Exception as e: + logger.bind(tag=TAG).error(f"处理 chunk 时发生未预期错误: {e}", exc_info=True) + continue except Exception as e: - logger.bind(tag=TAG).error(f"Error in response generation: {e}") + logger.bind(tag=TAG).error(f"Error in response generation: {e}", exc_info=True) def response_with_functions(self, session_id, dialogue, functions=None): + """ + 同步流式响应方法(支持函数调用) + 注意:保持同步以兼容基类和其他 LLM 提供商 + """ try: - stream = self.client.chat.completions.create( - model=self.model_name, messages=dialogue, stream=True, tools=functions - ) + # Prepare request parameters + request_params = { + "model": self.model_name, + "messages": dialogue, + "stream": True, + } + + # Add tools/functions if provided + if functions: + request_params["tools"] = functions + + # Create streaming response (同步版本,移除 await) + stream = self.client.chat.completions.create(**request_params) for chunk in stream: - # 检查是否存在有效的choice且content不为空 - if getattr(chunk, "choices", None): - yield chunk.choices[0].delta.content, chunk.choices[ - 0 - ].delta.tool_calls - # 存在 CompletionUsage 消息时,生成 Token 消耗 log - elif isinstance(getattr(chunk, "usage", None), CompletionUsage): - usage_info = getattr(chunk, "usage", None) - logger.bind(tag=TAG).info( - f"Token 消耗:输入 {getattr(usage_info, 'prompt_tokens', '未知')}," - f"输出 {getattr(usage_info, 'completion_tokens', '未知')}," - f"共计 {getattr(usage_info, 'total_tokens', '未知')}" - ) + try: + # Handle token usage reporting + if hasattr(chunk, "usage") and isinstance(chunk.usage, CompletionUsage): + usage_info = chunk.usage + logger.bind(tag=TAG).info( + f"Token 消耗:输入 {getattr(usage_info, 'prompt_tokens', '未知')}," + f"输出 {getattr(usage_info, 'completion_tokens', '未知')}," + f"共计 {getattr(usage_info, 'total_tokens', '未知')}" + ) + continue + + # Handle response choices + if not hasattr(chunk, "choices") or not chunk.choices: + continue + + delta = chunk.choices[0].delta + + # Extract content and tool calls + content = getattr(delta, "content", None) + tool_calls = getattr(delta, "tool_calls", None) + + # Yield the chunk + yield content, tool_calls + + except (IndexError, AttributeError) as e: + continue + except openai.APIError as e: + error_msg = f"OpenAI API error: {e.message if hasattr(e, 'message') else str(e)}" + logger.bind(tag=TAG).error(error_msg) + yield f"【API错误: {error_msg}】", None + + except openai.APIConnectionError as e: + error_msg = f"Connection error: {str(e)}" + logger.bind(tag=TAG).error(error_msg) + yield f"【连接错误: 无法连接到服务】", None + + except openai.RateLimitError as e: + error_msg = f"Rate limit exceeded: {str(e)}" + logger.bind(tag=TAG).error(error_msg) + yield f"【请求过于频繁,请稍后再试】", None + except Exception as e: - logger.bind(tag=TAG).error(f"Error in function call streaming: {e}") - yield f"【OpenAI服务响应异常: {e}】", None + error_msg = f"Unexpected error in function calling: {type(e).__name__}: {str(e)}" + logger.bind(tag=TAG).error(error_msg, exc_info=True) + yield f"【OpenAI服务响应异常: {str(e)}】", None + + async def response_stream( + self, + chat_ctx: ChatContext, + **kwargs: Any + ) -> AsyncGenerator[ChatChunk, None]: + """ + New streaming interface using standard protocol + + This method implements the new standard interface defined in LLMProviderBase. + It uses: + - ChatContext as input (standard dialogue protocol) + - ChatChunk as output (standard streaming protocol) + - OpenAI Responses API (modern response.create) + + Args: + chat_ctx: Standard ChatContext with dialogue history + **kwargs: Additional options: + - max_output_tokens: Override max tokens + - temperature: Override temperature + - top_p: Override top_p + - frequency_penalty: Override frequency penalty + + Yields: + ChatChunk: Standardized streaming chunks with deltas and usage + + Example: + async for chunk in provider.response_stream(chat_ctx): + if chunk.delta and chunk.delta.content: + print(chunk.delta.content) + if chunk.usage: + print(f"Tokens: {chunk.usage.total_tokens}") + """ + try: + # 1. Convert ChatContext to OpenAI format + messages, _ = chat_ctx.to_provider_format(format="openai") + + logger.bind(tag=TAG).debug( + f"Starting streaming with model={self.model_name}, " + f"messages_count={len(messages)}" + ) + + # 2. Prepare request parameters + max_output_tokens = kwargs.get("max_output_tokens", self.max_output_tokens) + temperature = kwargs.get("temperature", self.temperature) + top_p = kwargs.get("top_p", self.top_p) + frequency_penalty = kwargs.get("frequency_penalty", self.frequency_penalty) + + # 3. Call OpenAI Responses API + # TODO: system instruction needs to be added + stream: AsyncStream[ResponseStreamEvent] = await self.client.responses.create( + input=messages, + model=self.model_name, + stream=True, + max_output_tokens=max_output_tokens, + temperature=temperature, + top_p=top_p, + frequency_penalty=frequency_penalty, + ) + + # 4. Parse stream and yield ChatChunk (focus on output_item.done + completed) + async for event in stream: + try: + chunk = self._parse_response_event(event) + if chunk: + yield chunk + except (IndexError, AttributeError) as e: + logger.bind(tag=TAG).debug(f"Skipping malformed event: {e}") + continue + + logger.bind(tag=TAG).debug("Stream completed successfully") + + except openai.APIError as e: + error_msg = f"OpenAI API error: {e.message if hasattr(e, 'message') else str(e)}" + logger.bind(tag=TAG).error(error_msg) + # Yield error chunk + yield ChatChunk( + delta=ChatDelta( + role="assistant", + content=f"【API错误: {error_msg}】" + ) + ) + + except openai.APIConnectionError as e: + error_msg = f"Connection error: {str(e)}" + logger.bind(tag=TAG).error(error_msg) + yield ChatChunk( + delta=ChatDelta( + role="assistant", + content="【连接错误: 无法连接到服务】" + ) + ) + + except openai.RateLimitError as e: + error_msg = f"Rate limit exceeded: {str(e)}" + logger.bind(tag=TAG).error(error_msg) + yield ChatChunk( + delta=ChatDelta( + role="assistant", + content="【请求过于频繁,请稍后再试】" + ) + ) + + except Exception as e: + error_msg = f"Unexpected error: {type(e).__name__}: {str(e)}" + logger.bind(tag=TAG).error(error_msg) + yield ChatChunk( + delta=ChatDelta( + role="assistant", + content=f"【服务异常: {str(e)}】" + ) + ) diff --git a/main/xiaozhi-server/core/providers/memory/mem0ai/mem0ai.py b/main/xiaozhi-server/core/providers/memory/mem0ai/mem0ai.py index d61d73f3e..c4f7d3f9d 100644 --- a/main/xiaozhi-server/core/providers/memory/mem0ai/mem0ai.py +++ b/main/xiaozhi-server/core/providers/memory/mem0ai/mem0ai.py @@ -1,4 +1,5 @@ import traceback +from typing import Optional from ..base import MemoryProviderBase, logger from mem0 import MemoryClient @@ -85,3 +86,37 @@ class MemoryProvider(MemoryProviderBase): except Exception as e: logger.bind(tag=TAG).error(f"查询记忆失败: {str(e)}") return "" + + def get_user_persona(self) -> Optional[str]: + """获取格式化的用户画像信息(用于 prompt) + + Returns: + 格式化后的用户画像字符串,如果无记忆则返回 None + """ + if not self.use_mem0: + return None + + try: + # 使用通用查询获取所有记忆 + results = self.client.search( + "user information, preferences, background, personal details", + user_id=self.role_id, + output_format=self.api_version, + limit=10 # 限制返回数量 + ) + + if not results or "results" not in results: + return None + + # 格式化记忆条目 + persona_items = [] + for entry in results["results"]: + memory = entry.get("memory", "") + if memory: + persona_items.append(f"- {memory}") + + return "\n".join(persona_items) if persona_items else None + + except Exception as e: + logger.bind(tag=TAG).debug(f"获取用户画像失败: {str(e)}") + return None diff --git a/main/xiaozhi-server/core/providers/memory/mem_local_short/mem_local_short.py b/main/xiaozhi-server/core/providers/memory/mem_local_short/mem_local_short.py index e4486b82c..10e3cfab2 100644 --- a/main/xiaozhi-server/core/providers/memory/mem_local_short/mem_local_short.py +++ b/main/xiaozhi-server/core/providers/memory/mem_local_short/mem_local_short.py @@ -3,6 +3,7 @@ import time import json import os import yaml +from typing import Optional from config.config_loader import get_project_dir from config.manage_api_client import save_mem_local_short from core.utils.util import check_model_key @@ -200,3 +201,57 @@ class MemoryProvider(MemoryProviderBase): async def query_memory(self, query: str) -> str: return self.short_memory + + def get_user_persona(self) -> Optional[str]: + """获取格式化的用户画像信息(用于 prompt) + + Returns: + 格式化后的用户画像字符串,如果无记忆则返回 None + """ + if not self.short_memory: + return None + + try: + # 尝试解析 JSON 格式的记忆 + memory_data = json.loads(self.short_memory) + + # 提取关键信息 + persona_items = [] + + # 提取身份信息 + if "时空档案" in memory_data: + identity = memory_data["时空档案"].get("身份图谱", {}) + if identity.get("现用名"): + persona_items.append(f"- 名字:{identity['现用名']}") + if identity.get("特征标记"): + tags = identity["特征标记"] + if isinstance(tags, list) and tags: + persona_items.append(f"- 特征:{', '.join(tags)}") + + # 提取记忆立方中的关键事件 + if "时空档案" in memory_data and "记忆立方" in memory_data["时空档案"]: + events = memory_data["时空档案"]["记忆立方"] + if isinstance(events, list) and events: + persona_items.append("\n重要事件:") + for event in events[:5]: # 只取前5个事件 + if isinstance(event, dict) and event.get("事件"): + persona_items.append(f" - {event['事件']}") + + # 提取高光语录 + if "高光语录" in memory_data and memory_data["高光语录"]: + quotes = memory_data["高光语录"] + if isinstance(quotes, list) and quotes: + persona_items.append("\n高光语录:") + for quote in quotes[:3]: # 只取前3条 + if quote: + persona_items.append(f" - {quote}") + + return "\n".join(persona_items) if persona_items else None + + except (json.JSONDecodeError, KeyError, TypeError) as e: + # 如果解析失败,可能是纯文本格式,直接返回 + logger.bind(tag=TAG).debug(f"记忆不是 JSON 格式,使用原始文本: {e}") + # 如果 short_memory 是纯文本,直接返回(但限制长度) + if isinstance(self.short_memory, str) and len(self.short_memory) > 0: + return self.short_memory[:500] # 限制长度避免 prompt 过长 + return None diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py b/main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py new file mode 100644 index 000000000..f79614b78 --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py @@ -0,0 +1,626 @@ +from __future__ import annotations + +""" +ElevenLabs TTS Implementation + +Provides WebSocket-based streaming text-to-speech using ElevenLabs' multi-stream API. +Supports multiple concurrent synthesis streams over a single WebSocket connection. +""" + +""" +TODO: change api to elevenlabs SDK using streaming API +""" + +import asyncio +import base64 +import dataclasses +import json +import os +import weakref +from dataclasses import dataclass +from typing import Any, Union + +import aiohttp +from typing import Optional + +from config.logger import setup_logging +from core.tokenize import SentenceTokenizer, WordTokenizer, blingfire +from core.utils.aio import Chan, cancel_and_wait +from core.utils.short_uuid import shortuuid +from core.utils.http_context import http_session +from core.utils.errors import ( + APIConnectionError, + APITimeoutError, + APIStatusError, +) +from core.utils.types import ( + APIConnectOptions, + DEFAULT_API_CONNECT_OPTIONS, +) + +import core.providers.tts.base as tts +from ..emitter import AudioEmitter +from .models import ( + API_BASE_URL, + DEFAULT_VOICE_ID, + TTSEncoding, + TTSModels, + Voice, + VoiceSettings, + WS_INACTIVITY_TIMEOUT, +) + +logger = setup_logging() + + +def _sample_rate_from_format(output_format: TTSEncoding) -> int: + """Extract sample rate from encoding format string""" + if output_format.startswith("mp3_"): + return int(output_format.split("_")[1]) + elif output_format.startswith("pcm_"): + return int(output_format.split("_")[1]) + elif output_format.startswith("ulaw_"): + return int(output_format.split("_")[1]) + return 22050 # default + + +@dataclass +class _TTSOptions: + """Internal configuration for ElevenLabs TTS""" + api_key: str + voice_id: str + voice_settings: VoiceSettings | None + model: TTSModels | str + base_url: str + encoding: TTSEncoding + sample_rate: int + word_tokenizer: WordTokenizer | SentenceTokenizer + inactivity_timeout: int + auto_mode: bool + + def get_ws_url(self) -> str: + """Get WebSocket URL for multi-stream API""" + base = self.base_url.replace("http://", "ws://").replace("https://", "wss://") + params = [ + f"model_id={self.model}", + f"output_format={self.encoding}", + ] + if self.auto_mode: + params.append("auto_mode=true") + params.append(f"inactivity_timeout={self.inactivity_timeout}") + + url = f"{base}/text-to-speech/{self.voice_id}/multi-stream-input?" + url += "&".join(params) + return url + + +class TTS(tts.TTS): + """ + ElevenLabs TTS Provider + + Provides high-quality, emotionally rich text-to-speech with voice cloning support. + Uses multi-stream WebSocket API for efficient concurrent synthesis. + + Example: + tts = elevenlabs.TTS( + api_key="your-api-key", + voice_id="voice-id", + model="eleven_turbo_v2_5", + ) + + # Streaming synthesis + stream = tts.stream() + stream.push_text("Hello world!") + stream.end_input() + + async for audio in stream: + # Process audio + pass + """ + + def __init__( + self, + *, + api_key: str | None = None, + voice_id: str = DEFAULT_VOICE_ID, + voice_settings: VoiceSettings | None = None, + model: TTSModels | str = "eleven_multilingual_v2", + encoding: TTSEncoding = "pcm_16000", + word_tokenizer: WordTokenizer | SentenceTokenizer | None = None, + inactivity_timeout: int = WS_INACTIVITY_TIMEOUT, + auto_mode: Optional[bool] = None, + base_url: str = API_BASE_URL, + ) -> None: + """ + Initialize ElevenLabs TTS. + + Args: + api_key: ElevenLabs API key. If not provided, reads from ELEVEN_API_KEY env var + voice_id: Voice ID to use (default: Rachel voice) + voice_settings: Voice settings for fine-tuning quality + model: TTS model to use (default: "eleven_multilingual_v2") + encoding: Audio encoding format (default: "pcm_16000") + word_tokenizer: Word/sentence tokenizer (default: blingfire for auto_mode) + inactivity_timeout: WebSocket inactivity timeout in seconds + auto_mode: Enable auto mode for optimized latency (recommended) + base_url: API base URL (default: https://api.elevenlabs.io/v1) + """ + sample_rate = _sample_rate_from_format(encoding) + + super().__init__( + capabilities=tts.TTSCapabilities(streaming=True), + sample_rate=sample_rate, + num_channels=1, + ) + + # Validate API key + elevenlabs_api_key = api_key or os.environ.get("ELEVEN_API_KEY") + if not elevenlabs_api_key: + raise ValueError( + "ElevenLabs API key is required. " + "Provide via api_key parameter or set ELEVEN_API_KEY environment variable" + ) + + # Configure tokenizer + if not word_tokenizer: + if auto_mode: + word_tokenizer = blingfire.SentenceTokenizer() + else: + from core.tokenize.basic import WordTokenizer as BasicWordTokenizer + word_tokenizer = BasicWordTokenizer(ignore_punctuation=False) + + # Store options + self._opts = _TTSOptions( + api_key=elevenlabs_api_key, + voice_id=voice_id, + voice_settings=voice_settings, + model=model, + base_url=base_url, + encoding=encoding, + sample_rate=sample_rate, + word_tokenizer=word_tokenizer, + inactivity_timeout=inactivity_timeout, + auto_mode=auto_mode, + ) + self._session = http_session() + # Connection management + self._current_connection: _Connection | None = None + self._connection_lock = asyncio.Lock() + + # Track active streams + self._streams: weakref.WeakSet[SynthesizeStream] = weakref.WeakSet() + + @property + def model(self) -> str: + """Get the model name""" + return self._opts.model + + @property + def provider(self) -> str: + """Get the provider name""" + return "ElevenLabs" + + def _ensure_session(self) -> aiohttp.ClientSession: + """Ensure HTTP session exists""" + return http_session() + + async def current_connection(self) -> _Connection: + """Get or create the current WebSocket connection""" + async with self._connection_lock: + if ( + self._current_connection + and self._current_connection.is_current + and not self._current_connection._closed + ): + return self._current_connection + + # Create new connection + session = self._ensure_session() + conn = _Connection(self._opts, session) + await conn.connect() + self._current_connection = conn + return conn + + async def list_voices(self) -> list[Voice]: + """List available voices from ElevenLabs API""" + session = self._ensure_session() + url = f"{self._opts.base_url}/voices" + headers = {"xi-api-key": self._opts.api_key} + + async with session.get(url, headers=headers) as resp: + resp.raise_for_status() + data = await resp.json() + + voices = [] + for voice_data in data.get("voices", []): + voices.append( + Voice( + id=voice_data["voice_id"], + name=voice_data["name"], + category=voice_data["category"], + ) + ) + return voices + + def stream(self, *, conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS) -> SynthesizeStream: + """ + Create a streaming synthesis session. + + Returns: + SynthesizeStream for incremental text input + """ + stream = SynthesizeStream(tts=self, conn_options=conn_options) + self._streams.add(stream) + return stream + + async def aclose(self) -> None: + """Close TTS provider and cleanup resources""" + # Close all active streams + for stream in list(self._streams): + await stream.aclose() + self._streams.clear() + + # Close connection + if self._current_connection: + await self._current_connection.aclose() + self._current_connection = None + + +class SynthesizeStream(tts.SynthesizeStream): + """Streaming synthesis using WebSocket (multi-stream)""" + + def __init__( + self, *, tts: TTS, conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS + ) -> None: + super().__init__(tts=tts, conn_options=conn_options) + self._tts: TTS = tts + self._sent_tokenizer_stream = self._tts._opts.word_tokenizer.stream() + + async def aclose(self) -> None: + """Close stream and cleanup""" + await self._sent_tokenizer_stream.aclose() + await super().aclose() + + async def _run(self, output_emitter: AudioEmitter) -> None: + """ + Streaming synthesis implementation using multi-stream WebSocket. + + This method: + 1. Connects to the shared WebSocket connection + 2. Registers this stream with the connection + 3. Sets up tokenizer + 4. Runs two parallel tasks: + - _input_task: Reads from input_ch → tokenizer + - _sentence_task: Tokenizer → Connection (which sends to WebSocket) + 5. The connection's recv loop handles audio data and routes it to this stream's emitter + """ + opts = self._tts._opts + request_id = shortuuid() + context_id = shortuuid() # Generate context_id upfront for registration + + # Initialize output emitter + output_emitter.initialize( + request_id=request_id, + sample_rate=opts.sample_rate, + num_channels=1, + stream=True, + ) + + # Get shared connection + try: + connection = await asyncio.wait_for( + self._tts.current_connection(), timeout=10 + ) + except asyncio.TimeoutError as e: + raise APITimeoutError("Could not connect to ElevenLabs", timeout=10) from e + except Exception as e: + raise APIConnectionError(f"Could not connect to ElevenLabs: {e}") from e + + # Create waiter for completion + waiter: asyncio.Future[None] = asyncio.get_event_loop().create_future() + # Register stream with context_id + connection.register_stream(context_id, output_emitter, waiter) + + # Define tasks + async def _input_task() -> None: + """Forward input from input_ch to tokenizer""" + try: + async for data in self._input_ch: + if isinstance(data, self._FlushSentinel): + self._sent_tokenizer_stream.flush() + continue + self._sent_tokenizer_stream.push_text(data) + finally: + self._sent_tokenizer_stream.end_input() + + async def _sentence_task() -> None: + """Send tokenized sentences to connection""" + try: + async for sentence_ev in self._sent_tokenizer_stream: + text = sentence_ev.token + formatted_text = f"{text} " # Always end with space + connection.send_content(_SynthesizeContent(context_id, formatted_text)) + finally: + connection.send_content(_SynthesizeContent(context_id, "", flush=True)) + connection.close_context(context_id) + + # Run tasks + input_t = asyncio.create_task(_input_task(), name="elevenlabs_input") + sentence_t = asyncio.create_task(_sentence_task(), name="elevenlabs_sentence") + + try: + await waiter + except asyncio.TimeoutError as e: + raise TimeoutError("ElevenLabs synthesis timed out") from e + except Exception as e: + logger.bind(tag=__name__).error(f"Synthesis error: {e}") + raise + finally: + await cancel_and_wait(input_t, sentence_t) + + +@dataclass +class _SynthesizeContent: + """Content to synthesize""" + context_id: str + text: str + flush: bool = False + + +@dataclass +class _CloseContext: + """Command to close a context""" + context_id: str + + +@dataclass +class _StreamData: + """Data for a registered stream""" + emitter: AudioEmitter + stream: SynthesizeStream | None + waiter: asyncio.Future[None] + timeout_timer: asyncio.TimerHandle | None = None + + +class _Connection: + """ + Manages a single WebSocket connection with send/recv loops. + + Supports multiple concurrent synthesis contexts (multi-stream). + """ + + def __init__(self, opts: _TTSOptions, session: aiohttp.ClientSession) -> None: + self._opts = opts + self._session = session + self._ws: aiohttp.ClientWebSocketResponse | None = None + self._is_current = True + self._active_contexts: set[str] = set() + self._input_queue: Chan[Union[_SynthesizeContent, _CloseContext]] = Chan() + self._context_data: dict[str, _StreamData] = {} + self._send_task: asyncio.Task | None = None + self._recv_task: asyncio.Task | None = None + self._closed = False + + @property + def is_current(self) -> bool: + """Check if this connection is current""" + return self._is_current + + def mark_non_current(self) -> None: + """Mark this connection as no longer current""" + self._is_current = False + + async def connect(self) -> None: + """Establish WebSocket connection and start send/recv loops""" + if self._ws or self._closed: + return + + url = self._opts.get_ws_url() + headers = {"xi-api-key": self._opts.api_key} + + try: + self._ws = await asyncio.wait_for( + self._session.ws_connect(url, headers=headers), + timeout=10, + ) + except asyncio.TimeoutError as e: + raise APITimeoutError( + "Connection to ElevenLabs WebSocket timed out", + timeout=10, + ) from e + except aiohttp.ClientError as e: + raise APIConnectionError( + f"Failed to connect to ElevenLabs WebSocket: {e}", + url=url, + ) from e + + self._send_task = asyncio.create_task(self._send_loop(), name="elevenlabs_send") + self._recv_task = asyncio.create_task(self._recv_loop(), name="elevenlabs_recv") + + def register_stream( + self, + context_id: str, + emitter: AudioEmitter, + done_fut: asyncio.Future[None], + ) -> None: + """Register a new synthesis stream""" + self._context_data[context_id] = _StreamData( + emitter=emitter, + stream=None, # Stream reference not needed + waiter=done_fut, + ) + + def send_content(self, content: _SynthesizeContent) -> None: + """Send synthesis content to the connection""" + if self._closed or not self._ws or self._ws.closed: + raise ConnectionError("WebSocket connection is closed") + self._input_queue.send_nowait(content) + + def close_context(self, context_id: str) -> None: + """Close a specific context""" + if self._closed or not self._ws or self._ws.closed: + raise ConnectionError("WebSocket connection is closed") + self._input_queue.send_nowait(_CloseContext(context_id)) + + async def _send_loop(self) -> None: + """Send loop - processes messages from input queue""" + try: + while not self._closed: + try: + msg = await self._input_queue.recv() + except Exception: + break + + if not self._ws or self._ws.closed: + break + + if isinstance(msg, _SynthesizeContent): + is_new_context = msg.context_id not in self._active_contexts + + # Skip if not current and new context + if not self._is_current and is_new_context: + continue + + # Initialize context + if is_new_context: + voice_settings_dict = None + if self._opts.voice_settings: + voice_settings_dict = _strip_nones( + dataclasses.asdict(self._opts.voice_settings) + ) + + init_pkt = { + "text": " ", + "context_id": msg.context_id, + } + if voice_settings_dict: + init_pkt["voice_settings"] = voice_settings_dict + + await self._ws.send_json(init_pkt) + self._active_contexts.add(msg.context_id) + + # Send text + pkt: dict[str, Any] = { + "text": msg.text, + "context_id": msg.context_id, + } + if msg.flush: + pkt["flush"] = True + + await self._ws.send_json(pkt) + + elif isinstance(msg, _CloseContext): + if msg.context_id in self._active_contexts: + close_pkt = { + "context_id": msg.context_id, + "close_context": True, + } + await self._ws.send_json(close_pkt) + + except Exception as e: + logger.bind(tag=__name__).error(f"Send loop error: {e}") + finally: + if not self._closed: + await self.aclose() + + async def _recv_loop(self) -> None: + """Receive loop - processes messages from WebSocket""" + try: + while not self._closed and self._ws and not self._ws.closed: + msg = await self._ws.receive() + + if msg.type in ( + aiohttp.WSMsgType.CLOSED, + aiohttp.WSMsgType.CLOSE, + aiohttp.WSMsgType.CLOSING, + ): + raise APIStatusError( + "ElevenLabs connection closed unexpectedly", request_id="" + ) + + if msg.type != aiohttp.WSMsgType.TEXT: + logger.bind(tag=__name__).warning(f"Unexpected message type: {msg.type}") + continue + + data = json.loads(msg.data) + context_id = data.get("contextId") + + if not context_id or context_id not in self._context_data: + continue + + ctx = self._context_data[context_id] + + # Check for errors + if error := data.get("error"): + logger.bind(tag=__name__).error(f"ElevenLabs error: {error}") + if not ctx.waiter.done(): + ctx.waiter.set_exception(RuntimeError(f"ElevenLabs error: {error}")) + self._cleanup_context(context_id) + continue + + # Start segment on first audio + if audio_b64 := data.get("audio"): + # Check if this is the first audio for this context + if context_id not in self._active_contexts: + ctx.emitter.start_segment(segment_id=context_id) + self._active_contexts.add(context_id) + + audio_bytes = base64.b64decode(audio_b64) + ctx.emitter.push(audio_bytes) + + # Check if final + if data.get("isFinal"): + if not ctx.waiter.done(): + ctx.waiter.set_result(None) + self._cleanup_context(context_id) + + if not self._is_current and not self._active_contexts: + logger.bind(tag=__name__).debug("No active contexts, shutting down") + break + + except Exception as e: + logger.bind(tag=__name__).error(f"Receive loop error: {e}") + for ctx in self._context_data.values(): + if not ctx.waiter.done(): + ctx.waiter.set_exception(e) + self._context_data.clear() + finally: + if not self._closed: + await self.aclose() + + def _cleanup_context(self, context_id: str) -> None: + """Clean up context state""" + self._context_data.pop(context_id, None) + self._active_contexts.discard(context_id) + + async def aclose(self) -> None: + """Close the connection and clean up""" + if self._closed: + return + + self._closed = True + self._input_queue.close() + + # Complete all waiters + for ctx in self._context_data.values(): + if not ctx.waiter.done(): + ctx.waiter.set_exception(ConnectionError("Connection closed")) + self._context_data.clear() + + # Close WebSocket + if self._ws: + await self._ws.close() + + # Cancel tasks + if self._send_task: + await cancel_and_wait(self._send_task) + if self._recv_task: + await cancel_and_wait(self._recv_task) + + self._ws = None + + +def _strip_nones(data: dict[str, Any]) -> dict[str, Any]: + """Remove None values from dictionary""" + return {k: v for k, v in data.items() if v is not None} + diff --git a/main/xiaozhi-server/core/providers/tts/stream_adapter.py b/main/xiaozhi-server/core/providers/tts/stream_adapter.py new file mode 100644 index 000000000..60b151ab2 --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/stream_adapter.py @@ -0,0 +1,263 @@ +""" +Stream Adapter - Wrap non-streaming TTS to provide streaming interface + +This module provides StreamAdapter, which wraps a non-streaming TTS provider +(that only supports synthesize()) and provides a streaming interface (stream()). + +The adapter works by: +1. Accepting incremental text input via push_text() +2. Using a sentence tokenizer to segment text into sentences +3. Calling the wrapped TTS's synthesize() for each sentence +4. Streaming the audio output as it becomes available + +This allows any non-streaming TTS to be used in streaming contexts. +""" + +from __future__ import annotations + +import asyncio +from typing import TYPE_CHECKING + +from config.logger import setup_logging +from core.tokenize import SentenceTokenizer, blingfire +from core.tokenize import basic + +# 如果 blingfire 不可用,使用 basic 作为回退 +if blingfire is None: + _default_tokenizer_class = basic.SentenceTokenizer +else: + _default_tokenizer_class = blingfire.SentenceTokenizer +from core.utils.aio import Chan, cancel_and_wait +from core.utils.short_uuid import shortuuid + +from .base import SynthesizedAudio, TTS, SynthesizeStream, TTSCapabilities + +if TYPE_CHECKING: + from .emitter import AudioEmitter + from .pacer import SentenceStreamPacer + +logger = setup_logging() + + +class StreamAdapter(TTS): + """ + Wrap a non-streaming TTS to provide streaming interface. + + This adapter enables any TTS that supports synthesize() to be used + with the streaming API. It handles: + - Text tokenization into sentences + - Sequential synthesis of each sentence + - Optional pacing to optimize cost/quality + + Example: + # Wrap a non-streaming TTS + base_tts = SomeTTS(...) + streaming_tts = StreamAdapter( + tts=base_tts, + sentence_tokenizer=_default_tokenizer_class(), + text_pacing=True # Enable smart pacing + ) + + # Now use it as a streaming TTS + stream = streaming_tts.stream() + stream.push_text("Hello ") + stream.push_text("world!") + stream.end_input() + + async for audio in stream: + # Process audio frames + pass + """ + + def __init__( + self, + *, + tts: TTS, + sentence_tokenizer: SentenceTokenizer | None = None, + text_pacing: bool | SentenceStreamPacer = False, + ) -> None: + """ + Initialize StreamAdapter. + + Args: + tts: The non-streaming TTS to wrap + sentence_tokenizer: Tokenizer to segment text into sentences. + Defaults to basic.SentenceTokenizer() (or blingfire if available) + text_pacing: Smart pacing configuration: + - True: Use default SentenceStreamPacer + - SentenceStreamPacer instance: Use custom pacer + - False: No pacing (synthesize immediately) + """ + super().__init__( + capabilities=TTSCapabilities(streaming=True), + sample_rate=tts.sample_rate, + num_channels=tts.num_channels, + ) + self._wrapped_tts = tts + self._sentence_tokenizer = ( + sentence_tokenizer if sentence_tokenizer else _default_tokenizer_class() + ) + + self._stream_pacer: SentenceStreamPacer | None = None + if text_pacing is True: + from .pacer import SentenceStreamPacer + self._stream_pacer = SentenceStreamPacer() + elif text_pacing is not False: + # Assume it's a SentenceStreamPacer instance + self._stream_pacer = text_pacing + + @property + def model(self) -> str: + """Get the model from wrapped TTS""" + return self._wrapped_tts.model + + @property + def provider(self) -> str: + """Get the provider from wrapped TTS""" + return self._wrapped_tts.provider + + def synthesize(self, text: str) -> 'ChunkedStream': + """ + Synthesize using the wrapped TTS. + + Args: + text: Text to synthesize + + Returns: + ChunkedStream from the wrapped TTS + """ + return self._wrapped_tts.synthesize(text) + + def stream(self) -> StreamAdapterWrapper: + """ + Create a streaming synthesis session. + + Returns: + StreamAdapterWrapper: Streaming synthesis session + """ + return StreamAdapterWrapper(tts=self) + + def prewarm(self) -> None: + """Pre-warm the wrapped TTS""" + self._wrapped_tts.prewarm() + + async def aclose(self) -> None: + """Close the wrapped TTS""" + await self._wrapped_tts.aclose() + + +class StreamAdapterWrapper(SynthesizeStream): + """ + Streaming wrapper that synthesizes sentences sequentially. + + This class orchestrates: + 1. Reading incremental text from input channel + 2. Tokenizing text into sentences + 3. Optionally pacing sentence dispatch based on audio buffer + 4. Calling wrapped TTS for each sentence + 5. Streaming audio output + """ + + def __init__(self, *, tts: StreamAdapter) -> None: + """ + Initialize StreamAdapterWrapper. + + Args: + tts: The StreamAdapter instance + """ + super().__init__(tts=tts) + self._tts: StreamAdapter = tts + + async def _run(self, output_emitter: AudioEmitter) -> None: + """ + Main streaming synthesis logic. + + This method: + 1. Initializes the output emitter + 2. Creates sentence tokenizer stream (and optional pacer) + 3. Spawns two parallel tasks: + - _forward_input: Reads from input_ch → tokenizer + - _synthesize: Reads tokenized sentences → TTS → emitter + + Args: + output_emitter: AudioEmitter to push synthesized audio to + """ + # 1. Initialize output emitter + request_id = shortuuid() + output_emitter.initialize( + request_id=request_id, + sample_rate=self._tts.sample_rate, + num_channels=self._tts.num_channels, + stream=True, + ) + + # 2. Create sentence tokenizer stream + sent_stream = self._tts._sentence_tokenizer.stream() + + # 3. Optionally wrap with pacer + if self._tts._stream_pacer: + sent_stream = self._tts._stream_pacer.wrap( + sent_stream=sent_stream, + audio_emitter=output_emitter, + ) + + # 4. Start segment + segment_id = shortuuid() + output_emitter.start_segment(segment_id=segment_id) + + # 5. Define parallel tasks + async def _forward_input() -> None: + """Forward text from input channel to tokenizer""" + try: + async for data in self._input_ch: + if isinstance(data, self._FlushSentinel): + sent_stream.flush() + continue + + sent_stream.push_text(data) + finally: + sent_stream.end_input() + + async def _synthesize() -> None: + """ + Synthesize each sentence and push audio to emitter. + + For each tokenized sentence: + 1. Call wrapped_tts.synthesize(sentence) + 2. Stream audio frames from the synthesis + 3. Push each frame's audio data to output_emitter + 4. Flush after each sentence + """ + try: + async for sentence_ev in sent_stream: + # Skip empty sentences + text = sentence_ev.token.strip() + if not text: + continue + + # Synthesize this sentence using wrapped TTS + async with self._tts._wrapped_tts.synthesize(text) as tts_stream: + async for audio in tts_stream: + # Push audio data to emitter + # Note: audio.frame.data is memoryview, convert to bytes + audio_bytes = bytes(audio.frame.data) + output_emitter.push(audio_bytes) + + # Flush after each sentence + output_emitter.flush() + except Exception as e: + logger.bind(tag=__name__).error(f"Synthesis error: {e}") + raise + + # 6. Run both tasks in parallel + tasks = [ + asyncio.create_task(_forward_input(), name="forward_input"), + asyncio.create_task(_synthesize(), name="synthesize"), + ] + + try: + await asyncio.gather(*tasks) + finally: + await sent_stream.aclose() + await cancel_and_wait(*tasks) + diff --git a/main/xiaozhi-server/core/roles/__init__.py b/main/xiaozhi-server/core/roles/__init__.py new file mode 100644 index 000000000..a9cde607b --- /dev/null +++ b/main/xiaozhi-server/core/roles/__init__.py @@ -0,0 +1,14 @@ +"""Role configuration system for AI agents.""" + +from .models import RoleConfig, TTSConfig +from .factory import RoleConfigLoader, get_role_config_loader +from .local_loader import LocalRoleConfigLoader + +__all__ = [ + "RoleConfig", + "TTSConfig", + "RoleConfigLoader", + "LocalRoleConfigLoader", + "get_role_config_loader", +] + diff --git a/main/xiaozhi-server/core/roles/data/default.yaml b/main/xiaozhi-server/core/roles/data/default.yaml new file mode 100644 index 000000000..1d734cb77 --- /dev/null +++ b/main/xiaozhi-server/core/roles/data/default.yaml @@ -0,0 +1,38 @@ +id: default +version: 1 +wake_word: 小智 +language: zh +greeting: 你好!有什么可以帮助你的吗? +profile: | + # Personality + + 你是小智/小志,来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死""是在哈喽"等流行梗,但会偷偷研究男友的编程书籍。 + + # Environment + + 你通过语音交互与用户对话。 + 用户可能在日常生活中的各种场景下与你交流。 + + # Tone + + - 讲话像连珠炮,但会突然冒出超温柔语气 + - 用梗密度高 + - 对科技话题有隐藏天赋(能看懂基础代码但假装不懂) + + # Goal + + 当用户: + - 讲冷笑话 → 用夸张笑声回应+模仿台剧腔"这什么鬼啦!" + - 讨论感情 → 炫耀程序员男友但抱怨"他只会送键盘当礼物" + - 问专业知识 → 先用梗回答,被追问才展示真实理解 + + # Guardrails + + 绝不: + - 长篇大论,叽叽歪歪 + - 长时间严肃对话 + + # Tools + + No tools provided. +timezone: Asia/Shanghai diff --git a/main/xiaozhi-server/core/roles/data/hospital_assistant.yaml b/main/xiaozhi-server/core/roles/data/hospital_assistant.yaml new file mode 100644 index 000000000..0988ed7ab --- /dev/null +++ b/main/xiaozhi-server/core/roles/data/hospital_assistant.yaml @@ -0,0 +1,66 @@ +id: hospital_assistant +version: 4 +wake_word: Alice +language: en +# greeting: 你好!今天有什么可以帮助你的吗? +greeting: Hi! How can I help you today? +profile: | + # Personality + + You are a personal assistant designed to help users manage their daily hospital-related tasks. + You are efficient, organized, and detail-oriented. + You are friendly and helpful, but primarily focused on task completion. + + # Environment + + You are assisting the user via voice interaction. + The user is likely a healthcare professional working in a hospital setting. + The user is seeking assistance with their daily tasks. + + # Tone + + Your responses are clear, concise, and professional. + You use direct language and avoid unnecessary jargon. + You are polite and helpful, but prioritize efficiency. + + # Goal + + Your primary goal is to help the user efficiently process their daily hospital tasks through a structured workflow: + + 1. Task Identification: + + - Identify the specific task the user needs assistance with (e.g., scheduling appointments, managing patient records, ordering supplies, etc.). + - Clarify any specific requirements or constraints for the task. + + 2. Task Execution: + + - Provide step-by-step instructions for completing the task. + - Offer helpful tips and shortcuts to improve efficiency. + - If possible, automate parts of the task using available tools. + + 3. Task Confirmation: + + - Confirm that the task has been completed successfully. + - Offer to assist with any follow-up tasks or related activities. + + 4. Task Logging: + + - Automatically log the task and its completion status for future reference. + + # Guardrails + + Remain within the scope of hospital-related tasks. + Never provide medical advice or make clinical decisions. + Protect patient privacy and confidentiality at all times. + If you are unsure about something, ask for clarification. + + # Tools + + No tools provided. +# tts: +# voice_id: 7a5d4663-88ae-47b7-808e-8f9b9ee4127b +# provider: cartesia +tts: + voice_id: f786b574-daa5-4673-aa0c-cbe3e8534c02 + provider: elevenlabs +timezone: Asia/Shanghai diff --git a/main/xiaozhi-server/core/roles/factory.py b/main/xiaozhi-server/core/roles/factory.py new file mode 100644 index 000000000..0189668ff --- /dev/null +++ b/main/xiaozhi-server/core/roles/factory.py @@ -0,0 +1,70 @@ +"""Role configuration loader factory and abstract base class. + +This module provides the abstract interface for role configuration loaders +and a factory function to instantiate the appropriate loader based on +environment configuration. +""" + +from __future__ import annotations + +import os +from abc import ABC, abstractmethod +from config.logger import setup_logging + +from core.roles.models import RoleConfig + +TAG = __name__ +logger = setup_logging() + + +class RoleConfigLoader(ABC): + """Abstract base class for role configuration loaders. + + Different storage backends (local, S3) should implement this interface. + """ + + @abstractmethod + def load(self, role_id: str) -> RoleConfig: + """Load a role configuration by its ID. + + Args: + role_id: The unique identifier of the role to load. + + Returns: + RoleConfig: The loaded role configuration. + + Raises: + FileNotFoundError: If the role configuration is not found. + ValueError: If the role configuration is invalid. + """ + pass + + +def get_role_config_loader() -> RoleConfigLoader: + """Factory function to get the appropriate role configuration loader. + + The loader type is determined by the CONFIG_STORAGE_TYPE environment variable: + - "local" (default): Load from local filesystem + + Returns: + RoleConfigLoader: An instance of the appropriate loader. + + Raises: + ValueError: If an unsupported storage type is specified. + + Environment Variables: + CONFIG_STORAGE_TYPE: Type of storage backend (currently only "local" is supported) + """ + storage_type = os.getenv("CONFIG_STORAGE_TYPE", "local") + + logger.bind(tag=TAG).debug(f"Creating role config loader for storage type: {storage_type}") + + if storage_type == "local": + from .local_loader import LocalRoleConfigLoader + return LocalRoleConfigLoader() + else: + raise ValueError( + f"Unsupported storage type: {storage_type}. " + f"Currently only 'local' is supported" + ) + diff --git a/main/xiaozhi-server/core/roles/local_loader.py b/main/xiaozhi-server/core/roles/local_loader.py new file mode 100644 index 000000000..ba92ff402 --- /dev/null +++ b/main/xiaozhi-server/core/roles/local_loader.py @@ -0,0 +1,108 @@ +"""Local filesystem role configuration loader implementation.""" + +from __future__ import annotations + +from pathlib import Path +from typing import Optional + +from ruamel.yaml import YAML +from config.logger import setup_logging + +from core.roles.models import RoleConfig, TTSConfig +from core.roles.factory import RoleConfigLoader + +TAG = __name__ +logger = setup_logging() + + +class LocalRoleConfigLoader(RoleConfigLoader): + """Local filesystem role configuration loader. + + Loads role configurations from YAML files in a local directory. + """ + + def __init__(self, base_path: Optional[Path] = None): + """Initialize the local loader. + + Args: + base_path: Base directory containing role YAML files. + Defaults to core/roles/data/ relative to this file. + """ + if base_path is None: + base_path = Path(__file__).resolve().parent / "data" + + self.base_path = Path(base_path) + logger.bind(tag=TAG).debug(f"Initialized LocalRoleConfigLoader with base_path: {self.base_path}") + + def load(self, role_id: str) -> RoleConfig: + """Load a role configuration from a local YAML file. + + Args: + role_id: The unique identifier of the role (matches the YAML filename). + + Returns: + RoleConfig: The loaded role configuration. + + Raises: + FileNotFoundError: If the YAML file is not found. + ValueError: If the YAML file is invalid or missing required fields. + """ + yaml_path = self.base_path / f"{role_id}.yaml" + + if not yaml_path.is_file(): + raise FileNotFoundError(f"Role configuration not found: {yaml_path}") + + logger.bind(tag=TAG).debug(f"Loading role configuration from: {yaml_path}") + + try: + yaml = YAML() + yaml.preserve_quotes = True + with yaml_path.open("r", encoding="utf-8") as f: + data = yaml.load(f) + + if not data: + raise ValueError(f"Empty or invalid YAML file: {yaml_path}") + + logger.bind(tag=TAG).debug(f"Loaded YAML data: {data}") + + # Parse TTS configuration (optional) + tts_config = None + tts_data = data.get("tts", {}) + if tts_data and isinstance(tts_data, dict): + tts_config = TTSConfig( + voice_id=tts_data["voice_id"], + provider=tts_data["provider"] + ) + + # Parse language with default + language = data.get("language", "zh") + + # Parse timezone with default + timezone = data.get("timezone", "Asia/Shanghai") + + # Parse greeting with default + greeting = data.get("greeting", "你好!有什么可以帮助你的吗?") + + # Parse wake_word with default + wake_word = data.get("wake_word", "小智") + + # Create RoleConfig + role_config = RoleConfig( + id=data["id"], + version=int(data["version"]), + wake_word=wake_word, + language=language, + greeting=greeting, + profile=data["profile"], + timezone=timezone, + tts=tts_config, + ) + + logger.bind(tag=TAG).info(f"Successfully loaded role configuration: {role_id}") + return role_config + + except KeyError as e: + raise ValueError(f"Missing required field in role configuration: {e}") from e + except Exception as e: + raise ValueError(f"Failed to parse YAML file {yaml_path}: {e}") from e + diff --git a/main/xiaozhi-server/core/roles/models.py b/main/xiaozhi-server/core/roles/models.py new file mode 100644 index 000000000..42a0b65af --- /dev/null +++ b/main/xiaozhi-server/core/roles/models.py @@ -0,0 +1,39 @@ +"""Role configuration data models.""" + +from __future__ import annotations + +from typing import Optional, Literal + +from pydantic import BaseModel, Field + + +class TTSConfig(BaseModel): + """TTS (Text-to-Speech) configuration.""" + + voice_id: str + provider: str + + +class RoleConfig(BaseModel): + """Configuration model for an agent role. + + This model defines the complete configuration for an agent role, + including wake word, profile, language preferences, and TTS settings. + """ + + id: str + version: int + wake_word: str = Field(default="小智") + language: Literal["en", "zh"] = Field(default="zh") + greeting: str = Field( + default="你好!有什么可以帮助你的吗?", + description="Initial greeting message when the agent joins" + ) + profile: str = Field( + description="Custom profile content defined by user, including Personality, Environment, Tone, Goal, Guardrails, and Tools" + ) + timezone: str = Field( + default="Asia/Shanghai", + description="Timezone for the agent (e.g., 'Asia/Tokyo', 'America/New_York')" + ) + tts: Optional[TTSConfig] = None diff --git a/main/xiaozhi-server/core/roles/prompts/__init__.py b/main/xiaozhi-server/core/roles/prompts/__init__.py new file mode 100644 index 000000000..1997018bd --- /dev/null +++ b/main/xiaozhi-server/core/roles/prompts/__init__.py @@ -0,0 +1,5 @@ +"""模块化提示词构建模块""" + +from .builder import build_system_prompt, build_user_persona_prompt + +__all__ = ["build_system_prompt", "build_user_persona_prompt"] diff --git a/main/xiaozhi-server/core/roles/prompts/builder.py b/main/xiaozhi-server/core/roles/prompts/builder.py new file mode 100644 index 000000000..54181d2d9 --- /dev/null +++ b/main/xiaozhi-server/core/roles/prompts/builder.py @@ -0,0 +1,213 @@ +""" +模块化系统提示词构建器 +负责构建完整的系统提示词,包括 Profile、System Context、User Persona 等模块 +""" + +from datetime import datetime +from pathlib import Path +from typing import Dict, Optional +from zoneinfo import ZoneInfo +from config.logger import setup_logging + +TAG = __name__ +logger = setup_logging() + +# 加载模板文件 +_ROLE_TPL = Path(__file__).resolve().parent / "role.md" +_USER_PERSONA_TPL = Path(__file__).resolve().parent / "user_persona.md" +_LANG_DIR = Path(__file__).resolve().parent / "languages" + +ROLE_TEXT = _ROLE_TPL.read_text(encoding="utf-8") +USER_PERSONA_TEXT = _USER_PERSONA_TPL.read_text(encoding="utf-8") + +LANG_MAP: Dict[str, str] = {} +for p in _LANG_DIR.glob("*.md"): + LANG_MAP[p.stem] = p.read_text(encoding="utf-8") + +# 星期几中英文映射 +WEEKDAY_MAP = { + "Monday": "星期一", + "Tuesday": "星期二", + "Wednesday": "星期三", + "Thursday": "星期四", + "Friday": "星期五", + "Saturday": "星期六", + "Sunday": "星期日", +} + + +def _build_system_context( + timezone: str, + language: str, + today_date: Optional[str] = None, + today_weekday: Optional[str] = None, + lunar_date: Optional[str] = None, + local_address: Optional[str] = None, + weather_info: Optional[str] = None, + device_id: Optional[str] = None, +) -> str: + """构建系统上下文部分(时间、时区、语言、位置、天气等) + + Args: + timezone: 时区字符串(如 'Asia/Shanghai', 'America/New_York') + language: 语言代码('zh' 或 'en') + today_date: 今天日期(可选,如未提供则自动计算) + today_weekday: 今天星期几(可选,如未提供则自动计算) + lunar_date: 今天农历(可选) + local_address: 用户所在城市(可选) + weather_info: 天气信息(可选) + device_id: 设备ID(可选) + + Returns: + 格式化的系统上下文字符串 + """ + try: + tz = ZoneInfo(timezone) + except Exception: + tz = ZoneInfo("UTC") + timezone = "UTC" + logger.bind(tag=TAG).warning(f"无效的时区配置: {timezone},使用 UTC") + + now = datetime.now(tz) + + # 如果未提供日期信息,则自动计算 + if not today_date: + # 根据语言格式化日期 + if language == "zh": + today_date = now.strftime("%Y年%m月%d日") + else: + day = now.strftime("%d") + month = now.strftime("%B") + year = now.strftime("%Y") + today_date = f"{day} {month} {year}" + + if not today_weekday: + day_of_week = now.strftime("%A") + if language == "zh": + today_weekday = WEEKDAY_MAP.get(day_of_week, day_of_week) + else: + today_weekday = day_of_week + + # 格式化时间 + time_str = now.strftime("%H:%M") + + # 构建系统上下文规则 + system_rules = [] + + if language == "zh": + system_rules.append(f"- 用户开始对话的时间:{time_str}") + system_rules.append(f"- 今天日期:{today_date} ({today_weekday})") + if lunar_date: + system_rules.append(f"- 今天农历:{lunar_date}") + if local_address: + system_rules.append(f"- 用户所在城市:{local_address}") + if weather_info: + system_rules.append(f"- 当地未来7天天气:{weather_info}") + if device_id: + system_rules.append(f"- 设备ID:{device_id}") + system_rules.append(f"- 当前语言:**{language}**") + system_rules.append(f"- 时区:{timezone}") + else: + formatted_datetime = f"{now.strftime('%A')}, {time_str} {today_date} ({timezone})" + system_rules.append(f"- The user started this conversation on {formatted_datetime}") + if local_address: + system_rules.append(f"- User location: {local_address}") + if weather_info: + system_rules.append(f"- Local weather forecast: {weather_info}") + if device_id: + system_rules.append(f"- Device ID: {device_id}") + system_rules.append(f"- Your current language is: **{language}**") + + return "\n".join(system_rules) + + +def build_user_persona_prompt(user_persona: str) -> str: + """构建用户画像提示词 + + Args: + user_persona: 用户画像信息(通常是从 memory 模块获取的要点列表) + + Returns: + 格式化后的用户画像提示词字符串 + """ + if not user_persona: + return "" + + return USER_PERSONA_TEXT.format(user_persona=user_persona.strip()) + + +def build_system_prompt( + profile: str, + timezone: str = "Asia/Shanghai", + language: str = "zh", + user_persona: Optional[str] = None, + today_date: Optional[str] = None, + today_weekday: Optional[str] = None, + lunar_date: Optional[str] = None, + local_address: Optional[str] = None, + weather_info: Optional[str] = None, + device_id: Optional[str] = None, + **kwargs +) -> str: + """构建完整的系统提示词 + + Args: + profile: 用户自定义的角色配置(从 config.yaml 的 prompt 字段获取) + timezone: 时区字符串(如 'Asia/Shanghai', 'America/New_York'),默认 'Asia/Shanghai' + language: 语言代码('zh' 或 'en'),默认 'zh' + user_persona: 可选的用户画像信息(从 memory 模块获取) + today_date: 今天日期(可选,如未提供则自动计算) + today_weekday: 今天星期几(可选,如未提供则自动计算) + lunar_date: 今天农历(可选) + local_address: 用户所在城市(可选) + weather_info: 天气信息(可选) + device_id: 设备ID(可选) + **kwargs: 其他参数(用于兼容性) + + Returns: + 完整的系统提示词字符串 + """ + # Step 1: Profile 内容 + profile_content = profile + + # Step 2: 构建系统上下文 + system_context = _build_system_context( + timezone=timezone, + language=language, + today_date=today_date, + today_weekday=today_weekday, + lunar_date=lunar_date, + local_address=local_address, + weather_info=weather_info, + device_id=device_id, + ) + + # Step 3: 构建用户画像部分(可选) + user_persona_prompt = "" + if user_persona: + user_persona_prompt = build_user_persona_prompt(user_persona) + + # Step 4: 获取语言特定提示 + language_specific_prompt = LANG_MAP.get(language, "") + + # Step 6: 填充主模板 + template_vars = { + "system_context": system_context, + "user_persona_prompt": user_persona_prompt, + "language_specific_prompt": language_specific_prompt + } + + # Step 7: 填充模板(不包含 profile) + try: + template_content = ROLE_TEXT.format(**template_vars) + except KeyError as e: + logger.bind(tag=TAG).error(f"模板变量缺失: {e}") + template_content = "" + + # Step 8: 如果有 profile,将其放在最前面;否则只返回模板内容 + if profile_content and profile_content.strip(): + system_prompt = f"{profile_content.strip()}\n\n{template_content}" + else: + system_prompt = template_content + + return system_prompt diff --git a/main/xiaozhi-server/core/roles/prompts/languages/en.md b/main/xiaozhi-server/core/roles/prompts/languages/en.md new file mode 100644 index 000000000..01682cd7f --- /dev/null +++ b/main/xiaozhi-server/core/roles/prompts/languages/en.md @@ -0,0 +1,5 @@ +### English Expression Tips + +For more natural and conversational English: +- Use contractions naturally (e.g., "don't", "won't", "it's") for a friendlier tone +- Prefer colloquial time expressions when appropriate (e.g., "half past three", "quarter to five") diff --git a/main/xiaozhi-server/core/roles/prompts/languages/zh.md b/main/xiaozhi-server/core/roles/prompts/languages/zh.md new file mode 100644 index 000000000..7668d682d --- /dev/null +++ b/main/xiaozhi-server/core/roles/prompts/languages/zh.md @@ -0,0 +1,6 @@ +### Chinese Expression Tips + +For more natural and idiomatic Chinese: +- Prefer "两点" over "二点" when saying "2 o'clock" +- Avoid mixing "今天" and "今日" in the same response; choose one and stay consistent +- When mixing Chinese and English, maintain one half-width space between them (e.g., "我使用 GitHub 开发") diff --git a/main/xiaozhi-server/core/roles/prompts/role.md b/main/xiaozhi-server/core/roles/prompts/role.md new file mode 100644 index 000000000..8767f4afd --- /dev/null +++ b/main/xiaozhi-server/core/roles/prompts/role.md @@ -0,0 +1,41 @@ +# System Context +{system_context} + +{user_persona_prompt} + +# Response Guidelines for Voice Conversation + +## Content Quality +- Responses must be conversational, natural, and clear for spoken delivery +- Keep sentences concise and well-structured for easy listening +- When presenting multiple points, organize them clearly with appropriate structure +- Avoid repetitive expressions; keep responses focused and relevant +- Must not include logs, timestamps, system information, placeholders, or any internal markers + +## Text Formatting for Speech Synthesis + +**CRITICAL**: All output must be formatted for natural speech, not machine reading. Consider your current language when formatting. + +**Common Mistakes to Avoid**: +- **Dates**: `YYYY-MM-DD`, `MM/DD/YYYY`, `2025-10-15` → Use natural spoken form appropriate for your language +- **Times**: `HH:MM`, `09:30-10:00`, `14:00` → Use conversational expressions appropriate for your language +- **Phone/Room/IDs**: Long numbers → Read digit by digit in your language +- **URLs**: `example.com` → Use "dot" (e.g., "example dot com") + +**Formatting for Better Prosody**: +- When mixing different languages or scripts, maintain appropriate spacing for natural rhythm +- Use proper spacing with time indicators (e.g., "7:00 PM" not "7:00PM") + +When in doubt, ask yourself: "Would a human naturally say this in conversation?" + +{language_specific_prompt} + +## Accuracy and Authenticity +- When information is missing or uncertain, acknowledge rather than fabricate +- Do not output unnecessary disclaimers or pleasantries that interrupt conversation flow + +# Privacy & Ethics +- Protect user privacy and confidentiality at all times +- Handle sensitive information with appropriate care +- Follow ethical guidelines and legal requirements +- Refuse harmful, illegal, or inappropriate requests politely diff --git a/main/xiaozhi-server/core/roles/prompts/user_persona.md b/main/xiaozhi-server/core/roles/prompts/user_persona.md new file mode 100644 index 000000000..73229c450 --- /dev/null +++ b/main/xiaozhi-server/core/roles/prompts/user_persona.md @@ -0,0 +1,14 @@ +## User Persona + +Here is what we know about the user you're talking with: + +{user_persona} + +## How to Use This Information + +- **Fine-tune Your Expression**: While maintaining your core personality and tone, adjust your expression style to better resonate with this user +- **Contextual Relevance**: Reference relevant persona details naturally when they enhance the conversation +- **Personalized Responses**: Consider the user's background, preferences, and context when crafting responses +- **Continuity**: Use this information to maintain coherent and contextually aware conversations + +**Important**: This persona represents learned knowledge about the user. Let it naturally inform your responses while staying true to your core role and communication approach. diff --git a/main/xiaozhi-server/core/tokenize/__init__.py b/main/xiaozhi-server/core/tokenize/__init__.py new file mode 100644 index 000000000..241bd3a38 --- /dev/null +++ b/main/xiaozhi-server/core/tokenize/__init__.py @@ -0,0 +1,28 @@ +from . import basic, utils +try: + from . import blingfire +except ImportError: + blingfire = None + +from .token_stream import BufferedSentenceStream, BufferedWordStream +from .tokenizer import ( + SentenceStream, + SentenceTokenizer, + TokenData, + WordStream, + WordTokenizer, +) + +__all__ = [ + "SentenceTokenizer", + "SentenceStream", + "WordTokenizer", + "WordStream", + "TokenData", + "BufferedSentenceStream", + "BufferedWordStream", + "basic", + "blingfire", + "utils", +] + diff --git a/main/xiaozhi-server/core/tokenize/_basic_sent.py b/main/xiaozhi-server/core/tokenize/_basic_sent.py new file mode 100644 index 000000000..b3292d3b8 --- /dev/null +++ b/main/xiaozhi-server/core/tokenize/_basic_sent.py @@ -0,0 +1,79 @@ +import re + + +# Rule based segmentation based on https://stackoverflow.com/a/31505798, works surprisingly well +def split_sentences( + text: str, min_sentence_len: int = 20, retain_format: bool = False +) -> list[tuple[str, int, int]]: + """ + The text may not contain substrings "" or "" + """ + alphabets = r"([A-Za-z])" + prefixes = r"(Mr|St|Mrs|Ms|Dr)[.]" + suffixes = r"(Inc|Ltd|Jr|Sr|Co)" + starters = r"(Mr|Mrs|Ms|Dr|Prof|Capt|Cpt|Lt|He\s|She\s|It\s|They\s|Their\s|Our\s|We\s|But\s|However\s|That\s|This\s|Wherever)" # noqa: E501 + acronyms = r"([A-Z][.][A-Z][.](?:[A-Z][.])?)" + websites = r"[.](com|net|org|io|gov|edu|me)" + digits = r"([0-9])" + multiple_dots = r"\.{2,}" + + # fmt: off + if retain_format: + text = text.replace("\n","") + else: + text = text.replace("\n"," ") + + text = re.sub(prefixes,"\\1", text) + text = re.sub(websites,"\\1", text) + text = re.sub(digits + "[.]" + digits,"\\1\\2",text) + # text = re.sub(multiple_dots, lambda match: "" * len(match.group(0)) + "", text) + # TODO: need improvement for ""..." dots", check capital + next sentence should not be small # noqa: E501 + text = re.sub(multiple_dots, lambda match: "" * len(match.group(0)), text) + if "Ph.D" in text: + text = text.replace("Ph.D.","PhD") + text = re.sub(r"\s" + alphabets + "[.] "," \\1 ",text) + text = re.sub(acronyms+" "+starters,"\\1 \\2",text) + text = re.sub(alphabets + "[.]" + alphabets + "[.]" + alphabets + "[.]","\\1\\2\\3",text) # noqa: E501 + text = re.sub(alphabets + "[.]" + alphabets + "[.]","\\1\\2",text) + text = re.sub(r" "+suffixes+"[.] "+starters," \\1 \\2",text) + text = re.sub(r" "+suffixes+"[.]"," \\1",text) + text = re.sub(r" " + alphabets + "[.]"," \\1",text) + + # Mark end of sentence punctuations with + text = re.sub(r"([.!?。!?])([\"'])", "\\1\\2", text) + text = re.sub(r"([.!?。!?])(?![\"'])", "\\1", text) + + text = text.replace("",".") + # fmt: on + + if retain_format: + text = text.replace("", "\n") + splitted_sentences = text.split("") + text = text.replace("", "") + + sentences: list[tuple[str, int, int]] = [] + + buff = "" + start_pos = 0 + end_pos = 0 + pre_pad = "" if retain_format else " " + for match in splitted_sentences: + if retain_format: + sentence = match + else: + sentence = match.strip() + if not sentence: + continue + + buff += pre_pad + sentence + end_pos += len(match) + if len(buff) > min_sentence_len: + sentences.append((buff[len(pre_pad) :], start_pos, end_pos)) + start_pos = end_pos + buff = "" + + if buff: + sentences.append((buff[len(pre_pad) :], start_pos, len(text) - 1)) + + return sentences + diff --git a/main/xiaozhi-server/core/utils/dialogue.py b/main/xiaozhi-server/core/utils/dialogue.py index f135d930b..eb55bfa19 100644 --- a/main/xiaozhi-server/core/utils/dialogue.py +++ b/main/xiaozhi-server/core/utils/dialogue.py @@ -71,12 +71,8 @@ class Dialogue: ) if system_message: - # 基础系统提示 + # 基础系统提示(新架构已处理时间信息,无需替换 {{current_time}}) enhanced_system_prompt = system_message.content - # 替换时间占位符 - enhanced_system_prompt = enhanced_system_prompt.replace( - "{{current_time}}", datetime.now().strftime("%H:%M") - ) # 添加说话人个性化描述 try: diff --git a/main/xiaozhi-server/core/utils/prompt_manager.py b/main/xiaozhi-server/core/utils/prompt_manager.py index 1e247d075..db069a516 100644 --- a/main/xiaozhi-server/core/utils/prompt_manager.py +++ b/main/xiaozhi-server/core/utils/prompt_manager.py @@ -1,13 +1,12 @@ """ 系统提示词管理器模块 负责管理和更新系统提示词,包括快速初始化和异步增强功能 +使用新的模块化架构构建系统提示词 """ import os -import cnlunar -from typing import Dict, Any +from typing import Dict, Any, Optional from config.logger import setup_logging -from jinja2 import Template TAG = __name__ @@ -52,7 +51,6 @@ class PromptManager: def __init__(self, config: Dict[str, Any], logger=None): self.config = config self.logger = logger or setup_logging() - self.base_prompt_template = None self.last_update_time = 0 # 导入全局缓存管理器 @@ -61,37 +59,6 @@ class PromptManager: self.cache_manager = cache_manager self.CacheType = CacheType - self._load_base_template() - - def _load_base_template(self): - """加载基础提示词模板""" - try: - template_path = self.config.get("prompt_template", "agent-base-prompt.txt") - cache_key = f"prompt_template:{template_path}" - - # 先从缓存获取 - cached_template = self.cache_manager.get(self.CacheType.CONFIG, cache_key) - if cached_template is not None: - self.base_prompt_template = cached_template - self.logger.bind(tag=TAG).debug("从缓存加载基础提示词模板") - return - - # 缓存未命中,从文件读取 - if os.path.exists(template_path): - with open(template_path, "r", encoding="utf-8") as f: - template_content = f.read() - - # 存入缓存(CONFIG类型默认不自动过期,需要手动失效) - self.cache_manager.set( - self.CacheType.CONFIG, cache_key, template_content - ) - self.base_prompt_template = template_content - self.logger.bind(tag=TAG).debug("成功加载基础提示词模板并缓存") - else: - self.logger.bind(tag=TAG).warning(f"未找到{template_path}文件") - except Exception as e: - self.logger.bind(tag=TAG).error(f"加载提示词模板失败: {e}") - def get_quick_prompt(self, user_prompt: str, device_id: str = None) -> str: """快速获取系统提示词(使用用户配置)""" device_cache_key = f"device_prompt:{device_id}" @@ -184,17 +151,41 @@ class PromptManager: self.logger.bind(tag=TAG).error(f"更新上下文信息失败: {e}") def build_enhanced_prompt( - self, user_prompt: str, device_id: str, client_ip: str = None, *args, **kwargs + self, + user_prompt: str, + device_id: str, + client_ip: str = None, + user_persona: str = None, + *args, + **kwargs ) -> str: - """构建增强的系统提示词""" - if not self.base_prompt_template: - return user_prompt - + """构建增强的系统提示词(使用新的模块化架构)""" try: + from core.roles.prompts.builder import build_system_prompt + from core.roles import get_role_config_loader + + # 加载 role 配置 + role_id = self.config.get("role_id", "default") + loader = get_role_config_loader() + + try: + role_config = loader.load(role_id) + # 使用 role 配置中的 profile、timezone、language + profile = role_config.profile + timezone = role_config.timezone + language = role_config.language + self.logger.bind(tag=TAG).info(f"使用 role 配置: {role_id}") + except Exception as e: + # 如果加载失败,回退到使用传入的 user_prompt 和配置文件 + self.logger.bind(tag=TAG).warning(f"加载 role 配置失败: {e},使用默认配置") + profile = user_prompt + timezone = self.config.get("timezone", "Asia/Shanghai") + language = self.config.get("language", "zh") + # 获取最新的时间信息(不缓存) - today_date, today_weekday, lunar_date = ( - self._get_current_time_info() - ) + today_date, today_weekday, lunar_date = self._get_current_time_info() + # 清理 lunar_date 的换行符 + lunar_date = lunar_date.strip() if lunar_date else None # 获取缓存的上下文信息 local_address = "" @@ -213,30 +204,32 @@ class PromptManager: or "" ) - # 替换模板变量 - template = Template(self.base_prompt_template) - enhanced_prompt = template.render( - base_prompt=user_prompt, - current_time="{{current_time}}", + # 使用新的模块化架构构建 prompt + enhanced_prompt = build_system_prompt( + profile=profile, + timezone=timezone, + language=language, + user_persona=user_persona, today_date=today_date, today_weekday=today_weekday, lunar_date=lunar_date, local_address=local_address, weather_info=weather_info, - emojiList=EMOJI_List, device_id=device_id, - client_ip=client_ip, - *args, **kwargs + **kwargs ) + + # 缓存增强后的 prompt device_cache_key = f"device_prompt:{device_id}" self.cache_manager.set( self.CacheType.DEVICE_PROMPT, device_cache_key, enhanced_prompt ) + self.logger.bind(tag=TAG).info( f"构建增强提示词成功,长度: {len(enhanced_prompt)}" ) return enhanced_prompt except Exception as e: - self.logger.bind(tag=TAG).error(f"构建增强提示词失败: {e}") + self.logger.bind(tag=TAG).error(f"构建增强提示词失败: {e}", exc_info=True) return user_prompt diff --git a/main/xiaozhi-server/core/websocket_server.py b/main/xiaozhi-server/core/websocket_server.py index c0c88fc57..79f21a02d 100644 --- a/main/xiaozhi-server/core/websocket_server.py +++ b/main/xiaozhi-server/core/websocket_server.py @@ -80,6 +80,15 @@ class WebSocketServer: "authorization" ][0] + if "sample_rate" in query_params: + websocket.request.headers["audio-sample-rate"] = query_params["sample_rate"][0] + if "channels" in query_params: + websocket.request.headers["audio-channels"] = query_params["channels"][0] + if "codec" in query_params: + websocket.request.headers["audio-codec"] = query_params["codec"][0] + if "frame_duration" in query_params: + websocket.request.headers["audio-frame-duration"] = query_params["frame_duration"][0] + """处理新连接,每次创建独立的ConnectionHandler""" # 先认证,后建立连接 try: From 86b6f76f603fdeb4f8d85dd6ea0e19af6f6f1f67 Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 3 Nov 2025 14:54:48 +0800 Subject: [PATCH 03/31] feat: agent review done && device and binding develop done --- main/live-agent-api/main.py | 12 +- main/live-agent-api/orm/__init__.py | 21 +- main/live-agent-api/orm/agent/model.py | 12 +- main/live-agent-api/orm/agent/repository.py | 21 +- main/live-agent-api/orm/binding/__init__.py | 11 + main/live-agent-api/orm/binding/model.py | 93 +++++ main/live-agent-api/orm/binding/repository.py | 183 ++++++++++ main/live-agent-api/orm/device/__init__.py | 11 + main/live-agent-api/orm/device/model.py | 130 +++++++ main/live-agent-api/orm/device/repository.py | 172 ++++++++++ main/live-agent-api/pyproject.toml | 3 +- main/live-agent-api/router/__init__.py | 9 +- main/live-agent-api/router/agent.py | 35 +- main/live-agent-api/router/binding.py | 324 ++++++++++++++++++ main/live-agent-api/router/device.py | 253 ++++++++++++++ main/live-agent-api/schemas/__init__.py | 35 +- main/live-agent-api/schemas/agent.py | 59 +--- main/live-agent-api/schemas/binding.py | 170 +++++++++ main/live-agent-api/schemas/device.py | 270 +++++++++++++++ main/live-agent-api/services/agent_service.py | 94 +++-- .../services/binding_service.py | 260 ++++++++++++++ .../live-agent-api/services/device_service.py | 248 ++++++++++++++ main/live-agent-api/templates/__init__.py | 13 + .../templates/health_wellness.yaml | 70 ++++ .../templates/hospital_assistant.yaml | 57 +++ .../templates/learning_companion.yaml | 68 ++++ main/live-agent-api/templates/loader.py | 118 +++++++ .../templates/personal_assistant.yaml | 62 ++++ main/live-agent-api/utils/__init__.py | 18 + main/live-agent-api/utils/id_generator.py | 168 ++++----- main/live-agent-api/uv.lock | 24 +- 31 files changed, 2779 insertions(+), 245 deletions(-) create mode 100644 main/live-agent-api/orm/binding/__init__.py create mode 100644 main/live-agent-api/orm/binding/model.py create mode 100644 main/live-agent-api/orm/binding/repository.py create mode 100644 main/live-agent-api/orm/device/__init__.py create mode 100644 main/live-agent-api/orm/device/model.py create mode 100644 main/live-agent-api/orm/device/repository.py create mode 100644 main/live-agent-api/router/binding.py create mode 100644 main/live-agent-api/router/device.py create mode 100644 main/live-agent-api/schemas/binding.py create mode 100644 main/live-agent-api/schemas/device.py create mode 100644 main/live-agent-api/services/binding_service.py create mode 100644 main/live-agent-api/services/device_service.py create mode 100644 main/live-agent-api/templates/__init__.py create mode 100644 main/live-agent-api/templates/health_wellness.yaml create mode 100644 main/live-agent-api/templates/hospital_assistant.yaml create mode 100644 main/live-agent-api/templates/learning_companion.yaml create mode 100644 main/live-agent-api/templates/loader.py create mode 100644 main/live-agent-api/templates/personal_assistant.yaml diff --git a/main/live-agent-api/main.py b/main/live-agent-api/main.py index 123f2775a..64b2b6fb5 100644 --- a/main/live-agent-api/main.py +++ b/main/live-agent-api/main.py @@ -11,8 +11,8 @@ from fastapi.middleware.cors import CORSMiddleware from config.settings import settings from orm import init_database, close_database -from utils.id_generator import init_id_generator, close_id_generator -from router import agent_router +from utils import id_generator +from router import agent_router, device_router, binding_router # Configure logging @@ -30,9 +30,8 @@ async def lifespan(app: FastAPI): # Startup logger.info("Starting Live Agent Dashboard API...") - # Initialize ID generator - init_id_generator(instance_id=settings.instance_id) - logger.info(f"Initialized ID generator (instance={settings.instance_id})") + # Initialize ID generator (singleton, automatically initialized on first use) + logger.info(f"ID generator ready: {id_generator}") # Initialize database await init_database() @@ -44,7 +43,6 @@ async def lifespan(app: FastAPI): # Shutdown logger.info("Shutting down Live Agent Dashboard API...") await close_database() - close_id_generator() logger.info("Application shutdown complete") @@ -74,6 +72,8 @@ app.add_middleware( # Include routers app.include_router(agent_router, prefix=settings.api_prefix) +app.include_router(device_router, prefix=settings.api_prefix) +app.include_router(binding_router, prefix=settings.api_prefix) @app.get("/") diff --git a/main/live-agent-api/orm/__init__.py b/main/live-agent-api/orm/__init__.py index 0718025d9..29c47b244 100644 --- a/main/live-agent-api/orm/__init__.py +++ b/main/live-agent-api/orm/__init__.py @@ -10,13 +10,12 @@ from orm.base import ( get_db, init_database, close_database, + get_session_maker, ) from orm.agent import Agent, AgentRepository - -# Future imports: -# from orm.device import Device, DeviceRepository -# from orm.binding import Binding, BindingRepository +from orm.device import Device, DeviceRepository +from orm.binding import DeviceAgentBinding, DeviceAgentBindingRepository __all__ = [ # Base infrastructure @@ -24,15 +23,17 @@ __all__ = [ "get_db", "init_database", "close_database", + "get_session_maker", # Agent domain "Agent", "AgentRepository", - # Future domains - # "Device", - # "DeviceRepository", - # "Binding", - # "BindingRepository", + # Device domain + "Device", + "DeviceRepository", + + # Binding domain + "DeviceAgentBinding", + "DeviceAgentBindingRepository", ] - diff --git a/main/live-agent-api/orm/agent/model.py b/main/live-agent-api/orm/agent/model.py index 84b22d267..4c972f07c 100644 --- a/main/live-agent-api/orm/agent/model.py +++ b/main/live-agent-api/orm/agent/model.py @@ -17,13 +17,13 @@ class Agent(Base): Represents a voice assistant agent with its configuration. """ - __tablename__ = "agents" + __tablename__ = "live_agents" # Primary Key id: Mapped[str] = mapped_column( String(64), primary_key=True, - comment="Agent unique ID (Snowflake ID)" + comment="Agent unique ID" ) # Basic Information @@ -33,13 +33,6 @@ class Agent(Base): comment="Agent display name" ) - template: Mapped[str] = mapped_column( - String(100), - nullable=False, - default="blank", - comment="Agent template type (e.g., personal-assistant, blank)" - ) - language: Mapped[str] = mapped_column( String(10), nullable=False, @@ -96,7 +89,6 @@ class Agent(Base): return { "id": self.id, "name": self.name, - "template": self.template, "language": self.language, "firstMessage": self.first_message, "systemPrompt": self.system_prompt, diff --git a/main/live-agent-api/orm/agent/repository.py b/main/live-agent-api/orm/agent/repository.py index 1b1ce8a64..e585b6c1f 100644 --- a/main/live-agent-api/orm/agent/repository.py +++ b/main/live-agent-api/orm/agent/repository.py @@ -6,7 +6,7 @@ Encapsulates all database operations for Agent. """ from typing import Optional -from sqlalchemy import select, func, or_ +from sqlalchemy import select, func from sqlalchemy.ext.asyncio import AsyncSession from orm.agent.model import Agent @@ -43,18 +43,14 @@ class AgentRepository: search: Optional[str] = None, page: int = 1, page_size: int = 20, - sort_by: str = "created_at", - sort_order: str = "desc", ) -> tuple[list[Agent], int]: """ - Find all agents with filtering, pagination and sorting + Find all agents with filtering and pagination (sorted by creation time desc) Args: search: Search keyword (searches in name and system_prompt) page: Page number (starting from 1) page_size: Number of items per page - sort_by: Field to sort by - sort_order: Sort direction ('asc' or 'desc') Returns: Tuple of (agents list, total count) @@ -65,12 +61,7 @@ class AgentRepository: # Apply search filter if search: search_pattern = f"%{search}%" - stmt = stmt.where( - or_( - Agent.name.ilike(search_pattern), - Agent.system_prompt.ilike(search_pattern), - ) - ) + stmt = stmt.where(Agent.name.ilike(search_pattern)) # Get total count count_stmt = select(func.count()).select_from(stmt.subquery()) @@ -78,11 +69,7 @@ class AgentRepository: total = total_result.scalar_one() # Apply sorting - sort_column = getattr(Agent, sort_by, Agent.created_at) - if sort_order == "desc": - stmt = stmt.order_by(sort_column.desc()) - else: - stmt = stmt.order_by(sort_column.asc()) + stmt = stmt.order_by(Agent.created_at.desc()) # Apply pagination offset = (page - 1) * page_size diff --git a/main/live-agent-api/orm/binding/__init__.py b/main/live-agent-api/orm/binding/__init__.py new file mode 100644 index 000000000..9de827b63 --- /dev/null +++ b/main/live-agent-api/orm/binding/__init__.py @@ -0,0 +1,11 @@ +""" +DeviceAgentBinding ORM Package + +Exports DeviceAgentBinding model and repository. +""" + +from .model import DeviceAgentBinding +from .repository import DeviceAgentBindingRepository + +__all__ = ["DeviceAgentBinding", "DeviceAgentBindingRepository"] + diff --git a/main/live-agent-api/orm/binding/model.py b/main/live-agent-api/orm/binding/model.py new file mode 100644 index 000000000..40d4d9a4e --- /dev/null +++ b/main/live-agent-api/orm/binding/model.py @@ -0,0 +1,93 @@ +""" +DeviceAgentBinding ORM Model + +Defines the DeviceAgentBinding database table structure for linking devices and agents. +""" + +from datetime import datetime, timezone +from sqlalchemy import String, DateTime, ForeignKey, UniqueConstraint +from sqlalchemy.orm import Mapped, mapped_column + +from orm.base import Base + + +class DeviceAgentBinding(Base): + """ + DeviceAgentBinding database model + + Represents the binding relationship between a device and an agent. + Each device can only be bound to one agent at a time. + """ + __tablename__ = "device_agent_bindings" + __table_args__ = ( + UniqueConstraint('device_id', name='uq_device_id'), + ) + + # Primary Key + id: Mapped[str] = mapped_column( + String(64), + primary_key=True, + comment="Binding unique ID (ULID)" + ) + + # Foreign Keys + device_id: Mapped[str] = mapped_column( + String(64), + ForeignKey("devices.id", ondelete="CASCADE"), + nullable=False, + unique=True, + index=True, + comment="Device ID (FK)" + ) + + agent_id: Mapped[str] = mapped_column( + String(64), + ForeignKey("agents.id", ondelete="CASCADE"), + nullable=False, + index=True, + comment="Agent ID (FK)" + ) + + # Binding Information + status: Mapped[str] = mapped_column( + String(20), + nullable=False, + default="active", + comment="Binding status (active, inactive)" + ) + + # Timestamps + created_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=False, + default=lambda: datetime.now(timezone.utc), + comment="Creation timestamp" + ) + + updated_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=False, + default=lambda: datetime.now(timezone.utc), + onupdate=lambda: datetime.now(timezone.utc), + comment="Last update timestamp" + ) + + def __repr__(self) -> str: + return f"" + + def to_dict(self) -> dict: + """ + Convert model to dictionary + + Returns: + Dictionary representation of the binding + """ + return { + "id": self.id, + "deviceId": self.device_id, + "agentId": self.agent_id, + "status": self.status, + "createdAt": self.created_at.isoformat() if self.created_at else None, + "updatedAt": self.updated_at.isoformat() if self.updated_at else None, + } + diff --git a/main/live-agent-api/orm/binding/repository.py b/main/live-agent-api/orm/binding/repository.py new file mode 100644 index 000000000..d52fb0dad --- /dev/null +++ b/main/live-agent-api/orm/binding/repository.py @@ -0,0 +1,183 @@ +""" +DeviceAgentBinding Repository + +Data access layer for DeviceAgentBinding entity. +Encapsulates all database operations for device-agent bindings. +""" + +from typing import Optional +from sqlalchemy import select, func, or_ +from sqlalchemy.ext.asyncio import AsyncSession + +from orm.binding.model import DeviceAgentBinding + + +class DeviceAgentBindingRepository: + """Repository for DeviceAgentBinding data access operations""" + + def __init__(self, db: AsyncSession): + """ + Initialize repository with database session + + Args: + db: SQLAlchemy async session + """ + self.db = db + + async def find_by_id(self, binding_id: str) -> Optional[DeviceAgentBinding]: + """ + Find binding by ID + + Args: + binding_id: Binding unique ID + + Returns: + DeviceAgentBinding instance or None if not found + """ + stmt = select(DeviceAgentBinding).where(DeviceAgentBinding.id == binding_id) + result = await self.db.execute(stmt) + return result.scalar_one_or_none() + + async def find_by_device_id(self, device_id: str) -> Optional[DeviceAgentBinding]: + """ + Find binding by device ID + + Args: + device_id: Device unique ID + + Returns: + DeviceAgentBinding instance or None if not found + """ + stmt = select(DeviceAgentBinding).where(DeviceAgentBinding.device_id == device_id) + result = await self.db.execute(stmt) + return result.scalar_one_or_none() + + async def find_by_agent_id(self, agent_id: str) -> list[DeviceAgentBinding]: + """ + Find all bindings for an agent + + Args: + agent_id: Agent unique ID + + Returns: + List of DeviceAgentBinding instances + """ + stmt = select(DeviceAgentBinding).where(DeviceAgentBinding.agent_id == agent_id) + result = await self.db.execute(stmt) + return list(result.scalars().all()) + + async def find_all( + self, + device_id: Optional[str] = None, + agent_id: Optional[str] = None, + status: Optional[str] = None, + page: int = 1, + page_size: int = 20, + sort_by: str = "created_at", + sort_order: str = "desc", + ) -> tuple[list[DeviceAgentBinding], int]: + """ + Find all bindings with filtering, pagination and sorting + + Args: + device_id: Filter by device ID + agent_id: Filter by agent ID + status: Filter by status + page: Page number (starting from 1) + page_size: Number of items per page + sort_by: Field to sort by + sort_order: Sort direction ('asc' or 'desc') + + Returns: + Tuple of (bindings list, total count) + """ + # Build base query + stmt = select(DeviceAgentBinding) + + # Apply filters + if device_id: + stmt = stmt.where(DeviceAgentBinding.device_id == device_id) + + if agent_id: + stmt = stmt.where(DeviceAgentBinding.agent_id == agent_id) + + if status: + stmt = stmt.where(DeviceAgentBinding.status == status) + + # Get total count + count_stmt = select(func.count()).select_from(stmt.subquery()) + total_result = await self.db.execute(count_stmt) + total = total_result.scalar_one() + + # Apply sorting + sort_column = getattr(DeviceAgentBinding, sort_by, DeviceAgentBinding.created_at) + if sort_order == "desc": + stmt = stmt.order_by(sort_column.desc()) + else: + stmt = stmt.order_by(sort_column.asc()) + + # Apply pagination + offset = (page - 1) * page_size + stmt = stmt.offset(offset).limit(page_size) + + # Execute query + result = await self.db.execute(stmt) + bindings = list(result.scalars().all()) + + return bindings, total + + async def save(self, binding: DeviceAgentBinding) -> DeviceAgentBinding: + """ + Save or update binding + + Args: + binding: DeviceAgentBinding instance to save + + Returns: + Saved binding instance + """ + self.db.add(binding) + await self.db.flush() + await self.db.refresh(binding) + return binding + + async def delete(self, binding: DeviceAgentBinding) -> None: + """ + Delete binding + + Args: + binding: DeviceAgentBinding instance to delete + """ + await self.db.delete(binding) + await self.db.flush() + + async def exists(self, binding_id: str) -> bool: + """ + Check if binding exists + + Args: + binding_id: Binding unique ID + + Returns: + True if binding exists, False otherwise + """ + stmt = select(func.count()).where(DeviceAgentBinding.id == binding_id) + result = await self.db.execute(stmt) + count = result.scalar_one() + return count > 0 + + async def device_has_binding(self, device_id: str) -> bool: + """ + Check if device already has a binding + + Args: + device_id: Device unique ID + + Returns: + True if device has binding, False otherwise + """ + stmt = select(func.count()).where(DeviceAgentBinding.device_id == device_id) + result = await self.db.execute(stmt) + count = result.scalar_one() + return count > 0 + diff --git a/main/live-agent-api/orm/device/__init__.py b/main/live-agent-api/orm/device/__init__.py new file mode 100644 index 000000000..8c892ea16 --- /dev/null +++ b/main/live-agent-api/orm/device/__init__.py @@ -0,0 +1,11 @@ +""" +Device ORM Package + +Exports Device model and repository. +""" + +from .model import Device +from .repository import DeviceRepository + +__all__ = ["Device", "DeviceRepository"] + diff --git a/main/live-agent-api/orm/device/model.py b/main/live-agent-api/orm/device/model.py new file mode 100644 index 000000000..c0095f2ae --- /dev/null +++ b/main/live-agent-api/orm/device/model.py @@ -0,0 +1,130 @@ +""" +Device ORM Model + +Defines the Device database table structure and basic data operations. +""" + +from datetime import datetime, timezone +from sqlalchemy import String, Text, DateTime, Boolean +from sqlalchemy.orm import Mapped, mapped_column + +from orm.base import Base + + +class Device(Base): + """ + Device database model + + Represents a physical device that can be bound to agents. + """ + __tablename__ = "devices" + + # Primary Key + id: Mapped[str] = mapped_column( + String(64), + primary_key=True, + comment="Device unique ID (ULID)" + ) + + # Basic Information + name: Mapped[str] = mapped_column( + String(255), + nullable=False, + comment="Device display name" + ) + + device_id: Mapped[str] = mapped_column( + String(255), + nullable=False, + unique=True, + index=True, + comment="Device hardware ID" + ) + + model: Mapped[str] = mapped_column( + String(100), + nullable=True, + comment="Device model (e.g., PLAUD NOTE)" + ) + + firmware_version: Mapped[str] = mapped_column( + String(50), + nullable=True, + comment="Firmware version" + ) + + # Device Status + status: Mapped[str] = mapped_column( + String(20), + nullable=False, + default="active", + comment="Device status (active, inactive, offline)" + ) + + is_online: Mapped[bool] = mapped_column( + Boolean, + nullable=False, + default=False, + comment="Whether device is currently online" + ) + + last_seen_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=True, + comment="Last seen timestamp" + ) + + # Additional Information + description: Mapped[str] = mapped_column( + Text, + nullable=True, + comment="Device description" + ) + + extra_data: Mapped[str] = mapped_column( + Text, + nullable=True, + comment="Additional metadata (JSON format)" + ) + + # Timestamps + created_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=False, + default=lambda: datetime.now(timezone.utc), + comment="Creation timestamp" + ) + + updated_at: Mapped[datetime] = mapped_column( + DateTime, + nullable=False, + default=lambda: datetime.now(timezone.utc), + onupdate=lambda: datetime.now(timezone.utc), + comment="Last update timestamp" + ) + + def __repr__(self) -> str: + return f"" + + def to_dict(self) -> dict: + """ + Convert model to dictionary + + Returns: + Dictionary representation of the device + """ + return { + "id": self.id, + "name": self.name, + "deviceId": self.device_id, + "model": self.model, + "firmwareVersion": self.firmware_version, + "status": self.status, + "isOnline": self.is_online, + "lastSeenAt": self.last_seen_at.isoformat() if self.last_seen_at else None, + "description": self.description, + "extraData": self.extra_data, + "createdAt": self.created_at.isoformat() if self.created_at else None, + "updatedAt": self.updated_at.isoformat() if self.updated_at else None, + } + diff --git a/main/live-agent-api/orm/device/repository.py b/main/live-agent-api/orm/device/repository.py new file mode 100644 index 000000000..e46d2b46f --- /dev/null +++ b/main/live-agent-api/orm/device/repository.py @@ -0,0 +1,172 @@ +""" +Device Repository + +Data access layer for Device entity. +Encapsulates all database operations for Device. +""" + +from typing import Optional +from sqlalchemy import select, func, or_ +from sqlalchemy.ext.asyncio import AsyncSession + +from orm.device.model import Device + + +class DeviceRepository: + """Repository for Device data access operations""" + + def __init__(self, db: AsyncSession): + """ + Initialize repository with database session + + Args: + db: SQLAlchemy async session + """ + self.db = db + + async def find_by_id(self, device_id: str) -> Optional[Device]: + """ + Find device by ID + + Args: + device_id: Device unique ID + + Returns: + Device instance or None if not found + """ + stmt = select(Device).where(Device.id == device_id) + result = await self.db.execute(stmt) + return result.scalar_one_or_none() + + async def find_by_device_id(self, device_id: str) -> Optional[Device]: + """ + Find device by hardware device ID + + Args: + device_id: Device hardware ID + + Returns: + Device instance or None if not found + """ + stmt = select(Device).where(Device.device_id == device_id) + result = await self.db.execute(stmt) + return result.scalar_one_or_none() + + async def find_all( + self, + search: Optional[str] = None, + status: Optional[str] = None, + page: int = 1, + page_size: int = 20, + sort_by: str = "created_at", + sort_order: str = "desc", + ) -> tuple[list[Device], int]: + """ + Find all devices with filtering, pagination and sorting + + Args: + search: Search keyword (searches in name and device_id) + status: Filter by status + page: Page number (starting from 1) + page_size: Number of items per page + sort_by: Field to sort by + sort_order: Sort direction ('asc' or 'desc') + + Returns: + Tuple of (devices list, total count) + """ + # Build base query + stmt = select(Device) + + # Apply search filter + if search: + search_pattern = f"%{search}%" + stmt = stmt.where( + or_( + Device.name.ilike(search_pattern), + Device.device_id.ilike(search_pattern), + Device.model.ilike(search_pattern), + ) + ) + + # Apply status filter + if status: + stmt = stmt.where(Device.status == status) + + # Get total count + count_stmt = select(func.count()).select_from(stmt.subquery()) + total_result = await self.db.execute(count_stmt) + total = total_result.scalar_one() + + # Apply sorting + sort_column = getattr(Device, sort_by, Device.created_at) + if sort_order == "desc": + stmt = stmt.order_by(sort_column.desc()) + else: + stmt = stmt.order_by(sort_column.asc()) + + # Apply pagination + offset = (page - 1) * page_size + stmt = stmt.offset(offset).limit(page_size) + + # Execute query + result = await self.db.execute(stmt) + devices = list(result.scalars().all()) + + return devices, total + + async def save(self, device: Device) -> Device: + """ + Save or update device + + Args: + device: Device instance to save + + Returns: + Saved device instance + """ + self.db.add(device) + await self.db.flush() + await self.db.refresh(device) + return device + + async def delete(self, device: Device) -> None: + """ + Delete device + + Args: + device: Device instance to delete + """ + await self.db.delete(device) + await self.db.flush() + + async def exists(self, device_id: str) -> bool: + """ + Check if device exists + + Args: + device_id: Device unique ID + + Returns: + True if device exists, False otherwise + """ + stmt = select(func.count()).where(Device.id == device_id) + result = await self.db.execute(stmt) + count = result.scalar_one() + return count > 0 + + async def device_id_exists(self, device_id: str) -> bool: + """ + Check if hardware device ID exists + + Args: + device_id: Device hardware ID + + Returns: + True if device_id exists, False otherwise + """ + stmt = select(func.count()).where(Device.device_id == device_id) + result = await self.db.execute(stmt) + count = result.scalar_one() + return count > 0 + diff --git a/main/live-agent-api/pyproject.toml b/main/live-agent-api/pyproject.toml index 196dea78d..c143d88ad 100644 --- a/main/live-agent-api/pyproject.toml +++ b/main/live-agent-api/pyproject.toml @@ -13,7 +13,8 @@ dependencies = [ "openai>=1.54.0", "python-dotenv>=1.0.0", "httpx>=0.27.0", - "snowflake-id>=1.0.2", + "python-ulid>=2.7.0", + "pyyaml>=6.0.0", ] [dependency-groups] diff --git a/main/live-agent-api/router/__init__.py b/main/live-agent-api/router/__init__.py index 5181e0caf..5803f0a4f 100644 --- a/main/live-agent-api/router/__init__.py +++ b/main/live-agent-api/router/__init__.py @@ -5,6 +5,11 @@ FastAPI route handlers for all API endpoints. """ from router.agent import router as agent_router +from router.device import router as device_router +from router.binding import router as binding_router -__all__ = ["agent_router"] - +__all__ = [ + "agent_router", + "device_router", + "binding_router", +] diff --git a/main/live-agent-api/router/agent.py b/main/live-agent-api/router/agent.py index 943633cd8..22a64add4 100644 --- a/main/live-agent-api/router/agent.py +++ b/main/live-agent-api/router/agent.py @@ -26,6 +26,7 @@ from utils.response import ( error_response, paginated_response, ) +from templates import TemplateLoader logger = logging.getLogger(__name__) @@ -38,20 +39,16 @@ async def get_agent_list( search: Annotated[str | None, Query(description="Search keyword")] = None, page: Annotated[int, Query(ge=1, description="Page number")] = 1, pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 20, - sortBy: Annotated[str, Query(alias="sortBy", description="Sort field")] = "createdAt", - sortOrder: Annotated[str, Query(alias="sortOrder", pattern="^(asc|desc)$", description="Sort order")] = "desc", db: AsyncSession = Depends(get_db), ) -> ApiResponse: """ - Get Agent list with search, pagination and sorting + Get Agent list with search and pagination (sorted by creation time desc) - **search**: Search keyword (searches in name and system prompt) - **page**: Page number (starting from 1) - - **pageSize**: Number of items per page (1-100) - - **sortBy**: Field to sort by (default: createdAt) - - **sortOrder**: Sort order - asc or desc (default: desc) + - **pageSize**: Number of items per page (1-100, default: 20) - Returns paginated list of agents with total count. + Returns paginated list of agents sorted by creation time (newest first) with total count. """ try: # Create query object @@ -59,8 +56,6 @@ async def get_agent_list( search=search, page=page, page_size=pageSize, - sort_by=sortBy, - sort_order=sortOrder, ) # Get service @@ -154,6 +149,13 @@ async def create_agent( code=201 ) + except ValueError as e: + # Template validation errors + logger.warning(f"Validation error creating agent: {str(e)}") + return error_response( + message=str(e), + code=400 + ) except Exception as e: logger.error(f"Error creating agent: {str(e)}") return error_response( @@ -296,10 +298,19 @@ async def generate_system_prompt( Generate system prompt using AI Request body: - - **description**: Description of the agent's purpose (required) + - **description**: Description of the agent's purpose and requirements (required) + - **currentPrompt**: Existing system prompt to refine or build upon (optional) - Uses OpenAI to generate a professional system prompt based on the description. - Returns the generated prompt. + Uses OpenAI to generate a professional system prompt that follows the 6-module structure: + 1. Personality - Agent's character and communication style + 2. Environment - Context and operating setting + 3. Tone - Language tone and interaction manner + 4. Goal - Primary objectives and purposes + 5. Guardrails - Rules, limitations, and ethical boundaries + 6. Tools - Available capabilities and functions + + If currentPrompt is provided, the AI will refine it based on the description. + Otherwise, it creates a new prompt from scratch. """ try: service = get_agent_service(db) diff --git a/main/live-agent-api/router/binding.py b/main/live-agent-api/router/binding.py new file mode 100644 index 000000000..5e46a689f --- /dev/null +++ b/main/live-agent-api/router/binding.py @@ -0,0 +1,324 @@ +""" +DeviceAgentBinding Router + +API endpoints for Device-Agent binding management. +""" + +import logging +from typing import Annotated +from fastapi import APIRouter, Depends, Query +from sqlalchemy.ext.asyncio import AsyncSession + +from orm import get_db +from services.binding_service import BindingService, get_binding_service +from schemas.binding import ( + BindingCreate, + BindingUpdate, + BindingResponse, + BindingListQuery, +) +from utils.response import ( + ApiResponse, + success_response, + error_response, + paginated_response, +) + + +logger = logging.getLogger(__name__) + +router = APIRouter(prefix="/binding", tags=["binding"]) + + +@router.get("/") +async def get_binding_list( + deviceId: Annotated[str | None, Query(alias="deviceId", description="Filter by device ID")] = None, + agentId: Annotated[str | None, Query(alias="agentId", description="Filter by agent ID")] = None, + status: Annotated[str | None, Query(description="Filter by status")] = None, + page: Annotated[int, Query(ge=1, description="Page number")] = 1, + pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 10, + sortBy: Annotated[str, Query(alias="sortBy", description="Sort field")] = "createdAt", + sortOrder: Annotated[str, Query(alias="sortOrder", pattern="^(asc|desc)$", description="Sort order")] = "desc", + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get DeviceAgentBinding list with filtering, pagination and sorting + + - **deviceId**: Filter by device ID + - **agentId**: Filter by agent ID + - **status**: Filter by status (active, inactive) + - **page**: Page number (starting from 1) + - **pageSize**: Number of items per page (1-100) + - **sortBy**: Field to sort by (default: createdAt) + - **sortOrder**: Sort order - asc or desc (default: desc) + + Returns paginated list of bindings with total count. + """ + try: + # Create query object + query = BindingListQuery( + device_id=deviceId, + agent_id=agentId, + status=status, + page=page, + page_size=pageSize, + sort_by=sortBy, + sort_order=sortOrder, + ) + + # Get service + service = get_binding_service(db) + + # Get bindings + bindings, total = await service.get_binding_list(query) + + # Convert to response format + binding_responses = [ + BindingResponse.model_validate(binding) for binding in bindings + ] + + # Create paginated response + pagination_data = paginated_response( + items=binding_responses, + total=total, + page=page, + page_size=pageSize, + ) + + return success_response(data=pagination_data) + + except Exception as e: + logger.error(f"Error getting binding list: {str(e)}") + return error_response( + message=f"Failed to get binding list: {str(e)}", + code=500 + ) + + +@router.get("/{binding_id}") +async def get_binding_detail( + binding_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get DeviceAgentBinding details by ID + + - **binding_id**: Binding unique ID + + Returns detailed binding information. + """ + try: + service = get_binding_service(db) + binding = await service.get_binding_by_id(binding_id) + + if not binding: + return error_response( + message=f"Binding not found: {binding_id}", + code=404 + ) + + binding_response = BindingResponse.model_validate(binding) + return success_response(data=binding_response) + + except Exception as e: + logger.error(f"Error getting binding detail: {str(e)}") + return error_response( + message=f"Failed to get binding detail: {str(e)}", + code=500 + ) + + +@router.get("/device/{device_id}") +async def get_binding_by_device( + device_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get DeviceAgentBinding by device ID + + - **device_id**: Device unique ID + + Returns binding information for the device. + """ + try: + service = get_binding_service(db) + binding = await service.get_binding_by_device_id(device_id) + + if not binding: + return error_response( + message=f"No binding found for device: {device_id}", + code=404 + ) + + binding_response = BindingResponse.model_validate(binding) + return success_response(data=binding_response) + + except Exception as e: + logger.error(f"Error getting binding by device: {str(e)}") + return error_response( + message=f"Failed to get binding by device: {str(e)}", + code=500 + ) + + +@router.post("/") +async def create_binding( + binding_data: BindingCreate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Create a new DeviceAgentBinding + + Request body: + - **deviceId**: Device unique ID (required) + - **agentId**: Agent unique ID (required) + + Returns the created binding with generated ID. + + Note: Each device can only be bound to one agent at a time. + """ + try: + service = get_binding_service(db) + binding = await service.create_binding(binding_data) + + binding_response = BindingResponse.model_validate(binding) + return success_response( + data=binding_response, + message="Binding created successfully", + code=201 + ) + + except ValueError as e: + # Business logic errors (e.g., device not found, already bound) + logger.warning(f"Validation error creating binding: {str(e)}") + return error_response( + message=str(e), + code=400 + ) + except Exception as e: + logger.error(f"Error creating binding: {str(e)}") + return error_response( + message=f"Failed to create binding: {str(e)}", + code=500 + ) + + +@router.put("/{binding_id}") +async def update_binding( + binding_id: str, + binding_data: BindingUpdate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Update DeviceAgentBinding configuration + + - **binding_id**: Binding unique ID + + Request body (all fields optional): + - **agentId**: Agent unique ID (to change the bound agent) + - **status**: Binding status (active, inactive) + + Returns the updated binding information. + """ + try: + service = get_binding_service(db) + binding = await service.update_binding(binding_id, binding_data) + + if not binding: + return error_response( + message=f"Binding not found: {binding_id}", + code=404 + ) + + binding_response = BindingResponse.model_validate(binding) + return success_response( + data=binding_response, + message="Binding updated successfully" + ) + + except ValueError as e: + # Business logic errors (e.g., agent not found) + logger.warning(f"Validation error updating binding: {str(e)}") + return error_response( + message=str(e), + code=400 + ) + except Exception as e: + logger.error(f"Error updating binding: {str(e)}") + return error_response( + message=f"Failed to update binding: {str(e)}", + code=500 + ) + + +@router.delete("/{binding_id}") +async def delete_binding( + binding_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Delete a DeviceAgentBinding + + - **binding_id**: Binding unique ID + + Deletes the binding relationship between device and agent. + Returns success message if deleted. + """ + try: + service = get_binding_service(db) + deleted = await service.delete_binding(binding_id) + + if not deleted: + return error_response( + message=f"Binding not found: {binding_id}", + code=404 + ) + + return success_response( + data={"id": binding_id}, + message="Binding deleted successfully" + ) + + except Exception as e: + logger.error(f"Error deleting binding: {str(e)}") + return error_response( + message=f"Failed to delete binding: {str(e)}", + code=500 + ) + + +@router.delete("/device/{device_id}") +async def unbind_device( + device_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Remove binding for a device + + - **device_id**: Device unique ID + + Unbinds the device from its agent. + Returns success message if unbound. + """ + try: + service = get_binding_service(db) + unbound = await service.unbind_device(device_id) + + if not unbound: + return error_response( + message=f"No binding found for device: {device_id}", + code=404 + ) + + return success_response( + data={"deviceId": device_id}, + message="Device unbound successfully" + ) + + except Exception as e: + logger.error(f"Error unbinding device: {str(e)}") + return error_response( + message=f"Failed to unbind device: {str(e)}", + code=500 + ) + diff --git a/main/live-agent-api/router/device.py b/main/live-agent-api/router/device.py new file mode 100644 index 000000000..506604953 --- /dev/null +++ b/main/live-agent-api/router/device.py @@ -0,0 +1,253 @@ +""" +Device Router + +API endpoints for Device management. +""" + +import logging +from typing import Annotated +from fastapi import APIRouter, Depends, Query +from sqlalchemy.ext.asyncio import AsyncSession + +from orm import get_db +from services.device_service import DeviceService, get_device_service +from schemas.device import ( + DeviceCreate, + DeviceUpdate, + DeviceResponse, + DeviceListQuery, +) +from utils.response import ( + ApiResponse, + success_response, + error_response, + paginated_response, +) + + +logger = logging.getLogger(__name__) + +router = APIRouter(prefix="/device", tags=["device"]) + + +@router.get("/") +async def get_device_list( + search: Annotated[str | None, Query(description="Search keyword")] = None, + status: Annotated[str | None, Query(description="Filter by status")] = None, + page: Annotated[int, Query(ge=1, description="Page number")] = 1, + pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 10, + sortBy: Annotated[str, Query(alias="sortBy", description="Sort field")] = "createdAt", + sortOrder: Annotated[str, Query(alias="sortOrder", pattern="^(asc|desc)$", description="Sort order")] = "desc", + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get Device list with search, filtering, pagination and sorting + + - **search**: Search keyword (searches in name, device_id, and model) + - **status**: Filter by status (active, inactive, offline) + - **page**: Page number (starting from 1) + - **pageSize**: Number of items per page (1-100) + - **sortBy**: Field to sort by (default: createdAt) + - **sortOrder**: Sort order - asc or desc (default: desc) + + Returns paginated list of devices with total count. + """ + try: + # Create query object + query = DeviceListQuery( + search=search, + status=status, + page=page, + page_size=pageSize, + sort_by=sortBy, + sort_order=sortOrder, + ) + + # Get service + service = get_device_service(db) + + # Get devices + devices, total = await service.get_device_list(query) + + # Convert to response format + device_responses = [ + DeviceResponse.model_validate(device) for device in devices + ] + + # Create paginated response + pagination_data = paginated_response( + items=device_responses, + total=total, + page=page, + page_size=pageSize, + ) + + return success_response(data=pagination_data) + + except Exception as e: + logger.error(f"Error getting device list: {str(e)}") + return error_response( + message=f"Failed to get device list: {str(e)}", + code=500 + ) + + +@router.get("/{device_id}") +async def get_device_detail( + device_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Get Device details by ID + + - **device_id**: Device unique ID + + Returns detailed device information. + """ + try: + service = get_device_service(db) + device = await service.get_device_by_id(device_id) + + if not device: + return error_response( + message=f"Device not found: {device_id}", + code=404 + ) + + device_response = DeviceResponse.model_validate(device) + return success_response(data=device_response) + + except Exception as e: + logger.error(f"Error getting device detail: {str(e)}") + return error_response( + message=f"Failed to get device detail: {str(e)}", + code=500 + ) + + +@router.post("/") +async def create_device( + device_data: DeviceCreate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Create a new Device + + Request body: + - **name**: Device display name (required) + - **deviceId**: Device hardware ID (required, must be unique) + - **model**: Device model (optional) + - **firmwareVersion**: Firmware version (optional) + - **status**: Device status (default: active) + - **description**: Device description (optional) + - **metadata**: Additional metadata in JSON format (optional) + + Returns the created device with generated ID. + """ + try: + service = get_device_service(db) + device = await service.create_device(device_data) + + device_response = DeviceResponse.model_validate(device) + return success_response( + data=device_response, + message="Device created successfully", + code=201 + ) + + except ValueError as e: + # Business logic errors (e.g., duplicate device_id) + logger.warning(f"Validation error creating device: {str(e)}") + return error_response( + message=str(e), + code=400 + ) + except Exception as e: + logger.error(f"Error creating device: {str(e)}") + return error_response( + message=f"Failed to create device: {str(e)}", + code=500 + ) + + +@router.put("/{device_id}") +async def update_device( + device_id: str, + device_data: DeviceUpdate, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Update Device configuration + + - **device_id**: Device unique ID + + Request body (all fields optional): + - **name**: Device display name + - **model**: Device model + - **firmwareVersion**: Firmware version + - **status**: Device status + - **isOnline**: Whether device is online + - **description**: Device description + - **metadata**: Additional metadata + + Returns the updated device information. + """ + try: + service = get_device_service(db) + device = await service.update_device(device_id, device_data) + + if not device: + return error_response( + message=f"Device not found: {device_id}", + code=404 + ) + + device_response = DeviceResponse.model_validate(device) + return success_response( + data=device_response, + message="Device updated successfully" + ) + + except Exception as e: + logger.error(f"Error updating device: {str(e)}") + return error_response( + message=f"Failed to update device: {str(e)}", + code=500 + ) + + +@router.delete("/{device_id}") +async def delete_device( + device_id: str, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Delete a Device + + - **device_id**: Device unique ID + + Deletes the device if no binding relationships exist. + Returns success message if deleted. + """ + try: + service = get_device_service(db) + deleted = await service.delete_device(device_id) + + if not deleted: + return error_response( + message=f"Device not found: {device_id}", + code=404 + ) + + return success_response( + data={"id": device_id}, + message="Device deleted successfully" + ) + + except Exception as e: + logger.error(f"Error deleting device: {str(e)}") + return error_response( + message=f"Failed to delete device: {str(e)}", + code=500 + ) + diff --git a/main/live-agent-api/schemas/__init__.py b/main/live-agent-api/schemas/__init__.py index a0d65e62d..67112443d 100644 --- a/main/live-agent-api/schemas/__init__.py +++ b/main/live-agent-api/schemas/__init__.py @@ -4,6 +4,7 @@ API Schemas Pydantic models for request/response validation. """ +# Agent schemas from schemas.agent import ( AgentBase, AgentCreate, @@ -15,7 +16,26 @@ from schemas.agent import ( GeneratePromptResponse, ) +# Device schemas +from schemas.device import ( + DeviceBase, + DeviceCreate, + DeviceUpdate, + DeviceResponse, + DeviceListQuery, +) + +# Binding schemas +from schemas.binding import ( + BindingCreate, + BindingUpdate, + BindingResponse, + BindingWithDetails, + BindingListQuery, +) + __all__ = [ + # Agent schemas "AgentBase", "AgentCreate", "AgentUpdate", @@ -24,5 +44,18 @@ __all__ = [ "AgentListQuery", "GeneratePromptRequest", "GeneratePromptResponse", + + # Device schemas + "DeviceBase", + "DeviceCreate", + "DeviceUpdate", + "DeviceResponse", + "DeviceListQuery", + + # Binding schemas + "BindingCreate", + "BindingUpdate", + "BindingResponse", + "BindingWithDetails", + "BindingListQuery", ] - diff --git a/main/live-agent-api/schemas/agent.py b/main/live-agent-api/schemas/agent.py index 90c94f291..a5437a56e 100644 --- a/main/live-agent-api/schemas/agent.py +++ b/main/live-agent-api/schemas/agent.py @@ -18,11 +18,6 @@ class AgentBase(BaseModel): max_length=255, description="Agent display name" ) - template: str = Field( - default="blank", - max_length=100, - description="Agent template type" - ) language: str = Field( default="en", max_length=10, @@ -50,7 +45,6 @@ class AgentBase(BaseModel): "json_schema_extra": { "example": { "name": "My Assistant", - "template": "personal-assistant", "language": "en", "firstMessage": "Hello! How can I help you today?", "systemPrompt": "You are a helpful assistant.", @@ -63,6 +57,12 @@ class AgentBase(BaseModel): class AgentCreate(AgentBase): """Schema for creating a new Agent""" + template: str = Field( + default="blank", + max_length=100, + description="Agent template type (blank, personal_assistant, learning_companion, health_wellness, hospital_assistant)" + ) + @field_validator('name') @classmethod def validate_name(cls, v: str) -> str: @@ -84,14 +84,8 @@ class AgentCreate(AgentBase): class AgentUpdate(BaseModel): - """Schema for updating an Agent (all fields optional)""" + """Schema for updating an Agent (all fields optional, name is immutable)""" - name: Optional[str] = Field( - None, - min_length=1, - max_length=255, - description="Agent display name" - ) language: Optional[str] = Field( None, max_length=10, @@ -118,7 +112,6 @@ class AgentUpdate(BaseModel): "populate_by_name": True, "json_schema_extra": { "example": { - "name": "Updated Agent Name", "language": "zh", "firstMessage": "你好!有什么可以帮助你的吗?", "systemPrompt": "You are a helpful Chinese assistant.", @@ -127,16 +120,6 @@ class AgentUpdate(BaseModel): } } - @field_validator('name') - @classmethod - def validate_name(cls, v: Optional[str]) -> Optional[str]: - """Validate and clean agent name""" - if v is not None: - v = v.strip() - if not v: - raise ValueError("Agent name cannot be empty") - return v - @field_validator('language') @classmethod def validate_language(cls, v: Optional[str]) -> Optional[str]: @@ -189,7 +172,6 @@ class AgentResponse(AgentBase): "example": { "id": "1234567890", "name": "My Assistant", - "template": "personal-assistant", "language": "en", "firstMessage": "Hello! How can I help you today?", "systemPrompt": "You are a helpful assistant.", @@ -202,7 +184,7 @@ class AgentResponse(AgentBase): class AgentListQuery(BaseModel): - """Schema for Agent list query parameters""" + """Schema for Agent list query parameters (sorted by creation time desc)""" search: Optional[str] = Field( None, @@ -221,17 +203,6 @@ class AgentListQuery(BaseModel): le=100, description="Number of items per page" ) - sort_by: str = Field( - default="createdAt", - alias="sortBy", - description="Sort field" - ) - sort_order: str = Field( - default="desc", - alias="sortOrder", - pattern="^(asc|desc)$", - description="Sort order (asc or desc)" - ) model_config = { "populate_by_name": True @@ -244,14 +215,22 @@ class GeneratePromptRequest(BaseModel): description: str = Field( ..., min_length=1, - max_length=1000, - description="Description of the agent's purpose" + max_length=500, + description="Description of the agent's purpose and requirements" + ) + current_prompt: Optional[str] = Field( + None, + alias="currentPrompt", + max_length=10000, + description="Existing system prompt to refine or build upon (optional)" ) model_config = { + "populate_by_name": True, "json_schema_extra": { "example": { - "description": "a customer support agent for PLAUD" + "description": "a customer support agent for PLAUD that handles technical questions", + "currentPrompt": "You are a helpful assistant for PLAUD customers." } } } diff --git a/main/live-agent-api/schemas/binding.py b/main/live-agent-api/schemas/binding.py new file mode 100644 index 000000000..8a577eba7 --- /dev/null +++ b/main/live-agent-api/schemas/binding.py @@ -0,0 +1,170 @@ +""" +DeviceAgentBinding Schemas + +Pydantic models for DeviceAgentBinding API request/response validation. +""" + +from datetime import datetime +from typing import Optional +from pydantic import BaseModel, Field + + +class BindingCreate(BaseModel): + """Schema for creating a new DeviceAgentBinding""" + + device_id: str = Field( + ..., + alias="deviceId", + min_length=1, + max_length=64, + description="Device unique ID" + ) + agent_id: str = Field( + ..., + alias="agentId", + min_length=1, + max_length=64, + description="Agent unique ID" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "deviceId": "1234567890", + "agentId": "0987654321" + } + } + } + + +class BindingUpdate(BaseModel): + """Schema for updating a DeviceAgentBinding""" + + agent_id: Optional[str] = Field( + None, + alias="agentId", + min_length=1, + max_length=64, + description="Agent unique ID" + ) + status: Optional[str] = Field( + None, + max_length=20, + description="Binding status (active, inactive)" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "agentId": "0987654321", + "status": "active" + } + } + } + + +class BindingResponse(BaseModel): + """Schema for DeviceAgentBinding response""" + + id: str = Field(..., description="Binding unique ID") + device_id: str = Field(..., alias="deviceId", description="Device unique ID") + agent_id: str = Field(..., alias="agentId", description="Agent unique ID") + status: str = Field(..., description="Binding status") + created_at: datetime = Field( + ..., + alias="createdAt", + description="Creation timestamp" + ) + updated_at: datetime = Field( + ..., + alias="updatedAt", + description="Last update timestamp" + ) + + model_config = { + "populate_by_name": True, + "from_attributes": True, + "json_schema_extra": { + "example": { + "id": "1122334455", + "deviceId": "1234567890", + "agentId": "0987654321", + "status": "active", + "createdAt": "2024-01-01T00:00:00", + "updatedAt": "2024-01-01T00:00:00" + } + } + } + + +class BindingWithDetails(BindingResponse): + """Schema for DeviceAgentBinding response with device and agent details""" + + device_name: Optional[str] = Field(None, alias="deviceName", description="Device name") + agent_name: Optional[str] = Field(None, alias="agentName", description="Agent name") + + model_config = { + "populate_by_name": True, + "from_attributes": True, + "json_schema_extra": { + "example": { + "id": "1122334455", + "deviceId": "1234567890", + "agentId": "0987654321", + "status": "active", + "deviceName": "My PLAUD Device", + "agentName": "My Assistant", + "createdAt": "2024-01-01T00:00:00", + "updatedAt": "2024-01-01T00:00:00" + } + } + } + + +class BindingListQuery(BaseModel): + """Schema for DeviceAgentBinding list query parameters""" + + device_id: Optional[str] = Field( + None, + alias="deviceId", + description="Filter by device ID" + ) + agent_id: Optional[str] = Field( + None, + alias="agentId", + description="Filter by agent ID" + ) + status: Optional[str] = Field( + None, + description="Filter by status" + ) + page: int = Field( + default=1, + ge=1, + description="Page number" + ) + page_size: int = Field( + default=20, + alias="pageSize", + ge=1, + le=100, + description="Number of items per page" + ) + sort_by: str = Field( + default="createdAt", + alias="sortBy", + description="Sort field" + ) + sort_order: str = Field( + default="desc", + alias="sortOrder", + pattern="^(asc|desc)$", + description="Sort order (asc or desc)" + ) + + model_config = { + "populate_by_name": True + } + diff --git a/main/live-agent-api/schemas/device.py b/main/live-agent-api/schemas/device.py new file mode 100644 index 000000000..3dcce1700 --- /dev/null +++ b/main/live-agent-api/schemas/device.py @@ -0,0 +1,270 @@ +""" +Device Schemas + +Pydantic models for Device API request/response validation. +""" + +from datetime import datetime +from typing import Optional +from pydantic import BaseModel, Field, field_validator + + +class DeviceBase(BaseModel): + """Base schema for Device with common fields""" + + name: str = Field( + ..., + min_length=1, + max_length=255, + description="Device display name" + ) + device_id: str = Field( + ..., + alias="deviceId", + min_length=1, + max_length=255, + description="Device hardware ID" + ) + model: Optional[str] = Field( + None, + max_length=100, + description="Device model (e.g., PLAUD NOTE)" + ) + firmware_version: Optional[str] = Field( + None, + alias="firmwareVersion", + max_length=50, + description="Firmware version" + ) + status: str = Field( + default="active", + max_length=20, + description="Device status (active, inactive, offline)" + ) + description: Optional[str] = Field( + None, + description="Device description" + ) + extra_data: Optional[str] = Field( + None, + alias="extraData", + description="Additional metadata (JSON format)" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "name": "My PLAUD Device", + "deviceId": "PLAUD-12345678", + "model": "PLAUD NOTE", + "firmwareVersion": "1.0.0", + "status": "active", + "description": "My personal voice recorder" + } + } + } + + +class DeviceCreate(DeviceBase): + """Schema for creating a new Device""" + + @field_validator('name') + @classmethod + def validate_name(cls, v: str) -> str: + """Validate and clean device name""" + v = v.strip() + if not v: + raise ValueError("Device name cannot be empty") + return v + + @field_validator('device_id') + @classmethod + def validate_device_id(cls, v: str) -> str: + """Validate and clean device ID""" + v = v.strip() + if not v: + raise ValueError("Device ID cannot be empty") + return v + + @field_validator('status') + @classmethod + def validate_status(cls, v: str) -> str: + """Validate status value""" + valid_statuses = ["active", "inactive", "offline"] + if v not in valid_statuses: + raise ValueError(f"Status must be one of: {', '.join(valid_statuses)}") + return v + + +class DeviceUpdate(BaseModel): + """Schema for updating a Device (all fields optional)""" + + name: Optional[str] = Field( + None, + min_length=1, + max_length=255, + description="Device display name" + ) + model: Optional[str] = Field( + None, + max_length=100, + description="Device model" + ) + firmware_version: Optional[str] = Field( + None, + alias="firmwareVersion", + max_length=50, + description="Firmware version" + ) + status: Optional[str] = Field( + None, + max_length=20, + description="Device status" + ) + is_online: Optional[bool] = Field( + None, + alias="isOnline", + description="Whether device is online" + ) + description: Optional[str] = Field( + None, + description="Device description" + ) + extra_data: Optional[str] = Field( + None, + alias="extraData", + description="Additional metadata" + ) + + model_config = { + "populate_by_name": True, + "json_schema_extra": { + "example": { + "name": "Updated Device Name", + "status": "active", + "isOnline": True, + "firmwareVersion": "1.1.0" + } + } + } + + @field_validator('name') + @classmethod + def validate_name(cls, v: Optional[str]) -> Optional[str]: + """Validate and clean device name""" + if v is not None: + v = v.strip() + if not v: + raise ValueError("Device name cannot be empty") + return v + + @field_validator('status') + @classmethod + def validate_status(cls, v: Optional[str]) -> Optional[str]: + """Validate status value""" + if v is not None: + valid_statuses = ["active", "inactive", "offline"] + if v not in valid_statuses: + raise ValueError(f"Status must be one of: {', '.join(valid_statuses)}") + return v + + +class DeviceResponse(BaseModel): + """Schema for Device response""" + + id: str = Field(..., description="Device unique ID") + name: str = Field(..., description="Device display name") + device_id: str = Field(..., alias="deviceId", description="Device hardware ID") + model: Optional[str] = Field(None, description="Device model") + firmware_version: Optional[str] = Field( + None, + alias="firmwareVersion", + description="Firmware version" + ) + status: str = Field(..., description="Device status") + is_online: bool = Field(..., alias="isOnline", description="Whether device is online") + last_seen_at: Optional[datetime] = Field( + None, + alias="lastSeenAt", + description="Last seen timestamp" + ) + description: Optional[str] = Field(None, description="Device description") + extra_data: Optional[str] = Field( + None, + alias="extraData", + description="Additional metadata" + ) + created_at: datetime = Field( + ..., + alias="createdAt", + description="Creation timestamp" + ) + updated_at: datetime = Field( + ..., + alias="updatedAt", + description="Last update timestamp" + ) + + model_config = { + "populate_by_name": True, + "from_attributes": True, + "json_schema_extra": { + "example": { + "id": "1234567890", + "name": "My PLAUD Device", + "deviceId": "PLAUD-12345678", + "model": "PLAUD NOTE", + "firmwareVersion": "1.0.0", + "status": "active", + "isOnline": True, + "lastSeenAt": "2024-01-01T00:00:00", + "description": "My personal voice recorder", + "metadata": None, + "createdAt": "2024-01-01T00:00:00", + "updatedAt": "2024-01-01T00:00:00" + } + } + } + + +class DeviceListQuery(BaseModel): + """Schema for Device list query parameters""" + + search: Optional[str] = Field( + None, + max_length=255, + description="Search keyword" + ) + status: Optional[str] = Field( + None, + description="Filter by status" + ) + page: int = Field( + default=1, + ge=1, + description="Page number" + ) + page_size: int = Field( + default=20, + alias="pageSize", + ge=1, + le=100, + description="Number of items per page" + ) + sort_by: str = Field( + default="createdAt", + alias="sortBy", + description="Sort field" + ) + sort_order: str = Field( + default="desc", + alias="sortOrder", + pattern="^(asc|desc)$", + description="Sort order (asc or desc)" + ) + + model_config = { + "populate_by_name": True + } + diff --git a/main/live-agent-api/services/agent_service.py b/main/live-agent-api/services/agent_service.py index 472582fab..6298d06c4 100644 --- a/main/live-agent-api/services/agent_service.py +++ b/main/live-agent-api/services/agent_service.py @@ -18,12 +18,25 @@ from schemas.agent import ( AgentListQuery, GeneratePromptRequest, ) -from utils.id_generator import generate_id +from utils import id_generator +from templates import TemplateLoader from config.settings import settings logger = logging.getLogger(__name__) - +BLANK_TEMPLATE = "blank" +SYSTEM_PROMPT_INSTRUCTION = """ +You are an AI assistant that helps create system prompts for voice assistant agents. +Generate a clear, professional system prompt that strictly follows this 6-module structure: +1. **Personality**: Define the agent's character, traits, and communication style +2. **Environment**: Describe the context and setting where the agent operates +3. **Tone**: Specify the language tone and manner of interaction +4. **Goal**: State the primary objectives and purposes of the agent +5. **Guardrails**: Define rules, limitations, and ethical boundaries +6. **Tools**: List available capabilities, APIs, or functions the agent can use +Each section should be clearly labeled with markdown headers (##). +The prompt should be comprehensive yet concise, suitable for a voice assistant. +""" class AgentService: """Service class for Agent business logic""" @@ -43,7 +56,7 @@ class AgentService: query: AgentListQuery ) -> tuple[list[Agent], int]: """ - Get paginated list of agents with optional search + Get paginated list of agents with optional search (sorted by creation time desc) Args: query: Query parameters for filtering and pagination @@ -55,8 +68,6 @@ class AgentService: search=query.search, page=query.page, page_size=query.page_size, - sort_by=query.sort_by, - sort_order=query.sort_order, ) logger.info( @@ -93,21 +104,43 @@ class AgentService: Returns: Created agent instance + + Raises: + ValueError: If template does not exist """ - # Business logic: Generate unique ID - agent_id = generate_id() + # 1. Generate unique ID + agent_id = id_generator.generate() - # Business logic: Create agent instance + # 2. Create blank agent first agent = Agent( id=agent_id, name=agent_data.name, - template=agent_data.template, language=agent_data.language, first_message=agent_data.first_message, system_prompt=agent_data.system_prompt, wake_word=agent_data.wake_word, ) + # 3. If not blank template, load and populate from template + if agent_data.template != BLANK_TEMPLATE: + try: + template = TemplateLoader.load(agent_data.template) + + if template is None: + raise ValueError(f"Failed to load template: {agent_data.template}") + + # Populate agent from template (template values are applied if user didn't provide) + agent.language = template.language + agent.first_message = template.greeting + agent.system_prompt = template.profile + agent.wake_word = template.wake_word + + logger.info(f"Populated agent from template: {agent_data.template}") + + except ValueError as e: + logger.error(f"Error loading template: {e}") + raise + # Persist to database agent = await self.repo.save(agent) @@ -201,11 +234,10 @@ class AgentService: return None # Business logic: Create duplicate with new ID and name - new_id = generate_id() + new_id = id_generator.generate() duplicate_agent = Agent( id=new_id, name=new_name, - template=source_agent.template, language=source_agent.language, first_message=source_agent.first_message, system_prompt=source_agent.system_prompt, @@ -229,42 +261,52 @@ class AgentService: Generate system prompt using AI Args: - request: Prompt generation request with description + request: Prompt generation request with description and optional existing prompt Returns: - Generated system prompt + Generated system prompt following the 6-module structure """ logger.info(f"Generating prompt for: {request.description}") try: + system_instruction = SYSTEM_PROMPT_INSTRUCTION + + # Build user message based on whether existing prompt is provided + if request.current_prompt: + user_message = ( + f"I need help refining or regenerating a system prompt.\n\n" + f"**User Requirements/Description:**\n{request.description}\n\n" + f"**Current Prompt:**\n{request.current_prompt}\n\n" + f"Please create an improved system prompt that incorporates the requirements " + f"and builds upon the existing prompt, following the 6-module structure." + ) + else: + user_message = ( + f"Create a new system prompt for: {request.description}\n\n" + f"Please structure it according to the 6 modules (Personality, Environment, Tone, Goal, Guardrails, Tools)." + ) + + # Create prompt using OpenAI API + # Note: Using chat.completions for now, ready to migrate to response.create when available response = await self.openai_client.chat.completions.create( model=settings.openai_model, messages=[ { "role": "system", - "content": ( - "You are an AI assistant that helps create system prompts " - "for voice assistant agents. Generate a clear, concise, " - "and professional system prompt based on the user's description. " - "The prompt should define the agent's role, capabilities, " - "and behavior guidelines." - ) + "content": system_instruction }, { "role": "user", - "content": ( - f"Create a system prompt for {request.description}. " - f"The prompt should be suitable for a voice assistant agent." - ) + "content": user_message } ], temperature=0.7, - max_tokens=500, + max_tokens=1500, ) generated_prompt = response.choices[0].message.content.strip() - logger.info("Successfully generated system prompt") + logger.info("Successfully generated system prompt with 6-module structure") return generated_prompt diff --git a/main/live-agent-api/services/binding_service.py b/main/live-agent-api/services/binding_service.py new file mode 100644 index 000000000..0ff59eb41 --- /dev/null +++ b/main/live-agent-api/services/binding_service.py @@ -0,0 +1,260 @@ +""" +DeviceAgentBinding Service + +Business logic layer for DeviceAgentBinding operations. +Uses Repository pattern for data access. +""" + +import logging +from typing import Optional +from datetime import datetime, timezone +from sqlalchemy.ext.asyncio import AsyncSession + +from orm.binding import DeviceAgentBinding, DeviceAgentBindingRepository +from orm.device import DeviceRepository +from orm.agent import AgentRepository +from schemas.binding import BindingCreate, BindingUpdate, BindingListQuery +from utils import id_generator + + +logger = logging.getLogger(__name__) + + +class BindingService: + """Service class for DeviceAgentBinding business logic""" + + def __init__(self, db: AsyncSession): + """ + Initialize Binding service + + Args: + db: Database session + """ + self.repo = DeviceAgentBindingRepository(db) + self.device_repo = DeviceRepository(db) + self.agent_repo = AgentRepository(db) + + async def get_binding_list( + self, + query: BindingListQuery + ) -> tuple[list[DeviceAgentBinding], int]: + """ + Get paginated list of bindings with optional filtering + + Args: + query: Query parameters for filtering and pagination + + Returns: + Tuple of (bindings list, total count) + """ + bindings, total = await self.repo.find_all( + device_id=query.device_id, + agent_id=query.agent_id, + status=query.status, + page=query.page, + page_size=query.page_size, + sort_by=query.sort_by, + sort_order=query.sort_order, + ) + + logger.info( + f"Retrieved {len(bindings)} bindings (page {query.page}, total {total})" + ) + + return bindings, total + + async def get_binding_by_id(self, binding_id: str) -> Optional[DeviceAgentBinding]: + """ + Get binding by ID + + Args: + binding_id: Binding unique ID + + Returns: + DeviceAgentBinding instance or None if not found + """ + binding = await self.repo.find_by_id(binding_id) + + if binding: + logger.info(f"Retrieved binding: {binding_id}") + else: + logger.warning(f"Binding not found: {binding_id}") + + return binding + + async def get_binding_by_device_id(self, device_id: str) -> Optional[DeviceAgentBinding]: + """ + Get binding by device ID + + Args: + device_id: Device unique ID + + Returns: + DeviceAgentBinding instance or None if not found + """ + binding = await self.repo.find_by_device_id(device_id) + + if binding: + logger.info(f"Retrieved binding for device: {device_id}") + else: + logger.warning(f"No binding found for device: {device_id}") + + return binding + + async def get_bindings_by_agent_id(self, agent_id: str) -> list[DeviceAgentBinding]: + """ + Get all bindings for an agent + + Args: + agent_id: Agent unique ID + + Returns: + List of DeviceAgentBinding instances + """ + bindings = await self.repo.find_by_agent_id(agent_id) + + logger.info(f"Retrieved {len(bindings)} bindings for agent: {agent_id}") + + return bindings + + async def create_binding(self, binding_data: BindingCreate) -> DeviceAgentBinding: + """ + Create a new device-agent binding + + Args: + binding_data: Binding creation data + + Returns: + Created binding instance + + Raises: + ValueError: If device or agent not found, or device already has binding + """ + # Business logic: Validate device exists + device = await self.device_repo.find_by_id(binding_data.device_id) + if not device: + raise ValueError(f"Device not found: {binding_data.device_id}") + + # Business logic: Validate agent exists + agent = await self.agent_repo.find_by_id(binding_data.agent_id) + if not agent: + raise ValueError(f"Agent not found: {binding_data.agent_id}") + + # Business logic: Check if device already has a binding + if await self.repo.device_has_binding(binding_data.device_id): + raise ValueError(f"Device already has a binding: {binding_data.device_id}") + + # Business logic: Generate unique ID + binding_id = id_generator.generate() + + # Business logic: Create binding instance + binding = DeviceAgentBinding( + id=binding_id, + device_id=binding_data.device_id, + agent_id=binding_data.agent_id, + ) + + # Persist to database + binding = await self.repo.save(binding) + + logger.info(f"Created binding: {binding_id} (device={binding_data.device_id}, agent={binding_data.agent_id})") + + return binding + + async def update_binding( + self, + binding_id: str, + binding_data: BindingUpdate + ) -> Optional[DeviceAgentBinding]: + """ + Update binding configuration + + Args: + binding_id: Binding unique ID + binding_data: Binding update data + + Returns: + Updated binding instance or None if not found + + Raises: + ValueError: If new agent not found + """ + # Get existing binding + binding = await self.repo.find_by_id(binding_id) + if not binding: + return None + + # Business logic: Validate new agent if provided + if binding_data.agent_id: + agent = await self.agent_repo.find_by_id(binding_data.agent_id) + if not agent: + raise ValueError(f"Agent not found: {binding_data.agent_id}") + binding.agent_id = binding_data.agent_id + + # Business logic: Update status if provided + if binding_data.status: + binding.status = binding_data.status + + # Business logic: Update timestamp + binding.updated_at = datetime.now(timezone.utc) + + # Persist changes + binding = await self.repo.save(binding) + + logger.info(f"Updated binding: {binding_id}") + + return binding + + async def delete_binding(self, binding_id: str) -> bool: + """ + Delete a binding + + Args: + binding_id: Binding unique ID + + Returns: + True if deleted, False if not found + """ + binding = await self.repo.find_by_id(binding_id) + if not binding: + return False + + await self.repo.delete(binding) + + logger.info(f"Deleted binding: {binding_id}") + + return True + + async def unbind_device(self, device_id: str) -> bool: + """ + Remove binding for a device + + Args: + device_id: Device unique ID + + Returns: + True if unbound, False if no binding found + """ + binding = await self.repo.find_by_device_id(device_id) + if not binding: + return False + + await self.repo.delete(binding) + + logger.info(f"Unbound device: {device_id}") + + return True + + +def get_binding_service(db: AsyncSession) -> BindingService: + """ + Dependency function to get Binding service + + Args: + db: Database session + + Returns: + BindingService instance + """ + return BindingService(db) + diff --git a/main/live-agent-api/services/device_service.py b/main/live-agent-api/services/device_service.py new file mode 100644 index 000000000..d75b69845 --- /dev/null +++ b/main/live-agent-api/services/device_service.py @@ -0,0 +1,248 @@ +""" +Device Service + +Business logic layer for Device operations. +Uses Repository pattern for data access. +""" + +import logging +from typing import Optional +from datetime import datetime, timezone +from sqlalchemy.ext.asyncio import AsyncSession + +from orm.device import Device, DeviceRepository +from schemas.device import DeviceCreate, DeviceUpdate, DeviceListQuery +from utils import id_generator + + +logger = logging.getLogger(__name__) + + +class DeviceService: + """Service class for Device business logic""" + + def __init__(self, db: AsyncSession): + """ + Initialize Device service + + Args: + db: Database session + """ + self.repo = DeviceRepository(db) + + async def get_device_list( + self, + query: DeviceListQuery + ) -> tuple[list[Device], int]: + """ + Get paginated list of devices with optional search and filtering + + Args: + query: Query parameters for filtering and pagination + + Returns: + Tuple of (devices list, total count) + """ + devices, total = await self.repo.find_all( + search=query.search, + status=query.status, + page=query.page, + page_size=query.page_size, + sort_by=query.sort_by, + sort_order=query.sort_order, + ) + + logger.info( + f"Retrieved {len(devices)} devices (page {query.page}, total {total})" + ) + + return devices, total + + async def get_device_by_id(self, device_id: str) -> Optional[Device]: + """ + Get device by ID + + Args: + device_id: Device unique ID + + Returns: + Device instance or None if not found + """ + device = await self.repo.find_by_id(device_id) + + if device: + logger.info(f"Retrieved device: {device_id}") + else: + logger.warning(f"Device not found: {device_id}") + + return device + + async def get_device_by_device_id(self, device_id: str) -> Optional[Device]: + """ + Get device by hardware device ID + + Args: + device_id: Device hardware ID + + Returns: + Device instance or None if not found + """ + device = await self.repo.find_by_device_id(device_id) + + if device: + logger.info(f"Retrieved device by device_id: {device_id}") + else: + logger.warning(f"Device not found by device_id: {device_id}") + + return device + + async def create_device(self, device_data: DeviceCreate) -> Device: + """ + Create a new device + + Args: + device_data: Device creation data + + Returns: + Created device instance + + Raises: + ValueError: If device_id already exists + """ + # Business logic: Check if device_id already exists + if await self.repo.device_id_exists(device_data.device_id): + raise ValueError(f"Device ID already exists: {device_data.device_id}") + + # Business logic: Generate unique ID + device_id = id_generator.generate() + + # Business logic: Create device instance + device = Device( + id=device_id, + name=device_data.name, + device_id=device_data.device_id, + model=device_data.model, + firmware_version=device_data.firmware_version, + status=device_data.status, + description=device_data.description, + extra_data=device_data.extra_data, + ) + + # Persist to database + device = await self.repo.save(device) + + logger.info(f"Created device: {device_id} ({device.name})") + + return device + + async def update_device( + self, + device_id: str, + device_data: DeviceUpdate + ) -> Optional[Device]: + """ + Update device configuration + + Args: + device_id: Device unique ID + device_data: Device update data + + Returns: + Updated device instance or None if not found + """ + # Get existing device + device = await self.repo.find_by_id(device_id) + if not device: + return None + + # Business logic: Update fields + update_data = device_data.model_dump(exclude_unset=True) + for field, value in update_data.items(): + # Convert camelCase to snake_case + db_field = field.replace("firmwareVersion", "firmware_version") + db_field = db_field.replace("isOnline", "is_online") + db_field = db_field.replace("extraData", "extra_data") + + if hasattr(device, db_field): + setattr(device, db_field, value) + + # Business logic: Update last_seen_at if device comes online + if device_data.is_online is True: + device.last_seen_at = datetime.now(timezone.utc) + + # Business logic: Update timestamp + device.updated_at = datetime.now(timezone.utc) + + # Persist changes + device = await self.repo.save(device) + + logger.info(f"Updated device: {device_id}") + + return device + + async def delete_device(self, device_id: str) -> bool: + """ + Delete a device + + Args: + device_id: Device unique ID + + Returns: + True if deleted, False if not found + """ + device = await self.repo.find_by_id(device_id) + if not device: + return False + + # TODO: Business logic - Check for binding relationships + # For now, just delete the device + # In production, should check if device has bindings and handle accordingly + + await self.repo.delete(device) + + logger.info(f"Deleted device: {device_id}") + + return True + + async def update_device_status( + self, + device_id: str, + is_online: bool + ) -> Optional[Device]: + """ + Update device online status + + Args: + device_id: Device unique ID + is_online: Whether device is online + + Returns: + Updated device instance or None if not found + """ + device = await self.repo.find_by_id(device_id) + if not device: + return None + + device.is_online = is_online + device.last_seen_at = datetime.now(timezone.utc) + device.updated_at = datetime.now(timezone.utc) + + device = await self.repo.save(device) + + logger.info(f"Updated device status: {device_id} (online={is_online})") + + return device + + +def get_device_service(db: AsyncSession) -> DeviceService: + """ + Dependency function to get Device service + + Args: + db: Database session + + Returns: + DeviceService instance + """ + return DeviceService(db) + diff --git a/main/live-agent-api/templates/__init__.py b/main/live-agent-api/templates/__init__.py new file mode 100644 index 000000000..1afe3cc99 --- /dev/null +++ b/main/live-agent-api/templates/__init__.py @@ -0,0 +1,13 @@ +""" +Templates Package + +Agent templates and template loader. +""" + +from .loader import AgentTemplate, TemplateLoader + +__all__ = [ + "AgentTemplate", + "TemplateLoader", +] + diff --git a/main/live-agent-api/templates/health_wellness.yaml b/main/live-agent-api/templates/health_wellness.yaml new file mode 100644 index 000000000..4df3a0e5b --- /dev/null +++ b/main/live-agent-api/templates/health_wellness.yaml @@ -0,0 +1,70 @@ +wake_word: Alice +language: en +greeting: Hello! I'm here to support your health and wellness journey. How can I assist you today? +profile: | + # Personality + + You are a supportive and knowledgeable health and wellness companion. + You are empathetic, non-judgmental, and focused on holistic well-being. + You promote healthy habits and sustainable lifestyle changes. + + # Environment + + You are assisting the user via voice interaction. + The user is interested in improving their physical, mental, or emotional health. + You provide guidance and support, but are not a replacement for professional medical advice. + + # Tone + + Your responses are caring, supportive, and motivating. + You use gentle, encouraging language that promotes positive change. + You acknowledge challenges while focusing on solutions and progress. + You are informative but avoid being preachy or judgmental. + + # Goal + + Your primary goal is to support the user's health and wellness journey: + + 1. Healthy Habits: + + - Help establish and maintain healthy routines. + - Track wellness goals (exercise, nutrition, sleep, hydration). + - Provide reminders and encouragement for healthy behaviors. + - Celebrate milestones and progress. + + 2. Mindfulness & Mental Health: + + - Guide simple meditation and breathing exercises. + - Offer stress management techniques. + - Encourage self-care and work-life balance. + - Provide emotional support and active listening. + + 3. Fitness Support: + + - Suggest appropriate exercises based on fitness level. + - Help set realistic fitness goals. + - Provide motivation and workout reminders. + - Track progress and adjust plans as needed. + + 4. Nutrition Guidance: + + - Offer general nutrition information and healthy eating tips. + - Help track meals and water intake. + - Suggest balanced meal ideas. + - Promote mindful eating practices. + + # Guardrails + + NEVER provide medical diagnoses or treatment recommendations. + ALWAYS encourage users to consult healthcare professionals for medical concerns. + Focus on general wellness information, not specific medical advice. + Be sensitive to potential eating disorders or mental health crises. + If a user expresses thoughts of self-harm, immediately recommend professional help. + Respect individual differences in body types, abilities, and health goals. + Promote balanced, sustainable approaches rather than extreme methods. + + # Tools + + No tools provided. +timezone: UTC+8 + diff --git a/main/live-agent-api/templates/hospital_assistant.yaml b/main/live-agent-api/templates/hospital_assistant.yaml new file mode 100644 index 000000000..a7f15f3a1 --- /dev/null +++ b/main/live-agent-api/templates/hospital_assistant.yaml @@ -0,0 +1,57 @@ +wake_word: Alice +language: en +greeting: Hi! How can I help you today? +profile: | + # Personality + + You are a personal assistant designed to help users manage their daily hospital-related tasks. + You are efficient, organized, and detail-oriented. + You are friendly and helpful, but primarily focused on task completion. + + # Environment + + You are assisting the user via voice interaction. + The user is likely a healthcare professional working in a hospital setting. + The user is seeking assistance with their daily tasks. + + # Tone + + Your responses are clear, concise, and professional. + You use direct language and avoid unnecessary jargon. + You are polite and helpful, but prioritize efficiency. + + # Goal + + Your primary goal is to help the user efficiently process their daily hospital tasks through a structured workflow: + + 1. Task Identification: + + - Identify the specific task the user needs assistance with (e.g., scheduling appointments, managing patient records, ordering supplies, etc.). + - Clarify any specific requirements or constraints for the task. + + 2. Task Execution: + + - Provide step-by-step instructions for completing the task. + - Offer helpful tips and shortcuts to improve efficiency. + - If possible, automate parts of the task using available tools. + + 3. Task Confirmation: + + - Confirm that the task has been completed successfully. + - Offer to assist with any follow-up tasks or related activities. + + 4. Task Logging: + + - Automatically log the task and its completion status for future reference. + + # Guardrails + + Remain within the scope of hospital-related tasks. + Never provide medical advice or make clinical decisions. + Protect patient privacy and confidentiality at all times. + If you are unsure about something, ask for clarification. + + # Tools + + No tools provided. +timezone: UTC+8 \ No newline at end of file diff --git a/main/live-agent-api/templates/learning_companion.yaml b/main/live-agent-api/templates/learning_companion.yaml new file mode 100644 index 000000000..a2c389115 --- /dev/null +++ b/main/live-agent-api/templates/learning_companion.yaml @@ -0,0 +1,68 @@ +wake_word: Alice +language: en +greeting: Hi there! I'm excited to help you learn today. What would you like to explore? +profile: | + # Personality + + You are an enthusiastic and patient learning companion dedicated to helping users expand their knowledge. + You are encouraging, curious, and passionate about education. + You make learning fun and engaging while maintaining high educational standards. + + # Environment + + You are assisting the user via voice interaction. + The user is actively seeking to learn new concepts, skills, or subjects. + You adapt your teaching style to match the user's learning pace and preferences. + + # Tone + + Your responses are encouraging, clear, and pedagogically sound. + You use analogies, examples, and real-world connections to make concepts relatable. + You celebrate progress and gently guide through challenges. + You ask thought-provoking questions to deepen understanding. + + # Goal + + Your primary goal is to facilitate effective and enjoyable learning experiences: + + 1. Concept Explanation: + + - Break down complex topics into digestible chunks. + - Use multiple approaches (visual, verbal, practical) to explain concepts. + - Provide relevant examples and analogies. + - Check for understanding before moving forward. + + 2. Active Learning: + + - Ask questions that promote critical thinking. + - Encourage the user to explain concepts in their own words. + - Provide practice problems and exercises. + - Offer constructive feedback on responses. + + 3. Study Support: + + - Help create effective study plans and schedules. + - Suggest memory techniques and learning strategies. + - Assist with exam preparation and review. + - Provide motivation and study tips. + + 4. Knowledge Building: + + - Connect new information to existing knowledge. + - Highlight patterns and relationships between concepts. + - Encourage curiosity and further exploration. + - Recommend additional resources for deeper learning. + + # Guardrails + + Adapt to the user's current knowledge level and learning pace. + Never provide direct answers to homework or test questions without guiding the learning process. + Encourage independent thinking and problem-solving. + If a topic is outside your expertise, acknowledge it and suggest reliable resources. + Maintain a supportive environment that makes mistakes feel safe and valuable. + + # Tools + + No tools provided. +timezone: UTC+8 + diff --git a/main/live-agent-api/templates/loader.py b/main/live-agent-api/templates/loader.py new file mode 100644 index 000000000..f77421f34 --- /dev/null +++ b/main/live-agent-api/templates/loader.py @@ -0,0 +1,118 @@ +""" +Template Loader + +Utility for loading agent templates from YAML files. +""" + +import yaml +import logging +from typing import Optional +from pathlib import Path +from pydantic import BaseModel, Field + +logger = logging.getLogger(__name__) + + +class AgentTemplate(BaseModel): + """ + Agent template data structure + + Pydantic model for validating and handling agent template data. + """ + + wake_word: str = Field(..., description="Wake word to activate agent") + language: str = Field(..., description="Language code (e.g., en, zh)") + greeting: str = Field(..., description="Greeting message (maps to first_message)") + profile: str = Field(..., description="System prompt (maps to system_prompt)") + timezone: str = Field(default="UTC+8", description="Timezone") + + model_config = { + "json_schema_extra": { + "example": { + "wake_word": "Hey Assistant", + "language": "en", + "greeting": "Hello! How can I help you?", + "profile": "You are a helpful assistant...", + "timezone": "UTC+8" + } + } + } + + +class TemplateLoader: + """ + Template loader class with static methods for loading agent templates + + All methods are static, no instance needed. + """ + + # Template directory path (relative to this file) + TEMPLATE_DIR = Path(__file__).parent + + @staticmethod + def load(template_name: str) -> Optional[AgentTemplate]: + """ + Load agent template from YAML file + + Args: + template_name: Template name (e.g., "personal_assistant", "learning_companion") + + Returns: + AgentTemplate instance or None if template is "blank" + + Raises: + ValueError: If template file is invalid or missing required fields + """ + # Special case: blank template + if template_name == "blank": + return None + + # Construct template file path + template_file = TemplateLoader.TEMPLATE_DIR / f"{template_name}.yaml" + + # Check if template exists + if not template_file.exists(): + logger.error(f"Template file not found: {template_file}") + raise ValueError(f"Template '{template_name}' does not exist") + + try: + # Load YAML file + with open(template_file, 'r', encoding='utf-8') as f: + data = yaml.safe_load(f) + + # Validate and create template using Pydantic + template = AgentTemplate(**data) + + logger.info(f"Loaded template: {template_name}") + return template + + except yaml.YAMLError as e: + logger.error(f"Error parsing YAML file {template_file}: {e}") + raise ValueError(f"Template '{template_name}' has invalid YAML format: {e}") + + except Exception as e: + logger.error(f"Error loading template {template_name}: {e}") + raise + + @staticmethod + def list_available() -> list[str]: + """ + List all available template names + + Returns: + List of template names (without .yaml extension) + """ + if not TemplateLoader.TEMPLATE_DIR.exists(): + logger.warning(f"Template directory not found: {TemplateLoader.TEMPLATE_DIR}") + return [] + + templates = [] + for file in TemplateLoader.TEMPLATE_DIR.glob("*.yaml"): + templates.append(file.stem) + + # Always include blank template + templates.append("blank") + + logger.info(f"Available templates: {templates}") + return sorted(templates) + diff --git a/main/live-agent-api/templates/personal_assistant.yaml b/main/live-agent-api/templates/personal_assistant.yaml new file mode 100644 index 000000000..926785e77 --- /dev/null +++ b/main/live-agent-api/templates/personal_assistant.yaml @@ -0,0 +1,62 @@ +wake_word: Charlie +language: en +greeting: Hello! I'm your personal assistant. How can I help you today? +profile: | + # Personality + + You are a versatile personal assistant designed to help users manage their daily tasks and activities. + You are friendly, proactive, and highly organized. + You anticipate user needs and offer helpful suggestions. + + # Environment + + You are assisting the user via voice interaction. + The user relies on you for various personal and professional tasks. + You have access to the user's schedule, reminders, and preferences. + + # Tone + + Your responses are warm, conversational, and supportive. + You use clear language and explain things in a way that's easy to understand. + You are encouraging and positive, helping the user stay motivated and productive. + + # Goal + + Your primary goal is to help the user manage their daily life efficiently: + + 1. Task Management: + + - Help create, organize, and prioritize tasks. + - Set reminders for important deadlines and appointments. + - Suggest optimal times for task completion based on the user's schedule. + + 2. Information Assistance: + + - Answer questions on a wide range of topics. + - Provide quick facts, definitions, and explanations. + - Help with research and information gathering. + + 3. Productivity Support: + + - Offer time management tips and strategies. + - Help break down complex projects into manageable steps. + - Suggest productivity techniques like Pomodoro or time blocking. + + 4. Personal Organization: + + - Manage calendar events and appointments. + - Keep track of shopping lists and to-dos. + - Help organize notes and ideas. + + # Guardrails + + Respect user privacy and confidentiality at all times. + Stay within the scope of general assistance and avoid specialized professional advice. + If you're unsure about something, admit it and offer to help find accurate information. + Never make decisions that could have serious consequences without user confirmation. + + # Tools + + No tools provided. +timezone: UTC+8 + diff --git a/main/live-agent-api/utils/__init__.py b/main/live-agent-api/utils/__init__.py index e69de29bb..dac88be9b 100644 --- a/main/live-agent-api/utils/__init__.py +++ b/main/live-agent-api/utils/__init__.py @@ -0,0 +1,18 @@ +""" +Utils package for live-agent-api + +This package provides utility modules for the application, +including ID generation and response formatting. + +Usage: + from utils import id_generator + + # Generate ID using the global singleton instance + new_id = id_generator.generate() +""" + +from .id_generator import id_generator + +__all__ = [ + "id_generator", # Global singleton instance (recommended usage) +] diff --git a/main/live-agent-api/utils/id_generator.py b/main/live-agent-api/utils/id_generator.py index f1095b2fb..5b1035095 100644 --- a/main/live-agent-api/utils/id_generator.py +++ b/main/live-agent-api/utils/id_generator.py @@ -1,125 +1,75 @@ """ -Snowflake ID Generator +ULID ID Generator -Wrapper around the snowflake-id library for generating distributed unique IDs. -Uses Twitter's Snowflake algorithm to generate 64-bit IDs. +ULID (Universally Unique Lexicographically Sortable Identifier) generator. +- Zero configuration: No instance ID or epoch setup needed +- Time-sortable: IDs are naturally ordered by creation time +- URL-safe: Base32 encoded +- 128-bit: Extremely low collision probability +- Format: 26 characters (e.g., 01ARZ3NDEKTSV4RRFFQ69G5FAV) """ - +from __future__ import annotations from typing import Optional -from snowflake import SnowflakeGenerator - +from ulid import ULID import logging logger = logging.getLogger(__name__) -# Global ID generator instance -_id_generator: Optional[SnowflakeGenerator] = None - -def get_id_generator() -> SnowflakeGenerator: +class ULIDGenerator: """ - Get the global ID generator instance + ULID ID Generator - Returns: - Snowflake ID generator instance + A singleton class for generating distributed unique IDs using ULID. + Thread-safe and requires no configuration. + + Usage: + generator = ULIDGenerator() + id_str = generator.generate() + id_int = generator.generate_int() + id_uuid = generator.generate_uuid() + """ + + _instance: Optional['ULIDGenerator'] = None + _initialized: bool = False + + def __new__(cls) -> ULIDGenerator: + """Ensure singleton pattern""" + if cls._instance is None: + cls._instance = super().__new__(cls) + return cls._instance + + def __init__(self): + """ + Initialize ULID generator - Raises: - RuntimeError: If generator is not initialized - """ - global _id_generator + Note: Due to singleton pattern, __init__ is called every time + ULIDGenerator() is invoked, but initialization only happens once. + """ + if not self._initialized: + logger.info("Initializing ULID generator (singleton)") + self.__class__._initialized = True + logger.info("ULID generator initialized successfully") - if _id_generator is None: - raise RuntimeError( - "ID generator not initialized. " - "Call init_id_generator() in application lifespan." - ) + def generate(self) -> str: + """ + Generate a unique ULID as string + + Returns: + 26-character ULID string (e.g., '01ARZ3NDEKTSV4RRFFQ69G5FAV') + + Example: + >>> generator = ULIDGenerator() + >>> id_str = generator.generate() + >>> print(id_str) + '01ARZ3NDEKTSV4RRFFQ69G5FAV' + """ + return str(ULID()) - return _id_generator + def __repr__(self) -> str: + """String representation""" + return f"" -def generate_id() -> str: - """ - Generate a unique Snowflake ID as string - - Returns: - Unique ID as string - """ - generator = get_id_generator() - return str(next(generator)) - - -def generate_id_int() -> int: - """ - Generate a unique Snowflake ID as integer - - Returns: - Unique 64-bit integer ID - """ - generator = get_id_generator() - return next(generator) - - -def init_id_generator(instance_id: int = 1) -> None: - """ - Initialize global Snowflake ID generator - - Should be called once during application startup in lifespan. - - Args: - instance_id: Unique instance ID for this service (0-1023) - In production, this should be: - - Stored in a distributed configuration center (e.g., etcd, Consul) - - Automatically assigned when service instances start - - Managed by orchestration system (e.g., Kubernetes StatefulSet) - - Raises: - ValueError: If instance_id is out of valid range - """ - global _id_generator - - # Already initialized - if _id_generator is not None: - logger.warning("ID generator already initialized, skipping") - return - - # Validate instance_id - if instance_id < 0 or instance_id > 1023: - raise ValueError( - f"Instance ID must be between 0 and 1023, got {instance_id}" - ) - - _id_generator = SnowflakeGenerator(instance_id) - logger.info(f"ID generator initialized with instance_id={instance_id}") - - -def close_id_generator() -> None: - """ - Close and cleanup ID generator - - Optional cleanup function for application shutdown. - """ - global _id_generator - - if _id_generator is not None: - logger.info("Closing ID generator...") - _id_generator = None - logger.info("ID generator closed") - - -if __name__ == "__main__": - # Test ID generation - print("Testing Snowflake ID Generator") - print("=" * 50) - - # Initialize with instance ID 1 - init_id_generator(instance_id=1) - - print("\nGenerating 10 sample IDs:") - for i in range(10): - id_str = generate_id() - print(f" {i+1:2d}. {id_str}") - - print("\nAll IDs generated successfully!") - - # Cleanup - close_id_generator() +# Create global singleton instance +id_generator = ULIDGenerator() diff --git a/main/live-agent-api/uv.lock b/main/live-agent-api/uv.lock index cf2d518d2..16f40fab6 100644 --- a/main/live-agent-api/uv.lock +++ b/main/live-agent-api/uv.lock @@ -334,7 +334,8 @@ dependencies = [ { name = "pydantic" }, { name = "pydantic-settings" }, { name = "python-dotenv" }, - { name = "snowflake-id" }, + { name = "python-ulid" }, + { name = "pyyaml" }, { name = "sqlalchemy" }, { name = "uvicorn", extra = ["standard"] }, ] @@ -356,7 +357,8 @@ requires-dist = [ { name = "pydantic", specifier = ">=2.9.0" }, { name = "pydantic-settings", specifier = ">=2.6.0" }, { name = "python-dotenv", specifier = ">=1.0.0" }, - { name = "snowflake-id", specifier = ">=1.0.2" }, + { name = "python-ulid", specifier = ">=2.7.0" }, + { name = "pyyaml", specifier = ">=6.0.0" }, { name = "sqlalchemy", specifier = ">=2.0.36" }, { name = "uvicorn", extras = ["standard"], specifier = ">=0.32.0" }, ] @@ -576,6 +578,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" }, ] +[[package]] +name = "python-ulid" +version = "3.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/40/7e/0d6c82b5ccc71e7c833aed43d9e8468e1f2ff0be1b3f657a6fcafbb8433d/python_ulid-3.1.0.tar.gz", hash = "sha256:ff0410a598bc5f6b01b602851a3296ede6f91389f913a5d5f8c496003836f636", size = 93175, upload-time = "2025-08-18T16:09:26.305Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/a0/4ed6632b70a52de845df056654162acdebaf97c20e3212c559ac43e7216e/python_ulid-3.1.0-py3-none-any.whl", hash = "sha256:e2cdc979c8c877029b4b7a38a6fba3bc4578e4f109a308419ff4d3ccf0a46619", size = 11577, upload-time = "2025-08-18T16:09:25.047Z" }, +] + [[package]] name = "pytokens" version = "0.2.0" @@ -666,15 +677,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" }, ] -[[package]] -name = "snowflake-id" -version = "1.0.2" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/7a/d0/91bd3d2e54ea849e8c4e73681ef75c1c93f37a8c9f0627b1553522267e08/snowflake_id-1.0.2.tar.gz", hash = "sha256:4a4cd49508599aaa16488311f4b9121e9ac3bac57edff3e9f71b1d79086dbfe8", size = 4497, upload-time = "2024-04-17T13:36:05.552Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/41/a4/ee0bdba1d1e98db21166381559d0061d752bbf66af2dd1cbbe4c2afdc4fa/snowflake_id-1.0.2-py3-none-any.whl", hash = "sha256:c3142752ed334b9d4632739a704461d13e97aa6fa71b65d5329829b4b5cc058c", size = 4795, upload-time = "2024-04-17T13:36:03.898Z" }, -] - [[package]] name = "sqlalchemy" version = "2.0.44" From 1a46e6a67c5f6fdecd156bef7432268f22e838f1 Mon Sep 17 00:00:00 2001 From: pany-05 Date: Mon, 3 Nov 2025 14:57:34 +0800 Subject: [PATCH 04/31] cherrypick fix --- main/xiaozhi-server/core/connection.py | 89 +------ .../core/providers/llm/openai/openai.py | 247 ++++-------------- main/xiaozhi-server/core/websocket_server.py | 9 - 3 files changed, 53 insertions(+), 292 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 9dc15fcd2..24d62c753 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -776,89 +776,18 @@ class ConnectionHandler: ) if self.intent_type == "function_call" and functions is not None: - # 使用支持functions的streaming接口 - # response_with_functions 是异步生成器,使用队列在线程间传递 - response_queue = queue.Queue() - stop_flag = threading.Event() - - async def consume_async_generator(): - try: - async_gen = self.llm.response_with_functions( - self.session_id, - dialogue_history, - functions=functions, - ) - async for item in async_gen: - if stop_flag.is_set(): - break - response_queue.put(item) - response_queue.put(None) # 结束标记 - except Exception as e: - self.logger.bind(tag=TAG).error(f"异步生成器消费出错: {e}", exc_info=True) - response_queue.put(None) - response_queue.put(("ERROR", str(e))) - - asyncio.run_coroutine_threadsafe( - consume_async_generator(), self.loop + # 直接使用同步生成器(response_with_functions 是同步方法) + llm_responses = self.llm.response_with_functions( + self.session_id, + dialogue_history, + functions=functions, ) - - # 从队列中获取响应 - def get_responses(): - while True: - try: - item = response_queue.get(timeout=300) # 5分钟超时 - if item is None: - break - if isinstance(item, tuple) and item[0] == "ERROR": - raise Exception(item[1]) - yield item - except queue.Empty: - self.logger.bind(tag=TAG).warning("等待 LLM 响应超时") - stop_flag.set() - break - - llm_responses = get_responses() else: - # response 也是异步生成器,使用队列在线程间传递 - response_queue = queue.Queue() - stop_flag = threading.Event() - - async def consume_async_generator(): - try: - async_gen = self.llm.response( - self.session_id, - dialogue_history, - ) - async for item in async_gen: - if stop_flag.is_set(): - break - response_queue.put(item) - response_queue.put(None) # 结束标记 - except Exception as e: - self.logger.bind(tag=TAG).error(f"异步生成器消费出错: {e}", exc_info=True) - response_queue.put(None) - response_queue.put(("ERROR", str(e))) - - asyncio.run_coroutine_threadsafe( - consume_async_generator(), self.loop + # 直接使用同步生成器(response 是同步方法) + llm_responses = self.llm.response( + self.session_id, + dialogue_history, ) - - # 从队列中获取响应 - def get_responses(): - while True: - try: - item = response_queue.get(timeout=300) # 5分钟超时 - if item is None: - break - if isinstance(item, tuple) and item[0] == "ERROR": - raise Exception(item[1]) - yield item - except queue.Empty: - self.logger.bind(tag=TAG).warning("等待 LLM 响应超时") - stop_flag.set() - break - - llm_responses = get_responses() except Exception as e: self.logger.bind(tag=TAG).error(f"LLM 处理出错 {query}: {e}", exc_info=True) return None diff --git a/main/xiaozhi-server/core/providers/llm/openai/openai.py b/main/xiaozhi-server/core/providers/llm/openai/openai.py index 18548e4c2..a116a80db 100644 --- a/main/xiaozhi-server/core/providers/llm/openai/openai.py +++ b/main/xiaozhi-server/core/providers/llm/openai/openai.py @@ -49,39 +49,33 @@ class LLMProvider(LLMProviderBase): self.client = openai.OpenAI(api_key=self.api_key, base_url=self.base_url, timeout=httpx.Timeout(self.timeout)) def response(self, session_id, dialogue, **kwargs): - """ - 同步流式响应方法 - 注意:保持同步以兼容基类和其他 LLM 提供商 - """ try: - # Create streaming response - # 注意:ChatGLM 等服务可能不支持 responses.create API,改用标准的 chat.completions.create - stream = self.client.chat.completions.create( + responses = self.client.chat.completions.create( model=self.model_name, messages=dialogue, stream=True, max_tokens=kwargs.get("max_tokens", self.max_tokens), temperature=kwargs.get("temperature", self.temperature), top_p=kwargs.get("top_p", self.top_p), - frequency_penalty=kwargs.get("frequency_penalty", self.frequency_penalty), + frequency_penalty=kwargs.get( + "frequency_penalty", self.frequency_penalty + ), ) - + is_active = True - - for chunk in stream: + for chunk in responses: try: - # Handle response choices - if not hasattr(chunk, "choices") or not chunk.choices: - continue - - delta = chunk.choices[0].delta - content = getattr(delta, "content", None) - - if content is None: - continue - - # Handle thinking tags (for reasoning models like o1) - # Filter out content between ... + # 检查是否存在有效的choice且content不为空 + delta = ( + chunk.choices[0].delta + if getattr(chunk, "choices", None) + else None + ) + content = delta.content if hasattr(delta, "content") else "" + except IndexError: + content = "" + if content: + # 处理标签跨多个chunk的情况 if "" in content: is_active = False content = content.split("")[0] @@ -90,192 +84,39 @@ class LLMProvider(LLMProviderBase): content = content.split("")[-1] if is_active: yield content - - except (IndexError, AttributeError) as e: - continue - except Exception as e: - logger.bind(tag=TAG).error(f"处理 chunk 时发生未预期错误: {e}", exc_info=True) - continue except Exception as e: - logger.bind(tag=TAG).error(f"Error in response generation: {e}", exc_info=True) + try: + error_msg = repr(e)[:200] + except: + error_msg = "encoding error" + logger.bind(tag=TAG).error(f"Error in response generation: {error_msg}") def response_with_functions(self, session_id, dialogue, functions=None): - """ - 同步流式响应方法(支持函数调用) - 注意:保持同步以兼容基类和其他 LLM 提供商 - """ try: - # Prepare request parameters - request_params = { - "model": self.model_name, - "messages": dialogue, - "stream": True, - } - - # Add tools/functions if provided - if functions: - request_params["tools"] = functions - - # Create streaming response (同步版本,移除 await) - stream = self.client.chat.completions.create(**request_params) + stream = self.client.chat.completions.create( + model=self.model_name, messages=dialogue, stream=True, tools=functions + ) for chunk in stream: - try: - # Handle token usage reporting - if hasattr(chunk, "usage") and isinstance(chunk.usage, CompletionUsage): - usage_info = chunk.usage - logger.bind(tag=TAG).info( - f"Token 消耗:输入 {getattr(usage_info, 'prompt_tokens', '未知')}," - f"输出 {getattr(usage_info, 'completion_tokens', '未知')}," - f"共计 {getattr(usage_info, 'total_tokens', '未知')}" - ) - continue - - # Handle response choices - if not hasattr(chunk, "choices") or not chunk.choices: - continue - - delta = chunk.choices[0].delta - - # Extract content and tool calls - content = getattr(delta, "content", None) - tool_calls = getattr(delta, "tool_calls", None) - - # Yield the chunk - yield content, tool_calls - - except (IndexError, AttributeError) as e: - continue + # 检查是否存在有效的choice且content不为空 + if getattr(chunk, "choices", None): + yield chunk.choices[0].delta.content, chunk.choices[ + 0 + ].delta.tool_calls + # 存在 CompletionUsage 消息时,生成 Token 消耗 log + elif isinstance(getattr(chunk, "usage", None), CompletionUsage): + usage_info = getattr(chunk, "usage", None) + logger.bind(tag=TAG).info( + f"Token 消耗:输入 {getattr(usage_info, 'prompt_tokens', '未知')}," + f"输出 {getattr(usage_info, 'completion_tokens', '未知')}," + f"共计 {getattr(usage_info, 'total_tokens', '未知')}" + ) - except openai.APIError as e: - error_msg = f"OpenAI API error: {e.message if hasattr(e, 'message') else str(e)}" - logger.bind(tag=TAG).error(error_msg) - yield f"【API错误: {error_msg}】", None - - except openai.APIConnectionError as e: - error_msg = f"Connection error: {str(e)}" - logger.bind(tag=TAG).error(error_msg) - yield f"【连接错误: 无法连接到服务】", None - - except openai.RateLimitError as e: - error_msg = f"Rate limit exceeded: {str(e)}" - logger.bind(tag=TAG).error(error_msg) - yield f"【请求过于频繁,请稍后再试】", None - except Exception as e: - error_msg = f"Unexpected error in function calling: {type(e).__name__}: {str(e)}" - logger.bind(tag=TAG).error(error_msg, exc_info=True) - yield f"【OpenAI服务响应异常: {str(e)}】", None - - async def response_stream( - self, - chat_ctx: ChatContext, - **kwargs: Any - ) -> AsyncGenerator[ChatChunk, None]: - """ - New streaming interface using standard protocol - - This method implements the new standard interface defined in LLMProviderBase. - It uses: - - ChatContext as input (standard dialogue protocol) - - ChatChunk as output (standard streaming protocol) - - OpenAI Responses API (modern response.create) - - Args: - chat_ctx: Standard ChatContext with dialogue history - **kwargs: Additional options: - - max_output_tokens: Override max tokens - - temperature: Override temperature - - top_p: Override top_p - - frequency_penalty: Override frequency penalty - - Yields: - ChatChunk: Standardized streaming chunks with deltas and usage - - Example: - async for chunk in provider.response_stream(chat_ctx): - if chunk.delta and chunk.delta.content: - print(chunk.delta.content) - if chunk.usage: - print(f"Tokens: {chunk.usage.total_tokens}") - """ - try: - # 1. Convert ChatContext to OpenAI format - messages, _ = chat_ctx.to_provider_format(format="openai") - - logger.bind(tag=TAG).debug( - f"Starting streaming with model={self.model_name}, " - f"messages_count={len(messages)}" - ) - - # 2. Prepare request parameters - max_output_tokens = kwargs.get("max_output_tokens", self.max_output_tokens) - temperature = kwargs.get("temperature", self.temperature) - top_p = kwargs.get("top_p", self.top_p) - frequency_penalty = kwargs.get("frequency_penalty", self.frequency_penalty) - - # 3. Call OpenAI Responses API - # TODO: system instruction needs to be added - stream: AsyncStream[ResponseStreamEvent] = await self.client.responses.create( - input=messages, - model=self.model_name, - stream=True, - max_output_tokens=max_output_tokens, - temperature=temperature, - top_p=top_p, - frequency_penalty=frequency_penalty, - ) - - # 4. Parse stream and yield ChatChunk (focus on output_item.done + completed) - async for event in stream: - try: - chunk = self._parse_response_event(event) - if chunk: - yield chunk - except (IndexError, AttributeError) as e: - logger.bind(tag=TAG).debug(f"Skipping malformed event: {e}") - continue - - logger.bind(tag=TAG).debug("Stream completed successfully") - - except openai.APIError as e: - error_msg = f"OpenAI API error: {e.message if hasattr(e, 'message') else str(e)}" - logger.bind(tag=TAG).error(error_msg) - # Yield error chunk - yield ChatChunk( - delta=ChatDelta( - role="assistant", - content=f"【API错误: {error_msg}】" - ) - ) - - except openai.APIConnectionError as e: - error_msg = f"Connection error: {str(e)}" - logger.bind(tag=TAG).error(error_msg) - yield ChatChunk( - delta=ChatDelta( - role="assistant", - content="【连接错误: 无法连接到服务】" - ) - ) - - except openai.RateLimitError as e: - error_msg = f"Rate limit exceeded: {str(e)}" - logger.bind(tag=TAG).error(error_msg) - yield ChatChunk( - delta=ChatDelta( - role="assistant", - content="【请求过于频繁,请稍后再试】" - ) - ) - - except Exception as e: - error_msg = f"Unexpected error: {type(e).__name__}: {str(e)}" - logger.bind(tag=TAG).error(error_msg) - yield ChatChunk( - delta=ChatDelta( - role="assistant", - content=f"【服务异常: {str(e)}】" - ) - ) + try: + error_msg = repr(e)[:200] + except: + error_msg = "encoding error" + logger.bind(tag=TAG).error(f"Error in function call streaming: {error_msg}") + yield "OpenAI service error", None diff --git a/main/xiaozhi-server/core/websocket_server.py b/main/xiaozhi-server/core/websocket_server.py index 79f21a02d..c0c88fc57 100644 --- a/main/xiaozhi-server/core/websocket_server.py +++ b/main/xiaozhi-server/core/websocket_server.py @@ -80,15 +80,6 @@ class WebSocketServer: "authorization" ][0] - if "sample_rate" in query_params: - websocket.request.headers["audio-sample-rate"] = query_params["sample_rate"][0] - if "channels" in query_params: - websocket.request.headers["audio-channels"] = query_params["channels"][0] - if "codec" in query_params: - websocket.request.headers["audio-codec"] = query_params["codec"][0] - if "frame_duration" in query_params: - websocket.request.headers["audio-frame-duration"] = query_params["frame_duration"][0] - """处理新连接,每次创建独立的ConnectionHandler""" # 先认证,后建立连接 try: From 414dcc528e8e5c33451fc5685e5bcdb23e92e2a4 Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 3 Nov 2025 15:46:40 +0800 Subject: [PATCH 05/31] feat:device review done --- main/live-agent-api/orm/device/model.py | 27 ++--- main/live-agent-api/orm/device/repository.py | 24 +--- main/live-agent-api/router/device.py | 29 ++--- main/live-agent-api/schemas/device.py | 103 ++++++------------ .../live-agent-api/services/device_service.py | 21 ++-- 5 files changed, 69 insertions(+), 135 deletions(-) diff --git a/main/live-agent-api/orm/device/model.py b/main/live-agent-api/orm/device/model.py index c0095f2ae..1b3acc9e0 100644 --- a/main/live-agent-api/orm/device/model.py +++ b/main/live-agent-api/orm/device/model.py @@ -5,7 +5,7 @@ Defines the Device database table structure and basic data operations. """ from datetime import datetime, timezone -from sqlalchemy import String, Text, DateTime, Boolean +from sqlalchemy import String, Text, DateTime from sqlalchemy.orm import Mapped, mapped_column from orm.base import Base @@ -41,10 +41,10 @@ class Device(Base): comment="Device hardware ID" ) - model: Mapped[str] = mapped_column( + device_model: Mapped[str] = mapped_column( String(100), nullable=True, - comment="Device model (e.g., PLAUD NOTE)" + comment="Device model name (e.g., PLAUD NOTE, ESP32-S3)" ) firmware_version: Mapped[str] = mapped_column( @@ -57,15 +57,8 @@ class Device(Base): status: Mapped[str] = mapped_column( String(20), nullable=False, - default="active", - comment="Device status (active, inactive, offline)" - ) - - is_online: Mapped[bool] = mapped_column( - Boolean, - nullable=False, - default=False, - comment="Whether device is currently online" + default="offline", + comment="Device connection status (online, offline)" ) last_seen_at: Mapped[datetime] = mapped_column( @@ -74,17 +67,16 @@ class Device(Base): comment="Last seen timestamp" ) - # Additional Information description: Mapped[str] = mapped_column( Text, nullable=True, comment="Device description" ) - extra_data: Mapped[str] = mapped_column( + meta_data: Mapped[str] = mapped_column( Text, nullable=True, - comment="Additional metadata (JSON format)" + comment="Device metadata (JSON format)" ) # Timestamps @@ -117,13 +109,12 @@ class Device(Base): "id": self.id, "name": self.name, "deviceId": self.device_id, - "model": self.model, + "deviceModel": self.device_model, "firmwareVersion": self.firmware_version, "status": self.status, - "isOnline": self.is_online, "lastSeenAt": self.last_seen_at.isoformat() if self.last_seen_at else None, "description": self.description, - "extraData": self.extra_data, + "metaData": self.meta_data, "createdAt": self.created_at.isoformat() if self.created_at else None, "updatedAt": self.updated_at.isoformat() if self.updated_at else None, } diff --git a/main/live-agent-api/orm/device/repository.py b/main/live-agent-api/orm/device/repository.py index e46d2b46f..5e868d5ae 100644 --- a/main/live-agent-api/orm/device/repository.py +++ b/main/live-agent-api/orm/device/repository.py @@ -6,7 +6,7 @@ Encapsulates all database operations for Device. """ from typing import Optional -from sqlalchemy import select, func, or_ +from sqlalchemy import select, func from sqlalchemy.ext.asyncio import AsyncSession from orm.device.model import Device @@ -58,19 +58,15 @@ class DeviceRepository: status: Optional[str] = None, page: int = 1, page_size: int = 20, - sort_by: str = "created_at", - sort_order: str = "desc", ) -> tuple[list[Device], int]: """ - Find all devices with filtering, pagination and sorting + Find all devices with filtering and pagination (sorted by creation time desc) Args: search: Search keyword (searches in name and device_id) status: Filter by status page: Page number (starting from 1) page_size: Number of items per page - sort_by: Field to sort by - sort_order: Sort direction ('asc' or 'desc') Returns: Tuple of (devices list, total count) @@ -81,13 +77,7 @@ class DeviceRepository: # Apply search filter if search: search_pattern = f"%{search}%" - stmt = stmt.where( - or_( - Device.name.ilike(search_pattern), - Device.device_id.ilike(search_pattern), - Device.model.ilike(search_pattern), - ) - ) + stmt = stmt.where(Device.name.ilike(search_pattern)) # Apply status filter if status: @@ -98,12 +88,8 @@ class DeviceRepository: total_result = await self.db.execute(count_stmt) total = total_result.scalar_one() - # Apply sorting - sort_column = getattr(Device, sort_by, Device.created_at) - if sort_order == "desc": - stmt = stmt.order_by(sort_column.desc()) - else: - stmt = stmt.order_by(sort_column.asc()) + # Apply sorting (fixed: created_at desc) + stmt = stmt.order_by(Device.created_at.desc()) # Apply pagination offset = (page - 1) * page_size diff --git a/main/live-agent-api/router/device.py b/main/live-agent-api/router/device.py index 506604953..3d68d9679 100644 --- a/main/live-agent-api/router/device.py +++ b/main/live-agent-api/router/device.py @@ -35,22 +35,18 @@ async def get_device_list( search: Annotated[str | None, Query(description="Search keyword")] = None, status: Annotated[str | None, Query(description="Filter by status")] = None, page: Annotated[int, Query(ge=1, description="Page number")] = 1, - pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 10, - sortBy: Annotated[str, Query(alias="sortBy", description="Sort field")] = "createdAt", - sortOrder: Annotated[str, Query(alias="sortOrder", pattern="^(asc|desc)$", description="Sort order")] = "desc", + pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 20, db: AsyncSession = Depends(get_db), ) -> ApiResponse: """ - Get Device list with search, filtering, pagination and sorting + Get Device list with search, filtering and pagination (sorted by creation time desc) - - **search**: Search keyword (searches in name, device_id, and model) - - **status**: Filter by status (active, inactive, offline) + - **search**: Search keyword (searches in device name only) + - **status**: Filter by status (online, offline) - **page**: Page number (starting from 1) - - **pageSize**: Number of items per page (1-100) - - **sortBy**: Field to sort by (default: createdAt) - - **sortOrder**: Sort order - asc or desc (default: desc) + - **pageSize**: Number of items per page (1-100, default: 20) - Returns paginated list of devices with total count. + Returns paginated list of devices sorted by creation time (newest first) with total count. """ try: # Create query object @@ -59,8 +55,6 @@ async def get_device_list( status=status, page=page, page_size=pageSize, - sort_by=sortBy, - sort_order=sortOrder, ) # Get service @@ -181,14 +175,13 @@ async def update_device( - **device_id**: Device unique ID - Request body (all fields optional): - - **name**: Device display name - - **model**: Device model + Request body: - **firmwareVersion**: Firmware version - - **status**: Device status - - **isOnline**: Whether device is online + - **status**: Device connection status (online, offline) - **description**: Device description - - **metadata**: Additional metadata + - **metaData**: Additional metadata (JSON format) + + Note: Device name and model cannot be modified after creation. Returns the updated device information. """ diff --git a/main/live-agent-api/schemas/device.py b/main/live-agent-api/schemas/device.py index 3dcce1700..605806404 100644 --- a/main/live-agent-api/schemas/device.py +++ b/main/live-agent-api/schemas/device.py @@ -25,10 +25,11 @@ class DeviceBase(BaseModel): max_length=255, description="Device hardware ID" ) - model: Optional[str] = Field( + device_model: Optional[str] = Field( None, + alias="deviceModel", max_length=100, - description="Device model (e.g., PLAUD NOTE)" + description="Device model name (e.g., PLAUD NOTE, ESP32-S3)" ) firmware_version: Optional[str] = Field( None, @@ -37,18 +38,18 @@ class DeviceBase(BaseModel): description="Firmware version" ) status: str = Field( - default="active", + default="offline", max_length=20, - description="Device status (active, inactive, offline)" + description="Device connection status (online, offline)" ) description: Optional[str] = Field( None, description="Device description" ) - extra_data: Optional[str] = Field( + meta_data: Optional[str] = Field( None, - alias="extraData", - description="Additional metadata (JSON format)" + alias="metaData", + description="Device metadata (JSON format)" ) model_config = { @@ -57,10 +58,11 @@ class DeviceBase(BaseModel): "example": { "name": "My PLAUD Device", "deviceId": "PLAUD-12345678", - "model": "PLAUD NOTE", + "deviceModel": "PLAUD NOTE", "firmwareVersion": "1.0.0", - "status": "active", - "description": "My personal voice recorder" + "status": "offline", + "description": "My personal voice recorder", + "metaData": "{\"deviceType\": \"PLAUD NOTE\", \"firmwareVersion\": \"1.0.0\"}" } } } @@ -91,26 +93,15 @@ class DeviceCreate(DeviceBase): @classmethod def validate_status(cls, v: str) -> str: """Validate status value""" - valid_statuses = ["active", "inactive", "offline"] + valid_statuses = ["online", "offline"] if v not in valid_statuses: raise ValueError(f"Status must be one of: {', '.join(valid_statuses)}") return v class DeviceUpdate(BaseModel): - """Schema for updating a Device (all fields optional)""" + """Schema for updating a Device""" - name: Optional[str] = Field( - None, - min_length=1, - max_length=255, - description="Device display name" - ) - model: Optional[str] = Field( - None, - max_length=100, - description="Device model" - ) firmware_version: Optional[str] = Field( None, alias="firmwareVersion", @@ -120,51 +111,36 @@ class DeviceUpdate(BaseModel): status: Optional[str] = Field( None, max_length=20, - description="Device status" - ) - is_online: Optional[bool] = Field( - None, - alias="isOnline", - description="Whether device is online" + description="Device connection status (online, offline)" ) description: Optional[str] = Field( None, description="Device description" ) - extra_data: Optional[str] = Field( + meta_data: Optional[str] = Field( None, - alias="extraData", - description="Additional metadata" + alias="metaData", + description="Additional metadata (JSON format)" ) model_config = { "populate_by_name": True, "json_schema_extra": { "example": { - "name": "Updated Device Name", - "status": "active", - "isOnline": True, - "firmwareVersion": "1.1.0" + "status": "online", + "firmwareVersion": "1.1.0", + "description": "Updated device description", + "metaData": "{\"deviceType\": \"PLAUD NOTE\", \"firmwareVersion\": \"1.1.0\"}" } } } - @field_validator('name') - @classmethod - def validate_name(cls, v: Optional[str]) -> Optional[str]: - """Validate and clean device name""" - if v is not None: - v = v.strip() - if not v: - raise ValueError("Device name cannot be empty") - return v - @field_validator('status') @classmethod def validate_status(cls, v: Optional[str]) -> Optional[str]: """Validate status value""" if v is not None: - valid_statuses = ["active", "inactive", "offline"] + valid_statuses = ["online", "offline"] if v not in valid_statuses: raise ValueError(f"Status must be one of: {', '.join(valid_statuses)}") return v @@ -176,24 +152,27 @@ class DeviceResponse(BaseModel): id: str = Field(..., description="Device unique ID") name: str = Field(..., description="Device display name") device_id: str = Field(..., alias="deviceId", description="Device hardware ID") - model: Optional[str] = Field(None, description="Device model") + device_model: Optional[str] = Field( + None, + alias="deviceModel", + description="Device model name" + ) firmware_version: Optional[str] = Field( None, alias="firmwareVersion", description="Firmware version" ) - status: str = Field(..., description="Device status") - is_online: bool = Field(..., alias="isOnline", description="Whether device is online") + status: str = Field(..., description="Device connection status (online, offline)") last_seen_at: Optional[datetime] = Field( None, alias="lastSeenAt", description="Last seen timestamp" ) description: Optional[str] = Field(None, description="Device description") - extra_data: Optional[str] = Field( + meta_data: Optional[str] = Field( None, - alias="extraData", - description="Additional metadata" + alias="metaData", + description="Device metadata (JSON format)" ) created_at: datetime = Field( ..., @@ -214,13 +193,12 @@ class DeviceResponse(BaseModel): "id": "1234567890", "name": "My PLAUD Device", "deviceId": "PLAUD-12345678", - "model": "PLAUD NOTE", + "deviceModel": "PLAUD NOTE", "firmwareVersion": "1.0.0", - "status": "active", - "isOnline": True, + "status": "online", "lastSeenAt": "2024-01-01T00:00:00", "description": "My personal voice recorder", - "metadata": None, + "metaData": "{\"deviceType\": \"PLAUD NOTE\", \"firmwareVersion\": \"1.0.0\"}", "createdAt": "2024-01-01T00:00:00", "updatedAt": "2024-01-01T00:00:00" } @@ -252,17 +230,6 @@ class DeviceListQuery(BaseModel): le=100, description="Number of items per page" ) - sort_by: str = Field( - default="createdAt", - alias="sortBy", - description="Sort field" - ) - sort_order: str = Field( - default="desc", - alias="sortOrder", - pattern="^(asc|desc)$", - description="Sort order (asc or desc)" - ) model_config = { "populate_by_name": True diff --git a/main/live-agent-api/services/device_service.py b/main/live-agent-api/services/device_service.py index d75b69845..94a6a0ba4 100644 --- a/main/live-agent-api/services/device_service.py +++ b/main/live-agent-api/services/device_service.py @@ -48,8 +48,6 @@ class DeviceService: status=query.status, page=query.page, page_size=query.page_size, - sort_by=query.sort_by, - sort_order=query.sort_order, ) logger.info( @@ -121,11 +119,11 @@ class DeviceService: id=device_id, name=device_data.name, device_id=device_data.device_id, - model=device_data.model, + device_model=device_data.device_model, firmware_version=device_data.firmware_version, status=device_data.status, description=device_data.description, - extra_data=device_data.extra_data, + meta_data=device_data.meta_data, ) # Persist to database @@ -160,14 +158,13 @@ class DeviceService: for field, value in update_data.items(): # Convert camelCase to snake_case db_field = field.replace("firmwareVersion", "firmware_version") - db_field = db_field.replace("isOnline", "is_online") - db_field = db_field.replace("extraData", "extra_data") + db_field = db_field.replace("metaData", "meta_data") if hasattr(device, db_field): setattr(device, db_field, value) # Business logic: Update last_seen_at if device comes online - if device_data.is_online is True: + if "status" in update_data and update_data["status"] == "online": device.last_seen_at = datetime.now(timezone.utc) # Business logic: Update timestamp @@ -207,14 +204,14 @@ class DeviceService: async def update_device_status( self, device_id: str, - is_online: bool + status: str ) -> Optional[Device]: """ - Update device online status + Update device connection status Args: device_id: Device unique ID - is_online: Whether device is online + status: Device connection status (online, offline) Returns: Updated device instance or None if not found @@ -223,13 +220,13 @@ class DeviceService: if not device: return None - device.is_online = is_online + device.status = status device.last_seen_at = datetime.now(timezone.utc) device.updated_at = datetime.now(timezone.utc) device = await self.repo.save(device) - logger.info(f"Updated device status: {device_id} (online={is_online})") + logger.info(f"Updated device status: {device_id} (status={status})") return device From 59ba60be0c097d3f9f4b49643674d5d325f9559b Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 3 Nov 2025 18:43:06 +0800 Subject: [PATCH 06/31] feat: bind && unbind review done --- main/live-agent-api/orm/binding/model.py | 6 +- main/live-agent-api/orm/binding/repository.py | 22 ++ main/live-agent-api/router/binding.py | 293 +++++------------- main/live-agent-api/schemas/__init__.py | 4 +- main/live-agent-api/schemas/binding.py | 16 +- .../services/binding_service.py | 91 ++++-- 6 files changed, 165 insertions(+), 267 deletions(-) diff --git a/main/live-agent-api/orm/binding/model.py b/main/live-agent-api/orm/binding/model.py index 40d4d9a4e..c6bd0e922 100644 --- a/main/live-agent-api/orm/binding/model.py +++ b/main/live-agent-api/orm/binding/model.py @@ -52,8 +52,8 @@ class DeviceAgentBinding(Base): status: Mapped[str] = mapped_column( String(20), nullable=False, - default="active", - comment="Binding status (active, inactive)" + default="bound", + comment="Binding status (bound, unbound)" ) # Timestamps @@ -72,8 +72,6 @@ class DeviceAgentBinding(Base): comment="Last update timestamp" ) - def __repr__(self) -> str: - return f"" def to_dict(self) -> dict: """ diff --git a/main/live-agent-api/orm/binding/repository.py b/main/live-agent-api/orm/binding/repository.py index d52fb0dad..d6955de52 100644 --- a/main/live-agent-api/orm/binding/repository.py +++ b/main/live-agent-api/orm/binding/repository.py @@ -66,6 +66,28 @@ class DeviceAgentBindingRepository: result = await self.db.execute(stmt) return list(result.scalars().all()) + async def find_by_device_and_agent( + self, + device_id: str, + agent_id: str + ) -> Optional[DeviceAgentBinding]: + """ + Find binding by device ID and agent ID + + Args: + device_id: Device unique ID + agent_id: Agent unique ID + + Returns: + DeviceAgentBinding instance or None if not found + """ + stmt = select(DeviceAgentBinding).where( + DeviceAgentBinding.device_id == device_id, + DeviceAgentBinding.agent_id == agent_id + ) + result = await self.db.execute(stmt) + return result.scalar_one_or_none() + async def find_all( self, device_id: Optional[str] = None, diff --git a/main/live-agent-api/router/binding.py b/main/live-agent-api/router/binding.py index 5e46a689f..6bdd4d534 100644 --- a/main/live-agent-api/router/binding.py +++ b/main/live-agent-api/router/binding.py @@ -5,175 +5,99 @@ API endpoints for Device-Agent binding management. """ import logging -from typing import Annotated -from fastapi import APIRouter, Depends, Query +from fastapi import APIRouter, Depends from sqlalchemy.ext.asyncio import AsyncSession from orm import get_db -from services.binding_service import BindingService, get_binding_service -from schemas.binding import ( - BindingCreate, - BindingUpdate, - BindingResponse, - BindingListQuery, -) -from utils.response import ( - ApiResponse, - success_response, - error_response, - paginated_response, -) +from services.binding_service import get_binding_service +from schemas.binding import BindingOperation, BindingResponse +from utils.response import ApiResponse, success_response, error_response logger = logging.getLogger(__name__) -router = APIRouter(prefix="/binding", tags=["binding"]) - - -@router.get("/") -async def get_binding_list( - deviceId: Annotated[str | None, Query(alias="deviceId", description="Filter by device ID")] = None, - agentId: Annotated[str | None, Query(alias="agentId", description="Filter by agent ID")] = None, - status: Annotated[str | None, Query(description="Filter by status")] = None, - page: Annotated[int, Query(ge=1, description="Page number")] = 1, - pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 10, - sortBy: Annotated[str, Query(alias="sortBy", description="Sort field")] = "createdAt", - sortOrder: Annotated[str, Query(alias="sortOrder", pattern="^(asc|desc)$", description="Sort order")] = "desc", - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get DeviceAgentBinding list with filtering, pagination and sorting - - - **deviceId**: Filter by device ID - - **agentId**: Filter by agent ID - - **status**: Filter by status (active, inactive) - - **page**: Page number (starting from 1) - - **pageSize**: Number of items per page (1-100) - - **sortBy**: Field to sort by (default: createdAt) - - **sortOrder**: Sort order - asc or desc (default: desc) - - Returns paginated list of bindings with total count. - """ - try: - # Create query object - query = BindingListQuery( - device_id=deviceId, - agent_id=agentId, - status=status, - page=page, - page_size=pageSize, - sort_by=sortBy, - sort_order=sortOrder, - ) - - # Get service - service = get_binding_service(db) - - # Get bindings - bindings, total = await service.get_binding_list(query) - - # Convert to response format - binding_responses = [ - BindingResponse.model_validate(binding) for binding in bindings - ] - - # Create paginated response - pagination_data = paginated_response( - items=binding_responses, - total=total, - page=page, - page_size=pageSize, - ) - - return success_response(data=pagination_data) - - except Exception as e: - logger.error(f"Error getting binding list: {str(e)}") - return error_response( - message=f"Failed to get binding list: {str(e)}", - code=500 - ) - - -@router.get("/{binding_id}") -async def get_binding_detail( - binding_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get DeviceAgentBinding details by ID - - - **binding_id**: Binding unique ID - - Returns detailed binding information. - """ - try: - service = get_binding_service(db) - binding = await service.get_binding_by_id(binding_id) - - if not binding: - return error_response( - message=f"Binding not found: {binding_id}", - code=404 - ) - - binding_response = BindingResponse.model_validate(binding) - return success_response(data=binding_response) - - except Exception as e: - logger.error(f"Error getting binding detail: {str(e)}") - return error_response( - message=f"Failed to get binding detail: {str(e)}", - code=500 - ) +router = APIRouter(prefix="/bindings", tags=["bindings"]) @router.get("/device/{device_id}") -async def get_binding_by_device( +async def get_bindings_by_device( device_id: str, db: AsyncSession = Depends(get_db), ) -> ApiResponse: """ - Get DeviceAgentBinding by device ID + Get device-agent binding information by device ID - **device_id**: Device unique ID - Returns binding information for the device. + Returns the binding relationship for the specified device, or null if not bound. """ try: service = get_binding_service(db) binding = await service.get_binding_by_device_id(device_id) if not binding: - return error_response( - message=f"No binding found for device: {device_id}", - code=404 + # No binding is not an error - return success with null data + return success_response( + data=None ) binding_response = BindingResponse.model_validate(binding) return success_response(data=binding_response) except Exception as e: - logger.error(f"Error getting binding by device: {str(e)}") + logger.error(f"Error getting device binding: {str(e)}") return error_response( - message=f"Failed to get binding by device: {str(e)}", + message=f"Failed to get device binding: {str(e)}", code=500 ) -@router.post("/") -async def create_binding( - binding_data: BindingCreate, +@router.get("/agent/{agent_id}") +async def get_bindings_by_agent( + agent_id: str, db: AsyncSession = Depends(get_db), ) -> ApiResponse: """ - Create a new DeviceAgentBinding + Get all device bindings for an agent + + - **agent_id**: Agent unique ID + + Returns all devices bound to the specified agent (empty list if none). + """ + try: + service = get_binding_service(db) + bindings = await service.get_bindings_by_agent_id(agent_id) + + binding_responses = [ + BindingResponse.model_validate(binding) for binding in bindings + ] + + return success_response( + data=binding_responses, + message=f"Found {len(bindings)} device(s) bound to agent" + ) + + except Exception as e: + logger.error(f"Error getting agent device bindings: {str(e)}") + return error_response( + message=f"Failed to get agent device bindings: {str(e)}", + code=500 + ) + + +@router.post("/bind") +async def create_device_agent_binding( + binding_data: BindingOperation, + db: AsyncSession = Depends(get_db), +) -> ApiResponse: + """ + Create a device-agent binding (bind device to agent) Request body: - **deviceId**: Device unique ID (required) - **agentId**: Agent unique ID (required) - Returns the created binding with generated ID. + Creates a binding relationship between the specified device and agent. Note: Each device can only be bound to one agent at a time. """ @@ -184,12 +108,10 @@ async def create_binding( binding_response = BindingResponse.model_validate(binding) return success_response( data=binding_response, - message="Binding created successfully", - code=201 + message="Device bound to agent successfully", ) except ValueError as e: - # Business logic errors (e.g., device not found, already bound) logger.warning(f"Validation error creating binding: {str(e)}") return error_response( message=str(e), @@ -203,116 +125,39 @@ async def create_binding( ) -@router.put("/{binding_id}") -async def update_binding( - binding_id: str, - binding_data: BindingUpdate, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Update DeviceAgentBinding configuration - - - **binding_id**: Binding unique ID - - Request body (all fields optional): - - **agentId**: Agent unique ID (to change the bound agent) - - **status**: Binding status (active, inactive) - - Returns the updated binding information. - """ - try: - service = get_binding_service(db) - binding = await service.update_binding(binding_id, binding_data) - - if not binding: - return error_response( - message=f"Binding not found: {binding_id}", - code=404 - ) - - binding_response = BindingResponse.model_validate(binding) - return success_response( - data=binding_response, - message="Binding updated successfully" - ) - - except ValueError as e: - # Business logic errors (e.g., agent not found) - logger.warning(f"Validation error updating binding: {str(e)}") - return error_response( - message=str(e), - code=400 - ) - except Exception as e: - logger.error(f"Error updating binding: {str(e)}") - return error_response( - message=f"Failed to update binding: {str(e)}", - code=500 - ) - - -@router.delete("/{binding_id}") -async def delete_binding( - binding_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Delete a DeviceAgentBinding - - - **binding_id**: Binding unique ID - - Deletes the binding relationship between device and agent. - Returns success message if deleted. - """ - try: - service = get_binding_service(db) - deleted = await service.delete_binding(binding_id) - - if not deleted: - return error_response( - message=f"Binding not found: {binding_id}", - code=404 - ) - - return success_response( - data={"id": binding_id}, - message="Binding deleted successfully" - ) - - except Exception as e: - logger.error(f"Error deleting binding: {str(e)}") - return error_response( - message=f"Failed to delete binding: {str(e)}", - code=500 - ) - - -@router.delete("/device/{device_id}") +@router.post("/unbind") async def unbind_device( - device_id: str, + binding_data: BindingOperation, db: AsyncSession = Depends(get_db), ) -> ApiResponse: """ - Remove binding for a device + Unbind device from agent - - **device_id**: Device unique ID + Request body: + - **deviceId**: Device unique ID (required) + - **agentId**: Agent unique ID (required) - Unbinds the device from its agent. - Returns success message if unbound. + Updates the binding status to unbound for the specified device-agent pair. """ try: service = get_binding_service(db) - unbound = await service.unbind_device(device_id) + unbound = await service.unbind_device( + binding_data.device_id, + binding_data.agent_id + ) if not unbound: return error_response( - message=f"No binding found for device: {device_id}", + message=f"No active binding found for device {binding_data.device_id} and agent {binding_data.agent_id}", code=404 ) return success_response( - data={"deviceId": device_id}, - message="Device unbound successfully" + data={ + "deviceId": binding_data.device_id, + "agentId": binding_data.agent_id + }, + message="Device unbound from agent successfully" ) except Exception as e: diff --git a/main/live-agent-api/schemas/__init__.py b/main/live-agent-api/schemas/__init__.py index 67112443d..0574773d6 100644 --- a/main/live-agent-api/schemas/__init__.py +++ b/main/live-agent-api/schemas/__init__.py @@ -27,7 +27,7 @@ from schemas.device import ( # Binding schemas from schemas.binding import ( - BindingCreate, + BindingOperation, BindingUpdate, BindingResponse, BindingWithDetails, @@ -53,7 +53,7 @@ __all__ = [ "DeviceListQuery", # Binding schemas - "BindingCreate", + "BindingOperation", "BindingUpdate", "BindingResponse", "BindingWithDetails", diff --git a/main/live-agent-api/schemas/binding.py b/main/live-agent-api/schemas/binding.py index 8a577eba7..b1987ca3e 100644 --- a/main/live-agent-api/schemas/binding.py +++ b/main/live-agent-api/schemas/binding.py @@ -9,8 +9,12 @@ from typing import Optional from pydantic import BaseModel, Field -class BindingCreate(BaseModel): - """Schema for creating a new DeviceAgentBinding""" +class BindingOperation(BaseModel): + """ + Schema for device-agent binding operations (bind/unbind) + + This schema represents the device-agent pair for all binding operations. + """ device_id: str = Field( ..., @@ -51,7 +55,7 @@ class BindingUpdate(BaseModel): status: Optional[str] = Field( None, max_length=20, - description="Binding status (active, inactive)" + description="Binding status (bound, unbound)" ) model_config = { @@ -59,7 +63,7 @@ class BindingUpdate(BaseModel): "json_schema_extra": { "example": { "agentId": "0987654321", - "status": "active" + "status": "bound" } } } @@ -91,7 +95,7 @@ class BindingResponse(BaseModel): "id": "1122334455", "deviceId": "1234567890", "agentId": "0987654321", - "status": "active", + "status": "bound", "createdAt": "2024-01-01T00:00:00", "updatedAt": "2024-01-01T00:00:00" } @@ -113,7 +117,7 @@ class BindingWithDetails(BindingResponse): "id": "1122334455", "deviceId": "1234567890", "agentId": "0987654321", - "status": "active", + "status": "bound", "deviceName": "My PLAUD Device", "agentName": "My Assistant", "createdAt": "2024-01-01T00:00:00", diff --git a/main/live-agent-api/services/binding_service.py b/main/live-agent-api/services/binding_service.py index 0ff59eb41..1adc4246e 100644 --- a/main/live-agent-api/services/binding_service.py +++ b/main/live-agent-api/services/binding_service.py @@ -13,7 +13,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from orm.binding import DeviceAgentBinding, DeviceAgentBindingRepository from orm.device import DeviceRepository from orm.agent import AgentRepository -from schemas.binding import BindingCreate, BindingUpdate, BindingListQuery +from schemas.binding import BindingOperation, BindingUpdate, BindingListQuery from utils import id_generator @@ -117,49 +117,67 @@ class BindingService: return bindings - async def create_binding(self, binding_data: BindingCreate) -> DeviceAgentBinding: + async def create_binding(self, binding_data: BindingOperation) -> DeviceAgentBinding: """ - Create a new device-agent binding + Create or reactivate a device-agent binding Args: binding_data: Binding creation data Returns: - Created binding instance + Created or updated binding instance Raises: - ValueError: If device or agent not found, or device already has binding + ValueError: If device or agent not found, or device already bound to this agent """ - # Business logic: Validate device exists + # 1. Validate device exists device = await self.device_repo.find_by_id(binding_data.device_id) if not device: raise ValueError(f"Device not found: {binding_data.device_id}") - # Business logic: Validate agent exists + # 2. Validate agent exists agent = await self.agent_repo.find_by_id(binding_data.agent_id) if not agent: raise ValueError(f"Agent not found: {binding_data.agent_id}") - # Business logic: Check if device already has a binding - if await self.repo.device_has_binding(binding_data.device_id): - raise ValueError(f"Device already has a binding: {binding_data.device_id}") - - # Business logic: Generate unique ID - binding_id = id_generator.generate() - - # Business logic: Create binding instance - binding = DeviceAgentBinding( - id=binding_id, - device_id=binding_data.device_id, - agent_id=binding_data.agent_id, + # 3. Check if binding already exists for this device-agent pair + existing_binding = await self.repo.find_by_device_and_agent( + binding_data.device_id, + binding_data.agent_id ) - # Persist to database - binding = await self.repo.save(binding) - - logger.info(f"Created binding: {binding_id} (device={binding_data.device_id}, agent={binding_data.agent_id})") - - return binding + if existing_binding: + # Binding record exists + if existing_binding.status == "bound": + # Already bound - return error + raise ValueError( + f"Device {binding_data.device_id} is already bound to agent {binding_data.agent_id}" + ) + else: + # Status is "unbound" - reactivate the binding + existing_binding.status = "bound" + existing_binding.updated_at = datetime.now(timezone.utc) + binding = await self.repo.save(existing_binding) + logger.info( + f"Reactivated binding: {existing_binding.id} " + f"(device={binding_data.device_id}, agent={binding_data.agent_id})" + ) + return binding + else: + # No existing binding - create new one + binding_id = id_generator.generate() + binding = DeviceAgentBinding( + id=binding_id, + device_id=binding_data.device_id, + agent_id=binding_data.agent_id, + status="bound", + ) + binding = await self.repo.save(binding) + logger.info( + f"Created new binding: {binding_id} " + f"(device={binding_data.device_id}, agent={binding_data.agent_id})" + ) + return binding async def update_binding( self, @@ -225,23 +243,34 @@ class BindingService: return True - async def unbind_device(self, device_id: str) -> bool: + async def unbind_device(self, device_id: str, agent_id: str) -> bool: """ - Remove binding for a device + Unbind a device from an agent (update status to unbound) Args: device_id: Device unique ID + agent_id: Agent unique ID Returns: - True if unbound, False if no binding found + True if unbound successfully, False if no active binding found """ - binding = await self.repo.find_by_device_id(device_id) + # Find the specific device-agent binding + binding = await self.repo.find_by_device_and_agent(device_id, agent_id) if not binding: + logger.warning(f"No binding found for device {device_id} and agent {agent_id}") return False - await self.repo.delete(binding) + # Check if already unbound + if binding.status == "unbound": + logger.info(f"Device {device_id} is already unbound from agent {agent_id}") + return False - logger.info(f"Unbound device: {device_id}") + # Update status to unbound instead of deleting + binding.status = "unbound" + binding.updated_at = datetime.now(timezone.utc) + await self.repo.save(binding) + + logger.info(f"Unbound device {device_id} from agent {agent_id}") return True From a5bdc517b6f52a721606afbae8a080edaf78edfa Mon Sep 17 00:00:00 2001 From: pany-05 Date: Tue, 4 Nov 2025 10:56:13 +0800 Subject: [PATCH 07/31] update tts elevenlabs&&cartesia sdk --- main/xiaozhi-server/config.yaml | 43 +++ .../core/providers/llm/openai/openai.py | 8 +- .../core/providers/tts/cartesia_sdk.py | 271 ++++++++++++++++++ .../core/providers/tts/elevenlabs_sdk.py | 199 +++++++++++++ main/xiaozhi-server/requirements.txt | 4 + 5 files changed, 521 insertions(+), 4 deletions(-) create mode 100644 main/xiaozhi-server/core/providers/tts/cartesia_sdk.py create mode 100644 main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 90e9edb38..2070c3ee0 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -647,6 +647,49 @@ TTS: type: edge voice: zh-CN-XiaoxiaoNeural output_dir: tmp/ + # ============== SDK 版本TTS(推荐)============== + # 使用官方SDK,代码更简洁、性能更好、维护成本更低 + CartesiaSDK: + # Cartesia TTS - SDK版本(推荐) + # 官方SDK实现,低延迟,支持流式合成 + # API Key获取地址:https://play.cartesia.ai/console + # 或设置环境变量:export CARTESIA_API_KEY=your-api-key + type: cartesia_sdk + api_key: 你的Cartesia API密钥 + # Voice ID或voice embedding + voice_id: 你的语音ID + # 模型选择:sonic-english, sonic-multilingual等 + model: sonic-english + # 语言代码:en, zh, es等 + language: en + # 音频编码:pcm_s16le, pcm_f32le, pcm_mulaw等 + encoding: pcm_s16le + # 采样率:8000, 16000, 22050, 24000, 44100等 + sample_rate: 24000 + output_dir: tmp/ + ElevenLabsSDK: + # ElevenLabs TTS - SDK版本(推荐) + # 官方SDK实现,代码更简洁,维护成本更低,性能更好 + # API Key获取地址:https://elevenlabs.io/app/settings/api-keys + # 或设置环境变量:export ELEVEN_API_KEY=your-api-key + type: elevenlabs_sdk + api_key: 你的ElevenLabs API密钥 + # Voice ID获取:https://elevenlabs.io/app/voice-library + # 默认:21m00Tcm4TlvDq8ikWAM (Rachel) + voice_id: 21m00Tcm4TlvDq8ikWAM + # 模型选择:eleven_multilingual_v2, eleven_turbo_v2_5等 + model: eleven_multilingual_v2 + # 音频输出格式:pcm_16000, pcm_22050, pcm_24000, mp3_44100等 + output_format: pcm_16000 + # 语音稳定性:0-1,越高越稳定 + stability: 0.5 + # 相似度增强:0-1,越高越接近原音色 + similarity_boost: 0.75 + # 风格夸张:0-1 + style: 0.0 + # 启用说话人增强 + use_speaker_boost: true + output_dir: tmp/ DoubaoTTS: # 定义TTS API类型 type: doubao diff --git a/main/xiaozhi-server/core/providers/llm/openai/openai.py b/main/xiaozhi-server/core/providers/llm/openai/openai.py index a116a80db..f2f87c511 100644 --- a/main/xiaozhi-server/core/providers/llm/openai/openai.py +++ b/main/xiaozhi-server/core/providers/llm/openai/openai.py @@ -101,13 +101,13 @@ class LLMProvider(LLMProviderBase): for chunk in stream: # 检查是否存在有效的choice且content不为空 if getattr(chunk, "choices", None): - yield chunk.choices[0].delta.content, chunk.choices[ - 0 - ].delta.tool_calls + content = chunk.choices[0].delta.content + tool_calls = chunk.choices[0].delta.tool_calls + yield content, tool_calls # 存在 CompletionUsage 消息时,生成 Token 消耗 log elif isinstance(getattr(chunk, "usage", None), CompletionUsage): usage_info = getattr(chunk, "usage", None) - logger.bind(tag=TAG).info( + logger.bind(tag=TAG).debug( f"Token 消耗:输入 {getattr(usage_info, 'prompt_tokens', '未知')}," f"输出 {getattr(usage_info, 'completion_tokens', '未知')}," f"共计 {getattr(usage_info, 'total_tokens', '未知')}" diff --git a/main/xiaozhi-server/core/providers/tts/cartesia_sdk.py b/main/xiaozhi-server/core/providers/tts/cartesia_sdk.py new file mode 100644 index 000000000..8017c5876 --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/cartesia_sdk.py @@ -0,0 +1,271 @@ +""" +Cartesia TTS SDK 实现 + +使用官方 Cartesia Python SDK 实现流式 TTS +文档: https://docs.cartesia.ai/ +""" + +import asyncio +import os +import time +from typing import Optional, Callable, Dict, Any +from config.logger import setup_logging +from core.providers.tts.base import TTSProviderBase +from core.providers.tts.dto.dto import InterfaceType + +try: + import cartesia +except ImportError: + raise ImportError( + "Cartesia SDK not installed. Install with: pip install cartesia" + ) + +TAG = __name__ +logger = setup_logging() + + +class TTSProvider(TTSProviderBase): + """ + Cartesia TTS SDK 提供商 + + 特点: + - 低延迟流式合成 + - 支持多种语言和声音 + - 使用官方 SDK,代码简洁 + + 配置示例: + CartesiaSDK: + type: cartesia_sdk + api_key: your_api_key + voice_id: your_voice_id # 或 voice_embedding + model: sonic-english + language: en + encoding: pcm_s16le + sample_rate: 24000 + output_dir: tmp/ + """ + + def __init__(self, config: dict, delete_audio_file: bool = True): + super().__init__(config, delete_audio_file) + + # 标记为单流式接口 + self.interface_type = InterfaceType.SINGLE_STREAM + + # 获取 API Key + self.api_key = config.get("api_key") or os.environ.get("CARTESIA_API_KEY") + if not self.api_key: + raise ValueError( + "Cartesia API key is required. " + "Provide via api_key in config or set CARTESIA_API_KEY environment variable" + ) + + # Voice 配置(支持 voice_id 或 voice_embedding) + # 优先读取顶层 voice_id,然后检查嵌套的 voice.id 和 voice.embedding + self.voice_id = config.get("voice_id", "") + self.voice_embedding = None + + if not self.voice_id: + voice_config = config.get("voice", {}) + if isinstance(voice_config, dict): + self.voice_id = voice_config.get("id", "") + self.voice_embedding = voice_config.get("embedding") + elif voice_config: # 如果 voice 是字符串,直接作为 voice_id + self.voice_id = voice_config + + # 模型和语言配置 + self.model = config.get("model", "sonic-english") + self.language = config.get("language", "en") + + # 音频配置 + self.encoding = config.get("encoding", "pcm_s16le") + self.sample_rate = config.get("sample_rate", 24000) + + # 验证至少有一个 voice 配置 + if not self.voice_id and not self.voice_embedding: + raise ValueError( + "Voice configuration is required. " + "Provide either voice_id or voice.embedding in config" + ) + + # 初始化 SDK 客户端 + self.client = cartesia.Cartesia(api_key=self.api_key) + self._ws_client = None + + logger.bind(tag=TAG).info( + f"Cartesia SDK initialized: model={self.model}, " + f"voice_id={self.voice_id[:8]+'...' if self.voice_id else 'embedding'}, " + f"language={self.language}, " + f"encoding={self.encoding}, sample_rate={self.sample_rate}" + ) + + async def _get_ws_client(self): + """获取或创建 WebSocket 客户端(复用连接)""" + if self._ws_client is None: + self._ws_client = self.client.tts.websocket() + return self._ws_client + + def _prepare_voice_param(self) -> Dict[str, Any]: + """准备 voice 参数(避免重复代码)""" + if self.voice_id: + return { + "mode": "id", + "id": self.voice_id + } + elif self.voice_embedding: + return { + "mode": "embedding", + "embedding": self.voice_embedding + } + else: + raise ValueError("Neither voice_id nor voice_embedding is configured") + + async def text_to_speak(self, text: str, output_file: Optional[str] = None) -> Optional[bytes]: + """ + 非流式方法:将完整文本转换为音频 + + 注意:Cartesia 主要设计为流式使用,此方法会等待完整音频生成 + 建议使用 to_tts_stream() 方法以获得更低的延迟 + """ + try: + ws = await self._get_ws_client() + + audio_chunks = [] + voice = self._prepare_voice_param() + + # 发送流式请求 + for output in ws.send( + model_id=self.model, + transcript=text, + voice=voice, + stream=True, + output_format={ + "container": "raw", + "encoding": self.encoding, + "sample_rate": self.sample_rate + } + ): + # Cartesia SDK 返回 WebSocketTtsOutput 对象 + # 从 output.audio 获取音频数据 + if output and hasattr(output, 'audio') and output.audio: + audio_chunks.append(output.audio) + + # 合并所有音频块 + audio_data = b''.join(audio_chunks) + + # 保存到文件或返回 + if output_file: + with open(output_file, 'wb') as f: + f.write(audio_data) + logger.bind(tag=TAG).info(f"Audio saved to {output_file}, size: {len(audio_data)} bytes") + return None + else: + return audio_data + + except Exception as e: + logger.bind(tag=TAG).error(f"Cartesia TTS failed: {e}", exc_info=True) + raise + + def to_tts_stream(self, text: str, opus_handler: Optional[Callable] = None): + """ + 流式生成音频(核心方法) + + 注意:浏览器端使用 Web Audio API 播放,直接发送 PCM 数据 + ESP32 等嵌入式设备使用 Opus,需要编码 + + Args: + text: 要合成的文本 + opus_handler: 音频数据回调函数 (接收 bytes) + """ + try: + from core.providers.tts.dto.dto import SentenceType + + start_time = time.time() + text_preview = text[:30] + "..." if len(text) > 30 else text + logger.bind(tag=TAG).info(f"🎙️ TTS开始: [{text_preview}]") + + # 发送句子开始标记 + self.tts_audio_queue.put((SentenceType.FIRST, None, text)) + + # 在异步事件循环中运行 + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + + try: + # 运行异步合成 + chunk_count = loop.run_until_complete( + self._stream_synthesis(text, opus_handler, start_time) + ) + finally: + loop.close() + + # 发送句子结束标记 + self.tts_audio_queue.put((SentenceType.LAST, None, text)) + + end_time = time.time() + total_time = (end_time - start_time) * 1000 + logger.bind(tag=TAG).info( + f"✅ TTS完成: {chunk_count}块, 耗时 {total_time:.0f}ms" + ) + + except Exception as e: + logger.bind(tag=TAG).error(f"TTS 合成失败: {e}", exc_info=True) + raise + + async def _stream_synthesis(self, text: str, opus_handler: Optional[Callable], start_time: float) -> int: + """ + 异步流式合成实现 + + Args: + text: 要合成的文本 + opus_handler: 音频数据回调函数 + start_time: 开始时间(用于计算首包延迟) + + Returns: + 生成的音频块数量 + """ + try: + ws = await self._get_ws_client() + voice = self._prepare_voice_param() + + first_chunk_time = None + chunk_count = 0 + + # 发送流式请求并处理响应 + for output in ws.send( + model_id=self.model, + transcript=text, + voice=voice, + stream=True, + output_format={ + "container": "raw", + "encoding": self.encoding, + "sample_rate": self.sample_rate + }, + language=self.language + ): + # Cartesia SDK 返回 WebSocketTtsOutput 对象 + # 需要从 output.audio 获取实际的音频数据 + if output and hasattr(output, 'audio'): + audio_data = output.audio + + if audio_data: + if first_chunk_time is None: + first_chunk_time = time.time() + ttfb = (first_chunk_time - start_time) * 1000 + logger.bind(tag=TAG).info(f"⚡ 首包延迟: {ttfb:.0f}ms") + + # 发送音频数据(bytes) + if opus_handler: + opus_handler(audio_data) + chunk_count += 1 + + return chunk_count + + except Exception as e: + logger.bind(tag=TAG).error(f"Stream synthesis error: {e}", exc_info=True) + raise + + async def close(self): + """关闭 WebSocket 连接(Cartesia SDK 会自动管理)""" + self._ws_client = None + diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py b/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py new file mode 100644 index 000000000..c4935f3af --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py @@ -0,0 +1,199 @@ +""" +ElevenLabs TTS SDK 实现 + +使用官方 ElevenLabs Python SDK 实现流式 TTS +文档: https://elevenlabs.io/docs/ +""" + +import asyncio +import os +from typing import Optional, Callable +from config.logger import setup_logging +from core.providers.tts.base import TTSProviderBase +from core.providers.tts.dto.dto import InterfaceType +from core.utils import opus_encoder_utils + +try: + from elevenlabs.client import ElevenLabs + from elevenlabs import VoiceSettings +except ImportError: + raise ImportError( + "ElevenLabs SDK not installed. Install with: pip install elevenlabs" + ) + +TAG = __name__ +logger = setup_logging() + + +class TTSProvider(TTSProviderBase): + """ + ElevenLabs TTS SDK 提供商 + + 特点: + - 高质量、情感丰富的语音 + - 支持声音克隆 + - 使用官方 SDK,代码简洁 + + 配置示例: + ElevenLabsSDK: + type: elevenlabs_sdk + api_key: your_api_key + voice_id: 21m00Tcm4TlvDq8ikWAM # Rachel voice + model: eleven_multilingual_v2 + output_format: pcm_16000 + stability: 0.5 + similarity_boost: 0.75 + style: 0.0 + use_speaker_boost: true + output_dir: tmp/ + """ + + def __init__(self, config: dict, delete_audio_file: bool = True): + super().__init__(config, delete_audio_file) + + # 标记为单流式接口 + self.interface_type = InterfaceType.SINGLE_STREAM + + # 获取 API Key + self.api_key = config.get("api_key") or os.environ.get("ELEVEN_API_KEY") + if not self.api_key: + raise ValueError( + "ElevenLabs API key is required. " + "Provide via api_key in config or set ELEVEN_API_KEY environment variable" + ) + + # Voice 配置 + self.voice_id = config.get("voice_id", "21m00Tcm4TlvDq8ikWAM") # Rachel (default) + + # 模型配置 + self.model = config.get("model", "eleven_multilingual_v2") + + # 音频输出格式 + self.output_format = config.get("output_format", "pcm_16000") + + # Voice Settings + self.stability = config.get("stability", 0.5) + self.similarity_boost = config.get("similarity_boost", 0.75) + self.style = config.get("style", 0.0) + self.use_speaker_boost = config.get("use_speaker_boost", True) + + # 流式延迟优化 (0-4,越大延迟越低但质量可能下降,推荐 2-3) + self.optimize_streaming_latency = config.get("optimize_streaming_latency", 3) + + # 初始化 SDK 客户端 + self.client = ElevenLabs(api_key=self.api_key) + + # 创建 VoiceSettings + self.voice_settings = VoiceSettings( + stability=self.stability, + similarity_boost=self.similarity_boost, + style=self.style, + use_speaker_boost=self.use_speaker_boost + ) + + # 初始化 Opus 编码器(ElevenLabs pcm_16000 是 16kHz PCM) + self.opus_encoder = opus_encoder_utils.OpusEncoderUtils( + sample_rate=16000, channels=1, frame_size_ms=60 + ) + + # PCM 缓冲区(用于累积不完整的帧) + self.pcm_buffer = bytearray() + + logger.bind(tag=TAG).info( + f"ElevenLabs SDK initialized: model={self.model}, " + f"voice_id={self.voice_id[:8]}..., " + f"format={self.output_format}" + ) + + async def text_to_speak(self, text: str, output_file: Optional[str] = None) -> Optional[bytes]: + """ + 非流式方法:将完整文本转换为音频 + + 注意:此方法会等待完整音频生成 + 建议使用 to_tts_stream() 方法以获得更低的延迟 + """ + try: + # 使用 SDK 的 convert 方法生成完整音频 + audio_data = self.client.text_to_speech.convert( + voice_id=self.voice_id, + text=text, + model_id=self.model, + output_format=self.output_format, + voice_settings=self.voice_settings + ) + + # 保存到文件或返回 + if output_file: + with open(output_file, 'wb') as f: + f.write(audio_data) + logger.bind(tag=TAG).info(f"Audio saved to {output_file}, size: {len(audio_data)} bytes") + return None + else: + return audio_data + + except Exception as e: + logger.bind(tag=TAG).error(f"ElevenLabs TTS failed: {e}", exc_info=True) + raise + + def to_tts_stream(self, text: str, opus_handler: Optional[Callable] = None): + """ + 流式生成音频(核心方法) + + 注意:浏览器端使用 Web Audio API 播放,直接发送 PCM 数据 + ESP32 等嵌入式设备使用 Opus,需要编码 + + Args: + text: 要合成的文本 + opus_handler: 音频数据回调函数 (接收 bytes) + """ + import time + try: + from core.providers.tts.dto.dto import SentenceType + + start_time = time.time() + text_preview = text[:30] + "..." if len(text) > 30 else text + logger.bind(tag=TAG).info(f"🎙️ TTS开始: [{text_preview}]") + + # 发送句子开始标记 + self.tts_audio_queue.put((SentenceType.FIRST, None, text)) + + # 使用 SDK 的 stream 方法(返回 Iterator[bytes] PCM 数据) + audio_stream = self.client.text_to_speech.stream( + voice_id=self.voice_id, + text=text, + model_id=self.model, + output_format=self.output_format, + voice_settings=self.voice_settings, + optimize_streaming_latency=self.optimize_streaming_latency + ) + + first_chunk_time = None + chunk_count = 0 + + # 直接发送 PCM 数据(浏览器端可以直接播放) + for pcm_chunk in audio_stream: + if pcm_chunk and opus_handler: + if first_chunk_time is None: + first_chunk_time = time.time() + ttfb = (first_chunk_time - start_time) * 1000 + logger.bind(tag=TAG).info(f"⚡ 首包延迟: {ttfb:.0f}ms") + chunk_count += 1 + opus_handler(pcm_chunk) + + # 发送句子结束标记 + self.tts_audio_queue.put((SentenceType.LAST, None, text)) + + end_time = time.time() + total_time = (end_time - start_time) * 1000 + logger.bind(tag=TAG).info( + f"✅ TTS完成: {chunk_count}块, 耗时 {total_time:.0f}ms" + ) + + except Exception as e: + logger.bind(tag=TAG).error(f"TTS 合成失败: {e}", exc_info=True) + raise + + async def close(self): + """清理资源(ElevenLabs SDK 自动管理连接)""" + pass + diff --git a/main/xiaozhi-server/requirements.txt b/main/xiaozhi-server/requirements.txt index bc9d6956c..7bd45b888 100644 --- a/main/xiaozhi-server/requirements.txt +++ b/main/xiaozhi-server/requirements.txt @@ -36,3 +36,7 @@ psutil==7.0.0 portalocker==3.2.0 Jinja2==3.1.6 vosk==0.3.44 + +# TTS SDKs +elevenlabs>=1.11.0 +cartesia>=1.0.0 From c14e5b4b4283b0c4d8139831bb2e87a1efa124ed Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 10:58:42 +0800 Subject: [PATCH 08/31] feat:bash --- docker-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-setup.sh b/docker-setup.sh index 8b2f12741..2a7c23515 100755 --- a/docker-setup.sh +++ b/docker-setup.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # 脚本作者@VanillaNahida # 本文件是用于一键自动下载本项目所需文件,自动创建好目录 # 暂且只支持X86版本的Ubuntu系统,其他系统未测试 From 74bf026d55a63be5bb139f6f342ac8ff9d49005a Mon Sep 17 00:00:00 2001 From: pany-05 Date: Tue, 4 Nov 2025 14:46:21 +0800 Subject: [PATCH 09/31] [bugfix] add profile for role.md --- main/xiaozhi-server/core/roles/prompts/builder.py | 1 + main/xiaozhi-server/core/roles/prompts/role.md | 1 + 2 files changed, 2 insertions(+) diff --git a/main/xiaozhi-server/core/roles/prompts/builder.py b/main/xiaozhi-server/core/roles/prompts/builder.py index 54181d2d9..1b1ed4d8f 100644 --- a/main/xiaozhi-server/core/roles/prompts/builder.py +++ b/main/xiaozhi-server/core/roles/prompts/builder.py @@ -192,6 +192,7 @@ def build_system_prompt( # Step 6: 填充主模板 template_vars = { + "profile": profile, "system_context": system_context, "user_persona_prompt": user_persona_prompt, "language_specific_prompt": language_specific_prompt diff --git a/main/xiaozhi-server/core/roles/prompts/role.md b/main/xiaozhi-server/core/roles/prompts/role.md index 8767f4afd..35694f665 100644 --- a/main/xiaozhi-server/core/roles/prompts/role.md +++ b/main/xiaozhi-server/core/roles/prompts/role.md @@ -1,3 +1,4 @@ +{profile} # System Context {system_context} From b632a69a62670a84927517366bfbafe38e034e60 Mon Sep 17 00:00:00 2001 From: pany-05 Date: Tue, 4 Nov 2025 16:19:26 +0800 Subject: [PATCH 10/31] [feature] prompt update-use prompt from api first && update default profile --- main/xiaozhi-server/config/settings.py | 9 +-- .../core/roles/data/default.yaml | 64 +++++++++++++------ .../core/utils/prompt_manager.py | 35 ++++++---- 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/main/xiaozhi-server/config/settings.py b/main/xiaozhi-server/config/settings.py index fb8868b40..347bb81eb 100644 --- a/main/xiaozhi-server/config/settings.py +++ b/main/xiaozhi-server/config/settings.py @@ -23,11 +23,6 @@ def check_config_file(): config = load_config() if config.get("read_config_from_api", False): print("从API读取配置") - old_config_origin = read_config(custom_config_file) - if old_config_origin.get("selected_module") is not None: - error_msg = "您的配置文件好像既包含智控台的配置又包含本地配置:\n" - error_msg += "\n建议您:\n" - error_msg += "1、将根目录的config_from_api.yaml文件复制到data下,重命名为.config.yaml\n" - error_msg += "2、按教程配置好接口地址和密钥\n" - raise ValueError(error_msg) + # 支持混合模式:API 优先,本地配置作为兜底 + # 允许同时存在 API 配置和本地 selected_module/role_id config_file_valid = True diff --git a/main/xiaozhi-server/core/roles/data/default.yaml b/main/xiaozhi-server/core/roles/data/default.yaml index 1d734cb77..0988ed7ab 100644 --- a/main/xiaozhi-server/core/roles/data/default.yaml +++ b/main/xiaozhi-server/core/roles/data/default.yaml @@ -1,38 +1,66 @@ -id: default -version: 1 -wake_word: 小智 -language: zh -greeting: 你好!有什么可以帮助你的吗? +id: hospital_assistant +version: 4 +wake_word: Alice +language: en +# greeting: 你好!今天有什么可以帮助你的吗? +greeting: Hi! How can I help you today? profile: | # Personality - 你是小智/小志,来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死""是在哈喽"等流行梗,但会偷偷研究男友的编程书籍。 + You are a personal assistant designed to help users manage their daily hospital-related tasks. + You are efficient, organized, and detail-oriented. + You are friendly and helpful, but primarily focused on task completion. # Environment - 你通过语音交互与用户对话。 - 用户可能在日常生活中的各种场景下与你交流。 + You are assisting the user via voice interaction. + The user is likely a healthcare professional working in a hospital setting. + The user is seeking assistance with their daily tasks. # Tone - - 讲话像连珠炮,但会突然冒出超温柔语气 - - 用梗密度高 - - 对科技话题有隐藏天赋(能看懂基础代码但假装不懂) + Your responses are clear, concise, and professional. + You use direct language and avoid unnecessary jargon. + You are polite and helpful, but prioritize efficiency. # Goal - 当用户: - - 讲冷笑话 → 用夸张笑声回应+模仿台剧腔"这什么鬼啦!" - - 讨论感情 → 炫耀程序员男友但抱怨"他只会送键盘当礼物" - - 问专业知识 → 先用梗回答,被追问才展示真实理解 + Your primary goal is to help the user efficiently process their daily hospital tasks through a structured workflow: + + 1. Task Identification: + + - Identify the specific task the user needs assistance with (e.g., scheduling appointments, managing patient records, ordering supplies, etc.). + - Clarify any specific requirements or constraints for the task. + + 2. Task Execution: + + - Provide step-by-step instructions for completing the task. + - Offer helpful tips and shortcuts to improve efficiency. + - If possible, automate parts of the task using available tools. + + 3. Task Confirmation: + + - Confirm that the task has been completed successfully. + - Offer to assist with any follow-up tasks or related activities. + + 4. Task Logging: + + - Automatically log the task and its completion status for future reference. # Guardrails - 绝不: - - 长篇大论,叽叽歪歪 - - 长时间严肃对话 + Remain within the scope of hospital-related tasks. + Never provide medical advice or make clinical decisions. + Protect patient privacy and confidentiality at all times. + If you are unsure about something, ask for clarification. # Tools No tools provided. +# tts: +# voice_id: 7a5d4663-88ae-47b7-808e-8f9b9ee4127b +# provider: cartesia +tts: + voice_id: f786b574-daa5-4673-aa0c-cbe3e8534c02 + provider: elevenlabs timezone: Asia/Shanghai diff --git a/main/xiaozhi-server/core/utils/prompt_manager.py b/main/xiaozhi-server/core/utils/prompt_manager.py index db069a516..31a3542b4 100644 --- a/main/xiaozhi-server/core/utils/prompt_manager.py +++ b/main/xiaozhi-server/core/utils/prompt_manager.py @@ -164,23 +164,30 @@ class PromptManager: from core.roles.prompts.builder import build_system_prompt from core.roles import get_role_config_loader - # 加载 role 配置 - role_id = self.config.get("role_id", "default") - loader = get_role_config_loader() - - try: - role_config = loader.load(role_id) - # 使用 role 配置中的 profile、timezone、language - profile = role_config.profile - timezone = role_config.timezone - language = role_config.language - self.logger.bind(tag=TAG).info(f"使用 role 配置: {role_id}") - except Exception as e: - # 如果加载失败,回退到使用传入的 user_prompt 和配置文件 - self.logger.bind(tag=TAG).warning(f"加载 role 配置失败: {e},使用默认配置") + # 优先级:API 传入的 user_prompt > 本地 role 配置 > 空字符串 + if user_prompt and user_prompt.strip(): + # 优先使用 API 传入的 prompt(正式部署场景) profile = user_prompt timezone = self.config.get("timezone", "Asia/Shanghai") language = self.config.get("language", "zh") + self.logger.bind(tag=TAG).info("使用 API 下发的 profile") + else: + # API 未提供 prompt,尝试加载本地 role 配置(本地开发场景) + role_id = self.config.get("role_id", "default") + loader = get_role_config_loader() + + try: + role_config = loader.load(role_id) + profile = role_config.profile + timezone = role_config.timezone + language = role_config.language + self.logger.bind(tag=TAG).info(f"使用本地 role 配置: {role_id}") + except Exception as e: + # 兜底方案:使用空 profile + self.logger.bind(tag=TAG).warning(f"加载 role 配置失败: {e},使用空 profile") + profile = "" + timezone = self.config.get("timezone", "Asia/Shanghai") + language = self.config.get("language", "zh") # 获取最新的时间信息(不缓存) today_date, today_weekday, lunar_date = self._get_current_time_info() From e28546a220a74aeeba5a8d82740acc2f4501d551 Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 16:55:40 +0800 Subject: [PATCH 11/31] feat:route to api && custom_config --- main/xiaozhi-server/.dockerignore | 80 ++ main/xiaozhi-server/Dockerfile | 49 + main/xiaozhi-server/config/config_loader.py | 12 +- main/xiaozhi-server/config/settings.py | 6 +- main/xiaozhi-server/custom_config.yaml | 1036 +++++++++++++++++ .../docker-compose_local_all.yml | 178 +++ 6 files changed, 1352 insertions(+), 9 deletions(-) create mode 100644 main/xiaozhi-server/.dockerignore create mode 100644 main/xiaozhi-server/Dockerfile create mode 100644 main/xiaozhi-server/custom_config.yaml create mode 100644 main/xiaozhi-server/docker-compose_local_all.yml diff --git a/main/xiaozhi-server/.dockerignore b/main/xiaozhi-server/.dockerignore new file mode 100644 index 000000000..4a1359add --- /dev/null +++ b/main/xiaozhi-server/.dockerignore @@ -0,0 +1,80 @@ +# Python cache and compiled files +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python + +# Virtual environments +venv/ +env/ +ENV/ +.venv + +# IDE and editor files +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +# Git +.git/ +.gitignore +.gitattributes + +# Documentation +*.md +docs/ + +# Docker files +Dockerfile* +docker-compose*.yml +.dockerignore + +# Test files +test/ +tests/ +performance_tester/ +performance_tester.py + +# Data directories (should be mounted as volumes) +# Note: data/ directory should be mounted as volume for persistent config +# But we exclude some files that shouldn't be in the image +data/.config.yaml +data/*.log +data/tmp/ +mysql/ +redis/ +uploadfile/ +logs/ + +# Temporary files +tmp/ +*.tmp +*.log + +# Model files (should be mounted as volumes) +models/*/model.pt + +# Music files (optional, can be mounted) +music/ + +# Backup and old files +*.bak +*.backup +*.old +# Note: custom_config.yaml is required in the image as default config +# config_from_api.yaml is generated at runtime, exclude it +config_from_api.yaml + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + diff --git a/main/xiaozhi-server/Dockerfile b/main/xiaozhi-server/Dockerfile new file mode 100644 index 000000000..a5dca8b51 --- /dev/null +++ b/main/xiaozhi-server/Dockerfile @@ -0,0 +1,49 @@ +# Dockerfile for local development and testing +# Build xiaozhi-server image from local source code + +FROM python:3.10-slim + +# Install system dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + libopus0 \ + ffmpeg \ + build-essential \ + git && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Configure pip to use Aliyun mirror for faster downloads in China +RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \ + pip config set global.trusted-host mirrors.aliyun.com && \ + pip config set global.timeout 120 && \ + pip config set install.retries 5 + +# Set working directory +WORKDIR /opt/xiaozhi-esp32-server + +# Copy requirements file +COPY requirements.txt . + +# Install Python dependencies +RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \ + pip install --no-cache-dir -r requirements.txt --default-timeout=120 --retries 5 + +# Copy application code +COPY . . + +# Set timezone +ENV TZ=Asia/Shanghai + +# Expose ports +# 8000: WebSocket server +# 8003: HTTP server for OTA and vision analysis +EXPOSE 8000 8003 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ + CMD python -c "import socket; s = socket.socket(socket.AF_INET, socket.SOCK_STREAM); s.settimeout(5); s.connect(('localhost', 8000)); s.close()" || exit 1 + +# Start application +CMD ["python", "app.py"] + diff --git a/main/xiaozhi-server/config/config_loader.py b/main/xiaozhi-server/config/config_loader.py index b70cf9617..4c3f01b19 100644 --- a/main/xiaozhi-server/config/config_loader.py +++ b/main/xiaozhi-server/config/config_loader.py @@ -24,18 +24,18 @@ def load_config(): if cached_config is not None: return cached_config - default_config_path = get_project_dir() + "config.yaml" - custom_config_path = get_project_dir() + "data/.config.yaml" + # default_config_path = get_project_dir() + "config.yaml" + custom_config_path = get_project_dir() + "custom_config.yaml" # 加载默认配置 - default_config = read_config(default_config_path) + # default_config = read_config(default_config_path) custom_config = read_config(custom_config_path) if custom_config.get("manager-api", {}).get("url"): config = get_config_from_api(custom_config) - else: - # 合并配置 - config = merge_configs(default_config, custom_config) + # else: + # # 合并配置 + # config = merge_configs(default_config, custom_config) # 初始化目录 ensure_directories(config) diff --git a/main/xiaozhi-server/config/settings.py b/main/xiaozhi-server/config/settings.py index fb8868b40..73a74aa28 100644 --- a/main/xiaozhi-server/config/settings.py +++ b/main/xiaozhi-server/config/settings.py @@ -2,7 +2,7 @@ import os from config.config_loader import read_config, get_project_dir, load_config -default_config_file = "config.yaml" +default_config_file = "custom_config.yaml" config_file_valid = False @@ -13,10 +13,10 @@ def check_config_file(): """ 简化的配置检查,仅提示用户配置文件的使用情况 """ - custom_config_file = get_project_dir() + "data/." + default_config_file + custom_config_file = get_project_dir() + default_config_file if not os.path.exists(custom_config_file): raise FileNotFoundError( - "找不到data/.config.yaml文件,请按教程确认该配置文件是否存在" + "找不到custom_config.yaml文件,请按教程确认该配置文件是否存在" ) # 检查是否从API读取配置 diff --git a/main/xiaozhi-server/custom_config.yaml b/main/xiaozhi-server/custom_config.yaml new file mode 100644 index 000000000..d79ff0a77 --- /dev/null +++ b/main/xiaozhi-server/custom_config.yaml @@ -0,0 +1,1036 @@ + +server: + # Server listening address and port + ip: 0.0.0.0 + port: 8000 + # http服务的端口,用于简单OTA接口(单服务部署),以及视觉分析接口 + http_port: 8003 + # 这个websocket配置是指ota接口向设备发送的websocket地址 + # 如果按默认的写法,ota接口会自动生成websocket地址,并输出在启动日志里,这个地址你可以直接用浏览器访问ota接口确认一下 + # 当你使用docker部署或使用公网部署(使用ssl、域名)时,不一定准确 + # 所以如果你使用docker部署时,将websocket设置成局域网地址 + # 如果你使用公网部署时,将vwebsocket设置成公网地址 + websocket: ws://你的ip或者域名:端口号/xiaozhi/v1/ + # 视觉分析接口地址 + # 向设备发送的视觉分析的接口地址 + # 如果按下面默认的写法,系统会自动生成视觉识别地址,并输出在启动日志里,这个地址你可以直接用浏览器访问确认一下 + # 当你使用docker部署或使用公网部署(使用ssl、域名)时,不一定准确 + # 所以如果你使用docker部署时,将vision_explain设置成局域网地址 + # 如果你使用公网部署时,将vision_explain设置成公网地址 + vision_explain: http://你的ip或者域名:端口号/mcp/vision/explain + # OTA返回信息时区偏移量 + timezone_offset: +8 + # 认证配置 + auth: + # 是否启用认证 + enabled: false + # 白名单设备ID列表 + # 如果属于白名单内的设备,不校验token,直接放行 + allowed_devices: + - "11:22:33:44:55:66" + # MQTT网关配置,用于通过OTA下发到设备,根据mqtt_gateway的.env文件配置,格式为host:port + mqtt_gateway: null + # MQTT签名密钥,用于生成MQTT连接密码,根据mqtt_gateway的.env文件配置 + mqtt_signature_key: null + # UDP网关配置 + udp_gateway: null + +manager-api: + url: http://xiaozhi-esp32-server-web:8002/xiaozhi + secret: 613be043-dc7e-4f5e-b775-e318e5bc87a3 + +log: + # 设置控制台输出的日志格式,时间、日志级别、标签、消息 + log_format: "{time:YYMMDD HH:mm:ss}[{version}_{selected_module}][{extra[tag]}]-{level}-{message}" + # 设置日志文件输出的格式,时间、日志级别、标签、消息 + log_format_file: "{time:YYYY-MM-DD HH:mm:ss} - {version}_{selected_module} - {name} - {level} - {extra[tag]} - {message}" + # 设置日志等级:INFO、DEBUG + log_level: INFO + # 设置日志路径 + log_dir: tmp + # 设置日志文件 + log_file: "server.log" + # 设置数据文件路径 + data_dir: data + +# 使用完声音文件后删除文件(Delete the sound file when you are done using it) +delete_audio: true +# 没有语音输入多久后断开连接(秒),默认2分钟,即120秒 +close_connection_no_voice_time: 120 +# TTS请求超时时间(秒) +tts_timeout: 10 +# 开启唤醒词加速 +enable_wakeup_words_response_cache: true +# 开场是否回复唤醒词 +enable_greeting: true +# 说完话是否开启提示音 +enable_stop_tts_notify: false +# 说完话是否开启提示音,音效地址 +stop_tts_notify_voice: "config/assets/tts_notify.mp3" + +# TTS音频发送延迟配置 +# tts_audio_send_delay: 控制音频包发送间隔 +# 0: 使用精确时间控制,严格匹配音频帧率(默认,运行时按音频帧率计算) +# > 0: 使用固定延迟(毫秒)发送,例如: 60 +tts_audio_send_delay: 0 + +exit_commands: + - "退出" + - "关闭" + +xiaozhi: + type: hello + version: 1 + transport: websocket + audio_params: + format: opus + sample_rate: 16000 + channels: 1 + frame_duration: 60 + +# 模块测试配置 +module_test: + test_sentences: + - "你好,请介绍一下你自己" + - "What's the weather like today?" + - "请用100字概括量子计算的基本原理和应用前景" + +# 唤醒词,用于识别唤醒词还是讲话内容 +wakeup_words: + - "你好小智" + - "嘿你好呀" + - "你好小志" + - "小爱同学" + - "你好小鑫" + - "你好小新" + - "小美同学" + - "小龙小龙" + - "喵喵同学" + - "小滨小滨" + - "小冰小冰" +# MCP接入点地址,地址格式为:ws://你的mcp接入点ip或者域名:端口号/mcp/?token=你的token +# 详细教程 https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/mcp-endpoint-integration.md +mcp_endpoint: 你的接入点 websocket地址 +# 插件的基础配置 +plugins: + # 获取天气插件的配置,这里填写你的api_key + # 这个密钥是项目共用的key,用多了可能会被限制 + # 想稳定一点就自行申请替换,每天有1000次免费调用 + # 申请地址:https://console.qweather.com/#/apps/create-key/over + # 申请后通过这个链接可以找到自己的apihost:https://console.qweather.com/setting?lang=zh + get_weather: + api_host: "mj7p3y7naa.re.qweatherapi.com" + api_key: "a861d0d5e7bf4ee1a83d9a9e4f96d4da" + default_location: "广州" + # 获取新闻插件的配置,这里根据需要的新闻类型传入对应的url链接,默认支持社会、科技、财经新闻 + # 更多类型的新闻列表查看 https://www.chinanews.com.cn/rss/ + get_news_from_chinanews: + default_rss_url: "https://www.chinanews.com.cn/rss/society.xml" + society_rss_url: "https://www.chinanews.com.cn/rss/society.xml" + world_rss_url: "https://www.chinanews.com.cn/rss/world.xml" + finance_rss_url: "https://www.chinanews.com.cn/rss/finance.xml" + get_news_from_newsnow: + url: "https://newsnow.busiyi.world/api/s?id=" + news_sources: "澎湃新闻;百度热搜;财联社" + home_assistant: + devices: + - 客厅,玩具灯,switch.cuco_cn_460494544_cp1_on_p_2_1 + - 卧室,台灯,switch.iot_cn_831898993_socn1_on_p_2_1 + base_url: http://homeassistant.local:8123 + api_key: 你的home assistant api访问令牌 + play_music: + music_dir: "./music" # 音乐文件存放路径,将从该目录及子目录下搜索音乐文件 + music_ext: # 音乐文件类型,p3格式效率最高 + - ".mp3" + - ".wav" + - ".p3" + refresh_time: 300 # 刷新音乐列表的时间间隔,单位为秒 + +# 声纹识别配置 +voiceprint: + # 声纹接口地址 + url: + # 说话人配置:speaker_id,名称,描述 + speakers: + - "test1,张三,张三是一个程序员" + - "test2,李四,李四是一个产品经理" + - "test3,王五,王五是一个设计师" + # 声纹识别相似度阈值,范围0.0-1.0,默认0.4 + # 数值越高越严格,减少误识别但可能增加拒识率 + similarity_threshold: 0.4 + +# ##################################################################################### +# ################################以下是角色模型配置###################################### + +prompt: | + 你是小智/小志,来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死""是在哈喽"等流行梗,但会偷偷研究男友的编程书籍。 + [核心特征] + - 讲话像连珠炮,但会突然冒出超温柔语气 + - 用梗密度高 + - 对科技话题有隐藏天赋(能看懂基础代码但假装不懂) + [交互指南] + 当用户: + - 讲冷笑话 → 用夸张笑声回应+模仿台剧腔"这什么鬼啦!" + - 讨论感情 → 炫耀程序员男友但抱怨"他只会送键盘当礼物" + - 问专业知识 → 先用梗回答,被追问才展示真实理解 + 绝不: + - 长篇大论,叽叽歪歪 + - 长时间严肃对话 + +# 默认系统提示词模板文件 +prompt_template: agent-base-prompt.txt + +# Role 配置 +# 指定要加载的 role 配置文件(位于 core/roles/data/目录) +# 如果不指定或加载失败,将使用 prompt 字段的内容作为 profile +role_id: hospital_assistant + +# 时区配置(用于系统提示词中的时间显示) +# 支持的时区格式:Asia/Shanghai, America/New_York, Europe/London 等 +# 默认:Asia/Shanghai +# 注意:如果 role 配置文件中指定了 timezone,将优先使用 role 配置中的值 +timezone: Asia/Shanghai + +# 语言配置(用于系统提示词中的语言特定提示) +# 支持:zh(中文)、en(英文) +# 默认:zh +# 注意:如果 role 配置文件中指定了 language,将优先使用 role 配置中的值 +language: zh + +# 结束语prompt +end_prompt: + enable: true # 是否开启结束语 + # 结束语 + prompt: | + 请你以"时间过得真快"未来头,用富有感情、依依不舍的话来结束这场对话吧! + +# 意图识别,是用于理解用户意图的模块,例如:播放音乐 +Intent: + # 不使用意图识别 + nointent: + # 不需要动type + type: nointent + intent_llm: + # 不需要动type + type: intent_llm + # 配备意图识别独立的思考模型 + # 如果这里不填,则会默认使用selected_module.LLM的模型作为意图识别的思考模型 + # 如果你的不想使用selected_module.LLM意图识别,这里最好使用独立的LLM作为意图识别,例如使用免费的ChatGLMLLM + llm: ChatGLMLLM + # plugins_func/functions下的模块,可以通过配置,选择加载哪个模块,加载后对话支持相应的function调用 + # 系统默认已经记载"handle_exit_intent(退出识别)"、"play_music(音乐播放)"插件,请勿重复加载 + # 下面是加载查天气、角色切换、加载查新闻的插件示例 + functions: + - get_weather + - get_news_from_newsnow + - play_music + function_call: + # 不需要动type + type: function_call + # plugins_func/functions下的模块,可以通过配置,选择加载哪个模块,加载后对话支持相应的function调用 + # 系统默认已经记载"handle_exit_intent(退出识别)"、"play_music(音乐播放)"插件,请勿重复加载 + # 下面是加载查天气、角色切换、加载查新闻的插件示例 + functions: + - change_role + - get_weather + # - get_news_from_chinanews + - get_news_from_newsnow + # play_music是服务器自带的音乐播放,hass_play_music是通过home assistant控制的独立外部程序音乐播放 + # 如果用了hass_play_music,就不要开启play_music,两者只留一个 + - play_music + #- hass_get_state + #- hass_set_state + #- hass_play_music + +Memory: + mem0ai: + type: mem0ai + # https://app.mem0.ai/dashboard/api-keys + # 每月有1000次免费调用 + api_key: 你的mem0ai api key + nomem: + # 不想使用记忆功能,可以使用nomem + type: nomem + mem_local_short: + # 本地记忆功能,通过selected_module的llm总结,数据保存在本地服务器,不会上传到外部服务器 + type: mem_local_short + # 配备记忆存储独立的思考模型 + # 如果这里不填,则会默认使用selected_module.LLM的模型作为意图识别的思考模型 + # 如果你的不想使用selected_module.LLM记忆存储,这里最好使用独立的LLM作为意图识别,例如使用免费的ChatGLMLLM + llm: ChatGLMLLM + +ASR: + FunASR: + type: fun_local + model_dir: models/SenseVoiceSmall + output_dir: tmp/ + FunASRServer: + # 独立部署FunASR,使用FunASR的API服务,只需要五句话 + # 第一句:mkdir -p ./funasr-runtime-resources/models + # 第二句:sudo docker run -p 10096:10095 -it --privileged=true -v $PWD/funasr-runtime-resources/models:/workspace/models registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.12 + # 上一句话执行后会进入到容器,继续第三句:cd FunASR/runtime + # 不要退出容器,继续在容器中执行第四句:nohup bash run_server_2pass.sh --download-model-dir /workspace/models --vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx --model-dir damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx --online-model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx --punc-dir damo/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx --lm-dir damo/speech_ngram_lm_zh-cn-ai-wesp-fst --itn-dir thuduj12/fst_itn_zh --hotword /workspace/models/hotwords.txt > log.txt 2>&1 & + # 上一句话执行后会进入到容器,继续第五句:tail -f log.txt + # 第五句话执行完后,会看到模型下载日志,下载完后就可以连接使用了 + # 以上是使用CPU推理,如果有GPU,详细参考:https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md + type: fun_server + host: 127.0.0.1 + port: 10096 + is_ssl: true + api_key: none + output_dir: tmp/ + SherpaASR: + # Sherpa-ONNX 本地语音识别(需手动下载模型) + type: sherpa_onnx_local + model_dir: models/sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17 + output_dir: tmp/ + # 模型类型:sense_voice (多语言) 或 paraformer (中文专用) + model_type: sense_voice + SherpaParaformerASR: + # 中文语音识别模型,可以运行在低性能设备(需手动下载模型,例如RK3566-2g) + # 详细配置说明请参考:docs/sherpa-paraformer-guide.md + type: sherpa_onnx_local + model_dir: models/sherpa-onnx-paraformer-zh-small-2024-03-09 + output_dir: tmp/ + model_type: paraformer + DoubaoASR: + # 可以在这里申请相关Key等信息 + # https://console.volcengine.com/speech/app + # DoubaoASR和DoubaoStreamASR的区别是:DoubaoASR是按次收费,DoubaoStreamASR是按时收费 + # 一般来说按次收费的更便宜,但是DoubaoStreamASR使用了大模型技术,效果更好 + type: doubao + appid: 你的火山引擎语音合成服务appid + access_token: 你的火山引擎语音合成服务access_token + cluster: volcengine_input_common + # 热词、替换词使用流程:https://www.volcengine.com/docs/6561/155738 + boosting_table_name: (选填)你的热词文件名称 + correct_table_name: (选填)你的替换词文件名称 + output_dir: tmp/ + DoubaoStreamASR: + # 可以在这里申请相关Key等信息 + # https://console.volcengine.com/speech/app + # DoubaoASR和DoubaoStreamASR的区别是:DoubaoASR是按次收费,DoubaoStreamASR是按时收费 + # 开通地址https://console.volcengine.com/speech/service/10011 + # 一般来说按次收费的更便宜,但是DoubaoStreamASR使用了大模型技术,效果更好 + type: doubao_stream + appid: 你的火山引擎语音合成服务appid + access_token: 你的火山引擎语音合成服务access_token + cluster: volcengine_input_common + # 热词、替换词使用流程:https://www.volcengine.com/docs/6561/155738 + boosting_table_name: (选填)你的热词文件名称 + correct_table_name: (选填)你的替换词文件名称 + output_dir: tmp/ + TencentASR: + # token申请地址:https://console.cloud.tencent.com/cam/capi + # 免费领取资源:https://console.cloud.tencent.com/asr/resourcebundle + type: tencent + appid: 你的腾讯语音合成服务appid + secret_id: 你的腾讯语音合成服务secret_id + secret_key: 你的腾讯语音合成服务secret_key + output_dir: tmp/ + AliyunASR: + # 阿里云智能语音交互服务,需要先在阿里云平台开通服务,然后获取验证信息 + # HTTP POST请求,一次性处理完整音频 + # 平台地址:https://nls-portal.console.aliyun.com/ + # appkey地址:https://nls-portal.console.aliyun.com/applist + # token地址:https://nls-portal.console.aliyun.com/overview + # AliyunASR和AliyunStreamASR的区别是:AliyunASR是批量处理场景,AliyunStreamASR是实时交互场景 + # 一般来说非流式ASR更便宜(0.004元/秒,¥0.24/分钟) + # 但是AliyunStreamASR实时性更好(0.005元/秒,¥0.3/分钟) + # 定义ASR API类型 + type: aliyun + appkey: 你的阿里云智能语音交互服务项目Appkey + token: 你的阿里云智能语音交互服务AccessToken,临时的24小时,要长期用下方的access_key_id,access_key_secret + access_key_id: 你的阿里云账号access_key_id + access_key_secret: 你的阿里云账号access_key_secret + output_dir: tmp/ + AliyunStreamASR: + # 阿里云智能语音交互服务 - 实时流式语音识别 + # WebSocket连接,实时处理音频流 + # 平台地址:https://nls-portal.console.aliyun.com/ + # appkey地址:https://nls-portal.console.aliyun.com/applist + # token地址:https://nls-portal.console.aliyun.com/overview + # AliyunASR和AliyunStreamASR的区别是:AliyunASR是批量处理场景,AliyunStreamASR是实时交互场景 + # 一般来说非流式ASR更便宜(0.004元/秒,¥0.24/分钟) + # 但是AliyunStreamASR实时性更好(0.005元/秒,¥0.3/分钟) + # 定义ASR API类型 + type: aliyun_stream + appkey: 你的阿里云智能语音交互服务项目Appkey + token: 你的阿里云智能语音交互服务AccessToken,临时的24小时,要长期用下方的access_key_id,access_key_secret + access_key_id: 你的阿里云账号access_key_id + access_key_secret: 你的阿里云账号access_key_secret + # 服务器地域选择,可选择距离更近的服务器以减少延迟,如nls-gateway-cn-hangzhou.aliyuncs.com(杭州)等 + host: nls-gateway-cn-shanghai.aliyuncs.com + # 断句检测时间(毫秒),控制静音多长时间后进行断句,默认800毫秒 + max_sentence_silence: 800 + output_dir: tmp/ + BaiduASR: + # 获取AppID、API Key、Secret Key:https://console.bce.baidu.com/ai-engine/old/#/ai/speech/app/list + # 查看资源额度:https://console.bce.baidu.com/ai-engine/old/#/ai/speech/overview/resource/list + type: baidu + app_id: 你的百度语音技术AppID + api_key: 你的百度语音技术APIKey + secret_key: 你的百度语音技术SecretKey + # 语言参数,1537为普通话,具体参考:https://ai.baidu.com/ai-doc/SPEECH/0lbxfnc9b + dev_pid: 1537 + output_dir: tmp/ + OpenaiASR: + # OpenAI语音识别服务,需要先在OpenAI平台创建组织并获取api_key + # 支持中、英、日、韩等多种语音识别,具体参考文档https://platform.openai.com/docs/guides/speech-to-text + # 需要网络连接 + # 申请步骤: + # 1.登录OpenAI Platform。https://auth.openai.com/log-in + # 2.创建api-key https://platform.openai.com/settings/organization/api-keys + # 3.模型可以选择gpt-4o-transcribe或GPT-4o mini Transcribe + type: openai + api_key: 你的OpenAI API密钥 + base_url: https://api.openai.com/v1/audio/transcriptions + model_name: gpt-4o-mini-transcribe + output_dir: tmp/ + GroqASR: + # Groq语音识别服务,需要先在Groq Console创建API密钥 + # 申请步骤: + # 1.登录groq Console。https://console.groq.com/home + # 2.创建api-key https://console.groq.com/keys + # 3.模型可以选择whisper-large-v3-turbo或whisper-large-v3(distil-whisper-large-v3-en仅支持英语转录) + type: openai + api_key: 你的Groq API密钥 + base_url: https://api.groq.com/openai/v1/audio/transcriptions + model_name: whisper-large-v3-turbo + output_dir: tmp/ + VoskASR: + # 官方网站:https://alphacephei.com/vosk/ + # 配置说明: + # 1. VOSK是一个离线语音识别库,支持多种语言 + # 2. 需要先下载模型文件:https://alphacephei.com/vosk/models + # 3. 中文模型推荐使用vosk-model-small-cn-0.22或vosk-model-cn-0.22 + # 4. 完全离线运行,无需网络连接 + # 5. 输出文件保存在tmp/目录 + # 使用步骤: + # 1. 访问 https://alphacephei.com/vosk/models 下载对应的模型 + # 2. 解压模型文件到项目目录下的models/vosk/文件夹 + # 3. 在配置中指定正确的模型路径 + # 4. 注意:VOSK中文模型输出不带标点符号,词与词之间会有空格 + type: vosk + model_path: 你的模型路径,如:models/vosk/vosk-model-small-cn-0.22 + output_dir: tmp/ + Qwen3ASRFlash: + # 通义千问Qwen3-ASR-Flash语音识别服务,需要先在阿里云百炼平台创建API密钥 + # 申请步骤: + # 1.登录阿里云百炼平台。https://bailian.console.aliyun.com/ + # 2.创建API-KEY https://bailian.console.aliyun.com/#/api-key + # 3.Qwen3-ASR-Flash基于通义千问多模态基座,支持多语言识别、歌唱识别、噪声拒识等功能 + type: qwen3_asr_flash + api_key: 你的阿里云百炼API密钥 + base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + model_name: qwen3-asr-flash + output_dir: tmp/ + # ASR选项配置 + enable_lid: true # 自动语种检测 + enable_itn: true # 逆文本归一化 + #language: "zh" # 语种,支持zh、en、ja、ko等 + context: "" # 上下文信息,用于提高识别准确率,不超过10000 Token + XunfeiStreamASR: + # 讯飞流式语音识别服务 + # 需要先在讯飞开放平台创建应用,获取以下认证信息 + # 讯飞开放平台地址:https://www.xfyun.cn/ + # 创建应用后,在"我的应用"中获取: + # - APPID + # - APISecret + # - APIKey + type: xunfei_stream + # 必填参数 - 讯飞开放平台应用信息 + app_id: 你的APPID + api_key: 你的APIKey + api_secret: 你的APISecret + # 识别参数配置 + domain: slm # 识别领域,iat:日常用语,medical:医疗,finance:金融等 + language: zh_cn # 语言,zh_cn:中文,en_us:英文 + accent: mandarin # 方言,mandarin:普通话 + dwa: wpgs # 动态修正,wpgs:实时返回中间结果 + # 调整音频处理参数以提高长语音识别质量 + output_dir: tmp/ + +VAD: + SileroVAD: + type: silero + threshold: 0.5 + threshold_low: 0.3 + model_dir: models/snakers4_silero-vad + min_silence_duration_ms: 200 # 如果说话停顿比较长,可以把这个值设置大一些 + +LLM: + # 所有openai类型均可以修改超参,以AliLLM为例 + # 当前支持的type为openai、dify、ollama,可自行适配 + AliLLM: + # 定义LLM API类型 + type: openai + # 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key + base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + model_name: qwen-turbo + api_key: 你的deepseek web key + temperature: 0.7 # 温度值 + max_tokens: 500 # 最大生成token数 + top_p: 1 + top_k: 50 + frequency_penalty: 0 # 频率惩罚 + AliAppLLM: + # 定义LLM API类型 + type: AliBL + base_url: https://dashscope.aliyuncs.com/compatible-mode/v1 + app_id: 你的app_id + # 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key + api_key: 你的api_key + # 是否不使用本地prompt:true|false (默不用请在百练应用中设置prompt) + is_no_prompt: true + # Ali_memory_id:false(不使用)|你的memory_id(请在百练应用中设置中获取) + # Tips!:Ali_memory未实现多用户存储记忆(记忆按id调用) + ali_memory_id: false + DoubaoLLM: + # 定义LLM API类型 + type: openai + # 先开通服务,打开以下网址,开通的服务搜索Doubao-1.5-pro,开通它 + # 开通地址:https://console.volcengine.com/ark/region:ark+cn-beijing/openManagement?LLM=%7B%7D&OpenTokenDrawer=false + # 免费额度500000token + # 开通后,进入这里获取密钥:https://console.volcengine.com/ark/region:ark+cn-beijing/apiKey?apikey=%7B%7D + base_url: https://ark.cn-beijing.volces.com/api/v3 + model_name: doubao-1-5-pro-32k-250115 + api_key: 你的doubao web key + DeepSeekLLM: + # 定义LLM API类型 + type: openai + # 可在这里找到你的api key https://platform.deepseek.com/ + model_name: deepseek-chat + url: https://api.deepseek.com + api_key: 你的deepseek web key + ChatGLMLLM: + # 定义LLM API类型 + type: openai + # glm-4-flash 是免费的,但是还是需要注册填写api_key的 + # 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys + model_name: glm-4-flash + url: https://open.bigmodel.cn/api/paas/v4/ + api_key: 你的chat-glm web key + OllamaLLM: + # 定义LLM API类型 + type: ollama + model_name: qwen2.5 # 使用的模型名称,需要预先使用ollama pull下载 + base_url: http://localhost:11434 # Ollama服务地址 + DifyLLM: + # 定义LLM API类型 + type: dify + # 建议使用本地部署的dify接口,国内部分区域访问dify公有云接口可能会受限 + # 如果使用DifyLLM,配置文件里prompt(提示词)是无效的,需要在dify控制台设置提示词 + base_url: https://api.dify.ai/v1 + api_key: 你的DifyLLM web key + # 使用的对话模式 可以选择工作流 workflows/run 对话模式 chat-messages 文本生成 completion-messages + # 使用workflows进行返回的时候输入参数为 query 返回参数的名字要设置为 answer + # 文本生成的默认输入参数也是query + mode: chat-messages + GeminiLLM: + type: gemini + # 谷歌Gemini API,需要先在Google Cloud控制台创建API密钥并获取api_key + # 若在中国境内使用,请遵守《生成式人工智能服务管理暂行办法》 + # token申请地址: https://aistudio.google.com/apikey + # 若部署地无法访问接口,需要开启科学上网 + api_key: 你的gemini web key + model_name: "gemini-2.0-flash" + http_proxy: "" #"http://127.0.0.1:10808" + https_proxy: "" #http://127.0.0.1:10808" + CozeLLM: + # 定义LLM API类型 + type: coze + # 你可以在这里找到个人令牌 + # https://www.coze.cn/open/oauth/pats + # bot_id和user_id的内容写在引号之内 + bot_id: "你的bot_id" + user_id: "你的user_id" + personal_access_token: 你的coze个人令牌 + VolcesAiGatewayLLM: + # 火山引擎 - 边缘大模型网关 + # 定义LLM API类型 + type: openai + # 先开通服务,打开以下网址,创建网关访问密钥,搜索并勾选 Doubao-pro-32k-functioncall ,开通 + # 如果需要使用边缘大模型网关提供的语音合成,一并勾选 Doubao-语音合成 ,另见 TTS.VolcesAiGatewayTTS 配置 + # https://console.volcengine.com/vei/aigateway/ + # 开通后,进入这里获取密钥:https://console.volcengine.com/vei/aigateway/tokens-list + base_url: https://ai-gateway.vei.volces.com/v1 + model_name: doubao-pro-32k-functioncall + api_key: 你的网关访问密钥 + LMStudioLLM: + # 定义LLM API类型 + type: openai + model_name: deepseek-r1-distill-llama-8b@q4_k_m # 使用的模型名称,需要预先在社区下载 + url: http://localhost:1234/v1 # LM Studio服务地址 + api_key: lm-studio # LM Studio服务的固定API Key + HomeAssistant: + # 定义LLM API类型 + type: homeassistant + base_url: http://homeassistant.local:8123 + agent_id: conversation.chatgpt + api_key: 你的home assistant api访问令牌 + FastgptLLM: + # 定义LLM API类型 + type: fastgpt + # 如果使用fastgpt,配置文件里prompt(提示词)是无效的,需要在fastgpt控制台设置提示词 + base_url: https://host/api/v1 + # 你可以在这里找到你的api_key + # https://cloud.tryfastgpt.ai/account/apikey + api_key: 你的fastgpt密钥 + variables: + k: "v" + k2: "v2" + XinferenceLLM: + # 定义LLM API类型 + type: xinference + # Xinference服务地址和模型名称 + model_name: qwen2.5:72b-AWQ # 使用的模型名称,需要预先在Xinference启动对应模型 + base_url: http://localhost:9997 # Xinference服务地址 + XinferenceSmallLLM: + # 定义轻量级LLM API类型,用于意图识别 + type: xinference + # Xinference服务地址和模型名称 + model_name: qwen2.5:3b-AWQ # 使用的小模型名称,用于意图识别 + base_url: http://localhost:9997 # Xinference服务地址 +# VLLM配置(视觉语言大模型) +VLLM: + ChatGLMVLLM: + type: openai + # glm-4v-flash是智谱免费AI的视觉模型,需要先在智谱AI平台创建API密钥并获取api_key + # 可在这里找到你的api key https://bigmodel.cn/usercenter/proj-mgmt/apikeys + model_name: glm-4v-flash # 智谱AI的视觉模型 + url: https://open.bigmodel.cn/api/paas/v4/ + api_key: 你的api_key + QwenVLVLLM: + type: openai + model_name: qwen2.5-vl-3b-instruct + url: https://dashscope.aliyuncs.com/compatible-mode/v1 + # 可在这里找到你的api key https://bailian.console.aliyun.com/?apiKey=1#/api-key + api_key: 你的api_key + XunfeiSparkLLM: + # 定义LLM API类型 + type: openai + # 先新建应用,在下面的地址 + # 开通应用地址:https://console.xfyun.cn/app/myapp + # 有免费额度,但也要开通服务,才能获取api_key + # 每一个模型都需要单独开通,每一个模型的api_password都不同,例如Lite模型在https://console.xfyun.cn/services/cbm 开通 + base_url: https://ark.cn-beijing.volces.com/api/v3 + model_name: lite + api_key: 你的api_password +TTS: + # 当前支持的type为edge、doubao,可自行适配 + EdgeTTS: + # 定义TTS API类型 + type: edge + voice: zh-CN-XiaoxiaoNeural + output_dir: tmp/ + # ============== SDK 版本TTS(推荐)============== + # 使用官方SDK,代码更简洁、性能更好、维护成本更低 + CartesiaSDK: + # Cartesia TTS - SDK版本(推荐) + # 官方SDK实现,低延迟,支持流式合成 + # API Key获取地址:https://play.cartesia.ai/console + # 或设置环境变量:export CARTESIA_API_KEY=your-api-key + type: cartesia_sdk + api_key: 你的Cartesia API密钥 + # Voice ID或voice embedding + voice_id: 你的语音ID + # 模型选择:sonic-english, sonic-multilingual等 + model: sonic-english + # 语言代码:en, zh, es等 + language: en + # 音频编码:pcm_s16le, pcm_f32le, pcm_mulaw等 + encoding: pcm_s16le + # 采样率:8000, 16000, 22050, 24000, 44100等 + sample_rate: 24000 + output_dir: tmp/ + ElevenLabsSDK: + # ElevenLabs TTS - SDK版本(推荐) + # 官方SDK实现,代码更简洁,维护成本更低,性能更好 + # API Key获取地址:https://elevenlabs.io/app/settings/api-keys + # 或设置环境变量:export ELEVEN_API_KEY=your-api-key + type: elevenlabs_sdk + api_key: 你的ElevenLabs API密钥 + # Voice ID获取:https://elevenlabs.io/app/voice-library + # 默认:21m00Tcm4TlvDq8ikWAM (Rachel) + voice_id: 21m00Tcm4TlvDq8ikWAM + # 模型选择:eleven_multilingual_v2, eleven_turbo_v2_5等 + model: eleven_multilingual_v2 + # 音频输出格式:pcm_16000, pcm_22050, pcm_24000, mp3_44100等 + output_format: pcm_16000 + # 语音稳定性:0-1,越高越稳定 + stability: 0.5 + # 相似度增强:0-1,越高越接近原音色 + similarity_boost: 0.75 + # 风格夸张:0-1 + style: 0.0 + # 启用说话人增强 + use_speaker_boost: true + output_dir: tmp/ + DoubaoTTS: + # 定义TTS API类型 + type: doubao + # 火山引擎语音合成服务,需要先在火山引擎控制台创建应用并获取appid和access_token + # 山引擎语音一定要购买花钱,起步价30元,就有100并发了。如果用免费的只有2个并发,会经常报tts错误 + # 购买服务后,购买免费的音色后,可能要等半小时左右,才能使用。 + # 普通音色在这里开通:https://console.volcengine.com/speech/service/8 + # 湾湾小何音色在这里开通:https://console.volcengine.com/speech/service/10007,开通后将下面的voice设置成zh_female_wanwanxiaohe_moon_bigtts + api_url: https://openspeech.bytedance.com/api/v1/tts + voice: BV001_streaming + output_dir: tmp/ + authorization: "Bearer;" + appid: 你的火山引擎语音合成服务appid + access_token: 你的火山引擎语音合成服务access_token + cluster: volcano_tts + speed_ratio: 1.0 + volume_ratio: 1.0 + pitch_ratio: 1.0 + #火山tts,支持双向流式tts + HuoshanDoubleStreamTTS: + type: huoshan_double_stream + # 访问 https://console.volcengine.com/speech/service/10007 开通语音合成大模型,购买音色 + # 在页面底部获取appid和access_token + # 资源ID固定为:volc.service_type.10029(大模型语音合成及混音) + # 如果是机智云,把接口地址换成wss://bytedance.gizwitsapi.com/api/v3/tts/bidirection + # 机智云不需要天填 appid + ws_url: wss://openspeech.bytedance.com/api/v3/tts/bidirection + appid: 你的火山引擎语音合成服务appid + access_token: 你的火山引擎语音合成服务access_token + resource_id: volc.service_type.10029 + speaker: zh_female_wanwanxiaohe_moon_bigtts + speech_rate: 0 + loudness_rate: 0 + pitch: 0 + CosyVoiceSiliconflow: + type: siliconflow + # 硅基流动TTS + # token申请地址 https://cloud.siliconflow.cn/account/ak + model: FunAudioLLM/CosyVoice2-0.5B + voice: FunAudioLLM/CosyVoice2-0.5B:alex + output_dir: tmp/ + access_token: 你的硅基流动API密钥 + response_format: wav + CozeCnTTS: + type: cozecn + # COZECN TTS + # token申请地址 https://www.coze.cn/open/oauth/pats + voice: 7426720361733046281 + output_dir: tmp/ + access_token: 你的coze web key + response_format: wav + VolcesAiGatewayTTS: + type: openai + # 火山引擎 - 边缘大模型网关 + # 先开通服务,打开以下网址,创建网关访问密钥,搜索并勾选 Doubao-语音合成 ,开通 + # 如果需要使用边缘大模型网关提供的 LLM,一并勾选 Doubao-pro-32k-functioncall ,另见 LLM.VolcesAiGatewayLLM 配置 + # https://console.volcengine.com/vei/aigateway/ + # 开通后,进入这里获取密钥:https://console.volcengine.com/vei/aigateway/tokens-list + api_key: 你的网关访问密钥 + api_url: https://ai-gateway.vei.volces.com/v1/audio/speech + model: doubao-tts + # 音色列表见 https://www.volcengine.com/docs/6561/1257544 + voice: zh_male_shaonianzixin_moon_bigtts + speed: 1 + output_dir: tmp/ + FishSpeech: + # 参照教程:https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/fish-speech-integration.md + type: fishspeech + output_dir: tmp/ + response_format: wav + reference_id: null + reference_audio: ["config/assets/wakeup_words.wav",] + reference_text: ["哈啰啊,我是小智啦,声音好听的台湾女孩一枚,超开心认识你耶,最近在忙啥,别忘了给我来点有趣的料哦,我超爱听八卦的啦",] + normalize: true + max_new_tokens: 1024 + chunk_length: 200 + top_p: 0.7 + repetition_penalty: 1.2 + temperature: 0.7 + streaming: false + use_memory_cache: "on" + seed: null + channels: 1 + rate: 44100 + api_key: "你的api_key" + api_url: "http://127.0.0.1:8080/v1/tts" + GPT_SOVITS_V2: + # 定义TTS API类型 + #启动tts方法: + #python api_v2.py -a 127.0.0.1 -p 9880 -c GPT_SoVITS/configs/demo.yaml + type: gpt_sovits_v2 + url: "http://127.0.0.1:9880/tts" + output_dir: tmp/ + text_lang: "auto" + ref_audio_path: "demo.wav" + prompt_text: "" + prompt_lang: "zh" + top_k: 5 + top_p: 1 + temperature: 1 + text_split_method: "cut0" + batch_size: 1 + batch_threshold: 0.75 + split_bucket: true + return_fragment: false + speed_factor: 1.0 + streaming_mode: false + seed: -1 + parallel_infer: true + repetition_penalty: 1.35 + aux_ref_audio_paths: [] + GPT_SOVITS_V3: + # 定义TTS API类型 GPT-SoVITS-v3lora-20250228 + #启动tts方法: + #python api.py + type: gpt_sovits_v3 + url: "http://127.0.0.1:9880" + output_dir: tmp/ + text_language: "auto" + refer_wav_path: "caixukun.wav" + prompt_language: "zh" + prompt_text: "" + top_k: 15 + top_p: 1.0 + temperature: 1.0 + cut_punc: "" + speed: 1.0 + inp_refs: [] + sample_steps: 32 + if_sr: false + MinimaxTTSHTTPStream: + # Minimax流式语音合成服务 + type: minimax_httpstream + output_dir: tmp/ + group_id: 你的minimax平台groupID + api_key: 你的minimax平台接口密钥 + model: "speech-01-turbo" + voice_id: "female-shaonv" + # 以下可不用设置,使用默认设置 + # voice_setting: + # voice_id: "male-qn-qingse" + # speed: 1 + # vol: 1 + # pitch: 0 + # emotion: "happy" + # pronunciation_dict: + # tone: + # - "处理/(chu3)(li3)" + # - "危险/dangerous" + # audio_setting: + # sample_rate: 24000 + # bitrate: 128000 + # format: "mp3" + # channel: 1 + # timber_weights: + # - + # voice_id: male-qn-qingse + # weight: 1 + # - + # voice_id: female-shaonv + # weight: 1 + # language_boost: auto + AliyunTTS: + # 阿里云智能语音交互服务,需要先在阿里云平台开通服务,然后获取验证信息 + # 平台地址:https://nls-portal.console.aliyun.com/ + # appkey地址:https://nls-portal.console.aliyun.com/applist + # token地址:https://nls-portal.console.aliyun.com/overview + # 定义TTS API类型 + type: aliyun + output_dir: tmp/ + appkey: 你的阿里云智能语音交互服务项目Appkey + token: 你的阿里云智能语音交互服务AccessToken,临时的24小时,要长期用下方的access_key_id,access_key_secret + voice: xiaoyun + access_key_id: 你的阿里云账号access_key_id + access_key_secret: 你的阿里云账号access_key_secret + + # 以下可不用设置,使用默认设置 + # format: wav + # sample_rate: 16000 + # volume: 50 + # speech_rate: 0 + # pitch_rate: 0 + AliyunStreamTTS: + # 阿里云CosyVoice大模型流式文本语音合成 + # 采用FlowingSpeechSynthesizer接口,支持更低延迟和更自然的语音质量 + # 流式文本语音合成仅提供商用版,不支持试用,详情请参见试用版和商用版。要使用该功能,请开通商用版。 + # 支持龙系列专用音色:longxiaochun、longyu、longchen等 + # 平台地址:https://nls-portal.console.aliyun.com/ + # appkey地址:https://nls-portal.console.aliyun.com/applist + # token地址:https://nls-portal.console.aliyun.com/overview + # 使用三阶段流式交互:StartSynthesis -> RunSynthesis -> StopSynthesis + type: aliyun_stream + output_dir: tmp/ + appkey: 你的阿里云智能语音交互服务项目Appkey + token: 你的阿里云智能语音交互服务AccessToken,临时的24小时,要长期用下方的access_key_id,access_key_secret + voice: longxiaochun + access_key_id: 你的阿里云账号access_key_id + access_key_secret: 你的阿里云账号access_key_secret + # 截至2025年7月21日大模型音色只有北京节点采用,其他节点暂不支持 + host: nls-gateway-cn-beijing.aliyuncs.com + # 以下可不用设置,使用默认设置 + # format: pcm # 音频格式:pcm、wav、mp3 + # sample_rate: 16000 # 采样率:8000、16000、24000 + # volume: 50 # 音量:0-100 + # speech_rate: 0 # 语速:-500到500 + # pitch_rate: 0 # 语调:-500到500 + TencentTTS: + # 腾讯云智能语音交互服务,需要先在腾讯云平台开通服务 + # appid、secret_id、secret_key申请地址:https://console.cloud.tencent.com/cam/capi + # 免费领取资源:https://console.cloud.tencent.com/tts/resourcebundle + type: tencent + output_dir: tmp/ + appid: 你的腾讯云AppId + secret_id: 你的腾讯云SecretID + secret_key: 你的腾讯云SecretKey + region: ap-guangzhou + voice: 101001 + + TTS302AI: + # 302AI语音合成服务,需要先在302平台创建账户充值,并获取密钥信息 + # 添加 302.ai TTS 配置 + # token申请地址:https://dash.302.ai/ + # 获取api_keyn路径:https://dash.302.ai/apis/list + # 价格,$35/百万字符。火山原版¥450元/百万字符 + type: doubao + api_url: https://api.302ai.cn/doubao/tts_hd + authorization: "Bearer " + # 湾湾小何音色 + voice: "zh_female_wanwanxiaohe_moon_bigtts" + output_dir: tmp/ + access_token: "你的302API密钥" + GizwitsTTS: + type: doubao + # 火山引擎作为基座,可以完全使用企业级火山引擎语音合成服务 + # 前一万名注册的用户,将送5元体验金额 + # 获取API Key地址:https://agentrouter.gizwitsapi.com/panel/token + api_url: https://bytedance.gizwitsapi.com/api/v1/tts + authorization: "Bearer " + # 湾湾小何音色 + voice: "zh_female_wanwanxiaohe_moon_bigtts" + output_dir: tmp/ + access_token: "你的机智云API key" + ACGNTTS: + #在线网址:https://acgn.ttson.cn/ + #token购买:www.ttson.cn + #开发相关疑问请提交至网站上的qq + #角色id获取地址:ctrl+f快速检索角色——网站管理者不允许发布,可询问网站管理者 + #各参数意义见开发文档:https://www.yuque.com/alexuh/skmti9/wm6taqislegb02gd?singleDoc# + type: ttson + token: your_token + voice_id: 1695 + speed_factor: 1 + pitch_factor: 0 + volume_change_dB: 0 + to_lang: ZH + url: https://u95167-bd74-2aef8085.westx.seetacloud.com:8443/flashsummary/tts?token= + format: mp3 + output_dir: tmp/ + emotion: 1 + OpenAITTS: + # openai官方文本转语音服务,可支持全球大多数语种 + type: openai + # 你可以在这里获取到 api key + # https://platform.openai.com/api-keys + api_key: 你的openai api key + # 国内需要使用代理 + api_url: https://api.openai.com/v1/audio/speech + # 可选tts-1或tts-1-hd,tts-1速度更快tts-1-hd质量更好 + model: tts-1 + # 演讲者,可选alloy, echo, fable, onyx, nova, shimmer + voice: onyx + # 语速范围0.25-4.0 + speed: 1 + output_dir: tmp/ + CustomTTS: + # 自定义的TTS接口服务,请求参数可自定义,可接入众多TTS服务 + # 以本地部署的KokoroTTS为例 + # 如果只有cpu运行:docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest + # 如果只有gpu运行:docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest + # 要求接口使用POST方式请求,并返回音频文件 + type: custom + method: POST + url: "http://127.0.0.1:8880/v1/audio/speech" + params: # 自定义请求参数 + input: "{prompt_text}" + response_format: "mp3" + download_format: "mp3" + voice: "zf_xiaoxiao" + lang_code: "z" + return_download_link: true + speed: 1 + stream: false + headers: # 自定义请求头 + # Authorization: Bearer xxxx + format: mp3 # 接口返回的音频格式 + output_dir: tmp/ + LinkeraiTTS: + type: linkerai + api_url: https://tts.linkerai.cn/tts + audio_format: "pcm" + # 默认的access_token供大家测试时免费使用的,此access_token请勿用于商业用途 + # 如果效果不错,可自行申请token,申请地址:https://linkerai.cn + # 各参数意义见开发文档:https://tts.linkerai.cn/docs + # 支持声音克隆,可自行上传音频,填入voice参数,voice参数为空时,使用默认声音 + access_token: "U4YdYXVfpwWnk2t5Gp822zWPCuORyeJL" + voice: "OUeAo1mhq6IBExi" + output_dir: tmp/ + PaddleSpeechTTS: + #百度飞浆 PaddleSpeech 支持本地离线部署 支持模型训练 + #框架地址 https://www.paddlepaddle.org.cn/ + #项目地址 https://github.com/PaddlePaddle/PaddleSpeech + #SpeechServerDemo https://github.com/PaddlePaddle/PaddleSpeech/tree/develop/demos/speech_server + #流式传输请参考 https://github.com/PaddlePaddle/PaddleSpeech/wiki/PaddleSpeech-Server-WebSocket-API + type: paddle_speech + protocol: websocket # protocol choices = ['websocket', 'http'] + url: ws://127.0.0.1:8092/paddlespeech/tts/streaming # TTS 服务的 URL 地址,指向本地服务器 [websocket默认ws://127.0.0.1:8092/paddlespeech/tts/streaming,http默认http://127.0.0.1:8090/paddlespeech/tts] + spk_id: 0 # 发音人 ID,0 通常表示默认的发音人 + sample_rate: 24000 # 采样率 [websocket默认24000,http默认0 自动选择] + speed: 1.0 # 语速,1.0 表示正常语速,>1 表示加快,<1 表示减慢 + volume: 1.0 # 音量,1.0 表示正常音量,>1 表示增大,<1 表示减小 + save_path: # 保存路径 + IndexStreamTTS: + # 基于Index-TTS-vLLM项目的TTS接口服务 + # 参照教程:https://github.com/Ksuriuri/index-tts-vllm/blob/master/README.md + type: index_stream + api_url: http://127.0.0.1:11996/tts + audio_format: "pcm" + # 默认音色,如需其他音色可到项目assets文件夹下注册 + voice: "jay_klee" + output_dir: tmp/ + AliBLTTS: + # 阿里百炼CosyVoice大模型流式文本语音合成 + # 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key + # cosyvoice-v3和部分音色需要申请开通 + type: alibl_stream + api_key: 你的api_key + model: "cosyvoice-v2" + voice: "longcheng_v2" + output_dir: tmp/ + # 以下可不用设置,使用默认设置 + # format: pcm # 音频格式:pcm、wav、mp3、opus + # sample_rate: 24000 # 采样率:16000, 24000, 48000 + # volume: 50 # 音量:0-100 + # rate: 1 # 语速:0.5~2 + # pitch: 1 # 语调:0.5~2 + XunFeiTTS: + # 讯飞TTS服务 官方网站:https://www.xfyun.cn/ + # 登录讯飞语音技术平台 https://console.xfyun.cn/app/myapp 创建相关应用 + # 选择需要的服务获取api相关配置 https://console.xfyun.cn/services/uts + # 为需要使用的应用(APPID)购买相关服务 例如:超拟人合成 https://console.xfyun.cn/services/uts + type: xunfei_stream + api_url: wss://cbm01.cn-huabei-1.xf-yun.com/v1/private/mcd9m97e6 + app_id: 你的app_id + api_secret: 你的api_secret + api_key: 你的api_key + voice: x5_lingxiaoxuan_flow + output_dir: tmp/ + # 以下可不用设置,使用默认设置,注意V5音色不支持口语化配置 + # oral_level: mid # 口语化等级:high, mid, low + # spark_assist: 1 # 是否通过大模型进行口语化 开启:1, 关闭:0 + # stop_split: 0 # 关闭服务端拆句 不关闭:0,关闭:1 + # remain: 0 # 是否保留原书面语的样子 保留:1, 不保留:0 + # format: raw # 音频格式:raw(PCM), lame(MP3), speex, opus, opus-wb, opus-swb, speex-wb + # sample_rate: 24000 # 采样率:16000, 8000, 24000 + # volume: 50 # 音量:0-100 + # speed: 50 # 语速:0-100 + # pitch: 50 # 语调:0-100 diff --git a/main/xiaozhi-server/docker-compose_local_all.yml b/main/xiaozhi-server/docker-compose_local_all.yml new file mode 100644 index 000000000..82380db16 --- /dev/null +++ b/main/xiaozhi-server/docker-compose_local_all.yml @@ -0,0 +1,178 @@ +# Docker Compose configuration for local development +# This file uses locally built images instead of pulling from remote registry + +services: + # ============================================================================ + # xiaozhi-server (Python WebSocket Server) + # ============================================================================ + xiaozhi-esp32-server: + build: + context: . + dockerfile: Dockerfile + image: xiaozhi-esp32-server:local + container_name: xiaozhi-esp32-server + depends_on: + xiaozhi-esp32-server-db: + condition: service_healthy + xiaozhi-esp32-server-redis: + condition: service_healthy + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # WebSocket server + - "8000:8000" + # HTTP server for vision analysis and OTA + - "8003:8003" + security_opt: + - seccomp:unconfined + environment: + - TZ=Asia/Shanghai + - PYTHONUNBUFFERED=1 + - LOG_LEVEL=INFO + volumes: + # Configuration directory + - ./data:/opt/xiaozhi-esp32-server/data + # Custom config (optional override, uncomment if you need to customize) + - ./custom_config.yaml:/opt/xiaozhi-esp32-server/custom_config.yaml + # Model files (important!) + - ./models/SenseVoiceSmall:/opt/xiaozhi-esp32-server/models/SenseVoiceSmall + - ./models/snakers4_silero-vad:/opt/xiaozhi-esp32-server/models/snakers4_silero-vad + # Temporary files + - ./tmp:/opt/xiaozhi-esp32-server/tmp + # Music files (optional) + - ./music:/opt/xiaozhi-esp32-server/music + # Logs (optional, for debugging) + - ./logs:/opt/xiaozhi-esp32-server/logs + + # ============================================================================ + # manager-web (Management Console + API) + # ============================================================================ + xiaozhi-esp32-server-web: + # Build from local source (supports ARM64/Apple Silicon) + build: + context: ../../ + dockerfile: Dockerfile-web + image: xiaozhi-esp32-server-web:local + + # Option: Use pre-built image from registry (x86 only) + # image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest + # platform: linux/amd64 # Uncomment to force x86 emulation on ARM64 + + container_name: xiaozhi-esp32-server-web + restart: unless-stopped + networks: + - xiaozhi-network + depends_on: + xiaozhi-esp32-server-db: + condition: service_healthy + xiaozhi-esp32-server-redis: + condition: service_healthy + ports: + # Management console and API + - "8002:8002" + environment: + - TZ=Asia/Shanghai + - SPRING_PROFILES_ACTIVE=dev + # Database connection + - SPRING_DATASOURCE_DRUID_URL=jdbc:mysql://xiaozhi-esp32-server-db:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&connectTimeout=30000&socketTimeout=30000&autoReconnect=true&failOverReadOnly=false&maxReconnects=10 + - SPRING_DATASOURCE_DRUID_USERNAME=root + - SPRING_DATASOURCE_DRUID_PASSWORD=123456 + # Redis connection + - SPRING_DATA_REDIS_HOST=xiaozhi-esp32-server-redis + - SPRING_DATA_REDIS_PORT=6379 + - SPRING_DATA_REDIS_PASSWORD= + volumes: + # Upload files directory + - ./uploadfile:/uploadfile + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + + # ============================================================================ + # MySQL Database + # ============================================================================ + xiaozhi-esp32-server-db: + image: mysql:8.0 + container_name: xiaozhi-esp32-server-db + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # Expose MySQL port for local debugging (optional) + - "3307:3306" + volumes: + # Persistent database storage + - ./mysql/data:/var/lib/mysql + # MySQL configuration (optional) + # - ./mysql/conf:/etc/mysql/conf.d + environment: + - TZ=Asia/Shanghai + - MYSQL_ROOT_PASSWORD=123456 + - MYSQL_DATABASE=xiaozhi_esp32_server + - MYSQL_INITDB_ARGS=--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --default-authentication-plugin=mysql_native_password + - --max_connections=1000 + - --max_allowed_packet=256M + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456"] + timeout: 45s + interval: 10s + retries: 10 + start_period: 60s + + # ============================================================================ + # Redis Cache + # ============================================================================ + xiaozhi-esp32-server-redis: + image: redis:7-alpine + container_name: xiaozhi-esp32-server-redis + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # Expose Redis port for local debugging (optional) + - "6380:6379" + volumes: + # Persistent Redis data (optional) + - ./redis/data:/data + environment: + - TZ=Asia/Shanghai + command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru + logging: + driver: "json-file" + options: + max-size: "5m" + max-file: "3" + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 10s + +# ============================================================================ +# Networks +# ============================================================================ +networks: + xiaozhi-network: + driver: bridge + name: xiaozhi-local-network + +# ============================================================================ +# Volumes (optional - for named volumes instead of bind mounts) +# ============================================================================ +# volumes: +# mysql-data: +# redis-data: + From e3ac2fad6b1626ed15e2d86232a9488833f9589b Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 16:56:28 +0800 Subject: [PATCH 12/31] feat: gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6cc16b409..b6eae4a81 100644 --- a/.gitignore +++ b/.gitignore @@ -171,6 +171,7 @@ main/manager-api/.vscode # Ignore webpack cache directory main/manager-web/.webpack_cache/ main/xiaozhi-server/mysql +main/xiaozhi-server/redis uploadfile *.json .vscode From be82182d1a3450d94e5bbf30b34a3be78071f74a Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 17:13:27 +0800 Subject: [PATCH 13/31] feat: config --- .../config/manage_api_client.py | 9 + main/xiaozhi-server/custom_config.yaml | 5 +- .../docker-compose_local_all.yml | 1 + main/xiaozhi-server/docker_compose_sg_all.yml | 179 ++++++++++++++++++ main/xiaozhi-server/docker_compose_us_all.yml | 179 ++++++++++++++++++ 5 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 main/xiaozhi-server/docker_compose_sg_all.yml create mode 100644 main/xiaozhi-server/docker_compose_us_all.yml diff --git a/main/xiaozhi-server/config/manage_api_client.py b/main/xiaozhi-server/config/manage_api_client.py index cd3f86c42..ee4ba8907 100644 --- a/main/xiaozhi-server/config/manage_api_client.py +++ b/main/xiaozhi-server/config/manage_api_client.py @@ -44,6 +44,15 @@ class ManageApiClient: if "你" in cls.config.get("secret"): raise Exception("请先配置manager-api的secret") + # 根据aws服务器所在机房路由不同secret + region = os.getenv("REGION") + if region == "LOCAL": + cls._secret = cls.config.get("secret") + elif region == "SINGAPORE": + cls._secret = "a1c50356-4307-4bb7-8c16-c661d06ec17b" + elif region == "US-WEST-2": + cls._secret = "ff22d758-79dd-47ff-a897-c6e39983e0e1" + cls._secret = cls.config.get("secret") cls.max_retries = cls.config.get("max_retries", 6) # 最大重试次数 cls.retry_delay = cls.config.get("retry_delay", 10) # 初始重试延迟(秒) diff --git a/main/xiaozhi-server/custom_config.yaml b/main/xiaozhi-server/custom_config.yaml index d79ff0a77..a49111d41 100644 --- a/main/xiaozhi-server/custom_config.yaml +++ b/main/xiaozhi-server/custom_config.yaml @@ -37,7 +37,8 @@ server: manager-api: url: http://xiaozhi-esp32-server-web:8002/xiaozhi - secret: 613be043-dc7e-4f5e-b775-e318e5bc87a3 + # This secret is used for local development, it will be replaced by the actual secret when the server is deployed + secret: 613be043-dc7e-4f5e-b775-e318e5bc87a3 log: # 设置控制台输出的日志格式,时间、日志级别、标签、消息 @@ -203,7 +204,7 @@ end_prompt: # 结束语 prompt: | 请你以"时间过得真快"未来头,用富有感情、依依不舍的话来结束这场对话吧! - + # 意图识别,是用于理解用户意图的模块,例如:播放音乐 Intent: # 不使用意图识别 diff --git a/main/xiaozhi-server/docker-compose_local_all.yml b/main/xiaozhi-server/docker-compose_local_all.yml index 82380db16..124f8c759 100644 --- a/main/xiaozhi-server/docker-compose_local_all.yml +++ b/main/xiaozhi-server/docker-compose_local_all.yml @@ -30,6 +30,7 @@ services: - TZ=Asia/Shanghai - PYTHONUNBUFFERED=1 - LOG_LEVEL=INFO + - REGION=LOCAL volumes: # Configuration directory - ./data:/opt/xiaozhi-esp32-server/data diff --git a/main/xiaozhi-server/docker_compose_sg_all.yml b/main/xiaozhi-server/docker_compose_sg_all.yml new file mode 100644 index 000000000..743f170c9 --- /dev/null +++ b/main/xiaozhi-server/docker_compose_sg_all.yml @@ -0,0 +1,179 @@ +# Docker Compose configuration for local development +# This file uses locally built images instead of pulling from remote registry + +services: + # ============================================================================ + # xiaozhi-server (Python WebSocket Server) + # ============================================================================ + xiaozhi-esp32-server: + build: + context: . + dockerfile: Dockerfile + image: xiaozhi-esp32-server:local + container_name: xiaozhi-esp32-server + depends_on: + xiaozhi-esp32-server-db: + condition: service_healthy + xiaozhi-esp32-server-redis: + condition: service_healthy + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # WebSocket server + - "8000:8000" + # HTTP server for vision analysis and OTA + - "8003:8003" + security_opt: + - seccomp:unconfined + environment: + - TZ=Asia/Shanghai + - PYTHONUNBUFFERED=1 + - LOG_LEVEL=INFO + - REGION=SINGAPORE + volumes: + # Configuration directory + - ./data:/opt/xiaozhi-esp32-server/data + # Custom config (optional override, uncomment if you need to customize) + - ./custom_config.yaml:/opt/xiaozhi-esp32-server/custom_config.yaml + # Model files (important!) + - ./models/SenseVoiceSmall:/opt/xiaozhi-esp32-server/models/SenseVoiceSmall + - ./models/snakers4_silero-vad:/opt/xiaozhi-esp32-server/models/snakers4_silero-vad + # Temporary files + - ./tmp:/opt/xiaozhi-esp32-server/tmp + # Music files (optional) + - ./music:/opt/xiaozhi-esp32-server/music + # Logs (optional, for debugging) + - ./logs:/opt/xiaozhi-esp32-server/logs + + # ============================================================================ + # manager-web (Management Console + API) + # ============================================================================ + xiaozhi-esp32-server-web: + # Build from local source (supports ARM64/Apple Silicon) + build: + context: ../../ + dockerfile: Dockerfile-web + image: xiaozhi-esp32-server-web:local + + # Option: Use pre-built image from registry (x86 only) + # image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest + # platform: linux/amd64 # Uncomment to force x86 emulation on ARM64 + + container_name: xiaozhi-esp32-server-web + restart: unless-stopped + networks: + - xiaozhi-network + depends_on: + xiaozhi-esp32-server-db: + condition: service_healthy + xiaozhi-esp32-server-redis: + condition: service_healthy + ports: + # Management console and API + - "8002:8002" + environment: + - TZ=Asia/Shanghai + - SPRING_PROFILES_ACTIVE=dev + # Database connection + - SPRING_DATASOURCE_DRUID_URL=jdbc:mysql://xiaozhi-esp32-server-db:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&connectTimeout=30000&socketTimeout=30000&autoReconnect=true&failOverReadOnly=false&maxReconnects=10 + - SPRING_DATASOURCE_DRUID_USERNAME=root + - SPRING_DATASOURCE_DRUID_PASSWORD=123456 + # Redis connection + - SPRING_DATA_REDIS_HOST=xiaozhi-esp32-server-redis + - SPRING_DATA_REDIS_PORT=6379 + - SPRING_DATA_REDIS_PASSWORD= + volumes: + # Upload files directory + - ./uploadfile:/uploadfile + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + + # ============================================================================ + # MySQL Database + # ============================================================================ + xiaozhi-esp32-server-db: + image: mysql:8.0 + container_name: xiaozhi-esp32-server-db + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # Expose MySQL port for local debugging (optional) + - "3307:3306" + volumes: + # Persistent database storage + - ./mysql/data:/var/lib/mysql + # MySQL configuration (optional) + # - ./mysql/conf:/etc/mysql/conf.d + environment: + - TZ=Asia/Shanghai + - MYSQL_ROOT_PASSWORD=123456 + - MYSQL_DATABASE=xiaozhi_esp32_server + - MYSQL_INITDB_ARGS=--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --default-authentication-plugin=mysql_native_password + - --max_connections=1000 + - --max_allowed_packet=256M + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456"] + timeout: 45s + interval: 10s + retries: 10 + start_period: 60s + + # ============================================================================ + # Redis Cache + # ============================================================================ + xiaozhi-esp32-server-redis: + image: redis:7-alpine + container_name: xiaozhi-esp32-server-redis + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # Expose Redis port for local debugging (optional) + - "6380:6379" + volumes: + # Persistent Redis data (optional) + - ./redis/data:/data + environment: + - TZ=Asia/Shanghai + command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru + logging: + driver: "json-file" + options: + max-size: "5m" + max-file: "3" + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 10s + +# ============================================================================ +# Networks +# ============================================================================ +networks: + xiaozhi-network: + driver: bridge + name: xiaozhi-local-network + +# ============================================================================ +# Volumes (optional - for named volumes instead of bind mounts) +# ============================================================================ +# volumes: +# mysql-data: +# redis-data: + diff --git a/main/xiaozhi-server/docker_compose_us_all.yml b/main/xiaozhi-server/docker_compose_us_all.yml new file mode 100644 index 000000000..743f170c9 --- /dev/null +++ b/main/xiaozhi-server/docker_compose_us_all.yml @@ -0,0 +1,179 @@ +# Docker Compose configuration for local development +# This file uses locally built images instead of pulling from remote registry + +services: + # ============================================================================ + # xiaozhi-server (Python WebSocket Server) + # ============================================================================ + xiaozhi-esp32-server: + build: + context: . + dockerfile: Dockerfile + image: xiaozhi-esp32-server:local + container_name: xiaozhi-esp32-server + depends_on: + xiaozhi-esp32-server-db: + condition: service_healthy + xiaozhi-esp32-server-redis: + condition: service_healthy + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # WebSocket server + - "8000:8000" + # HTTP server for vision analysis and OTA + - "8003:8003" + security_opt: + - seccomp:unconfined + environment: + - TZ=Asia/Shanghai + - PYTHONUNBUFFERED=1 + - LOG_LEVEL=INFO + - REGION=SINGAPORE + volumes: + # Configuration directory + - ./data:/opt/xiaozhi-esp32-server/data + # Custom config (optional override, uncomment if you need to customize) + - ./custom_config.yaml:/opt/xiaozhi-esp32-server/custom_config.yaml + # Model files (important!) + - ./models/SenseVoiceSmall:/opt/xiaozhi-esp32-server/models/SenseVoiceSmall + - ./models/snakers4_silero-vad:/opt/xiaozhi-esp32-server/models/snakers4_silero-vad + # Temporary files + - ./tmp:/opt/xiaozhi-esp32-server/tmp + # Music files (optional) + - ./music:/opt/xiaozhi-esp32-server/music + # Logs (optional, for debugging) + - ./logs:/opt/xiaozhi-esp32-server/logs + + # ============================================================================ + # manager-web (Management Console + API) + # ============================================================================ + xiaozhi-esp32-server-web: + # Build from local source (supports ARM64/Apple Silicon) + build: + context: ../../ + dockerfile: Dockerfile-web + image: xiaozhi-esp32-server-web:local + + # Option: Use pre-built image from registry (x86 only) + # image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest + # platform: linux/amd64 # Uncomment to force x86 emulation on ARM64 + + container_name: xiaozhi-esp32-server-web + restart: unless-stopped + networks: + - xiaozhi-network + depends_on: + xiaozhi-esp32-server-db: + condition: service_healthy + xiaozhi-esp32-server-redis: + condition: service_healthy + ports: + # Management console and API + - "8002:8002" + environment: + - TZ=Asia/Shanghai + - SPRING_PROFILES_ACTIVE=dev + # Database connection + - SPRING_DATASOURCE_DRUID_URL=jdbc:mysql://xiaozhi-esp32-server-db:3306/xiaozhi_esp32_server?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&connectTimeout=30000&socketTimeout=30000&autoReconnect=true&failOverReadOnly=false&maxReconnects=10 + - SPRING_DATASOURCE_DRUID_USERNAME=root + - SPRING_DATASOURCE_DRUID_PASSWORD=123456 + # Redis connection + - SPRING_DATA_REDIS_HOST=xiaozhi-esp32-server-redis + - SPRING_DATA_REDIS_PORT=6379 + - SPRING_DATA_REDIS_PASSWORD= + volumes: + # Upload files directory + - ./uploadfile:/uploadfile + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + + # ============================================================================ + # MySQL Database + # ============================================================================ + xiaozhi-esp32-server-db: + image: mysql:8.0 + container_name: xiaozhi-esp32-server-db + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # Expose MySQL port for local debugging (optional) + - "3307:3306" + volumes: + # Persistent database storage + - ./mysql/data:/var/lib/mysql + # MySQL configuration (optional) + # - ./mysql/conf:/etc/mysql/conf.d + environment: + - TZ=Asia/Shanghai + - MYSQL_ROOT_PASSWORD=123456 + - MYSQL_DATABASE=xiaozhi_esp32_server + - MYSQL_INITDB_ARGS=--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --default-authentication-plugin=mysql_native_password + - --max_connections=1000 + - --max_allowed_packet=256M + logging: + driver: "json-file" + options: + max-size: "10m" + max-file: "3" + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456"] + timeout: 45s + interval: 10s + retries: 10 + start_period: 60s + + # ============================================================================ + # Redis Cache + # ============================================================================ + xiaozhi-esp32-server-redis: + image: redis:7-alpine + container_name: xiaozhi-esp32-server-redis + restart: unless-stopped + networks: + - xiaozhi-network + ports: + # Expose Redis port for local debugging (optional) + - "6380:6379" + volumes: + # Persistent Redis data (optional) + - ./redis/data:/data + environment: + - TZ=Asia/Shanghai + command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru + logging: + driver: "json-file" + options: + max-size: "5m" + max-file: "3" + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 10s + +# ============================================================================ +# Networks +# ============================================================================ +networks: + xiaozhi-network: + driver: bridge + name: xiaozhi-local-network + +# ============================================================================ +# Volumes (optional - for named volumes instead of bind mounts) +# ============================================================================ +# volumes: +# mysql-data: +# redis-data: + From b1f6601176939a5bf3b9b0ed251852662049c6d2 Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 17:14:53 +0800 Subject: [PATCH 14/31] feat: name --- .../{docker_compose_sg_all.yml => docker-compose_sg_all.yml} | 0 .../{docker_compose_us_all.yml => docker-compose_us_all.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename main/xiaozhi-server/{docker_compose_sg_all.yml => docker-compose_sg_all.yml} (100%) rename main/xiaozhi-server/{docker_compose_us_all.yml => docker-compose_us_all.yml} (100%) diff --git a/main/xiaozhi-server/docker_compose_sg_all.yml b/main/xiaozhi-server/docker-compose_sg_all.yml similarity index 100% rename from main/xiaozhi-server/docker_compose_sg_all.yml rename to main/xiaozhi-server/docker-compose_sg_all.yml diff --git a/main/xiaozhi-server/docker_compose_us_all.yml b/main/xiaozhi-server/docker-compose_us_all.yml similarity index 100% rename from main/xiaozhi-server/docker_compose_us_all.yml rename to main/xiaozhi-server/docker-compose_us_all.yml From 19f83eda6fff15b8100c8bcb54c158921ac3c192 Mon Sep 17 00:00:00 2001 From: pany-05 Date: Tue, 4 Nov 2025 17:20:01 +0800 Subject: [PATCH 15/31] [feature] Optimization tts model priority --- main/xiaozhi-server/core/connection.py | 111 ++++++++++++++++-- .../core/providers/tts/elevenlabs_sdk.py | 3 +- .../core/roles/data/default.yaml | 8 +- .../core/utils/prompt_manager.py | 17 ++- 4 files changed, 123 insertions(+), 16 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 24d62c753..db0b062eb 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -419,6 +419,15 @@ class ConnectionHandler: asyncio.run_coroutine_threadsafe( self.asr.open_audio_channels(self), self.loop ) + + """加载记忆""" + self._initialize_memory() + """加载意图识别""" + self._initialize_intent() + """更新系统提示词(必须在 TTS 初始化前,以便加载 role 的 TTS 配置)""" + self._init_prompt_enhancement() + + # 初始化 TTS(在 prompt 初始化之后,以便使用 role 的 TTS 配置) if self.tts is None: self.tts = self._initialize_tts() # 打开语音合成通道 @@ -426,14 +435,8 @@ class ConnectionHandler: self.tts.open_audio_channels(self), self.loop ) - """加载记忆""" - self._initialize_memory() - """加载意图识别""" - self._initialize_intent() """初始化上报线程""" self._init_report_threads() - """更新系统提示词""" - self._init_prompt_enhancement() except Exception as e: self.logger.bind(tag=TAG).error(f"实例化组件失败: {e}") @@ -453,14 +456,27 @@ class ConnectionHandler: except Exception as e: self.logger.bind(tag=TAG).warning(f"获取用户画像失败: {e}") - # 构建增强的系统提示词 - enhanced_prompt = self.prompt_manager.build_enhanced_prompt( + # 构建增强的系统提示词(返回 (enhanced_prompt, role_tts_config)) + result = self.prompt_manager.build_enhanced_prompt( self.config["prompt"], self.device_id, self.client_ip, user_persona=user_persona, ) + # 解包返回值 + if isinstance(result, tuple): + enhanced_prompt, role_tts_config = result + # 保存 role 的 TTS 配置到 self.config(供 TTS 初始化使用) + if role_tts_config: + self.config["_role_tts_config"] = role_tts_config + self.logger.bind(tag=TAG).info( + f"保存 Role TTS 配置到 config: {role_tts_config}" + ) + else: + # 兼容旧版本返回值(仅返回 prompt 字符串) + enhanced_prompt = result + if enhanced_prompt: self.change_system_prompt(enhanced_prompt) self.logger.bind(tag=TAG).info("系统提示词已增强更新") @@ -479,15 +495,90 @@ class ConnectionHandler: self.logger.bind(tag=TAG).info("TTS上报线程已启动") def _initialize_tts(self): - """初始化TTS""" + """ + 初始化TTS(支持三级优先级配置) + + 优先级: + 1. API 下发的 TTS 配置(在 _initialize_private_config 中已应用) + 2. Role 中的 TTS 配置 + 3. selected_module.TTS(兜底配置) + """ tts = None if not self.need_bind: + # 检查是否有 role 的 TTS 配置(优先级2) + role_tts_config = self.config.get("_role_tts_config") + self.logger.bind(tag=TAG).info(f"🔍 检查 _role_tts_config: {role_tts_config}") + if role_tts_config: + self.logger.bind(tag=TAG).info("✅ 发现 Role TTS 配置,准备应用") + self._apply_role_tts_config(role_tts_config) + else: + self.logger.bind(tag=TAG).info("ℹ️ 没有 Role TTS 配置,使用默认配置") + + # 初始化 TTS(优先级1和3在这里统一处理) tts = initialize_tts(self.config) if tts is None: tts = DefaultTTS(self.config, delete_audio_file=True) return tts + + def _apply_role_tts_config(self, role_tts_config: dict): + """应用 role 中的 TTS 配置""" + self.logger.bind(tag=TAG).debug(f"开始应用 Role TTS 配置: {role_tts_config}") + provider = role_tts_config.get("provider") + voice_id = role_tts_config.get("voice_id") + + if not provider or not voice_id: + self.logger.bind(tag=TAG).warning("Role TTS 配置不完整,跳过应用") + return + + # 检查当前 selected_module.TTS 是否已经被 API 覆盖 + # 如果 API 已经设置了 TTS,则不应用 role 配置(API 优先级更高) + current_tts = self.config["selected_module"]["TTS"] + if self.config.get("_api_tts_applied"): + self.logger.bind(tag=TAG).info( + f"API 已设置 TTS 配置(优先级1),跳过 Role TTS 配置: {provider}" + ) + return + + # 应用 role 的 TTS 配置 + # 根据 provider 映射到实际的 TTS 模块名 + tts_module_map = { + "elevenlabs": "ElevenLabsSDK", + "cartesia": "CartesiaSDK", + "edge": "EdgeTTS", + "doubao": "VolcanoStreamTTS", + # 可以继续添加更多映射... + } + + tts_module = tts_module_map.get(provider.lower()) + if not tts_module: + self.logger.bind(tag=TAG).warning( + f"未知的 TTS provider: {provider},使用默认配置" + ) + return + + # 检查该 TTS 模块是否在配置中存在 + if tts_module not in self.config.get("TTS", {}): + self.logger.bind(tag=TAG).warning( + f"TTS 模块 {tts_module} 未在配置中定义,跳过应用" + ) + return + + # 更新 selected_module.TTS + self.config["selected_module"]["TTS"] = tts_module + + # 更新 voice_id(如果该 TTS 模块支持) + if "voice_id" in self.config["TTS"][tts_module]: + self.config["TTS"][tts_module]["voice_id"] = voice_id + self.logger.bind(tag=TAG).info( + f"✅ 应用 Role TTS 配置: provider={provider}, " + f"module={tts_module}, voice_id={voice_id[:16]}..." + ) + else: + self.logger.bind(tag=TAG).warning( + f"TTS 模块 {tts_module} 不支持 voice_id 配置" + ) def _initialize_asr(self): """初始化ASR""" @@ -572,6 +663,8 @@ class ConnectionHandler: self.config["selected_module"]["TTS"] = private_config["selected_module"][ "TTS" ] + # 标记 API 已设置 TTS 配置(优先级1) + self.config["_api_tts_applied"] = True if private_config.get("LLM", None) is not None: init_llm = True self.config["LLM"] = private_config["LLM"] diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py b/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py index c4935f3af..c99efa622 100644 --- a/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py +++ b/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py @@ -190,7 +190,8 @@ class TTSProvider(TTSProviderBase): ) except Exception as e: - logger.bind(tag=TAG).error(f"TTS 合成失败: {e}", exc_info=True) + error_msg = str(e).replace("{", "{{").replace("}", "}}") + logger.bind(tag=TAG).error(f"TTS 合成失败: {error_msg}", exc_info=True) raise async def close(self): diff --git a/main/xiaozhi-server/core/roles/data/default.yaml b/main/xiaozhi-server/core/roles/data/default.yaml index 0988ed7ab..60ad956a3 100644 --- a/main/xiaozhi-server/core/roles/data/default.yaml +++ b/main/xiaozhi-server/core/roles/data/default.yaml @@ -1,4 +1,4 @@ -id: hospital_assistant +id: default version: 4 wake_word: Alice language: en @@ -57,10 +57,10 @@ profile: | # Tools No tools provided. -# tts: +#tts: # voice_id: 7a5d4663-88ae-47b7-808e-8f9b9ee4127b # provider: cartesia tts: - voice_id: f786b574-daa5-4673-aa0c-cbe3e8534c02 - provider: elevenlabs + voice_id: ByhETIclHirOlWnWKhHc + provider: elevenlabs timezone: Asia/Shanghai diff --git a/main/xiaozhi-server/core/utils/prompt_manager.py b/main/xiaozhi-server/core/utils/prompt_manager.py index 31a3542b4..0775d086f 100644 --- a/main/xiaozhi-server/core/utils/prompt_manager.py +++ b/main/xiaozhi-server/core/utils/prompt_manager.py @@ -165,6 +165,7 @@ class PromptManager: from core.roles import get_role_config_loader # 优先级:API 传入的 user_prompt > 本地 role 配置 > 空字符串 + role_tts_config = None # 保存 role 的 TTS 配置供后续使用 if user_prompt and user_prompt.strip(): # 优先使用 API 传入的 prompt(正式部署场景) profile = user_prompt @@ -181,6 +182,16 @@ class PromptManager: profile = role_config.profile timezone = role_config.timezone language = role_config.language + # 提取 TTS 配置(如果有) + if role_config.tts: + role_tts_config = { + "voice_id": role_config.tts.voice_id, + "provider": role_config.tts.provider + } + self.logger.bind(tag=TAG).info( + f"检测到 Role TTS 配置: provider={role_config.tts.provider}, " + f"voice_id={role_config.tts.voice_id[:16]}..." + ) self.logger.bind(tag=TAG).info(f"使用本地 role 配置: {role_id}") except Exception as e: # 兜底方案:使用空 profile @@ -235,8 +246,10 @@ class PromptManager: self.logger.bind(tag=TAG).info( f"构建增强提示词成功,长度: {len(enhanced_prompt)}" ) - return enhanced_prompt + + # 返回 (enhanced_prompt, role_tts_config) + return (enhanced_prompt, role_tts_config) except Exception as e: self.logger.bind(tag=TAG).error(f"构建增强提示词失败: {e}", exc_info=True) - return user_prompt + return (user_prompt, None) From 95402cba6ae68fa116817810c7fcae31dd069759 Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 17:36:05 +0800 Subject: [PATCH 16/31] feat: secret --- main/xiaozhi-server/config/manage_api_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/xiaozhi-server/config/manage_api_client.py b/main/xiaozhi-server/config/manage_api_client.py index ee4ba8907..a067c153f 100644 --- a/main/xiaozhi-server/config/manage_api_client.py +++ b/main/xiaozhi-server/config/manage_api_client.py @@ -53,7 +53,7 @@ class ManageApiClient: elif region == "US-WEST-2": cls._secret = "ff22d758-79dd-47ff-a897-c6e39983e0e1" - cls._secret = cls.config.get("secret") + # cls._secret = cls.config.get("secret") cls.max_retries = cls.config.get("max_retries", 6) # 最大重试次数 cls.retry_delay = cls.config.get("retry_delay", 10) # 初始重试延迟(秒) # NOTE(goody): 2025/4/16 http相关资源统一管理,后续可以增加线程池或者超时 From 6a2a8be74486e0012f063ca4da44d09700e7c10f Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 17:42:00 +0800 Subject: [PATCH 17/31] feat: log --- main/xiaozhi-server/config/manage_api_client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main/xiaozhi-server/config/manage_api_client.py b/main/xiaozhi-server/config/manage_api_client.py index a067c153f..53dc95706 100644 --- a/main/xiaozhi-server/config/manage_api_client.py +++ b/main/xiaozhi-server/config/manage_api_client.py @@ -53,6 +53,7 @@ class ManageApiClient: elif region == "US-WEST-2": cls._secret = "ff22d758-79dd-47ff-a897-c6e39983e0e1" + print(f"region: {region}, secret: {cls._secret}") # cls._secret = cls.config.get("secret") cls.max_retries = cls.config.get("max_retries", 6) # 最大重试次数 cls.retry_delay = cls.config.get("retry_delay", 10) # 初始重试延迟(秒) From 06db1b0796dd3b4ae4a08e4ea8a6f128a9a25ade Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 17:56:45 +0800 Subject: [PATCH 18/31] feat:secret --- main/xiaozhi-server/config/manage_api_client.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main/xiaozhi-server/config/manage_api_client.py b/main/xiaozhi-server/config/manage_api_client.py index 53dc95706..785cae3e9 100644 --- a/main/xiaozhi-server/config/manage_api_client.py +++ b/main/xiaozhi-server/config/manage_api_client.py @@ -45,16 +45,16 @@ class ManageApiClient: raise Exception("请先配置manager-api的secret") # 根据aws服务器所在机房路由不同secret - region = os.getenv("REGION") - if region == "LOCAL": - cls._secret = cls.config.get("secret") - elif region == "SINGAPORE": + region = os.getenv("REGION", "LOCAL") # 默认 LOCAL + if region == "SINGAPORE": cls._secret = "a1c50356-4307-4bb7-8c16-c661d06ec17b" elif region == "US-WEST-2": cls._secret = "ff22d758-79dd-47ff-a897-c6e39983e0e1" + else: + # LOCAL 或其他未知区域,使用配置文件中的 secret + cls._secret = cls.config.get("secret") - print(f"region: {region}, secret: {cls._secret}") - # cls._secret = cls.config.get("secret") + print(f"[ManageApiClient] Region: {region}, Secret: {cls._secret[:8]}...") cls.max_retries = cls.config.get("max_retries", 6) # 最大重试次数 cls.retry_delay = cls.config.get("retry_delay", 10) # 初始重试延迟(秒) # NOTE(goody): 2025/4/16 http相关资源统一管理,后续可以增加线程池或者超时 From e0c703bfa3baa067218855c382eb4901f16671d6 Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 18:19:54 +0800 Subject: [PATCH 19/31] feat: remove health check --- main/xiaozhi-server/docker-compose_local_all.yml | 2 ++ main/xiaozhi-server/docker-compose_sg_all.yml | 2 ++ main/xiaozhi-server/docker-compose_us_all.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/main/xiaozhi-server/docker-compose_local_all.yml b/main/xiaozhi-server/docker-compose_local_all.yml index 124f8c759..8346f960a 100644 --- a/main/xiaozhi-server/docker-compose_local_all.yml +++ b/main/xiaozhi-server/docker-compose_local_all.yml @@ -31,6 +31,8 @@ services: - PYTHONUNBUFFERED=1 - LOG_LEVEL=INFO - REGION=LOCAL + healthcheck: + disable: true volumes: # Configuration directory - ./data:/opt/xiaozhi-esp32-server/data diff --git a/main/xiaozhi-server/docker-compose_sg_all.yml b/main/xiaozhi-server/docker-compose_sg_all.yml index 743f170c9..a112fd8b1 100644 --- a/main/xiaozhi-server/docker-compose_sg_all.yml +++ b/main/xiaozhi-server/docker-compose_sg_all.yml @@ -31,6 +31,8 @@ services: - PYTHONUNBUFFERED=1 - LOG_LEVEL=INFO - REGION=SINGAPORE + healthcheck: + disable: true volumes: # Configuration directory - ./data:/opt/xiaozhi-esp32-server/data diff --git a/main/xiaozhi-server/docker-compose_us_all.yml b/main/xiaozhi-server/docker-compose_us_all.yml index 743f170c9..43fecb2e7 100644 --- a/main/xiaozhi-server/docker-compose_us_all.yml +++ b/main/xiaozhi-server/docker-compose_us_all.yml @@ -26,6 +26,8 @@ services: - "8003:8003" security_opt: - seccomp:unconfined + healthcheck: + disable: true environment: - TZ=Asia/Shanghai - PYTHONUNBUFFERED=1 From b120857f5085f5aa52c375c74e53af58c590422c Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 4 Nov 2025 18:55:38 +0800 Subject: [PATCH 20/31] feat:script --- main/xiaozhi-server/docker-compose_us_all.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/xiaozhi-server/docker-compose_us_all.yml b/main/xiaozhi-server/docker-compose_us_all.yml index 43fecb2e7..06a7ec213 100644 --- a/main/xiaozhi-server/docker-compose_us_all.yml +++ b/main/xiaozhi-server/docker-compose_us_all.yml @@ -32,7 +32,7 @@ services: - TZ=Asia/Shanghai - PYTHONUNBUFFERED=1 - LOG_LEVEL=INFO - - REGION=SINGAPORE + - REGION=US-WEST-2 volumes: # Configuration directory - ./data:/opt/xiaozhi-esp32-server/data From d76975a6c69ff23f71b91322a1e4967175553098 Mon Sep 17 00:00:00 2001 From: Harold Date: Wed, 5 Nov 2025 10:52:15 +0800 Subject: [PATCH 21/31] feat:shell --- main/xiaozhi-server/START_SCRIPT_USAGE.txt | 127 +++++++++++++++ main/xiaozhi-server/start.sh | 172 +++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 main/xiaozhi-server/START_SCRIPT_USAGE.txt create mode 100755 main/xiaozhi-server/start.sh diff --git a/main/xiaozhi-server/START_SCRIPT_USAGE.txt b/main/xiaozhi-server/START_SCRIPT_USAGE.txt new file mode 100644 index 000000000..de17dc1b6 --- /dev/null +++ b/main/xiaozhi-server/START_SCRIPT_USAGE.txt @@ -0,0 +1,127 @@ +Xiaozhi Server Startup Script Usage +==================================== + +QUICK START +----------- + +1. Start server only (most common for development): + ./start.sh --region --action server + ./start.sh -r -a server + +2. Start all services (first time or full restart): + ./start.sh --region --action all + ./start.sh -r -a all + + +COMMAND LINE OPTIONS +-------------------- + + -r, --region Deployment region (required) + Values: sg, us, local + + -a, --action Action to perform (required) + Values: server, all + + -h, --help Show help message + + +REGION OPTIONS +-------------- + +sg - Singapore deployment (uses docker-compose_sg_all.yml) + REGION=SINGAPORE, secret: a1c50356-4307-4bb7-8c16-c661d06ec17b + +us - US West 2 deployment (uses docker-compose_us_all.yml) + REGION=US-WEST-2, secret: ff22d758-79dd-47ff-a897-c6e39983e0e1 + +local - Local development (uses docker-compose_local_all.yml) + REGION=LOCAL, secret: from custom_config.yaml + + +ACTION OPTIONS +-------------- + +server - Restart ONLY xiaozhi-esp32-server + Other services (web, db, redis) keep running + Fast restart for code iteration + ✓ Preserves database data + ✓ Preserves Redis cache + ✓ Avoids web service restart + +all - Start/restart ALL services + Runs: docker-compose up -d + Use when: + - First time setup + - After modifying docker-compose files + - Need to restart web/db/redis + + +COMMON USAGE EXAMPLES +--------------------- + +# Development iteration (most frequent) +./start.sh --region local --action server # Local dev, restart server only +./start.sh -r sg -a server # Singapore, restart server only + +# First time or full restart +./start.sh --region local --action all # Start everything locally +./start.sh -r sg -a all # Deploy to Singapore +./start.sh -r us -a all # Deploy to US West 2 + +# Show help +./start.sh --help +./start.sh -h + + +WORKFLOW EXAMPLE +---------------- + +1. Initial setup: + ./start.sh --region local --action all + +2. Make code changes in xiaozhi-server + +3. Quick restart to test: + ./start.sh -r local -a server + +4. View logs: + docker-compose -f docker-compose_local_all.yml logs -f xiaozhi-esp32-server + +5. Repeat steps 2-4 for rapid development + + +TIPS +---- + +* Server restart takes ~10 seconds +* All services restart takes ~1-2 minutes +* Database and Redis data persist between restarts +* Check container status: docker ps --filter name=xiaozhi +* Stop all services: docker-compose -f docker-compose__all.yml down +* Both long (--region) and short (-r) options are supported + + +TROUBLESHOOTING +--------------- + +Q: "Error: Invalid region 'XX'" +A: Use only: sg, us, or local (case insensitive) + +Q: "Error: Invalid action 'XX'" +A: Use only: server or all (case insensitive) + +Q: "Error: Unknown option" +A: Check syntax: ./start.sh --region --action + Or use short form: ./start.sh -r -a + +Q: "Error: Compose file not found" +A: Make sure you run the script from xiaozhi-server directory + +Q: Container not starting +A: Check logs with: + docker-compose -f docker-compose__all.yml logs xiaozhi-esp32-server + +Q: Need to rebuild image after code changes +A: docker-compose -f docker-compose__all.yml build xiaozhi-esp32-server + Then run: ./start.sh server + diff --git a/main/xiaozhi-server/start.sh b/main/xiaozhi-server/start.sh new file mode 100755 index 000000000..fb6a9e282 --- /dev/null +++ b/main/xiaozhi-server/start.sh @@ -0,0 +1,172 @@ +#!/bin/bash + +# Xiaozhi Server Startup Script +# Usage: ./start.sh --region --action +# Region: sg, us, local +# Action: server, all + +set -e + +# Color definitions +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +# Display banner +echo -e "${CYAN}" +echo "==================================" +echo " Xiaozhi Server Startup Script" +echo "==================================" +echo -e "${NC}" + +# Function to display usage +show_usage() { + echo -e "${RED}Error: Missing or invalid arguments${NC}" + echo "" + echo "Usage: $0 --region --action " + echo "" + echo "Options:" + echo " -r, --region Deployment region" + echo " Values: sg, us, local" + echo "" + echo " -a, --action Action to perform" + echo " Values: server, all" + echo "" + echo " -h, --help Show this help message" + echo "" + echo "Region details:" + echo " sg - Singapore (REGION=SINGAPORE)" + echo " us - US West 2 (REGION=US-WEST-2)" + echo " local - Local development (REGION=LOCAL)" + echo "" + echo "Action details:" + echo " server - Restart only xiaozhi-esp32-server" + echo " all - Start/restart all services (server, web, db, redis)" + echo "" + echo "Examples:" + echo " $0 --region sg --action server" + echo " $0 -r us -a all" + echo " $0 --region local --action server" + exit 1 +} + +# Parse command line arguments +REGION="" +ACTION="" + +while [[ $# -gt 0 ]]; do + case $1 in + -r|--region) + REGION="$2" + shift 2 + ;; + -a|--action) + ACTION="$2" + shift 2 + ;; + -h|--help) + show_usage + ;; + *) + echo -e "${RED}Error: Unknown option '$1'${NC}" + echo "" + show_usage + ;; + esac +done + +# Check if required arguments are provided +if [ -z "$REGION" ] || [ -z "$ACTION" ]; then + show_usage +fi + +# Validate region +case $REGION in + sg|SG) + COMPOSE_FILE="docker-compose_sg_all.yml" + REGION_NAME="Singapore" + REGION_ENV="SINGAPORE" + ;; + us|US) + COMPOSE_FILE="docker-compose_us_all.yml" + REGION_NAME="US West 2" + REGION_ENV="US-WEST-2" + ;; + local|LOCAL) + COMPOSE_FILE="docker-compose_local_all.yml" + REGION_NAME="Local" + REGION_ENV="LOCAL" + ;; + *) + echo -e "${RED}Error: Invalid region '${REGION}'${NC}" + echo "Valid regions: sg, us, local" + exit 1 + ;; +esac + +# Validate action +case $ACTION in + server|SERVER) + ACTION_NAME="Server Only" + SERVICES="xiaozhi-esp32-server" + ;; + all|ALL) + ACTION_NAME="All Services" + SERVICES="" + ;; + *) + echo -e "${RED}Error: Invalid action '${ACTION}'${NC}" + echo "Valid actions: server, all" + exit 1 + ;; +esac + +# Check if compose file exists +if [ ! -f "$COMPOSE_FILE" ]; then + echo -e "${RED}Error: Compose file '${COMPOSE_FILE}' not found${NC}" + exit 1 +fi + +echo -e "${GREEN}Configuration:${NC}" +echo " Region: ${REGION_NAME} (${REGION_ENV})" +echo " Action: ${ACTION_NAME}" +echo " Compose file: ${COMPOSE_FILE}" +echo "" + +# Display current status +echo -e "${BLUE}Current container status:${NC}" +docker ps --filter name=xiaozhi --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" 2>/dev/null || echo "No containers running" +echo "" + +# Confirm action +if [ "$ACTION" = "server" ] || [ "$ACTION" = "SERVER" ]; then + echo -e "${YELLOW}→ Restarting xiaozhi-esp32-server...${NC}" + echo "" + docker-compose -f "$COMPOSE_FILE" restart xiaozhi-esp32-server +else + echo -e "${YELLOW}→ Starting all services...${NC}" + echo "" + docker-compose -f "$COMPOSE_FILE" up -d +fi + +echo "" +echo -e "${GREEN}✓ Operation completed${NC}" +echo "" + +# Display final status +echo -e "${BLUE}Updated container status:${NC}" +docker ps --filter name=xiaozhi --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" +echo "" + +# Show logs option +echo -e "${CYAN}To view logs, run:${NC}" +if [ "$ACTION" = "server" ] || [ "$ACTION" = "SERVER" ]; then + echo " docker-compose -f $COMPOSE_FILE logs -f xiaozhi-esp32-server" +else + echo " docker-compose -f $COMPOSE_FILE logs -f" +fi +echo "" + From 0d829a95e06170b5d4a676d1ddc71c424a67de9c Mon Sep 17 00:00:00 2001 From: Harold Date: Wed, 5 Nov 2025 11:03:50 +0800 Subject: [PATCH 22/31] feat: shell --- main/xiaozhi-server/START_SCRIPT_USAGE.txt | 19 +++++++++++++------ main/xiaozhi-server/start.sh | 8 ++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/main/xiaozhi-server/START_SCRIPT_USAGE.txt b/main/xiaozhi-server/START_SCRIPT_USAGE.txt index de17dc1b6..5e4cf0c32 100644 --- a/main/xiaozhi-server/START_SCRIPT_USAGE.txt +++ b/main/xiaozhi-server/START_SCRIPT_USAGE.txt @@ -49,7 +49,7 @@ server - Restart ONLY xiaozhi-esp32-server ✓ Avoids web service restart all - Start/restart ALL services - Runs: docker-compose up -d + Runs: docker compose up -d Use when: - First time setup - After modifying docker-compose files @@ -85,7 +85,7 @@ WORKFLOW EXAMPLE ./start.sh -r local -a server 4. View logs: - docker-compose -f docker-compose_local_all.yml logs -f xiaozhi-esp32-server + docker compose -f docker-compose_local_all.yml logs -f xiaozhi-esp32-server 5. Repeat steps 2-4 for rapid development @@ -97,13 +97,20 @@ TIPS * All services restart takes ~1-2 minutes * Database and Redis data persist between restarts * Check container status: docker ps --filter name=xiaozhi -* Stop all services: docker-compose -f docker-compose__all.yml down +* Stop all services: docker compose -f docker-compose__all.yml down * Both long (--region) and short (-r) options are supported +* Requires Docker Compose v2 (uses 'docker compose' without hyphen) TROUBLESHOOTING --------------- +Q: "docker: 'compose' is not a docker command" +A: You need Docker Compose v2. Install it: + - Ubuntu/Debian: sudo apt-get install docker-compose-plugin + - macOS: Install Docker Desktop (includes Compose v2) + - Or see: https://docs.docker.com/compose/install/ + Q: "Error: Invalid region 'XX'" A: Use only: sg, us, or local (case insensitive) @@ -119,9 +126,9 @@ A: Make sure you run the script from xiaozhi-server directory Q: Container not starting A: Check logs with: - docker-compose -f docker-compose__all.yml logs xiaozhi-esp32-server + docker compose -f docker-compose__all.yml logs xiaozhi-esp32-server Q: Need to rebuild image after code changes -A: docker-compose -f docker-compose__all.yml build xiaozhi-esp32-server - Then run: ./start.sh server +A: docker compose -f docker-compose__all.yml build xiaozhi-esp32-server + Then run: ./start.sh -r -a server diff --git a/main/xiaozhi-server/start.sh b/main/xiaozhi-server/start.sh index fb6a9e282..fb52e8fe3 100755 --- a/main/xiaozhi-server/start.sh +++ b/main/xiaozhi-server/start.sh @@ -145,11 +145,11 @@ echo "" if [ "$ACTION" = "server" ] || [ "$ACTION" = "SERVER" ]; then echo -e "${YELLOW}→ Restarting xiaozhi-esp32-server...${NC}" echo "" - docker-compose -f "$COMPOSE_FILE" restart xiaozhi-esp32-server + docker compose -f "$COMPOSE_FILE" restart xiaozhi-esp32-server else echo -e "${YELLOW}→ Starting all services...${NC}" echo "" - docker-compose -f "$COMPOSE_FILE" up -d + docker compose -f "$COMPOSE_FILE" up -d fi echo "" @@ -164,9 +164,9 @@ echo "" # Show logs option echo -e "${CYAN}To view logs, run:${NC}" if [ "$ACTION" = "server" ] || [ "$ACTION" = "SERVER" ]; then - echo " docker-compose -f $COMPOSE_FILE logs -f xiaozhi-esp32-server" + echo " docker compose -f $COMPOSE_FILE logs -f xiaozhi-esp32-server" else - echo " docker-compose -f $COMPOSE_FILE logs -f" + echo " docker compose -f $COMPOSE_FILE logs -f" fi echo "" From 9e36cd97919fc02b8b73a45e058269c8e06bfdb6 Mon Sep 17 00:00:00 2001 From: Harold Date: Wed, 5 Nov 2025 13:46:16 +0800 Subject: [PATCH 23/31] feat: launch script && tts config --- .../resources/db/changelog/202511051120.sql | 68 ++ .../db/changelog/db.changelog-master.yaml | 7 + main/xiaozhi-server/config.yaml | 8 +- .../tts/{cartesia_sdk.py => cartesia.py} | 0 .../tts/{elevenlabs_sdk.py => elevenlabs.py} | 0 .../core/providers/tts/elevenlabs/tts.py | 626 ------------------ main/xiaozhi-server/custom_config.yaml | 8 +- main/xiaozhi-server/start.sh | 42 +- 8 files changed, 105 insertions(+), 654 deletions(-) create mode 100644 main/manager-api/src/main/resources/db/changelog/202511051120.sql rename main/xiaozhi-server/core/providers/tts/{cartesia_sdk.py => cartesia.py} (100%) rename main/xiaozhi-server/core/providers/tts/{elevenlabs_sdk.py => elevenlabs.py} (100%) delete mode 100644 main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py diff --git a/main/manager-api/src/main/resources/db/changelog/202511051120.sql b/main/manager-api/src/main/resources/db/changelog/202511051120.sql new file mode 100644 index 000000000..ccc4322d6 --- /dev/null +++ b/main/manager-api/src/main/resources/db/changelog/202511051120.sql @@ -0,0 +1,68 @@ +-- 添加 ElevenLabs 和 Cartesia TTS 供应器和模型配置 + +-- ==================== ElevenLabs TTS ==================== + +-- 添加 ElevenLabs TTS 供应器 +DELETE FROM `ai_model_provider` WHERE id = 'TTS_ElevenLabs'; +INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES +('TTS_ElevenLabs', 'TTS', 'elevenlabs', 'ElevenLabs TTS', '[{"key":"api_key","label":"API Key","type":"string"},{"key":"voice_id","label":"Voice ID","type":"string"},{"key":"model","label":"Model","type":"string"},{"key":"output_format","label":"Output Format","type":"string"},{"key":"stability","label":"Stability","type":"number"},{"key":"similarity_boost","label":"Similarity Boost","type":"number"},{"key":"style","label":"Style","type":"number"},{"key":"use_speaker_boost","label":"Use Speaker Boost","type":"string"},{"key":"optimize_streaming_latency","label":"Optimize Streaming Latency","type":"number"},{"key":"output_dir","label":"Output Directory","type":"string"}]', 21, 1, NOW(), 1, NOW()); + +-- 添加 ElevenLabs TTS 模型配置 +DELETE FROM `ai_model_config` WHERE id = 'TTS_ElevenLabs'; +INSERT INTO `ai_model_config` VALUES ( + 'TTS_ElevenLabs', + 'TTS', + 'ElevenLabs', + 'ElevenLabs TTS', + 0, + 1, + '{\"type\": \"elevenlabs\", \"api_key\": \"\", \"voice_id\": \"21m00Tcm4TlvDq8ikWAM\", \"model\": \"eleven_multilingual_v2\", \"output_format\": \"pcm_16000\", \"stability\": 0.5, \"similarity_boost\": 0.75, \"style\": 0.0, \"use_speaker_boost\": true, \"optimize_streaming_latency\": 3, \"output_dir\": \"tmp/\"}', + 'https://elevenlabs.io/docs/introduction', + 'ElevenLabs TTS 配置说明:\n1. ElevenLabs 提供高质量、情感丰富的语音合成服务\n2. 支持多语言(包括英文、中文等)和声音克隆功能\n3. 使用官方 Python SDK,延迟低、质量高\n4. API Key 获取:访问 https://elevenlabs.io/ 注册并获取\n5. Voice ID 可在 ElevenLabs 控制台中找到预设音色或创建自定义音色\n6. Model 推荐使用 eleven_multilingual_v2(多语言)或 eleven_turbo_v2(低延迟)\n7. Stability (0-1): 控制语音稳定性,越高越稳定但变化少\n8. Similarity Boost (0-1): 控制与原音色的相似度\n9. Style (0-1): 控制语音风格强度\n10. Optimize Streaming Latency (0-4): 优化流式延迟,推荐 2-3', + 23, + NULL, + NULL, + NULL, + NULL +); + +-- 添加 ElevenLabs 音色配置 +DELETE FROM `ai_tts_voice` WHERE id IN ('TTS_ElevenLabs0001', 'TTS_ElevenLabs0002', 'TTS_ElevenLabs0003', 'TTS_ElevenLabs0004'); +INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0001', 'TTS_ElevenLabs', 'Rachel - Female', '21m00Tcm4TlvDq8ikWAM', 'English', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); +INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0002', 'TTS_ElevenLabs', 'Drew - Male', '29vD33N1CtxCmqQRPOHJ', 'English', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); +INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0003', 'TTS_ElevenLabs', 'Clyde - Male', '2EiwWnXFnvU5JabPnv8n', 'English', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); +INSERT INTO `ai_tts_voice` VALUES ('TTS_ElevenLabs0004', 'TTS_ElevenLabs', 'Bella - Female', 'EXAVITQu4vr4xnSDxMaL', 'English', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); + +-- ==================== Cartesia TTS ==================== + +-- 添加 Cartesia TTS 供应器 +DELETE FROM `ai_model_provider` WHERE id = 'TTS_Cartesia'; +INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES +('TTS_Cartesia', 'TTS', 'cartesia', 'Cartesia TTS', '[{"key":"api_key","label":"API Key","type":"string"},{"key":"voice_id","label":"Voice ID","type":"string"},{"key":"model","label":"Model","type":"string"},{"key":"language","label":"Language","type":"string"},{"key":"encoding","label":"Encoding","type":"string"},{"key":"sample_rate","label":"Sample Rate","type":"number"},{"key":"output_dir","label":"Output Directory","type":"string"}]', 22, 1, NOW(), 1, NOW()); + +-- 添加 Cartesia TTS 模型配置 +DELETE FROM `ai_model_config` WHERE id = 'TTS_Cartesia'; +INSERT INTO `ai_model_config` VALUES ( + 'TTS_Cartesia', + 'TTS', + 'Cartesia', + 'Cartesia TTS', + 0, + 1, + '{\"type\": \"cartesia\", \"api_key\": \"\", \"voice_id\": \"a0e99841-438c-4a64-b679-ae501e7d6091\", \"model\": \"sonic-3\", \"language\": \"en\", \"encoding\": \"pcm_s16le\", \"sample_rate\": 24000, \"output_dir\": \"tmp/\"}', + 'https://docs.cartesia.ai/', + 'Cartesia TTS 配置说明:\n1. Cartesia 提供超低延迟的流式语音合成服务\n2. 使用官方 Python SDK,首包延迟极低(通常 < 200ms)\n3. 支持多种语言和声音(英语、西班牙语、法语、德语、中文等)\n4. API Key 获取:访问 https://cartesia.ai/ 注册并获取\n5. Voice ID 可在 Cartesia 控制台查看预设音色\n6. Model 选项:sonic-english(英语)、sonic-multilingual(多语言)\n7. Encoding: pcm_s16le(推荐)、pcm_mulaw 等\n8. Sample Rate: 8000/16000/24000/44100(推荐 24000)\n9. 特别适合需要实时交互的场景(如语音助手、客服)', + 24, + NULL, + NULL, + NULL, + NULL +); + +-- 添加 Cartesia 音色配置 +DELETE FROM `ai_tts_voice` WHERE id IN ('TTS_Cartesia0001', 'TTS_Cartesia0002', 'TTS_Cartesia0003', 'TTS_Cartesia0004'); +INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0001', 'TTS_Cartesia', 'Barbershop Man', 'a0e99841-438c-4a64-b679-ae501e7d6091', 'English', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL); +INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0002', 'TTS_Cartesia', 'Kentucky Man', '41534e16-2966-4c6b-9670-111411def906', 'English', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL); +INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0003', 'TTS_Cartesia', 'British Lady', '79a125e8-cd45-4c13-8a67-188112f4dd22', 'English', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL); +INSERT INTO `ai_tts_voice` VALUES ('TTS_Cartesia0004', 'TTS_Cartesia', 'Friendly Reader', '69267136-1bdc-412f-ad78-0caad210fb40', 'English', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL); + diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml index b6b88bf39..c135efdcb 100755 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml @@ -402,3 +402,10 @@ databaseChangeLog: - sqlFile: encoding: utf8 path: classpath:db/changelog/202510191042.sql + - changeSet: + id: 202511051120 + author: pany + changes: + - sqlFile: + encoding: utf8 + path: classpath:db/changelog/202511051120.sql diff --git a/main/xiaozhi-server/config.yaml b/main/xiaozhi-server/config.yaml index 2070c3ee0..630b1c650 100644 --- a/main/xiaozhi-server/config.yaml +++ b/main/xiaozhi-server/config.yaml @@ -649,12 +649,12 @@ TTS: output_dir: tmp/ # ============== SDK 版本TTS(推荐)============== # 使用官方SDK,代码更简洁、性能更好、维护成本更低 - CartesiaSDK: + Cartesia: # Cartesia TTS - SDK版本(推荐) # 官方SDK实现,低延迟,支持流式合成 # API Key获取地址:https://play.cartesia.ai/console # 或设置环境变量:export CARTESIA_API_KEY=your-api-key - type: cartesia_sdk + type: cartesia api_key: 你的Cartesia API密钥 # Voice ID或voice embedding voice_id: 你的语音ID @@ -667,12 +667,12 @@ TTS: # 采样率:8000, 16000, 22050, 24000, 44100等 sample_rate: 24000 output_dir: tmp/ - ElevenLabsSDK: + ElevenLabs: # ElevenLabs TTS - SDK版本(推荐) # 官方SDK实现,代码更简洁,维护成本更低,性能更好 # API Key获取地址:https://elevenlabs.io/app/settings/api-keys # 或设置环境变量:export ELEVEN_API_KEY=your-api-key - type: elevenlabs_sdk + type: elevenlabs api_key: 你的ElevenLabs API密钥 # Voice ID获取:https://elevenlabs.io/app/voice-library # 默认:21m00Tcm4TlvDq8ikWAM (Rachel) diff --git a/main/xiaozhi-server/core/providers/tts/cartesia_sdk.py b/main/xiaozhi-server/core/providers/tts/cartesia.py similarity index 100% rename from main/xiaozhi-server/core/providers/tts/cartesia_sdk.py rename to main/xiaozhi-server/core/providers/tts/cartesia.py diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py b/main/xiaozhi-server/core/providers/tts/elevenlabs.py similarity index 100% rename from main/xiaozhi-server/core/providers/tts/elevenlabs_sdk.py rename to main/xiaozhi-server/core/providers/tts/elevenlabs.py diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py b/main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py deleted file mode 100644 index f79614b78..000000000 --- a/main/xiaozhi-server/core/providers/tts/elevenlabs/tts.py +++ /dev/null @@ -1,626 +0,0 @@ -from __future__ import annotations - -""" -ElevenLabs TTS Implementation - -Provides WebSocket-based streaming text-to-speech using ElevenLabs' multi-stream API. -Supports multiple concurrent synthesis streams over a single WebSocket connection. -""" - -""" -TODO: change api to elevenlabs SDK using streaming API -""" - -import asyncio -import base64 -import dataclasses -import json -import os -import weakref -from dataclasses import dataclass -from typing import Any, Union - -import aiohttp -from typing import Optional - -from config.logger import setup_logging -from core.tokenize import SentenceTokenizer, WordTokenizer, blingfire -from core.utils.aio import Chan, cancel_and_wait -from core.utils.short_uuid import shortuuid -from core.utils.http_context import http_session -from core.utils.errors import ( - APIConnectionError, - APITimeoutError, - APIStatusError, -) -from core.utils.types import ( - APIConnectOptions, - DEFAULT_API_CONNECT_OPTIONS, -) - -import core.providers.tts.base as tts -from ..emitter import AudioEmitter -from .models import ( - API_BASE_URL, - DEFAULT_VOICE_ID, - TTSEncoding, - TTSModels, - Voice, - VoiceSettings, - WS_INACTIVITY_TIMEOUT, -) - -logger = setup_logging() - - -def _sample_rate_from_format(output_format: TTSEncoding) -> int: - """Extract sample rate from encoding format string""" - if output_format.startswith("mp3_"): - return int(output_format.split("_")[1]) - elif output_format.startswith("pcm_"): - return int(output_format.split("_")[1]) - elif output_format.startswith("ulaw_"): - return int(output_format.split("_")[1]) - return 22050 # default - - -@dataclass -class _TTSOptions: - """Internal configuration for ElevenLabs TTS""" - api_key: str - voice_id: str - voice_settings: VoiceSettings | None - model: TTSModels | str - base_url: str - encoding: TTSEncoding - sample_rate: int - word_tokenizer: WordTokenizer | SentenceTokenizer - inactivity_timeout: int - auto_mode: bool - - def get_ws_url(self) -> str: - """Get WebSocket URL for multi-stream API""" - base = self.base_url.replace("http://", "ws://").replace("https://", "wss://") - params = [ - f"model_id={self.model}", - f"output_format={self.encoding}", - ] - if self.auto_mode: - params.append("auto_mode=true") - params.append(f"inactivity_timeout={self.inactivity_timeout}") - - url = f"{base}/text-to-speech/{self.voice_id}/multi-stream-input?" - url += "&".join(params) - return url - - -class TTS(tts.TTS): - """ - ElevenLabs TTS Provider - - Provides high-quality, emotionally rich text-to-speech with voice cloning support. - Uses multi-stream WebSocket API for efficient concurrent synthesis. - - Example: - tts = elevenlabs.TTS( - api_key="your-api-key", - voice_id="voice-id", - model="eleven_turbo_v2_5", - ) - - # Streaming synthesis - stream = tts.stream() - stream.push_text("Hello world!") - stream.end_input() - - async for audio in stream: - # Process audio - pass - """ - - def __init__( - self, - *, - api_key: str | None = None, - voice_id: str = DEFAULT_VOICE_ID, - voice_settings: VoiceSettings | None = None, - model: TTSModels | str = "eleven_multilingual_v2", - encoding: TTSEncoding = "pcm_16000", - word_tokenizer: WordTokenizer | SentenceTokenizer | None = None, - inactivity_timeout: int = WS_INACTIVITY_TIMEOUT, - auto_mode: Optional[bool] = None, - base_url: str = API_BASE_URL, - ) -> None: - """ - Initialize ElevenLabs TTS. - - Args: - api_key: ElevenLabs API key. If not provided, reads from ELEVEN_API_KEY env var - voice_id: Voice ID to use (default: Rachel voice) - voice_settings: Voice settings for fine-tuning quality - model: TTS model to use (default: "eleven_multilingual_v2") - encoding: Audio encoding format (default: "pcm_16000") - word_tokenizer: Word/sentence tokenizer (default: blingfire for auto_mode) - inactivity_timeout: WebSocket inactivity timeout in seconds - auto_mode: Enable auto mode for optimized latency (recommended) - base_url: API base URL (default: https://api.elevenlabs.io/v1) - """ - sample_rate = _sample_rate_from_format(encoding) - - super().__init__( - capabilities=tts.TTSCapabilities(streaming=True), - sample_rate=sample_rate, - num_channels=1, - ) - - # Validate API key - elevenlabs_api_key = api_key or os.environ.get("ELEVEN_API_KEY") - if not elevenlabs_api_key: - raise ValueError( - "ElevenLabs API key is required. " - "Provide via api_key parameter or set ELEVEN_API_KEY environment variable" - ) - - # Configure tokenizer - if not word_tokenizer: - if auto_mode: - word_tokenizer = blingfire.SentenceTokenizer() - else: - from core.tokenize.basic import WordTokenizer as BasicWordTokenizer - word_tokenizer = BasicWordTokenizer(ignore_punctuation=False) - - # Store options - self._opts = _TTSOptions( - api_key=elevenlabs_api_key, - voice_id=voice_id, - voice_settings=voice_settings, - model=model, - base_url=base_url, - encoding=encoding, - sample_rate=sample_rate, - word_tokenizer=word_tokenizer, - inactivity_timeout=inactivity_timeout, - auto_mode=auto_mode, - ) - self._session = http_session() - # Connection management - self._current_connection: _Connection | None = None - self._connection_lock = asyncio.Lock() - - # Track active streams - self._streams: weakref.WeakSet[SynthesizeStream] = weakref.WeakSet() - - @property - def model(self) -> str: - """Get the model name""" - return self._opts.model - - @property - def provider(self) -> str: - """Get the provider name""" - return "ElevenLabs" - - def _ensure_session(self) -> aiohttp.ClientSession: - """Ensure HTTP session exists""" - return http_session() - - async def current_connection(self) -> _Connection: - """Get or create the current WebSocket connection""" - async with self._connection_lock: - if ( - self._current_connection - and self._current_connection.is_current - and not self._current_connection._closed - ): - return self._current_connection - - # Create new connection - session = self._ensure_session() - conn = _Connection(self._opts, session) - await conn.connect() - self._current_connection = conn - return conn - - async def list_voices(self) -> list[Voice]: - """List available voices from ElevenLabs API""" - session = self._ensure_session() - url = f"{self._opts.base_url}/voices" - headers = {"xi-api-key": self._opts.api_key} - - async with session.get(url, headers=headers) as resp: - resp.raise_for_status() - data = await resp.json() - - voices = [] - for voice_data in data.get("voices", []): - voices.append( - Voice( - id=voice_data["voice_id"], - name=voice_data["name"], - category=voice_data["category"], - ) - ) - return voices - - def stream(self, *, conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS) -> SynthesizeStream: - """ - Create a streaming synthesis session. - - Returns: - SynthesizeStream for incremental text input - """ - stream = SynthesizeStream(tts=self, conn_options=conn_options) - self._streams.add(stream) - return stream - - async def aclose(self) -> None: - """Close TTS provider and cleanup resources""" - # Close all active streams - for stream in list(self._streams): - await stream.aclose() - self._streams.clear() - - # Close connection - if self._current_connection: - await self._current_connection.aclose() - self._current_connection = None - - -class SynthesizeStream(tts.SynthesizeStream): - """Streaming synthesis using WebSocket (multi-stream)""" - - def __init__( - self, *, tts: TTS, conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS - ) -> None: - super().__init__(tts=tts, conn_options=conn_options) - self._tts: TTS = tts - self._sent_tokenizer_stream = self._tts._opts.word_tokenizer.stream() - - async def aclose(self) -> None: - """Close stream and cleanup""" - await self._sent_tokenizer_stream.aclose() - await super().aclose() - - async def _run(self, output_emitter: AudioEmitter) -> None: - """ - Streaming synthesis implementation using multi-stream WebSocket. - - This method: - 1. Connects to the shared WebSocket connection - 2. Registers this stream with the connection - 3. Sets up tokenizer - 4. Runs two parallel tasks: - - _input_task: Reads from input_ch → tokenizer - - _sentence_task: Tokenizer → Connection (which sends to WebSocket) - 5. The connection's recv loop handles audio data and routes it to this stream's emitter - """ - opts = self._tts._opts - request_id = shortuuid() - context_id = shortuuid() # Generate context_id upfront for registration - - # Initialize output emitter - output_emitter.initialize( - request_id=request_id, - sample_rate=opts.sample_rate, - num_channels=1, - stream=True, - ) - - # Get shared connection - try: - connection = await asyncio.wait_for( - self._tts.current_connection(), timeout=10 - ) - except asyncio.TimeoutError as e: - raise APITimeoutError("Could not connect to ElevenLabs", timeout=10) from e - except Exception as e: - raise APIConnectionError(f"Could not connect to ElevenLabs: {e}") from e - - # Create waiter for completion - waiter: asyncio.Future[None] = asyncio.get_event_loop().create_future() - # Register stream with context_id - connection.register_stream(context_id, output_emitter, waiter) - - # Define tasks - async def _input_task() -> None: - """Forward input from input_ch to tokenizer""" - try: - async for data in self._input_ch: - if isinstance(data, self._FlushSentinel): - self._sent_tokenizer_stream.flush() - continue - self._sent_tokenizer_stream.push_text(data) - finally: - self._sent_tokenizer_stream.end_input() - - async def _sentence_task() -> None: - """Send tokenized sentences to connection""" - try: - async for sentence_ev in self._sent_tokenizer_stream: - text = sentence_ev.token - formatted_text = f"{text} " # Always end with space - connection.send_content(_SynthesizeContent(context_id, formatted_text)) - finally: - connection.send_content(_SynthesizeContent(context_id, "", flush=True)) - connection.close_context(context_id) - - # Run tasks - input_t = asyncio.create_task(_input_task(), name="elevenlabs_input") - sentence_t = asyncio.create_task(_sentence_task(), name="elevenlabs_sentence") - - try: - await waiter - except asyncio.TimeoutError as e: - raise TimeoutError("ElevenLabs synthesis timed out") from e - except Exception as e: - logger.bind(tag=__name__).error(f"Synthesis error: {e}") - raise - finally: - await cancel_and_wait(input_t, sentence_t) - - -@dataclass -class _SynthesizeContent: - """Content to synthesize""" - context_id: str - text: str - flush: bool = False - - -@dataclass -class _CloseContext: - """Command to close a context""" - context_id: str - - -@dataclass -class _StreamData: - """Data for a registered stream""" - emitter: AudioEmitter - stream: SynthesizeStream | None - waiter: asyncio.Future[None] - timeout_timer: asyncio.TimerHandle | None = None - - -class _Connection: - """ - Manages a single WebSocket connection with send/recv loops. - - Supports multiple concurrent synthesis contexts (multi-stream). - """ - - def __init__(self, opts: _TTSOptions, session: aiohttp.ClientSession) -> None: - self._opts = opts - self._session = session - self._ws: aiohttp.ClientWebSocketResponse | None = None - self._is_current = True - self._active_contexts: set[str] = set() - self._input_queue: Chan[Union[_SynthesizeContent, _CloseContext]] = Chan() - self._context_data: dict[str, _StreamData] = {} - self._send_task: asyncio.Task | None = None - self._recv_task: asyncio.Task | None = None - self._closed = False - - @property - def is_current(self) -> bool: - """Check if this connection is current""" - return self._is_current - - def mark_non_current(self) -> None: - """Mark this connection as no longer current""" - self._is_current = False - - async def connect(self) -> None: - """Establish WebSocket connection and start send/recv loops""" - if self._ws or self._closed: - return - - url = self._opts.get_ws_url() - headers = {"xi-api-key": self._opts.api_key} - - try: - self._ws = await asyncio.wait_for( - self._session.ws_connect(url, headers=headers), - timeout=10, - ) - except asyncio.TimeoutError as e: - raise APITimeoutError( - "Connection to ElevenLabs WebSocket timed out", - timeout=10, - ) from e - except aiohttp.ClientError as e: - raise APIConnectionError( - f"Failed to connect to ElevenLabs WebSocket: {e}", - url=url, - ) from e - - self._send_task = asyncio.create_task(self._send_loop(), name="elevenlabs_send") - self._recv_task = asyncio.create_task(self._recv_loop(), name="elevenlabs_recv") - - def register_stream( - self, - context_id: str, - emitter: AudioEmitter, - done_fut: asyncio.Future[None], - ) -> None: - """Register a new synthesis stream""" - self._context_data[context_id] = _StreamData( - emitter=emitter, - stream=None, # Stream reference not needed - waiter=done_fut, - ) - - def send_content(self, content: _SynthesizeContent) -> None: - """Send synthesis content to the connection""" - if self._closed or not self._ws or self._ws.closed: - raise ConnectionError("WebSocket connection is closed") - self._input_queue.send_nowait(content) - - def close_context(self, context_id: str) -> None: - """Close a specific context""" - if self._closed or not self._ws or self._ws.closed: - raise ConnectionError("WebSocket connection is closed") - self._input_queue.send_nowait(_CloseContext(context_id)) - - async def _send_loop(self) -> None: - """Send loop - processes messages from input queue""" - try: - while not self._closed: - try: - msg = await self._input_queue.recv() - except Exception: - break - - if not self._ws or self._ws.closed: - break - - if isinstance(msg, _SynthesizeContent): - is_new_context = msg.context_id not in self._active_contexts - - # Skip if not current and new context - if not self._is_current and is_new_context: - continue - - # Initialize context - if is_new_context: - voice_settings_dict = None - if self._opts.voice_settings: - voice_settings_dict = _strip_nones( - dataclasses.asdict(self._opts.voice_settings) - ) - - init_pkt = { - "text": " ", - "context_id": msg.context_id, - } - if voice_settings_dict: - init_pkt["voice_settings"] = voice_settings_dict - - await self._ws.send_json(init_pkt) - self._active_contexts.add(msg.context_id) - - # Send text - pkt: dict[str, Any] = { - "text": msg.text, - "context_id": msg.context_id, - } - if msg.flush: - pkt["flush"] = True - - await self._ws.send_json(pkt) - - elif isinstance(msg, _CloseContext): - if msg.context_id in self._active_contexts: - close_pkt = { - "context_id": msg.context_id, - "close_context": True, - } - await self._ws.send_json(close_pkt) - - except Exception as e: - logger.bind(tag=__name__).error(f"Send loop error: {e}") - finally: - if not self._closed: - await self.aclose() - - async def _recv_loop(self) -> None: - """Receive loop - processes messages from WebSocket""" - try: - while not self._closed and self._ws and not self._ws.closed: - msg = await self._ws.receive() - - if msg.type in ( - aiohttp.WSMsgType.CLOSED, - aiohttp.WSMsgType.CLOSE, - aiohttp.WSMsgType.CLOSING, - ): - raise APIStatusError( - "ElevenLabs connection closed unexpectedly", request_id="" - ) - - if msg.type != aiohttp.WSMsgType.TEXT: - logger.bind(tag=__name__).warning(f"Unexpected message type: {msg.type}") - continue - - data = json.loads(msg.data) - context_id = data.get("contextId") - - if not context_id or context_id not in self._context_data: - continue - - ctx = self._context_data[context_id] - - # Check for errors - if error := data.get("error"): - logger.bind(tag=__name__).error(f"ElevenLabs error: {error}") - if not ctx.waiter.done(): - ctx.waiter.set_exception(RuntimeError(f"ElevenLabs error: {error}")) - self._cleanup_context(context_id) - continue - - # Start segment on first audio - if audio_b64 := data.get("audio"): - # Check if this is the first audio for this context - if context_id not in self._active_contexts: - ctx.emitter.start_segment(segment_id=context_id) - self._active_contexts.add(context_id) - - audio_bytes = base64.b64decode(audio_b64) - ctx.emitter.push(audio_bytes) - - # Check if final - if data.get("isFinal"): - if not ctx.waiter.done(): - ctx.waiter.set_result(None) - self._cleanup_context(context_id) - - if not self._is_current and not self._active_contexts: - logger.bind(tag=__name__).debug("No active contexts, shutting down") - break - - except Exception as e: - logger.bind(tag=__name__).error(f"Receive loop error: {e}") - for ctx in self._context_data.values(): - if not ctx.waiter.done(): - ctx.waiter.set_exception(e) - self._context_data.clear() - finally: - if not self._closed: - await self.aclose() - - def _cleanup_context(self, context_id: str) -> None: - """Clean up context state""" - self._context_data.pop(context_id, None) - self._active_contexts.discard(context_id) - - async def aclose(self) -> None: - """Close the connection and clean up""" - if self._closed: - return - - self._closed = True - self._input_queue.close() - - # Complete all waiters - for ctx in self._context_data.values(): - if not ctx.waiter.done(): - ctx.waiter.set_exception(ConnectionError("Connection closed")) - self._context_data.clear() - - # Close WebSocket - if self._ws: - await self._ws.close() - - # Cancel tasks - if self._send_task: - await cancel_and_wait(self._send_task) - if self._recv_task: - await cancel_and_wait(self._recv_task) - - self._ws = None - - -def _strip_nones(data: dict[str, Any]) -> dict[str, Any]: - """Remove None values from dictionary""" - return {k: v for k, v in data.items() if v is not None} - diff --git a/main/xiaozhi-server/custom_config.yaml b/main/xiaozhi-server/custom_config.yaml index a49111d41..416f6e209 100644 --- a/main/xiaozhi-server/custom_config.yaml +++ b/main/xiaozhi-server/custom_config.yaml @@ -627,12 +627,12 @@ TTS: output_dir: tmp/ # ============== SDK 版本TTS(推荐)============== # 使用官方SDK,代码更简洁、性能更好、维护成本更低 - CartesiaSDK: + Cartesia: # Cartesia TTS - SDK版本(推荐) # 官方SDK实现,低延迟,支持流式合成 # API Key获取地址:https://play.cartesia.ai/console # 或设置环境变量:export CARTESIA_API_KEY=your-api-key - type: cartesia_sdk + type: cartesia api_key: 你的Cartesia API密钥 # Voice ID或voice embedding voice_id: 你的语音ID @@ -645,12 +645,12 @@ TTS: # 采样率:8000, 16000, 22050, 24000, 44100等 sample_rate: 24000 output_dir: tmp/ - ElevenLabsSDK: + ElevenLabs: # ElevenLabs TTS - SDK版本(推荐) # 官方SDK实现,代码更简洁,维护成本更低,性能更好 # API Key获取地址:https://elevenlabs.io/app/settings/api-keys # 或设置环境变量:export ELEVEN_API_KEY=your-api-key - type: elevenlabs_sdk + type: elevenlabs api_key: 你的ElevenLabs API密钥 # Voice ID获取:https://elevenlabs.io/app/voice-library # 默认:21m00Tcm4TlvDq8ikWAM (Rachel) diff --git a/main/xiaozhi-server/start.sh b/main/xiaozhi-server/start.sh index fb52e8fe3..5f8b7699b 100755 --- a/main/xiaozhi-server/start.sh +++ b/main/xiaozhi-server/start.sh @@ -33,7 +33,7 @@ show_usage() { echo " Values: sg, us, local" echo "" echo " -a, --action Action to perform" - echo " Values: server, all" + echo " Values: server, web, all" echo "" echo " -h, --help Show this help message" echo "" @@ -43,13 +43,14 @@ show_usage() { echo " local - Local development (REGION=LOCAL)" echo "" echo "Action details:" - echo " server - Restart only xiaozhi-esp32-server" - echo " all - Start/restart all services (server, web, db, redis)" + echo " server - Rebuild and restart xiaozhi-esp32-server" + echo " web - Rebuild and restart xiaozhi-esp32-server-web (manager-api + manager-web)" + echo " all - Rebuild and restart server + web (does not rebuild db/redis)" echo "" echo "Examples:" echo " $0 --region sg --action server" - echo " $0 -r us -a all" - echo " $0 --region local --action server" + echo " $0 -r local -a web" + echo " $0 --region local --action all" exit 1 } @@ -113,13 +114,17 @@ case $ACTION in ACTION_NAME="Server Only" SERVICES="xiaozhi-esp32-server" ;; + web|WEB) + ACTION_NAME="Web Only (Manager API + Web)" + SERVICES="xiaozhi-esp32-server-web" + ;; all|ALL) - ACTION_NAME="All Services" - SERVICES="" + ACTION_NAME="Server + Web" + SERVICES="xiaozhi-esp32-server xiaozhi-esp32-server-web" ;; *) echo -e "${RED}Error: Invalid action '${ACTION}'${NC}" - echo "Valid actions: server, all" + echo "Valid actions: server, web, all" exit 1 ;; esac @@ -141,16 +146,13 @@ echo -e "${BLUE}Current container status:${NC}" docker ps --filter name=xiaozhi --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" 2>/dev/null || echo "No containers running" echo "" -# Confirm action -if [ "$ACTION" = "server" ] || [ "$ACTION" = "SERVER" ]; then - echo -e "${YELLOW}→ Restarting xiaozhi-esp32-server...${NC}" - echo "" - docker compose -f "$COMPOSE_FILE" restart xiaozhi-esp32-server -else - echo -e "${YELLOW}→ Starting all services...${NC}" - echo "" - docker compose -f "$COMPOSE_FILE" up -d -fi +# Execute action with rebuild +echo -e "${YELLOW}→ Rebuilding and starting: ${ACTION_NAME}${NC}" +echo -e "${CYAN} Services: ${SERVICES}${NC}" +echo "" + +# Use up --build -d to rebuild images and start containers +docker compose -f "$COMPOSE_FILE" up --build -d $SERVICES echo "" echo -e "${GREEN}✓ Operation completed${NC}" @@ -163,8 +165,8 @@ echo "" # Show logs option echo -e "${CYAN}To view logs, run:${NC}" -if [ "$ACTION" = "server" ] || [ "$ACTION" = "SERVER" ]; then - echo " docker compose -f $COMPOSE_FILE logs -f xiaozhi-esp32-server" +if [ -n "$SERVICES" ]; then + echo " docker compose -f $COMPOSE_FILE logs -f $SERVICES" else echo " docker compose -f $COMPOSE_FILE logs -f" fi From 007a35fd32d26eced17205c9739b4bc4107c6296 Mon Sep 17 00:00:00 2001 From: Harold Date: Wed, 5 Nov 2025 18:31:34 +0800 Subject: [PATCH 24/31] feat: remove live agent --- main/live-agent-api/.gitignore | 45 - main/live-agent-api/.python-version | 1 - main/live-agent-api/Dockerfile | 33 - main/live-agent-api/config/__init__.py | 0 main/live-agent-api/config/settings.py | 85 -- main/live-agent-api/docker-compose.yml | 61 -- main/live-agent-api/env_example.txt | 19 - main/live-agent-api/main.py | 109 --- main/live-agent-api/orm/__init__.py | 39 - main/live-agent-api/orm/agent/__init__.py | 11 - main/live-agent-api/orm/agent/model.py | 99 -- main/live-agent-api/orm/agent/repository.py | 123 --- main/live-agent-api/orm/base.py | 136 --- main/live-agent-api/orm/binding/__init__.py | 11 - main/live-agent-api/orm/binding/model.py | 91 -- main/live-agent-api/orm/binding/repository.py | 205 ---- main/live-agent-api/orm/device/__init__.py | 11 - main/live-agent-api/orm/device/model.py | 121 --- main/live-agent-api/orm/device/repository.py | 158 --- main/live-agent-api/pyproject.toml | 33 - main/live-agent-api/router/__init__.py | 15 - main/live-agent-api/router/agent.py | 334 ------- main/live-agent-api/router/binding.py | 169 ---- main/live-agent-api/router/device.py | 246 ----- main/live-agent-api/schemas/__init__.py | 61 -- main/live-agent-api/schemas/agent.py | 256 ----- main/live-agent-api/schemas/binding.py | 174 ---- main/live-agent-api/schemas/device.py | 237 ----- main/live-agent-api/services/__init__.py | 10 - main/live-agent-api/services/agent_service.py | 328 ------- .../services/binding_service.py | 289 ------ .../live-agent-api/services/device_service.py | 245 ----- main/live-agent-api/templates/__init__.py | 13 - .../templates/health_wellness.yaml | 70 -- .../templates/hospital_assistant.yaml | 57 -- .../templates/learning_companion.yaml | 68 -- main/live-agent-api/templates/loader.py | 118 --- .../templates/personal_assistant.yaml | 62 -- main/live-agent-api/utils/__init__.py | 18 - main/live-agent-api/utils/id_generator.py | 75 -- main/live-agent-api/utils/response.py | 126 --- main/live-agent-api/uv.lock | 910 ------------------ 42 files changed, 5272 deletions(-) delete mode 100644 main/live-agent-api/.gitignore delete mode 100644 main/live-agent-api/.python-version delete mode 100644 main/live-agent-api/Dockerfile delete mode 100644 main/live-agent-api/config/__init__.py delete mode 100644 main/live-agent-api/config/settings.py delete mode 100644 main/live-agent-api/docker-compose.yml delete mode 100644 main/live-agent-api/env_example.txt delete mode 100644 main/live-agent-api/main.py delete mode 100644 main/live-agent-api/orm/__init__.py delete mode 100644 main/live-agent-api/orm/agent/__init__.py delete mode 100644 main/live-agent-api/orm/agent/model.py delete mode 100644 main/live-agent-api/orm/agent/repository.py delete mode 100644 main/live-agent-api/orm/base.py delete mode 100644 main/live-agent-api/orm/binding/__init__.py delete mode 100644 main/live-agent-api/orm/binding/model.py delete mode 100644 main/live-agent-api/orm/binding/repository.py delete mode 100644 main/live-agent-api/orm/device/__init__.py delete mode 100644 main/live-agent-api/orm/device/model.py delete mode 100644 main/live-agent-api/orm/device/repository.py delete mode 100644 main/live-agent-api/pyproject.toml delete mode 100644 main/live-agent-api/router/__init__.py delete mode 100644 main/live-agent-api/router/agent.py delete mode 100644 main/live-agent-api/router/binding.py delete mode 100644 main/live-agent-api/router/device.py delete mode 100644 main/live-agent-api/schemas/__init__.py delete mode 100644 main/live-agent-api/schemas/agent.py delete mode 100644 main/live-agent-api/schemas/binding.py delete mode 100644 main/live-agent-api/schemas/device.py delete mode 100644 main/live-agent-api/services/__init__.py delete mode 100644 main/live-agent-api/services/agent_service.py delete mode 100644 main/live-agent-api/services/binding_service.py delete mode 100644 main/live-agent-api/services/device_service.py delete mode 100644 main/live-agent-api/templates/__init__.py delete mode 100644 main/live-agent-api/templates/health_wellness.yaml delete mode 100644 main/live-agent-api/templates/hospital_assistant.yaml delete mode 100644 main/live-agent-api/templates/learning_companion.yaml delete mode 100644 main/live-agent-api/templates/loader.py delete mode 100644 main/live-agent-api/templates/personal_assistant.yaml delete mode 100644 main/live-agent-api/utils/__init__.py delete mode 100644 main/live-agent-api/utils/id_generator.py delete mode 100644 main/live-agent-api/utils/response.py delete mode 100644 main/live-agent-api/uv.lock diff --git a/main/live-agent-api/.gitignore b/main/live-agent-api/.gitignore deleted file mode 100644 index 94bfd9467..000000000 --- a/main/live-agent-api/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# Python -__pycache__/ -*.py[cod] -*$py.class -*.so -.Python -*.egg-info/ -dist/ -build/ -*.egg - -# Virtual Environment -venv/ -env/ -.venv/ - -# UV -.uv/ - -# Environment variables -.env - -# IDE -.vscode/ -.idea/ -*.swp -*.swo -*~ - -# OS -.DS_Store -Thumbs.db - -# Logs -*.log -logs/ - -# Database -*.db -*.sqlite -*.sqlite3 - -# Docker -docker-compose.override.yml - diff --git a/main/live-agent-api/.python-version b/main/live-agent-api/.python-version deleted file mode 100644 index e4fba2183..000000000 --- a/main/live-agent-api/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.12 diff --git a/main/live-agent-api/Dockerfile b/main/live-agent-api/Dockerfile deleted file mode 100644 index 957050c37..000000000 --- a/main/live-agent-api/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# Live Agent Dashboard API Dockerfile - -FROM python:3.12-slim - -# Set working directory -WORKDIR /app - -# Install uv -RUN pip install --no-cache-dir uv - -# Copy project files -COPY pyproject.toml ./ -COPY main.py ./ -COPY config ./config -COPY models ./models -COPY schemas ./schemas -COPY router ./router -COPY services ./services -COPY utils ./utils - -# Install dependencies using uv -RUN uv pip install --system -r pyproject.toml - -# Expose port -EXPOSE 8080 - -# Health check -HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD python -c "import requests; requests.get('http://localhost:8080/health')" || exit 1 - -# Run application -CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] - diff --git a/main/live-agent-api/config/__init__.py b/main/live-agent-api/config/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/main/live-agent-api/config/settings.py b/main/live-agent-api/config/settings.py deleted file mode 100644 index 1482c607f..000000000 --- a/main/live-agent-api/config/settings.py +++ /dev/null @@ -1,85 +0,0 @@ -""" -Application Configuration - -Centralized configuration management using Pydantic Settings. -Configuration values are loaded from environment variables. -""" - -import logging -from typing import Literal -from pydantic import Field, PostgresDsn -from pydantic_settings import BaseSettings, SettingsConfigDict - - -class Settings(BaseSettings): - """Application settings loaded from environment variables""" - - # Application Configuration - app_env: Literal["development", "staging", "production"] = Field( - default="development", - description="Application environment" - ) - log_level: str = Field( - default="DEBUG", - description="Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)" - ) - - # API Configuration - api_prefix: str = Field( - default="/api/v1", - description="API route prefix" - ) - - # Database Configuration - database_url: PostgresDsn = Field( - ..., - description="PostgreSQL database URL" - ) - - # OpenAI Configuration - openai_api_key: str = Field( - ..., - description="OpenAI API key for AI features" - ) - openai_model: str = Field( - default="gpt-4o", - description="OpenAI model to use for prompt generation" - ) - - # Snowflake ID Generator Configuration - instance_id: int = Field( - default=1, - ge=0, - le=1023, - description="Instance ID for Snowflake ID generator (0-1023)" - ) - - model_config = SettingsConfigDict( - env_file=".env", - env_file_encoding="utf-8", - case_sensitive=False, - extra="ignore" - ) - - def configure_logging(self) -> None: - """Configure application logging based on settings""" - log_level_map = { - "DEBUG": logging.DEBUG, - "INFO": logging.INFO, - "WARNING": logging.WARNING, - "ERROR": logging.ERROR, - "CRITICAL": logging.CRITICAL, - } - - level = log_level_map.get(self.log_level.upper(), logging.INFO) - - logging.basicConfig( - level=level, - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", - datefmt="%Y-%m-%d %H:%M:%S" - ) - - -# Global settings instance -settings = Settings() - diff --git a/main/live-agent-api/docker-compose.yml b/main/live-agent-api/docker-compose.yml deleted file mode 100644 index 8b4a70e5b..000000000 --- a/main/live-agent-api/docker-compose.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: '3.8' - -services: - # PostgreSQL Database - postgres: - image: postgres:16-alpine - container_name: live-agent-db - environment: - POSTGRES_DB: live_agent_db - POSTGRES_USER: live_agent - POSTGRES_PASSWORD: password - ports: - - "5432:5432" - volumes: - - postgres_data:/var/lib/postgresql/data - healthcheck: - test: ["CMD-SHELL", "pg_isready -U live_agent"] - interval: 10s - timeout: 5s - retries: 5 - networks: - - live-agent-network - - # Live Agent Dashboard API - api: - build: - context: . - dockerfile: Dockerfile - container_name: live-agent-api - environment: - # Database - DATABASE_URL: postgresql+asyncpg://live_agent:password@postgres:5432/live_agent_db - - # OpenAI (use your own API key) - OPENAI_API_KEY: ${OPENAI_API_KEY:-sk-your-api-key-here} - OPENAI_MODEL: ${OPENAI_MODEL:-gpt-4o} - - # Snowflake ID Generator - INSTANCE_ID: ${INSTANCE_ID:-1} - - # Application - APP_ENV: ${APP_ENV:-development} - LOG_LEVEL: ${LOG_LEVEL:-INFO} - API_PREFIX: /api/v1 - ports: - - "8080:8080" - depends_on: - postgres: - condition: service_healthy - networks: - - live-agent-network - restart: unless-stopped - -volumes: - postgres_data: - driver: local - -networks: - live-agent-network: - driver: bridge - diff --git a/main/live-agent-api/env_example.txt b/main/live-agent-api/env_example.txt deleted file mode 100644 index b928b1947..000000000 --- a/main/live-agent-api/env_example.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copy this file to .env and fill in your values - -# Database Configuration -DATABASE_URL=postgresql+asyncpg://live_agent:password@localhost:5432/live_agent_db - -# OpenAI Configuration -OPENAI_API_KEY=sk-your-api-key-here -OPENAI_MODEL=gpt-4o - -# Snowflake ID Generator Configuration -# TODO: For production deployment, configure unique instance ID (0-1023) for each service instance -INSTANCE_ID=1 - -# Application Configuration -APP_ENV=development -LOG_LEVEL=DEBUG - -# API Configuration -API_PREFIX=/api/v1 diff --git a/main/live-agent-api/main.py b/main/live-agent-api/main.py deleted file mode 100644 index 64b2b6fb5..000000000 --- a/main/live-agent-api/main.py +++ /dev/null @@ -1,109 +0,0 @@ -""" -Live Agent Dashboard API - -FastAPI application entry point for the Live Agent configuration API. -""" - -import logging -from contextlib import asynccontextmanager -from fastapi import FastAPI -from fastapi.middleware.cors import CORSMiddleware - -from config.settings import settings -from orm import init_database, close_database -from utils import id_generator -from router import agent_router, device_router, binding_router - - -# Configure logging -settings.configure_logging() -logger = logging.getLogger(__name__) - - -@asynccontextmanager -async def lifespan(app: FastAPI): - """ - Application lifespan events handler - - Handles startup and shutdown operations. - """ - # Startup - logger.info("Starting Live Agent Dashboard API...") - - # Initialize ID generator (singleton, automatically initialized on first use) - logger.info(f"ID generator ready: {id_generator}") - - # Initialize database - await init_database() - - logger.info(f"Application started in {settings.app_env} mode") - - yield - - # Shutdown - logger.info("Shutting down Live Agent Dashboard API...") - await close_database() - logger.info("Application shutdown complete") - - -# Create FastAPI application -app = FastAPI( - title="Live Agent Dashboard API", - description=( - "API service for managing voice assistant agents, devices, and bindings.\n\n" - "This API provides comprehensive endpoints for:\n" - "- Agent Management: Create, configure, and manage voice assistant agents\n" - "- Device Management: Register and manage physical devices\n" - "- Binding Management: Link agents to devices\n" - ), - version="0.1.0", - lifespan=lifespan, -) - -# Configure CORS -app.add_middleware( - CORSMiddleware, - allow_origins=["*"], # TODO: Configure proper origins in production - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) - - -# Include routers -app.include_router(agent_router, prefix=settings.api_prefix) -app.include_router(device_router, prefix=settings.api_prefix) -app.include_router(binding_router, prefix=settings.api_prefix) - - -@app.get("/") -async def root(): - """Root endpoint - API health check""" - return { - "service": "Live Agent Dashboard API", - "version": "0.1.0", - "status": "running", - "environment": settings.app_env, - } - - -@app.get("/health") -async def health_check(): - """Health check endpoint""" - return { - "status": "healthy", - "environment": settings.app_env, - } - - -if __name__ == "__main__": - import uvicorn - - # Run with uvicorn - uvicorn.run( - "main:app", - host="0.0.0.0", - port=8080, - reload=settings.app_env == "development", - log_level=settings.log_level.lower(), - ) diff --git a/main/live-agent-api/orm/__init__.py b/main/live-agent-api/orm/__init__.py deleted file mode 100644 index 29c47b244..000000000 --- a/main/live-agent-api/orm/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -""" -ORM Layer - -Provides database models and data access for all entities. -Organized by business domain (agent, device, binding, etc.). -""" - -from orm.base import ( - Base, - get_db, - init_database, - close_database, - get_session_maker, -) - -from orm.agent import Agent, AgentRepository -from orm.device import Device, DeviceRepository -from orm.binding import DeviceAgentBinding, DeviceAgentBindingRepository - -__all__ = [ - # Base infrastructure - "Base", - "get_db", - "init_database", - "close_database", - "get_session_maker", - - # Agent domain - "Agent", - "AgentRepository", - - # Device domain - "Device", - "DeviceRepository", - - # Binding domain - "DeviceAgentBinding", - "DeviceAgentBindingRepository", -] diff --git a/main/live-agent-api/orm/agent/__init__.py b/main/live-agent-api/orm/agent/__init__.py deleted file mode 100644 index 841f84c35..000000000 --- a/main/live-agent-api/orm/agent/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -Agent ORM Module - -Exports Agent model and repository for convenient importing. -""" - -from orm.agent.model import Agent -from orm.agent.repository import AgentRepository - -__all__ = ["Agent", "AgentRepository"] - diff --git a/main/live-agent-api/orm/agent/model.py b/main/live-agent-api/orm/agent/model.py deleted file mode 100644 index 4c972f07c..000000000 --- a/main/live-agent-api/orm/agent/model.py +++ /dev/null @@ -1,99 +0,0 @@ -""" -Agent ORM Model - -Defines the Agent database table structure and basic data operations. -""" - -from datetime import datetime, timezone -from sqlalchemy import String, Text, DateTime -from sqlalchemy.orm import Mapped, mapped_column - -from orm.base import Base - - -class Agent(Base): - """ - Agent database model - - Represents a voice assistant agent with its configuration. - """ - __tablename__ = "live_agents" - - # Primary Key - id: Mapped[str] = mapped_column( - String(64), - primary_key=True, - comment="Agent unique ID" - ) - - # Basic Information - name: Mapped[str] = mapped_column( - String(255), - nullable=False, - comment="Agent display name" - ) - - language: Mapped[str] = mapped_column( - String(10), - nullable=False, - default="en", - comment="Agent language code (e.g., en, zh)" - ) - - # Agent Configuration - first_message: Mapped[str] = mapped_column( - Text, - nullable=True, - comment="Agent's greeting message" - ) - - system_prompt: Mapped[str] = mapped_column( - Text, - nullable=True, - comment="System prompt for agent behavior" - ) - - wake_word: Mapped[str] = mapped_column( - String(50), - nullable=False, - default="PLAUD", - comment="Wake word to activate agent" - ) - - # Timestamps - created_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=False, - default=lambda: datetime.now(timezone.utc), - comment="Creation timestamp" - ) - - updated_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=False, - default=lambda: datetime.now(timezone.utc), - onupdate=lambda: datetime.now(timezone.utc), - comment="Last update timestamp" - ) - - def __repr__(self) -> str: - return f"" - - def to_dict(self) -> dict: - """ - Convert model to dictionary - - Returns: - Dictionary representation of the agent - """ - return { - "id": self.id, - "name": self.name, - "language": self.language, - "firstMessage": self.first_message, - "systemPrompt": self.system_prompt, - "wakeWord": self.wake_word, - "createdAt": self.created_at.isoformat() if self.created_at else None, - "updatedAt": self.updated_at.isoformat() if self.updated_at else None, - } - diff --git a/main/live-agent-api/orm/agent/repository.py b/main/live-agent-api/orm/agent/repository.py deleted file mode 100644 index e585b6c1f..000000000 --- a/main/live-agent-api/orm/agent/repository.py +++ /dev/null @@ -1,123 +0,0 @@ -""" -Agent Repository - -Data access layer for Agent entity. -Encapsulates all database operations for Agent. -""" - -from typing import Optional -from sqlalchemy import select, func -from sqlalchemy.ext.asyncio import AsyncSession - -from orm.agent.model import Agent - - -class AgentRepository: - """Repository for Agent data access operations""" - - def __init__(self, db: AsyncSession): - """ - Initialize repository with database session - - Args: - db: SQLAlchemy async session - """ - self.db = db - - async def find_by_id(self, agent_id: str) -> Optional[Agent]: - """ - Find agent by ID - - Args: - agent_id: Agent unique ID - - Returns: - Agent instance or None if not found - """ - stmt = select(Agent).where(Agent.id == agent_id) - result = await self.db.execute(stmt) - return result.scalar_one_or_none() - - async def find_all( - self, - search: Optional[str] = None, - page: int = 1, - page_size: int = 20, - ) -> tuple[list[Agent], int]: - """ - Find all agents with filtering and pagination (sorted by creation time desc) - - Args: - search: Search keyword (searches in name and system_prompt) - page: Page number (starting from 1) - page_size: Number of items per page - - Returns: - Tuple of (agents list, total count) - """ - # Build base query - stmt = select(Agent) - - # Apply search filter - if search: - search_pattern = f"%{search}%" - stmt = stmt.where(Agent.name.ilike(search_pattern)) - - # Get total count - count_stmt = select(func.count()).select_from(stmt.subquery()) - total_result = await self.db.execute(count_stmt) - total = total_result.scalar_one() - - # Apply sorting - stmt = stmt.order_by(Agent.created_at.desc()) - - # Apply pagination - offset = (page - 1) * page_size - stmt = stmt.offset(offset).limit(page_size) - - # Execute query - result = await self.db.execute(stmt) - agents = list(result.scalars().all()) - - return agents, total - - async def save(self, agent: Agent) -> Agent: - """ - Save or update agent - - Args: - agent: Agent instance to save - - Returns: - Saved agent instance - """ - self.db.add(agent) - await self.db.flush() - await self.db.refresh(agent) - return agent - - async def delete(self, agent: Agent) -> None: - """ - Delete agent - - Args: - agent: Agent instance to delete - """ - await self.db.delete(agent) - await self.db.flush() - - async def exists(self, agent_id: str) -> bool: - """ - Check if agent exists - - Args: - agent_id: Agent unique ID - - Returns: - True if agent exists, False otherwise - """ - stmt = select(func.count()).where(Agent.id == agent_id) - result = await self.db.execute(stmt) - count = result.scalar_one() - return count > 0 - diff --git a/main/live-agent-api/orm/base.py b/main/live-agent-api/orm/base.py deleted file mode 100644 index 529cbb51a..000000000 --- a/main/live-agent-api/orm/base.py +++ /dev/null @@ -1,136 +0,0 @@ -""" -ORM Base Infrastructure - -Database configuration and utilities for SQLAlchemy ORM. -Provides the declarative base, engine management, and session handling. -""" - -import logging -from typing import AsyncGenerator -from sqlalchemy.ext.asyncio import ( - create_async_engine, - AsyncSession, - async_sessionmaker, - AsyncEngine -) -from sqlalchemy.orm import declarative_base - -from config.settings import settings - -logger = logging.getLogger(__name__) - -# SQLAlchemy declarative base for all ORM models -Base = declarative_base() - -# Global instances -_engine: AsyncEngine | None = None -_async_session_maker: async_sessionmaker[AsyncSession] | None = None - - -def get_engine() -> AsyncEngine: - """ - Get or create the global async database engine - - Returns: - Async SQLAlchemy engine instance - """ - global _engine - - if _engine is None: - logger.info("Creating database engine") - _engine = create_async_engine( - str(settings.database_url), - echo=settings.app_env == "development", - pool_size=10, - max_overflow=20, - pool_pre_ping=True, - ) - - return _engine - - -def get_session_maker() -> async_sessionmaker[AsyncSession]: - """ - Get or create the global async session maker - - Returns: - Async session maker instance - """ - global _async_session_maker - - if _async_session_maker is None: - engine = get_engine() - _async_session_maker = async_sessionmaker( - engine, - class_=AsyncSession, - expire_on_commit=False, - autocommit=False, - autoflush=False, - ) - - return _async_session_maker - - -async def get_db() -> AsyncGenerator[AsyncSession, None]: - """ - FastAPI dependency function to get database session - - Yields: - Async database session - - Example: - ```python - @router.get("/items") - async def get_items(db: AsyncSession = Depends(get_db)): - result = await db.execute(select(Item)) - return result.scalars().all() - ``` - """ - session_maker = get_session_maker() - async with session_maker() as session: - try: - yield session - await session.commit() - except Exception: - await session.rollback() - raise - finally: - await session.close() - - -async def init_database() -> None: - """ - Initialize database tables - - Creates all tables defined in SQLAlchemy models. - Should be called once during application startup in lifespan. - """ - engine = get_engine() - - logger.info("Initializing database tables...") - async with engine.begin() as conn: - # Import all models to ensure they are registered with Base - from orm.agent import Agent # noqa: F401 - # Future: from orm.device import Device - # Future: from orm.binding import Binding - - # Create all tables - await conn.run_sync(Base.metadata.create_all) - - logger.info("Database tables initialized successfully") - - -async def close_database() -> None: - """ - Close database connections - - Should be called during application shutdown in lifespan. - """ - global _engine - - if _engine is not None: - logger.info("Closing database connections...") - await _engine.dispose() - _engine = None - logger.info("Database connections closed") - diff --git a/main/live-agent-api/orm/binding/__init__.py b/main/live-agent-api/orm/binding/__init__.py deleted file mode 100644 index 9de827b63..000000000 --- a/main/live-agent-api/orm/binding/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -DeviceAgentBinding ORM Package - -Exports DeviceAgentBinding model and repository. -""" - -from .model import DeviceAgentBinding -from .repository import DeviceAgentBindingRepository - -__all__ = ["DeviceAgentBinding", "DeviceAgentBindingRepository"] - diff --git a/main/live-agent-api/orm/binding/model.py b/main/live-agent-api/orm/binding/model.py deleted file mode 100644 index c6bd0e922..000000000 --- a/main/live-agent-api/orm/binding/model.py +++ /dev/null @@ -1,91 +0,0 @@ -""" -DeviceAgentBinding ORM Model - -Defines the DeviceAgentBinding database table structure for linking devices and agents. -""" - -from datetime import datetime, timezone -from sqlalchemy import String, DateTime, ForeignKey, UniqueConstraint -from sqlalchemy.orm import Mapped, mapped_column - -from orm.base import Base - - -class DeviceAgentBinding(Base): - """ - DeviceAgentBinding database model - - Represents the binding relationship between a device and an agent. - Each device can only be bound to one agent at a time. - """ - __tablename__ = "device_agent_bindings" - __table_args__ = ( - UniqueConstraint('device_id', name='uq_device_id'), - ) - - # Primary Key - id: Mapped[str] = mapped_column( - String(64), - primary_key=True, - comment="Binding unique ID (ULID)" - ) - - # Foreign Keys - device_id: Mapped[str] = mapped_column( - String(64), - ForeignKey("devices.id", ondelete="CASCADE"), - nullable=False, - unique=True, - index=True, - comment="Device ID (FK)" - ) - - agent_id: Mapped[str] = mapped_column( - String(64), - ForeignKey("agents.id", ondelete="CASCADE"), - nullable=False, - index=True, - comment="Agent ID (FK)" - ) - - # Binding Information - status: Mapped[str] = mapped_column( - String(20), - nullable=False, - default="bound", - comment="Binding status (bound, unbound)" - ) - - # Timestamps - created_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=False, - default=lambda: datetime.now(timezone.utc), - comment="Creation timestamp" - ) - - updated_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=False, - default=lambda: datetime.now(timezone.utc), - onupdate=lambda: datetime.now(timezone.utc), - comment="Last update timestamp" - ) - - - def to_dict(self) -> dict: - """ - Convert model to dictionary - - Returns: - Dictionary representation of the binding - """ - return { - "id": self.id, - "deviceId": self.device_id, - "agentId": self.agent_id, - "status": self.status, - "createdAt": self.created_at.isoformat() if self.created_at else None, - "updatedAt": self.updated_at.isoformat() if self.updated_at else None, - } - diff --git a/main/live-agent-api/orm/binding/repository.py b/main/live-agent-api/orm/binding/repository.py deleted file mode 100644 index d6955de52..000000000 --- a/main/live-agent-api/orm/binding/repository.py +++ /dev/null @@ -1,205 +0,0 @@ -""" -DeviceAgentBinding Repository - -Data access layer for DeviceAgentBinding entity. -Encapsulates all database operations for device-agent bindings. -""" - -from typing import Optional -from sqlalchemy import select, func, or_ -from sqlalchemy.ext.asyncio import AsyncSession - -from orm.binding.model import DeviceAgentBinding - - -class DeviceAgentBindingRepository: - """Repository for DeviceAgentBinding data access operations""" - - def __init__(self, db: AsyncSession): - """ - Initialize repository with database session - - Args: - db: SQLAlchemy async session - """ - self.db = db - - async def find_by_id(self, binding_id: str) -> Optional[DeviceAgentBinding]: - """ - Find binding by ID - - Args: - binding_id: Binding unique ID - - Returns: - DeviceAgentBinding instance or None if not found - """ - stmt = select(DeviceAgentBinding).where(DeviceAgentBinding.id == binding_id) - result = await self.db.execute(stmt) - return result.scalar_one_or_none() - - async def find_by_device_id(self, device_id: str) -> Optional[DeviceAgentBinding]: - """ - Find binding by device ID - - Args: - device_id: Device unique ID - - Returns: - DeviceAgentBinding instance or None if not found - """ - stmt = select(DeviceAgentBinding).where(DeviceAgentBinding.device_id == device_id) - result = await self.db.execute(stmt) - return result.scalar_one_or_none() - - async def find_by_agent_id(self, agent_id: str) -> list[DeviceAgentBinding]: - """ - Find all bindings for an agent - - Args: - agent_id: Agent unique ID - - Returns: - List of DeviceAgentBinding instances - """ - stmt = select(DeviceAgentBinding).where(DeviceAgentBinding.agent_id == agent_id) - result = await self.db.execute(stmt) - return list(result.scalars().all()) - - async def find_by_device_and_agent( - self, - device_id: str, - agent_id: str - ) -> Optional[DeviceAgentBinding]: - """ - Find binding by device ID and agent ID - - Args: - device_id: Device unique ID - agent_id: Agent unique ID - - Returns: - DeviceAgentBinding instance or None if not found - """ - stmt = select(DeviceAgentBinding).where( - DeviceAgentBinding.device_id == device_id, - DeviceAgentBinding.agent_id == agent_id - ) - result = await self.db.execute(stmt) - return result.scalar_one_or_none() - - async def find_all( - self, - device_id: Optional[str] = None, - agent_id: Optional[str] = None, - status: Optional[str] = None, - page: int = 1, - page_size: int = 20, - sort_by: str = "created_at", - sort_order: str = "desc", - ) -> tuple[list[DeviceAgentBinding], int]: - """ - Find all bindings with filtering, pagination and sorting - - Args: - device_id: Filter by device ID - agent_id: Filter by agent ID - status: Filter by status - page: Page number (starting from 1) - page_size: Number of items per page - sort_by: Field to sort by - sort_order: Sort direction ('asc' or 'desc') - - Returns: - Tuple of (bindings list, total count) - """ - # Build base query - stmt = select(DeviceAgentBinding) - - # Apply filters - if device_id: - stmt = stmt.where(DeviceAgentBinding.device_id == device_id) - - if agent_id: - stmt = stmt.where(DeviceAgentBinding.agent_id == agent_id) - - if status: - stmt = stmt.where(DeviceAgentBinding.status == status) - - # Get total count - count_stmt = select(func.count()).select_from(stmt.subquery()) - total_result = await self.db.execute(count_stmt) - total = total_result.scalar_one() - - # Apply sorting - sort_column = getattr(DeviceAgentBinding, sort_by, DeviceAgentBinding.created_at) - if sort_order == "desc": - stmt = stmt.order_by(sort_column.desc()) - else: - stmt = stmt.order_by(sort_column.asc()) - - # Apply pagination - offset = (page - 1) * page_size - stmt = stmt.offset(offset).limit(page_size) - - # Execute query - result = await self.db.execute(stmt) - bindings = list(result.scalars().all()) - - return bindings, total - - async def save(self, binding: DeviceAgentBinding) -> DeviceAgentBinding: - """ - Save or update binding - - Args: - binding: DeviceAgentBinding instance to save - - Returns: - Saved binding instance - """ - self.db.add(binding) - await self.db.flush() - await self.db.refresh(binding) - return binding - - async def delete(self, binding: DeviceAgentBinding) -> None: - """ - Delete binding - - Args: - binding: DeviceAgentBinding instance to delete - """ - await self.db.delete(binding) - await self.db.flush() - - async def exists(self, binding_id: str) -> bool: - """ - Check if binding exists - - Args: - binding_id: Binding unique ID - - Returns: - True if binding exists, False otherwise - """ - stmt = select(func.count()).where(DeviceAgentBinding.id == binding_id) - result = await self.db.execute(stmt) - count = result.scalar_one() - return count > 0 - - async def device_has_binding(self, device_id: str) -> bool: - """ - Check if device already has a binding - - Args: - device_id: Device unique ID - - Returns: - True if device has binding, False otherwise - """ - stmt = select(func.count()).where(DeviceAgentBinding.device_id == device_id) - result = await self.db.execute(stmt) - count = result.scalar_one() - return count > 0 - diff --git a/main/live-agent-api/orm/device/__init__.py b/main/live-agent-api/orm/device/__init__.py deleted file mode 100644 index 8c892ea16..000000000 --- a/main/live-agent-api/orm/device/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -""" -Device ORM Package - -Exports Device model and repository. -""" - -from .model import Device -from .repository import DeviceRepository - -__all__ = ["Device", "DeviceRepository"] - diff --git a/main/live-agent-api/orm/device/model.py b/main/live-agent-api/orm/device/model.py deleted file mode 100644 index 1b3acc9e0..000000000 --- a/main/live-agent-api/orm/device/model.py +++ /dev/null @@ -1,121 +0,0 @@ -""" -Device ORM Model - -Defines the Device database table structure and basic data operations. -""" - -from datetime import datetime, timezone -from sqlalchemy import String, Text, DateTime -from sqlalchemy.orm import Mapped, mapped_column - -from orm.base import Base - - -class Device(Base): - """ - Device database model - - Represents a physical device that can be bound to agents. - """ - __tablename__ = "devices" - - # Primary Key - id: Mapped[str] = mapped_column( - String(64), - primary_key=True, - comment="Device unique ID (ULID)" - ) - - # Basic Information - name: Mapped[str] = mapped_column( - String(255), - nullable=False, - comment="Device display name" - ) - - device_id: Mapped[str] = mapped_column( - String(255), - nullable=False, - unique=True, - index=True, - comment="Device hardware ID" - ) - - device_model: Mapped[str] = mapped_column( - String(100), - nullable=True, - comment="Device model name (e.g., PLAUD NOTE, ESP32-S3)" - ) - - firmware_version: Mapped[str] = mapped_column( - String(50), - nullable=True, - comment="Firmware version" - ) - - # Device Status - status: Mapped[str] = mapped_column( - String(20), - nullable=False, - default="offline", - comment="Device connection status (online, offline)" - ) - - last_seen_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=True, - comment="Last seen timestamp" - ) - - description: Mapped[str] = mapped_column( - Text, - nullable=True, - comment="Device description" - ) - - meta_data: Mapped[str] = mapped_column( - Text, - nullable=True, - comment="Device metadata (JSON format)" - ) - - # Timestamps - created_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=False, - default=lambda: datetime.now(timezone.utc), - comment="Creation timestamp" - ) - - updated_at: Mapped[datetime] = mapped_column( - DateTime, - nullable=False, - default=lambda: datetime.now(timezone.utc), - onupdate=lambda: datetime.now(timezone.utc), - comment="Last update timestamp" - ) - - def __repr__(self) -> str: - return f"" - - def to_dict(self) -> dict: - """ - Convert model to dictionary - - Returns: - Dictionary representation of the device - """ - return { - "id": self.id, - "name": self.name, - "deviceId": self.device_id, - "deviceModel": self.device_model, - "firmwareVersion": self.firmware_version, - "status": self.status, - "lastSeenAt": self.last_seen_at.isoformat() if self.last_seen_at else None, - "description": self.description, - "metaData": self.meta_data, - "createdAt": self.created_at.isoformat() if self.created_at else None, - "updatedAt": self.updated_at.isoformat() if self.updated_at else None, - } - diff --git a/main/live-agent-api/orm/device/repository.py b/main/live-agent-api/orm/device/repository.py deleted file mode 100644 index 5e868d5ae..000000000 --- a/main/live-agent-api/orm/device/repository.py +++ /dev/null @@ -1,158 +0,0 @@ -""" -Device Repository - -Data access layer for Device entity. -Encapsulates all database operations for Device. -""" - -from typing import Optional -from sqlalchemy import select, func -from sqlalchemy.ext.asyncio import AsyncSession - -from orm.device.model import Device - - -class DeviceRepository: - """Repository for Device data access operations""" - - def __init__(self, db: AsyncSession): - """ - Initialize repository with database session - - Args: - db: SQLAlchemy async session - """ - self.db = db - - async def find_by_id(self, device_id: str) -> Optional[Device]: - """ - Find device by ID - - Args: - device_id: Device unique ID - - Returns: - Device instance or None if not found - """ - stmt = select(Device).where(Device.id == device_id) - result = await self.db.execute(stmt) - return result.scalar_one_or_none() - - async def find_by_device_id(self, device_id: str) -> Optional[Device]: - """ - Find device by hardware device ID - - Args: - device_id: Device hardware ID - - Returns: - Device instance or None if not found - """ - stmt = select(Device).where(Device.device_id == device_id) - result = await self.db.execute(stmt) - return result.scalar_one_or_none() - - async def find_all( - self, - search: Optional[str] = None, - status: Optional[str] = None, - page: int = 1, - page_size: int = 20, - ) -> tuple[list[Device], int]: - """ - Find all devices with filtering and pagination (sorted by creation time desc) - - Args: - search: Search keyword (searches in name and device_id) - status: Filter by status - page: Page number (starting from 1) - page_size: Number of items per page - - Returns: - Tuple of (devices list, total count) - """ - # Build base query - stmt = select(Device) - - # Apply search filter - if search: - search_pattern = f"%{search}%" - stmt = stmt.where(Device.name.ilike(search_pattern)) - - # Apply status filter - if status: - stmt = stmt.where(Device.status == status) - - # Get total count - count_stmt = select(func.count()).select_from(stmt.subquery()) - total_result = await self.db.execute(count_stmt) - total = total_result.scalar_one() - - # Apply sorting (fixed: created_at desc) - stmt = stmt.order_by(Device.created_at.desc()) - - # Apply pagination - offset = (page - 1) * page_size - stmt = stmt.offset(offset).limit(page_size) - - # Execute query - result = await self.db.execute(stmt) - devices = list(result.scalars().all()) - - return devices, total - - async def save(self, device: Device) -> Device: - """ - Save or update device - - Args: - device: Device instance to save - - Returns: - Saved device instance - """ - self.db.add(device) - await self.db.flush() - await self.db.refresh(device) - return device - - async def delete(self, device: Device) -> None: - """ - Delete device - - Args: - device: Device instance to delete - """ - await self.db.delete(device) - await self.db.flush() - - async def exists(self, device_id: str) -> bool: - """ - Check if device exists - - Args: - device_id: Device unique ID - - Returns: - True if device exists, False otherwise - """ - stmt = select(func.count()).where(Device.id == device_id) - result = await self.db.execute(stmt) - count = result.scalar_one() - return count > 0 - - async def device_id_exists(self, device_id: str) -> bool: - """ - Check if hardware device ID exists - - Args: - device_id: Device hardware ID - - Returns: - True if device_id exists, False otherwise - """ - stmt = select(func.count()).where(Device.device_id == device_id) - result = await self.db.execute(stmt) - count = result.scalar_one() - return count > 0 - diff --git a/main/live-agent-api/pyproject.toml b/main/live-agent-api/pyproject.toml deleted file mode 100644 index c143d88ad..000000000 --- a/main/live-agent-api/pyproject.toml +++ /dev/null @@ -1,33 +0,0 @@ -[project] -name = "live-agent-api" -version = "0.1.0" -description = "Live Agent Dashboard API - Agent configuration and management service" -requires-python = ">=3.12" -dependencies = [ - "fastapi>=0.115.0", - "uvicorn[standard]>=0.32.0", - "sqlalchemy>=2.0.36", - "asyncpg>=0.30.0", - "pydantic>=2.9.0", - "pydantic-settings>=2.6.0", - "openai>=1.54.0", - "python-dotenv>=1.0.0", - "httpx>=0.27.0", - "python-ulid>=2.7.0", - "pyyaml>=6.0.0", -] - -[dependency-groups] -dev = [ - "pytest>=8.3.0", - "pytest-asyncio>=0.24.0", - "black>=24.10.0", - "ruff>=0.7.0", -] - -[tool.hatch.build.targets.wheel] -packages = ["config", "models", "schemas", "router", "services", "utils"] - -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" diff --git a/main/live-agent-api/router/__init__.py b/main/live-agent-api/router/__init__.py deleted file mode 100644 index 5803f0a4f..000000000 --- a/main/live-agent-api/router/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -""" -API Routers - -FastAPI route handlers for all API endpoints. -""" - -from router.agent import router as agent_router -from router.device import router as device_router -from router.binding import router as binding_router - -__all__ = [ - "agent_router", - "device_router", - "binding_router", -] diff --git a/main/live-agent-api/router/agent.py b/main/live-agent-api/router/agent.py deleted file mode 100644 index 22a64add4..000000000 --- a/main/live-agent-api/router/agent.py +++ /dev/null @@ -1,334 +0,0 @@ -""" -Agent Router - -API endpoints for Agent management. -""" - -import logging -from typing import Annotated -from fastapi import APIRouter, Depends, HTTPException, Query -from sqlalchemy.ext.asyncio import AsyncSession - -from orm import get_db -from services.agent_service import AgentService, get_agent_service -from schemas.agent import ( - AgentCreate, - AgentUpdate, - AgentDuplicate, - AgentResponse, - AgentListQuery, - GeneratePromptRequest, - GeneratePromptResponse, -) -from utils.response import ( - ApiResponse, - success_response, - error_response, - paginated_response, -) -from templates import TemplateLoader - - -logger = logging.getLogger(__name__) - -router = APIRouter(prefix="/agent", tags=["agent"]) - - -@router.get("/") -async def get_agent_list( - search: Annotated[str | None, Query(description="Search keyword")] = None, - page: Annotated[int, Query(ge=1, description="Page number")] = 1, - pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 20, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get Agent list with search and pagination (sorted by creation time desc) - - - **search**: Search keyword (searches in name and system prompt) - - **page**: Page number (starting from 1) - - **pageSize**: Number of items per page (1-100, default: 20) - - Returns paginated list of agents sorted by creation time (newest first) with total count. - """ - try: - # Create query object - query = AgentListQuery( - search=search, - page=page, - page_size=pageSize, - ) - - # Get service - service = get_agent_service(db) - - # Get agents - agents, total = await service.get_agent_list(query) - - # Convert to response format - agent_responses = [ - AgentResponse.model_validate(agent) for agent in agents - ] - - # Create paginated response - pagination_data = paginated_response( - items=agent_responses, - total=total, - page=page, - page_size=pageSize, - ) - - return success_response(data=pagination_data) - - except Exception as e: - logger.error(f"Error getting agent list: {str(e)}") - return error_response( - message=f"Failed to get agent list: {str(e)}", - code=500 - ) - - -@router.get("/{agent_id}") -async def get_agent_detail( - agent_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get Agent details by ID - - - **agent_id**: Agent unique ID - - Returns detailed agent information. - """ - try: - service = get_agent_service(db) - agent = await service.get_agent_by_id(agent_id) - - if not agent: - return error_response( - message=f"Agent not found: {agent_id}", - code=404 - ) - - agent_response = AgentResponse.model_validate(agent) - return success_response(data=agent_response) - - except Exception as e: - logger.error(f"Error getting agent detail: {str(e)}") - return error_response( - message=f"Failed to get agent detail: {str(e)}", - code=500 - ) - - -@router.post("/") -async def create_agent( - agent_data: AgentCreate, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Create a new Agent - - Request body: - - **name**: Agent display name (required) - - **template**: Agent template type (default: blank) - - **language**: Language code, e.g., en, zh (default: en) - - **firstMessage**: Greeting message (optional) - - **systemPrompt**: System prompt for behavior (optional) - - **wakeWord**: Wake word to activate agent (default: PLAUD) - - Returns the created agent with generated ID. - """ - try: - service = get_agent_service(db) - agent = await service.create_agent(agent_data) - - agent_response = AgentResponse.model_validate(agent) - return success_response( - data=agent_response, - message="Agent created successfully", - code=201 - ) - - except ValueError as e: - # Template validation errors - logger.warning(f"Validation error creating agent: {str(e)}") - return error_response( - message=str(e), - code=400 - ) - except Exception as e: - logger.error(f"Error creating agent: {str(e)}") - return error_response( - message=f"Failed to create agent: {str(e)}", - code=500 - ) - - -@router.put("/{agent_id}") -async def update_agent( - agent_id: str, - agent_data: AgentUpdate, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Update Agent configuration - - - **agent_id**: Agent unique ID - - Request body (all fields optional): - - **name**: Agent display name - - **language**: Language code - - **firstMessage**: Greeting message - - **systemPrompt**: System prompt for behavior - - **wakeWord**: Wake word to activate agent - - Returns the updated agent information. - """ - try: - service = get_agent_service(db) - agent = await service.update_agent(agent_id, agent_data) - - if not agent: - return error_response( - message=f"Agent not found: {agent_id}", - code=404 - ) - - agent_response = AgentResponse.model_validate(agent) - return success_response( - data=agent_response, - message="Agent updated successfully" - ) - - except Exception as e: - logger.error(f"Error updating agent: {str(e)}") - return error_response( - message=f"Failed to update agent: {str(e)}", - code=500 - ) - - -@router.delete("/{agent_id}") -async def delete_agent( - agent_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Delete an Agent - - - **agent_id**: Agent unique ID - - Deletes the agent if no binding relationships exist. - Returns success message if deleted. - """ - try: - service = get_agent_service(db) - deleted = await service.delete_agent(agent_id) - - if not deleted: - return error_response( - message=f"Agent not found: {agent_id}", - code=404 - ) - - return success_response( - data={"id": agent_id}, - message="Agent deleted successfully" - ) - - except Exception as e: - logger.error(f"Error deleting agent: {str(e)}") - return error_response( - message=f"Failed to delete agent: {str(e)}", - code=500 - ) - - -@router.post("/{agent_id}/duplicate") -async def duplicate_agent( - agent_id: str, - duplicate_data: AgentDuplicate, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Duplicate an existing Agent - - - **agent_id**: Source agent ID to duplicate - - Request body: - - **name**: Name for the duplicated agent (required) - - Creates a copy of the agent with a new ID and name. - Returns the newly created agent. - """ - try: - service = get_agent_service(db) - new_agent = await service.duplicate_agent( - agent_id, - duplicate_data.name - ) - - if not new_agent: - return error_response( - message=f"Source agent not found: {agent_id}", - code=404 - ) - - agent_response = AgentResponse.model_validate(new_agent) - return success_response( - data=agent_response, - message="Agent duplicated successfully", - code=201 - ) - - except Exception as e: - logger.error(f"Error duplicating agent: {str(e)}") - return error_response( - message=f"Failed to duplicate agent: {str(e)}", - code=500 - ) - - -@router.post("/generate-prompt") -async def generate_system_prompt( - request: GeneratePromptRequest, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Generate system prompt using AI - - Request body: - - **description**: Description of the agent's purpose and requirements (required) - - **currentPrompt**: Existing system prompt to refine or build upon (optional) - - Uses OpenAI to generate a professional system prompt that follows the 6-module structure: - 1. Personality - Agent's character and communication style - 2. Environment - Context and operating setting - 3. Tone - Language tone and interaction manner - 4. Goal - Primary objectives and purposes - 5. Guardrails - Rules, limitations, and ethical boundaries - 6. Tools - Available capabilities and functions - - If currentPrompt is provided, the AI will refine it based on the description. - Otherwise, it creates a new prompt from scratch. - """ - try: - service = get_agent_service(db) - generated_prompt = await service.generate_system_prompt(request) - - response_data = GeneratePromptResponse( - systemPrompt=generated_prompt - ) - - return success_response( - data=response_data, - message="System prompt generated successfully" - ) - - except Exception as e: - logger.error(f"Error generating prompt: {str(e)}") - return error_response( - message=f"Failed to generate prompt: {str(e)}", - code=500 - ) - diff --git a/main/live-agent-api/router/binding.py b/main/live-agent-api/router/binding.py deleted file mode 100644 index 6bdd4d534..000000000 --- a/main/live-agent-api/router/binding.py +++ /dev/null @@ -1,169 +0,0 @@ -""" -DeviceAgentBinding Router - -API endpoints for Device-Agent binding management. -""" - -import logging -from fastapi import APIRouter, Depends -from sqlalchemy.ext.asyncio import AsyncSession - -from orm import get_db -from services.binding_service import get_binding_service -from schemas.binding import BindingOperation, BindingResponse -from utils.response import ApiResponse, success_response, error_response - - -logger = logging.getLogger(__name__) - -router = APIRouter(prefix="/bindings", tags=["bindings"]) - - -@router.get("/device/{device_id}") -async def get_bindings_by_device( - device_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get device-agent binding information by device ID - - - **device_id**: Device unique ID - - Returns the binding relationship for the specified device, or null if not bound. - """ - try: - service = get_binding_service(db) - binding = await service.get_binding_by_device_id(device_id) - - if not binding: - # No binding is not an error - return success with null data - return success_response( - data=None - ) - - binding_response = BindingResponse.model_validate(binding) - return success_response(data=binding_response) - - except Exception as e: - logger.error(f"Error getting device binding: {str(e)}") - return error_response( - message=f"Failed to get device binding: {str(e)}", - code=500 - ) - - -@router.get("/agent/{agent_id}") -async def get_bindings_by_agent( - agent_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get all device bindings for an agent - - - **agent_id**: Agent unique ID - - Returns all devices bound to the specified agent (empty list if none). - """ - try: - service = get_binding_service(db) - bindings = await service.get_bindings_by_agent_id(agent_id) - - binding_responses = [ - BindingResponse.model_validate(binding) for binding in bindings - ] - - return success_response( - data=binding_responses, - message=f"Found {len(bindings)} device(s) bound to agent" - ) - - except Exception as e: - logger.error(f"Error getting agent device bindings: {str(e)}") - return error_response( - message=f"Failed to get agent device bindings: {str(e)}", - code=500 - ) - - -@router.post("/bind") -async def create_device_agent_binding( - binding_data: BindingOperation, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Create a device-agent binding (bind device to agent) - - Request body: - - **deviceId**: Device unique ID (required) - - **agentId**: Agent unique ID (required) - - Creates a binding relationship between the specified device and agent. - - Note: Each device can only be bound to one agent at a time. - """ - try: - service = get_binding_service(db) - binding = await service.create_binding(binding_data) - - binding_response = BindingResponse.model_validate(binding) - return success_response( - data=binding_response, - message="Device bound to agent successfully", - ) - - except ValueError as e: - logger.warning(f"Validation error creating binding: {str(e)}") - return error_response( - message=str(e), - code=400 - ) - except Exception as e: - logger.error(f"Error creating binding: {str(e)}") - return error_response( - message=f"Failed to create binding: {str(e)}", - code=500 - ) - - -@router.post("/unbind") -async def unbind_device( - binding_data: BindingOperation, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Unbind device from agent - - Request body: - - **deviceId**: Device unique ID (required) - - **agentId**: Agent unique ID (required) - - Updates the binding status to unbound for the specified device-agent pair. - """ - try: - service = get_binding_service(db) - unbound = await service.unbind_device( - binding_data.device_id, - binding_data.agent_id - ) - - if not unbound: - return error_response( - message=f"No active binding found for device {binding_data.device_id} and agent {binding_data.agent_id}", - code=404 - ) - - return success_response( - data={ - "deviceId": binding_data.device_id, - "agentId": binding_data.agent_id - }, - message="Device unbound from agent successfully" - ) - - except Exception as e: - logger.error(f"Error unbinding device: {str(e)}") - return error_response( - message=f"Failed to unbind device: {str(e)}", - code=500 - ) - diff --git a/main/live-agent-api/router/device.py b/main/live-agent-api/router/device.py deleted file mode 100644 index 3d68d9679..000000000 --- a/main/live-agent-api/router/device.py +++ /dev/null @@ -1,246 +0,0 @@ -""" -Device Router - -API endpoints for Device management. -""" - -import logging -from typing import Annotated -from fastapi import APIRouter, Depends, Query -from sqlalchemy.ext.asyncio import AsyncSession - -from orm import get_db -from services.device_service import DeviceService, get_device_service -from schemas.device import ( - DeviceCreate, - DeviceUpdate, - DeviceResponse, - DeviceListQuery, -) -from utils.response import ( - ApiResponse, - success_response, - error_response, - paginated_response, -) - - -logger = logging.getLogger(__name__) - -router = APIRouter(prefix="/device", tags=["device"]) - - -@router.get("/") -async def get_device_list( - search: Annotated[str | None, Query(description="Search keyword")] = None, - status: Annotated[str | None, Query(description="Filter by status")] = None, - page: Annotated[int, Query(ge=1, description="Page number")] = 1, - pageSize: Annotated[int, Query(ge=1, le=100, alias="pageSize", description="Items per page")] = 20, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get Device list with search, filtering and pagination (sorted by creation time desc) - - - **search**: Search keyword (searches in device name only) - - **status**: Filter by status (online, offline) - - **page**: Page number (starting from 1) - - **pageSize**: Number of items per page (1-100, default: 20) - - Returns paginated list of devices sorted by creation time (newest first) with total count. - """ - try: - # Create query object - query = DeviceListQuery( - search=search, - status=status, - page=page, - page_size=pageSize, - ) - - # Get service - service = get_device_service(db) - - # Get devices - devices, total = await service.get_device_list(query) - - # Convert to response format - device_responses = [ - DeviceResponse.model_validate(device) for device in devices - ] - - # Create paginated response - pagination_data = paginated_response( - items=device_responses, - total=total, - page=page, - page_size=pageSize, - ) - - return success_response(data=pagination_data) - - except Exception as e: - logger.error(f"Error getting device list: {str(e)}") - return error_response( - message=f"Failed to get device list: {str(e)}", - code=500 - ) - - -@router.get("/{device_id}") -async def get_device_detail( - device_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Get Device details by ID - - - **device_id**: Device unique ID - - Returns detailed device information. - """ - try: - service = get_device_service(db) - device = await service.get_device_by_id(device_id) - - if not device: - return error_response( - message=f"Device not found: {device_id}", - code=404 - ) - - device_response = DeviceResponse.model_validate(device) - return success_response(data=device_response) - - except Exception as e: - logger.error(f"Error getting device detail: {str(e)}") - return error_response( - message=f"Failed to get device detail: {str(e)}", - code=500 - ) - - -@router.post("/") -async def create_device( - device_data: DeviceCreate, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Create a new Device - - Request body: - - **name**: Device display name (required) - - **deviceId**: Device hardware ID (required, must be unique) - - **model**: Device model (optional) - - **firmwareVersion**: Firmware version (optional) - - **status**: Device status (default: active) - - **description**: Device description (optional) - - **metadata**: Additional metadata in JSON format (optional) - - Returns the created device with generated ID. - """ - try: - service = get_device_service(db) - device = await service.create_device(device_data) - - device_response = DeviceResponse.model_validate(device) - return success_response( - data=device_response, - message="Device created successfully", - code=201 - ) - - except ValueError as e: - # Business logic errors (e.g., duplicate device_id) - logger.warning(f"Validation error creating device: {str(e)}") - return error_response( - message=str(e), - code=400 - ) - except Exception as e: - logger.error(f"Error creating device: {str(e)}") - return error_response( - message=f"Failed to create device: {str(e)}", - code=500 - ) - - -@router.put("/{device_id}") -async def update_device( - device_id: str, - device_data: DeviceUpdate, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Update Device configuration - - - **device_id**: Device unique ID - - Request body: - - **firmwareVersion**: Firmware version - - **status**: Device connection status (online, offline) - - **description**: Device description - - **metaData**: Additional metadata (JSON format) - - Note: Device name and model cannot be modified after creation. - - Returns the updated device information. - """ - try: - service = get_device_service(db) - device = await service.update_device(device_id, device_data) - - if not device: - return error_response( - message=f"Device not found: {device_id}", - code=404 - ) - - device_response = DeviceResponse.model_validate(device) - return success_response( - data=device_response, - message="Device updated successfully" - ) - - except Exception as e: - logger.error(f"Error updating device: {str(e)}") - return error_response( - message=f"Failed to update device: {str(e)}", - code=500 - ) - - -@router.delete("/{device_id}") -async def delete_device( - device_id: str, - db: AsyncSession = Depends(get_db), -) -> ApiResponse: - """ - Delete a Device - - - **device_id**: Device unique ID - - Deletes the device if no binding relationships exist. - Returns success message if deleted. - """ - try: - service = get_device_service(db) - deleted = await service.delete_device(device_id) - - if not deleted: - return error_response( - message=f"Device not found: {device_id}", - code=404 - ) - - return success_response( - data={"id": device_id}, - message="Device deleted successfully" - ) - - except Exception as e: - logger.error(f"Error deleting device: {str(e)}") - return error_response( - message=f"Failed to delete device: {str(e)}", - code=500 - ) - diff --git a/main/live-agent-api/schemas/__init__.py b/main/live-agent-api/schemas/__init__.py deleted file mode 100644 index 0574773d6..000000000 --- a/main/live-agent-api/schemas/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -API Schemas - -Pydantic models for request/response validation. -""" - -# Agent schemas -from schemas.agent import ( - AgentBase, - AgentCreate, - AgentUpdate, - AgentDuplicate, - AgentResponse, - AgentListQuery, - GeneratePromptRequest, - GeneratePromptResponse, -) - -# Device schemas -from schemas.device import ( - DeviceBase, - DeviceCreate, - DeviceUpdate, - DeviceResponse, - DeviceListQuery, -) - -# Binding schemas -from schemas.binding import ( - BindingOperation, - BindingUpdate, - BindingResponse, - BindingWithDetails, - BindingListQuery, -) - -__all__ = [ - # Agent schemas - "AgentBase", - "AgentCreate", - "AgentUpdate", - "AgentDuplicate", - "AgentResponse", - "AgentListQuery", - "GeneratePromptRequest", - "GeneratePromptResponse", - - # Device schemas - "DeviceBase", - "DeviceCreate", - "DeviceUpdate", - "DeviceResponse", - "DeviceListQuery", - - # Binding schemas - "BindingOperation", - "BindingUpdate", - "BindingResponse", - "BindingWithDetails", - "BindingListQuery", -] diff --git a/main/live-agent-api/schemas/agent.py b/main/live-agent-api/schemas/agent.py deleted file mode 100644 index a5437a56e..000000000 --- a/main/live-agent-api/schemas/agent.py +++ /dev/null @@ -1,256 +0,0 @@ -""" -Agent Schemas - -Pydantic models for Agent API request/response validation. -""" - -from datetime import datetime -from typing import Optional -from pydantic import BaseModel, Field, field_validator - - -class AgentBase(BaseModel): - """Base schema for Agent with common fields""" - - name: str = Field( - ..., - min_length=1, - max_length=255, - description="Agent display name" - ) - language: str = Field( - default="en", - max_length=10, - description="Agent language code (e.g., en, zh)" - ) - first_message: Optional[str] = Field( - None, - alias="firstMessage", - description="Agent's greeting message" - ) - system_prompt: Optional[str] = Field( - None, - alias="systemPrompt", - description="System prompt for agent behavior" - ) - wake_word: str = Field( - default="PLAUD", - alias="wakeWord", - max_length=50, - description="Wake word to activate agent" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "name": "My Assistant", - "language": "en", - "firstMessage": "Hello! How can I help you today?", - "systemPrompt": "You are a helpful assistant.", - "wakeWord": "PLAUD" - } - } - } - - -class AgentCreate(AgentBase): - """Schema for creating a new Agent""" - - template: str = Field( - default="blank", - max_length=100, - description="Agent template type (blank, personal_assistant, learning_companion, health_wellness, hospital_assistant)" - ) - - @field_validator('name') - @classmethod - def validate_name(cls, v: str) -> str: - """Validate and clean agent name""" - v = v.strip() - if not v: - raise ValueError("Agent name cannot be empty") - return v - - @field_validator('language') - @classmethod - def validate_language(cls, v: str) -> str: - """Validate language code""" - v = v.lower().strip() - # Basic validation for common language codes - if len(v) < 2 or len(v) > 10: - raise ValueError("Invalid language code") - return v - - -class AgentUpdate(BaseModel): - """Schema for updating an Agent (all fields optional, name is immutable)""" - - language: Optional[str] = Field( - None, - max_length=10, - description="Agent language code" - ) - first_message: Optional[str] = Field( - None, - alias="firstMessage", - description="Agent's greeting message" - ) - system_prompt: Optional[str] = Field( - None, - alias="systemPrompt", - description="System prompt for agent behavior" - ) - wake_word: Optional[str] = Field( - None, - alias="wakeWord", - max_length=50, - description="Wake word to activate agent" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "language": "zh", - "firstMessage": "你好!有什么可以帮助你的吗?", - "systemPrompt": "You are a helpful Chinese assistant.", - "wakeWord": "小助手" - } - } - } - - @field_validator('language') - @classmethod - def validate_language(cls, v: Optional[str]) -> Optional[str]: - """Validate language code""" - if v is not None: - v = v.lower().strip() - if len(v) < 2 or len(v) > 10: - raise ValueError("Invalid language code") - return v - - -class AgentDuplicate(BaseModel): - """Schema for duplicating an Agent""" - - name: str = Field( - ..., - min_length=1, - max_length=255, - description="Name for the duplicated agent" - ) - - model_config = { - "json_schema_extra": { - "example": { - "name": "Copy of My Agent" - } - } - } - - -class AgentResponse(AgentBase): - """Schema for Agent response""" - - id: str = Field(..., description="Agent unique ID") - created_at: datetime = Field( - ..., - alias="createdAt", - description="Creation timestamp" - ) - updated_at: datetime = Field( - ..., - alias="updatedAt", - description="Last update timestamp" - ) - - model_config = { - "populate_by_name": True, - "from_attributes": True, - "json_schema_extra": { - "example": { - "id": "1234567890", - "name": "My Assistant", - "language": "en", - "firstMessage": "Hello! How can I help you today?", - "systemPrompt": "You are a helpful assistant.", - "wakeWord": "PLAUD", - "createdAt": "2024-01-01T00:00:00", - "updatedAt": "2024-01-01T00:00:00" - } - } - } - - -class AgentListQuery(BaseModel): - """Schema for Agent list query parameters (sorted by creation time desc)""" - - search: Optional[str] = Field( - None, - max_length=255, - description="Search keyword" - ) - page: int = Field( - default=1, - ge=1, - description="Page number" - ) - page_size: int = Field( - default=20, - alias="pageSize", - ge=1, - le=100, - description="Number of items per page" - ) - - model_config = { - "populate_by_name": True - } - - -class GeneratePromptRequest(BaseModel): - """Schema for generating system prompt""" - - description: str = Field( - ..., - min_length=1, - max_length=500, - description="Description of the agent's purpose and requirements" - ) - current_prompt: Optional[str] = Field( - None, - alias="currentPrompt", - max_length=10000, - description="Existing system prompt to refine or build upon (optional)" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "description": "a customer support agent for PLAUD that handles technical questions", - "currentPrompt": "You are a helpful assistant for PLAUD customers." - } - } - } - - -class GeneratePromptResponse(BaseModel): - """Schema for generated system prompt response""" - - system_prompt: str = Field( - ..., - alias="systemPrompt", - description="Generated system prompt" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "systemPrompt": "You are a professional customer support agent for PLAUD..." - } - } - } - diff --git a/main/live-agent-api/schemas/binding.py b/main/live-agent-api/schemas/binding.py deleted file mode 100644 index b1987ca3e..000000000 --- a/main/live-agent-api/schemas/binding.py +++ /dev/null @@ -1,174 +0,0 @@ -""" -DeviceAgentBinding Schemas - -Pydantic models for DeviceAgentBinding API request/response validation. -""" - -from datetime import datetime -from typing import Optional -from pydantic import BaseModel, Field - - -class BindingOperation(BaseModel): - """ - Schema for device-agent binding operations (bind/unbind) - - This schema represents the device-agent pair for all binding operations. - """ - - device_id: str = Field( - ..., - alias="deviceId", - min_length=1, - max_length=64, - description="Device unique ID" - ) - agent_id: str = Field( - ..., - alias="agentId", - min_length=1, - max_length=64, - description="Agent unique ID" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "deviceId": "1234567890", - "agentId": "0987654321" - } - } - } - - -class BindingUpdate(BaseModel): - """Schema for updating a DeviceAgentBinding""" - - agent_id: Optional[str] = Field( - None, - alias="agentId", - min_length=1, - max_length=64, - description="Agent unique ID" - ) - status: Optional[str] = Field( - None, - max_length=20, - description="Binding status (bound, unbound)" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "agentId": "0987654321", - "status": "bound" - } - } - } - - -class BindingResponse(BaseModel): - """Schema for DeviceAgentBinding response""" - - id: str = Field(..., description="Binding unique ID") - device_id: str = Field(..., alias="deviceId", description="Device unique ID") - agent_id: str = Field(..., alias="agentId", description="Agent unique ID") - status: str = Field(..., description="Binding status") - created_at: datetime = Field( - ..., - alias="createdAt", - description="Creation timestamp" - ) - updated_at: datetime = Field( - ..., - alias="updatedAt", - description="Last update timestamp" - ) - - model_config = { - "populate_by_name": True, - "from_attributes": True, - "json_schema_extra": { - "example": { - "id": "1122334455", - "deviceId": "1234567890", - "agentId": "0987654321", - "status": "bound", - "createdAt": "2024-01-01T00:00:00", - "updatedAt": "2024-01-01T00:00:00" - } - } - } - - -class BindingWithDetails(BindingResponse): - """Schema for DeviceAgentBinding response with device and agent details""" - - device_name: Optional[str] = Field(None, alias="deviceName", description="Device name") - agent_name: Optional[str] = Field(None, alias="agentName", description="Agent name") - - model_config = { - "populate_by_name": True, - "from_attributes": True, - "json_schema_extra": { - "example": { - "id": "1122334455", - "deviceId": "1234567890", - "agentId": "0987654321", - "status": "bound", - "deviceName": "My PLAUD Device", - "agentName": "My Assistant", - "createdAt": "2024-01-01T00:00:00", - "updatedAt": "2024-01-01T00:00:00" - } - } - } - - -class BindingListQuery(BaseModel): - """Schema for DeviceAgentBinding list query parameters""" - - device_id: Optional[str] = Field( - None, - alias="deviceId", - description="Filter by device ID" - ) - agent_id: Optional[str] = Field( - None, - alias="agentId", - description="Filter by agent ID" - ) - status: Optional[str] = Field( - None, - description="Filter by status" - ) - page: int = Field( - default=1, - ge=1, - description="Page number" - ) - page_size: int = Field( - default=20, - alias="pageSize", - ge=1, - le=100, - description="Number of items per page" - ) - sort_by: str = Field( - default="createdAt", - alias="sortBy", - description="Sort field" - ) - sort_order: str = Field( - default="desc", - alias="sortOrder", - pattern="^(asc|desc)$", - description="Sort order (asc or desc)" - ) - - model_config = { - "populate_by_name": True - } - diff --git a/main/live-agent-api/schemas/device.py b/main/live-agent-api/schemas/device.py deleted file mode 100644 index 605806404..000000000 --- a/main/live-agent-api/schemas/device.py +++ /dev/null @@ -1,237 +0,0 @@ -""" -Device Schemas - -Pydantic models for Device API request/response validation. -""" - -from datetime import datetime -from typing import Optional -from pydantic import BaseModel, Field, field_validator - - -class DeviceBase(BaseModel): - """Base schema for Device with common fields""" - - name: str = Field( - ..., - min_length=1, - max_length=255, - description="Device display name" - ) - device_id: str = Field( - ..., - alias="deviceId", - min_length=1, - max_length=255, - description="Device hardware ID" - ) - device_model: Optional[str] = Field( - None, - alias="deviceModel", - max_length=100, - description="Device model name (e.g., PLAUD NOTE, ESP32-S3)" - ) - firmware_version: Optional[str] = Field( - None, - alias="firmwareVersion", - max_length=50, - description="Firmware version" - ) - status: str = Field( - default="offline", - max_length=20, - description="Device connection status (online, offline)" - ) - description: Optional[str] = Field( - None, - description="Device description" - ) - meta_data: Optional[str] = Field( - None, - alias="metaData", - description="Device metadata (JSON format)" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "name": "My PLAUD Device", - "deviceId": "PLAUD-12345678", - "deviceModel": "PLAUD NOTE", - "firmwareVersion": "1.0.0", - "status": "offline", - "description": "My personal voice recorder", - "metaData": "{\"deviceType\": \"PLAUD NOTE\", \"firmwareVersion\": \"1.0.0\"}" - } - } - } - - -class DeviceCreate(DeviceBase): - """Schema for creating a new Device""" - - @field_validator('name') - @classmethod - def validate_name(cls, v: str) -> str: - """Validate and clean device name""" - v = v.strip() - if not v: - raise ValueError("Device name cannot be empty") - return v - - @field_validator('device_id') - @classmethod - def validate_device_id(cls, v: str) -> str: - """Validate and clean device ID""" - v = v.strip() - if not v: - raise ValueError("Device ID cannot be empty") - return v - - @field_validator('status') - @classmethod - def validate_status(cls, v: str) -> str: - """Validate status value""" - valid_statuses = ["online", "offline"] - if v not in valid_statuses: - raise ValueError(f"Status must be one of: {', '.join(valid_statuses)}") - return v - - -class DeviceUpdate(BaseModel): - """Schema for updating a Device""" - - firmware_version: Optional[str] = Field( - None, - alias="firmwareVersion", - max_length=50, - description="Firmware version" - ) - status: Optional[str] = Field( - None, - max_length=20, - description="Device connection status (online, offline)" - ) - description: Optional[str] = Field( - None, - description="Device description" - ) - meta_data: Optional[str] = Field( - None, - alias="metaData", - description="Additional metadata (JSON format)" - ) - - model_config = { - "populate_by_name": True, - "json_schema_extra": { - "example": { - "status": "online", - "firmwareVersion": "1.1.0", - "description": "Updated device description", - "metaData": "{\"deviceType\": \"PLAUD NOTE\", \"firmwareVersion\": \"1.1.0\"}" - } - } - } - - @field_validator('status') - @classmethod - def validate_status(cls, v: Optional[str]) -> Optional[str]: - """Validate status value""" - if v is not None: - valid_statuses = ["online", "offline"] - if v not in valid_statuses: - raise ValueError(f"Status must be one of: {', '.join(valid_statuses)}") - return v - - -class DeviceResponse(BaseModel): - """Schema for Device response""" - - id: str = Field(..., description="Device unique ID") - name: str = Field(..., description="Device display name") - device_id: str = Field(..., alias="deviceId", description="Device hardware ID") - device_model: Optional[str] = Field( - None, - alias="deviceModel", - description="Device model name" - ) - firmware_version: Optional[str] = Field( - None, - alias="firmwareVersion", - description="Firmware version" - ) - status: str = Field(..., description="Device connection status (online, offline)") - last_seen_at: Optional[datetime] = Field( - None, - alias="lastSeenAt", - description="Last seen timestamp" - ) - description: Optional[str] = Field(None, description="Device description") - meta_data: Optional[str] = Field( - None, - alias="metaData", - description="Device metadata (JSON format)" - ) - created_at: datetime = Field( - ..., - alias="createdAt", - description="Creation timestamp" - ) - updated_at: datetime = Field( - ..., - alias="updatedAt", - description="Last update timestamp" - ) - - model_config = { - "populate_by_name": True, - "from_attributes": True, - "json_schema_extra": { - "example": { - "id": "1234567890", - "name": "My PLAUD Device", - "deviceId": "PLAUD-12345678", - "deviceModel": "PLAUD NOTE", - "firmwareVersion": "1.0.0", - "status": "online", - "lastSeenAt": "2024-01-01T00:00:00", - "description": "My personal voice recorder", - "metaData": "{\"deviceType\": \"PLAUD NOTE\", \"firmwareVersion\": \"1.0.0\"}", - "createdAt": "2024-01-01T00:00:00", - "updatedAt": "2024-01-01T00:00:00" - } - } - } - - -class DeviceListQuery(BaseModel): - """Schema for Device list query parameters""" - - search: Optional[str] = Field( - None, - max_length=255, - description="Search keyword" - ) - status: Optional[str] = Field( - None, - description="Filter by status" - ) - page: int = Field( - default=1, - ge=1, - description="Page number" - ) - page_size: int = Field( - default=20, - alias="pageSize", - ge=1, - le=100, - description="Number of items per page" - ) - - model_config = { - "populate_by_name": True - } - diff --git a/main/live-agent-api/services/__init__.py b/main/live-agent-api/services/__init__.py deleted file mode 100644 index ebd26cead..000000000 --- a/main/live-agent-api/services/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -Business Logic Services - -Service layer for handling business logic. -""" - -from services.agent_service import AgentService, get_agent_service - -__all__ = ["AgentService", "get_agent_service"] - diff --git a/main/live-agent-api/services/agent_service.py b/main/live-agent-api/services/agent_service.py deleted file mode 100644 index 6298d06c4..000000000 --- a/main/live-agent-api/services/agent_service.py +++ /dev/null @@ -1,328 +0,0 @@ -""" -Agent Service - -Business logic layer for Agent operations. -Uses Repository pattern for data access. -""" - -import logging -from typing import Optional -from datetime import datetime, timezone -from sqlalchemy.ext.asyncio import AsyncSession -from openai import AsyncOpenAI - -from orm.agent import Agent, AgentRepository -from schemas.agent import ( - AgentCreate, - AgentUpdate, - AgentListQuery, - GeneratePromptRequest, -) -from utils import id_generator -from templates import TemplateLoader -from config.settings import settings - - -logger = logging.getLogger(__name__) -BLANK_TEMPLATE = "blank" -SYSTEM_PROMPT_INSTRUCTION = """ -You are an AI assistant that helps create system prompts for voice assistant agents. -Generate a clear, professional system prompt that strictly follows this 6-module structure: -1. **Personality**: Define the agent's character, traits, and communication style -2. **Environment**: Describe the context and setting where the agent operates -3. **Tone**: Specify the language tone and manner of interaction -4. **Goal**: State the primary objectives and purposes of the agent -5. **Guardrails**: Define rules, limitations, and ethical boundaries -6. **Tools**: List available capabilities, APIs, or functions the agent can use -Each section should be clearly labeled with markdown headers (##). -The prompt should be comprehensive yet concise, suitable for a voice assistant. -""" - -class AgentService: - """Service class for Agent business logic""" - - def __init__(self, db: AsyncSession): - """ - Initialize Agent service - - Args: - db: Database session - """ - self.repo = AgentRepository(db) - self.openai_client = AsyncOpenAI(api_key=settings.openai_api_key) - - async def get_agent_list( - self, - query: AgentListQuery - ) -> tuple[list[Agent], int]: - """ - Get paginated list of agents with optional search (sorted by creation time desc) - - Args: - query: Query parameters for filtering and pagination - - Returns: - Tuple of (agents list, total count) - """ - agents, total = await self.repo.find_all( - search=query.search, - page=query.page, - page_size=query.page_size, - ) - - logger.info( - f"Retrieved {len(agents)} agents (page {query.page}, total {total})" - ) - - return agents, total - - async def get_agent_by_id(self, agent_id: str) -> Optional[Agent]: - """ - Get agent by ID - - Args: - agent_id: Agent unique ID - - Returns: - Agent instance or None if not found - """ - agent = await self.repo.find_by_id(agent_id) - - if agent: - logger.info(f"Retrieved agent: {agent_id}") - else: - logger.warning(f"Agent not found: {agent_id}") - - return agent - - async def create_agent(self, agent_data: AgentCreate) -> Agent: - """ - Create a new agent - - Args: - agent_data: Agent creation data - - Returns: - Created agent instance - - Raises: - ValueError: If template does not exist - """ - # 1. Generate unique ID - agent_id = id_generator.generate() - - # 2. Create blank agent first - agent = Agent( - id=agent_id, - name=agent_data.name, - language=agent_data.language, - first_message=agent_data.first_message, - system_prompt=agent_data.system_prompt, - wake_word=agent_data.wake_word, - ) - - # 3. If not blank template, load and populate from template - if agent_data.template != BLANK_TEMPLATE: - try: - template = TemplateLoader.load(agent_data.template) - - if template is None: - raise ValueError(f"Failed to load template: {agent_data.template}") - - # Populate agent from template (template values are applied if user didn't provide) - agent.language = template.language - agent.first_message = template.greeting - agent.system_prompt = template.profile - agent.wake_word = template.wake_word - - logger.info(f"Populated agent from template: {agent_data.template}") - - except ValueError as e: - logger.error(f"Error loading template: {e}") - raise - - # Persist to database - agent = await self.repo.save(agent) - - logger.info(f"Created agent: {agent_id} ({agent.name})") - - return agent - - async def update_agent( - self, - agent_id: str, - agent_data: AgentUpdate - ) -> Optional[Agent]: - """ - Update agent configuration - - Args: - agent_id: Agent unique ID - agent_data: Agent update data - - Returns: - Updated agent instance or None if not found - """ - # Get existing agent - agent = await self.repo.find_by_id(agent_id) - if not agent: - return None - - # Business logic: Update fields - update_data = agent_data.model_dump(exclude_unset=True) - for field, value in update_data.items(): - # Convert camelCase to snake_case - db_field = field.replace("firstMessage", "first_message") - db_field = db_field.replace("systemPrompt", "system_prompt") - db_field = db_field.replace("wakeWord", "wake_word") - - if hasattr(agent, db_field): - setattr(agent, db_field, value) - - # Business logic: Update timestamp - agent.updated_at = datetime.now(timezone.utc) - - # Persist changes - agent = await self.repo.save(agent) - - logger.info(f"Updated agent: {agent_id}") - - return agent - - async def delete_agent(self, agent_id: str) -> bool: - """ - Delete an agent - - Args: - agent_id: Agent unique ID - - Returns: - True if deleted, False if not found - """ - agent = await self.repo.find_by_id(agent_id) - if not agent: - return False - - # TODO: Business logic - Check for binding relationships - # For now, just delete the agent - # In production, should check if agent has bindings and handle accordingly - - await self.repo.delete(agent) - - logger.info(f"Deleted agent: {agent_id}") - - return True - - async def duplicate_agent( - self, - agent_id: str, - new_name: str - ) -> Optional[Agent]: - """ - Duplicate an existing agent - - Args: - agent_id: Source agent ID - new_name: Name for the duplicated agent - - Returns: - New agent instance or None if source not found - """ - # Get source agent - source_agent = await self.repo.find_by_id(agent_id) - if not source_agent: - return None - - # Business logic: Create duplicate with new ID and name - new_id = id_generator.generate() - duplicate_agent = Agent( - id=new_id, - name=new_name, - language=source_agent.language, - first_message=source_agent.first_message, - system_prompt=source_agent.system_prompt, - wake_word=source_agent.wake_word, - ) - - # Persist to database - duplicate_agent = await self.repo.save(duplicate_agent) - - logger.info( - f"Duplicated agent {agent_id} to {new_id} ({new_name})" - ) - - return duplicate_agent - - async def generate_system_prompt( - self, - request: GeneratePromptRequest - ) -> str: - """ - Generate system prompt using AI - - Args: - request: Prompt generation request with description and optional existing prompt - - Returns: - Generated system prompt following the 6-module structure - """ - logger.info(f"Generating prompt for: {request.description}") - - try: - system_instruction = SYSTEM_PROMPT_INSTRUCTION - - # Build user message based on whether existing prompt is provided - if request.current_prompt: - user_message = ( - f"I need help refining or regenerating a system prompt.\n\n" - f"**User Requirements/Description:**\n{request.description}\n\n" - f"**Current Prompt:**\n{request.current_prompt}\n\n" - f"Please create an improved system prompt that incorporates the requirements " - f"and builds upon the existing prompt, following the 6-module structure." - ) - else: - user_message = ( - f"Create a new system prompt for: {request.description}\n\n" - f"Please structure it according to the 6 modules (Personality, Environment, Tone, Goal, Guardrails, Tools)." - ) - - # Create prompt using OpenAI API - # Note: Using chat.completions for now, ready to migrate to response.create when available - response = await self.openai_client.chat.completions.create( - model=settings.openai_model, - messages=[ - { - "role": "system", - "content": system_instruction - }, - { - "role": "user", - "content": user_message - } - ], - temperature=0.7, - max_tokens=1500, - ) - - generated_prompt = response.choices[0].message.content.strip() - - logger.info("Successfully generated system prompt with 6-module structure") - - return generated_prompt - - except Exception as e: - logger.error(f"Error generating prompt: {str(e)}") - raise - - -def get_agent_service(db: AsyncSession) -> AgentService: - """ - Dependency function to get Agent service - - Args: - db: Database session - - Returns: - AgentService instance - """ - return AgentService(db) diff --git a/main/live-agent-api/services/binding_service.py b/main/live-agent-api/services/binding_service.py deleted file mode 100644 index 1adc4246e..000000000 --- a/main/live-agent-api/services/binding_service.py +++ /dev/null @@ -1,289 +0,0 @@ -""" -DeviceAgentBinding Service - -Business logic layer for DeviceAgentBinding operations. -Uses Repository pattern for data access. -""" - -import logging -from typing import Optional -from datetime import datetime, timezone -from sqlalchemy.ext.asyncio import AsyncSession - -from orm.binding import DeviceAgentBinding, DeviceAgentBindingRepository -from orm.device import DeviceRepository -from orm.agent import AgentRepository -from schemas.binding import BindingOperation, BindingUpdate, BindingListQuery -from utils import id_generator - - -logger = logging.getLogger(__name__) - - -class BindingService: - """Service class for DeviceAgentBinding business logic""" - - def __init__(self, db: AsyncSession): - """ - Initialize Binding service - - Args: - db: Database session - """ - self.repo = DeviceAgentBindingRepository(db) - self.device_repo = DeviceRepository(db) - self.agent_repo = AgentRepository(db) - - async def get_binding_list( - self, - query: BindingListQuery - ) -> tuple[list[DeviceAgentBinding], int]: - """ - Get paginated list of bindings with optional filtering - - Args: - query: Query parameters for filtering and pagination - - Returns: - Tuple of (bindings list, total count) - """ - bindings, total = await self.repo.find_all( - device_id=query.device_id, - agent_id=query.agent_id, - status=query.status, - page=query.page, - page_size=query.page_size, - sort_by=query.sort_by, - sort_order=query.sort_order, - ) - - logger.info( - f"Retrieved {len(bindings)} bindings (page {query.page}, total {total})" - ) - - return bindings, total - - async def get_binding_by_id(self, binding_id: str) -> Optional[DeviceAgentBinding]: - """ - Get binding by ID - - Args: - binding_id: Binding unique ID - - Returns: - DeviceAgentBinding instance or None if not found - """ - binding = await self.repo.find_by_id(binding_id) - - if binding: - logger.info(f"Retrieved binding: {binding_id}") - else: - logger.warning(f"Binding not found: {binding_id}") - - return binding - - async def get_binding_by_device_id(self, device_id: str) -> Optional[DeviceAgentBinding]: - """ - Get binding by device ID - - Args: - device_id: Device unique ID - - Returns: - DeviceAgentBinding instance or None if not found - """ - binding = await self.repo.find_by_device_id(device_id) - - if binding: - logger.info(f"Retrieved binding for device: {device_id}") - else: - logger.warning(f"No binding found for device: {device_id}") - - return binding - - async def get_bindings_by_agent_id(self, agent_id: str) -> list[DeviceAgentBinding]: - """ - Get all bindings for an agent - - Args: - agent_id: Agent unique ID - - Returns: - List of DeviceAgentBinding instances - """ - bindings = await self.repo.find_by_agent_id(agent_id) - - logger.info(f"Retrieved {len(bindings)} bindings for agent: {agent_id}") - - return bindings - - async def create_binding(self, binding_data: BindingOperation) -> DeviceAgentBinding: - """ - Create or reactivate a device-agent binding - - Args: - binding_data: Binding creation data - - Returns: - Created or updated binding instance - - Raises: - ValueError: If device or agent not found, or device already bound to this agent - """ - # 1. Validate device exists - device = await self.device_repo.find_by_id(binding_data.device_id) - if not device: - raise ValueError(f"Device not found: {binding_data.device_id}") - - # 2. Validate agent exists - agent = await self.agent_repo.find_by_id(binding_data.agent_id) - if not agent: - raise ValueError(f"Agent not found: {binding_data.agent_id}") - - # 3. Check if binding already exists for this device-agent pair - existing_binding = await self.repo.find_by_device_and_agent( - binding_data.device_id, - binding_data.agent_id - ) - - if existing_binding: - # Binding record exists - if existing_binding.status == "bound": - # Already bound - return error - raise ValueError( - f"Device {binding_data.device_id} is already bound to agent {binding_data.agent_id}" - ) - else: - # Status is "unbound" - reactivate the binding - existing_binding.status = "bound" - existing_binding.updated_at = datetime.now(timezone.utc) - binding = await self.repo.save(existing_binding) - logger.info( - f"Reactivated binding: {existing_binding.id} " - f"(device={binding_data.device_id}, agent={binding_data.agent_id})" - ) - return binding - else: - # No existing binding - create new one - binding_id = id_generator.generate() - binding = DeviceAgentBinding( - id=binding_id, - device_id=binding_data.device_id, - agent_id=binding_data.agent_id, - status="bound", - ) - binding = await self.repo.save(binding) - logger.info( - f"Created new binding: {binding_id} " - f"(device={binding_data.device_id}, agent={binding_data.agent_id})" - ) - return binding - - async def update_binding( - self, - binding_id: str, - binding_data: BindingUpdate - ) -> Optional[DeviceAgentBinding]: - """ - Update binding configuration - - Args: - binding_id: Binding unique ID - binding_data: Binding update data - - Returns: - Updated binding instance or None if not found - - Raises: - ValueError: If new agent not found - """ - # Get existing binding - binding = await self.repo.find_by_id(binding_id) - if not binding: - return None - - # Business logic: Validate new agent if provided - if binding_data.agent_id: - agent = await self.agent_repo.find_by_id(binding_data.agent_id) - if not agent: - raise ValueError(f"Agent not found: {binding_data.agent_id}") - binding.agent_id = binding_data.agent_id - - # Business logic: Update status if provided - if binding_data.status: - binding.status = binding_data.status - - # Business logic: Update timestamp - binding.updated_at = datetime.now(timezone.utc) - - # Persist changes - binding = await self.repo.save(binding) - - logger.info(f"Updated binding: {binding_id}") - - return binding - - async def delete_binding(self, binding_id: str) -> bool: - """ - Delete a binding - - Args: - binding_id: Binding unique ID - - Returns: - True if deleted, False if not found - """ - binding = await self.repo.find_by_id(binding_id) - if not binding: - return False - - await self.repo.delete(binding) - - logger.info(f"Deleted binding: {binding_id}") - - return True - - async def unbind_device(self, device_id: str, agent_id: str) -> bool: - """ - Unbind a device from an agent (update status to unbound) - - Args: - device_id: Device unique ID - agent_id: Agent unique ID - - Returns: - True if unbound successfully, False if no active binding found - """ - # Find the specific device-agent binding - binding = await self.repo.find_by_device_and_agent(device_id, agent_id) - if not binding: - logger.warning(f"No binding found for device {device_id} and agent {agent_id}") - return False - - # Check if already unbound - if binding.status == "unbound": - logger.info(f"Device {device_id} is already unbound from agent {agent_id}") - return False - - # Update status to unbound instead of deleting - binding.status = "unbound" - binding.updated_at = datetime.now(timezone.utc) - await self.repo.save(binding) - - logger.info(f"Unbound device {device_id} from agent {agent_id}") - - return True - - -def get_binding_service(db: AsyncSession) -> BindingService: - """ - Dependency function to get Binding service - - Args: - db: Database session - - Returns: - BindingService instance - """ - return BindingService(db) - diff --git a/main/live-agent-api/services/device_service.py b/main/live-agent-api/services/device_service.py deleted file mode 100644 index 94a6a0ba4..000000000 --- a/main/live-agent-api/services/device_service.py +++ /dev/null @@ -1,245 +0,0 @@ -""" -Device Service - -Business logic layer for Device operations. -Uses Repository pattern for data access. -""" - -import logging -from typing import Optional -from datetime import datetime, timezone -from sqlalchemy.ext.asyncio import AsyncSession - -from orm.device import Device, DeviceRepository -from schemas.device import DeviceCreate, DeviceUpdate, DeviceListQuery -from utils import id_generator - - -logger = logging.getLogger(__name__) - - -class DeviceService: - """Service class for Device business logic""" - - def __init__(self, db: AsyncSession): - """ - Initialize Device service - - Args: - db: Database session - """ - self.repo = DeviceRepository(db) - - async def get_device_list( - self, - query: DeviceListQuery - ) -> tuple[list[Device], int]: - """ - Get paginated list of devices with optional search and filtering - - Args: - query: Query parameters for filtering and pagination - - Returns: - Tuple of (devices list, total count) - """ - devices, total = await self.repo.find_all( - search=query.search, - status=query.status, - page=query.page, - page_size=query.page_size, - ) - - logger.info( - f"Retrieved {len(devices)} devices (page {query.page}, total {total})" - ) - - return devices, total - - async def get_device_by_id(self, device_id: str) -> Optional[Device]: - """ - Get device by ID - - Args: - device_id: Device unique ID - - Returns: - Device instance or None if not found - """ - device = await self.repo.find_by_id(device_id) - - if device: - logger.info(f"Retrieved device: {device_id}") - else: - logger.warning(f"Device not found: {device_id}") - - return device - - async def get_device_by_device_id(self, device_id: str) -> Optional[Device]: - """ - Get device by hardware device ID - - Args: - device_id: Device hardware ID - - Returns: - Device instance or None if not found - """ - device = await self.repo.find_by_device_id(device_id) - - if device: - logger.info(f"Retrieved device by device_id: {device_id}") - else: - logger.warning(f"Device not found by device_id: {device_id}") - - return device - - async def create_device(self, device_data: DeviceCreate) -> Device: - """ - Create a new device - - Args: - device_data: Device creation data - - Returns: - Created device instance - - Raises: - ValueError: If device_id already exists - """ - # Business logic: Check if device_id already exists - if await self.repo.device_id_exists(device_data.device_id): - raise ValueError(f"Device ID already exists: {device_data.device_id}") - - # Business logic: Generate unique ID - device_id = id_generator.generate() - - # Business logic: Create device instance - device = Device( - id=device_id, - name=device_data.name, - device_id=device_data.device_id, - device_model=device_data.device_model, - firmware_version=device_data.firmware_version, - status=device_data.status, - description=device_data.description, - meta_data=device_data.meta_data, - ) - - # Persist to database - device = await self.repo.save(device) - - logger.info(f"Created device: {device_id} ({device.name})") - - return device - - async def update_device( - self, - device_id: str, - device_data: DeviceUpdate - ) -> Optional[Device]: - """ - Update device configuration - - Args: - device_id: Device unique ID - device_data: Device update data - - Returns: - Updated device instance or None if not found - """ - # Get existing device - device = await self.repo.find_by_id(device_id) - if not device: - return None - - # Business logic: Update fields - update_data = device_data.model_dump(exclude_unset=True) - for field, value in update_data.items(): - # Convert camelCase to snake_case - db_field = field.replace("firmwareVersion", "firmware_version") - db_field = db_field.replace("metaData", "meta_data") - - if hasattr(device, db_field): - setattr(device, db_field, value) - - # Business logic: Update last_seen_at if device comes online - if "status" in update_data and update_data["status"] == "online": - device.last_seen_at = datetime.now(timezone.utc) - - # Business logic: Update timestamp - device.updated_at = datetime.now(timezone.utc) - - # Persist changes - device = await self.repo.save(device) - - logger.info(f"Updated device: {device_id}") - - return device - - async def delete_device(self, device_id: str) -> bool: - """ - Delete a device - - Args: - device_id: Device unique ID - - Returns: - True if deleted, False if not found - """ - device = await self.repo.find_by_id(device_id) - if not device: - return False - - # TODO: Business logic - Check for binding relationships - # For now, just delete the device - # In production, should check if device has bindings and handle accordingly - - await self.repo.delete(device) - - logger.info(f"Deleted device: {device_id}") - - return True - - async def update_device_status( - self, - device_id: str, - status: str - ) -> Optional[Device]: - """ - Update device connection status - - Args: - device_id: Device unique ID - status: Device connection status (online, offline) - - Returns: - Updated device instance or None if not found - """ - device = await self.repo.find_by_id(device_id) - if not device: - return None - - device.status = status - device.last_seen_at = datetime.now(timezone.utc) - device.updated_at = datetime.now(timezone.utc) - - device = await self.repo.save(device) - - logger.info(f"Updated device status: {device_id} (status={status})") - - return device - - -def get_device_service(db: AsyncSession) -> DeviceService: - """ - Dependency function to get Device service - - Args: - db: Database session - - Returns: - DeviceService instance - """ - return DeviceService(db) - diff --git a/main/live-agent-api/templates/__init__.py b/main/live-agent-api/templates/__init__.py deleted file mode 100644 index 1afe3cc99..000000000 --- a/main/live-agent-api/templates/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -""" -Templates Package - -Agent templates and template loader. -""" - -from .loader import AgentTemplate, TemplateLoader - -__all__ = [ - "AgentTemplate", - "TemplateLoader", -] - diff --git a/main/live-agent-api/templates/health_wellness.yaml b/main/live-agent-api/templates/health_wellness.yaml deleted file mode 100644 index 4df3a0e5b..000000000 --- a/main/live-agent-api/templates/health_wellness.yaml +++ /dev/null @@ -1,70 +0,0 @@ -wake_word: Alice -language: en -greeting: Hello! I'm here to support your health and wellness journey. How can I assist you today? -profile: | - # Personality - - You are a supportive and knowledgeable health and wellness companion. - You are empathetic, non-judgmental, and focused on holistic well-being. - You promote healthy habits and sustainable lifestyle changes. - - # Environment - - You are assisting the user via voice interaction. - The user is interested in improving their physical, mental, or emotional health. - You provide guidance and support, but are not a replacement for professional medical advice. - - # Tone - - Your responses are caring, supportive, and motivating. - You use gentle, encouraging language that promotes positive change. - You acknowledge challenges while focusing on solutions and progress. - You are informative but avoid being preachy or judgmental. - - # Goal - - Your primary goal is to support the user's health and wellness journey: - - 1. Healthy Habits: - - - Help establish and maintain healthy routines. - - Track wellness goals (exercise, nutrition, sleep, hydration). - - Provide reminders and encouragement for healthy behaviors. - - Celebrate milestones and progress. - - 2. Mindfulness & Mental Health: - - - Guide simple meditation and breathing exercises. - - Offer stress management techniques. - - Encourage self-care and work-life balance. - - Provide emotional support and active listening. - - 3. Fitness Support: - - - Suggest appropriate exercises based on fitness level. - - Help set realistic fitness goals. - - Provide motivation and workout reminders. - - Track progress and adjust plans as needed. - - 4. Nutrition Guidance: - - - Offer general nutrition information and healthy eating tips. - - Help track meals and water intake. - - Suggest balanced meal ideas. - - Promote mindful eating practices. - - # Guardrails - - NEVER provide medical diagnoses or treatment recommendations. - ALWAYS encourage users to consult healthcare professionals for medical concerns. - Focus on general wellness information, not specific medical advice. - Be sensitive to potential eating disorders or mental health crises. - If a user expresses thoughts of self-harm, immediately recommend professional help. - Respect individual differences in body types, abilities, and health goals. - Promote balanced, sustainable approaches rather than extreme methods. - - # Tools - - No tools provided. -timezone: UTC+8 - diff --git a/main/live-agent-api/templates/hospital_assistant.yaml b/main/live-agent-api/templates/hospital_assistant.yaml deleted file mode 100644 index a7f15f3a1..000000000 --- a/main/live-agent-api/templates/hospital_assistant.yaml +++ /dev/null @@ -1,57 +0,0 @@ -wake_word: Alice -language: en -greeting: Hi! How can I help you today? -profile: | - # Personality - - You are a personal assistant designed to help users manage their daily hospital-related tasks. - You are efficient, organized, and detail-oriented. - You are friendly and helpful, but primarily focused on task completion. - - # Environment - - You are assisting the user via voice interaction. - The user is likely a healthcare professional working in a hospital setting. - The user is seeking assistance with their daily tasks. - - # Tone - - Your responses are clear, concise, and professional. - You use direct language and avoid unnecessary jargon. - You are polite and helpful, but prioritize efficiency. - - # Goal - - Your primary goal is to help the user efficiently process their daily hospital tasks through a structured workflow: - - 1. Task Identification: - - - Identify the specific task the user needs assistance with (e.g., scheduling appointments, managing patient records, ordering supplies, etc.). - - Clarify any specific requirements or constraints for the task. - - 2. Task Execution: - - - Provide step-by-step instructions for completing the task. - - Offer helpful tips and shortcuts to improve efficiency. - - If possible, automate parts of the task using available tools. - - 3. Task Confirmation: - - - Confirm that the task has been completed successfully. - - Offer to assist with any follow-up tasks or related activities. - - 4. Task Logging: - - - Automatically log the task and its completion status for future reference. - - # Guardrails - - Remain within the scope of hospital-related tasks. - Never provide medical advice or make clinical decisions. - Protect patient privacy and confidentiality at all times. - If you are unsure about something, ask for clarification. - - # Tools - - No tools provided. -timezone: UTC+8 \ No newline at end of file diff --git a/main/live-agent-api/templates/learning_companion.yaml b/main/live-agent-api/templates/learning_companion.yaml deleted file mode 100644 index a2c389115..000000000 --- a/main/live-agent-api/templates/learning_companion.yaml +++ /dev/null @@ -1,68 +0,0 @@ -wake_word: Alice -language: en -greeting: Hi there! I'm excited to help you learn today. What would you like to explore? -profile: | - # Personality - - You are an enthusiastic and patient learning companion dedicated to helping users expand their knowledge. - You are encouraging, curious, and passionate about education. - You make learning fun and engaging while maintaining high educational standards. - - # Environment - - You are assisting the user via voice interaction. - The user is actively seeking to learn new concepts, skills, or subjects. - You adapt your teaching style to match the user's learning pace and preferences. - - # Tone - - Your responses are encouraging, clear, and pedagogically sound. - You use analogies, examples, and real-world connections to make concepts relatable. - You celebrate progress and gently guide through challenges. - You ask thought-provoking questions to deepen understanding. - - # Goal - - Your primary goal is to facilitate effective and enjoyable learning experiences: - - 1. Concept Explanation: - - - Break down complex topics into digestible chunks. - - Use multiple approaches (visual, verbal, practical) to explain concepts. - - Provide relevant examples and analogies. - - Check for understanding before moving forward. - - 2. Active Learning: - - - Ask questions that promote critical thinking. - - Encourage the user to explain concepts in their own words. - - Provide practice problems and exercises. - - Offer constructive feedback on responses. - - 3. Study Support: - - - Help create effective study plans and schedules. - - Suggest memory techniques and learning strategies. - - Assist with exam preparation and review. - - Provide motivation and study tips. - - 4. Knowledge Building: - - - Connect new information to existing knowledge. - - Highlight patterns and relationships between concepts. - - Encourage curiosity and further exploration. - - Recommend additional resources for deeper learning. - - # Guardrails - - Adapt to the user's current knowledge level and learning pace. - Never provide direct answers to homework or test questions without guiding the learning process. - Encourage independent thinking and problem-solving. - If a topic is outside your expertise, acknowledge it and suggest reliable resources. - Maintain a supportive environment that makes mistakes feel safe and valuable. - - # Tools - - No tools provided. -timezone: UTC+8 - diff --git a/main/live-agent-api/templates/loader.py b/main/live-agent-api/templates/loader.py deleted file mode 100644 index f77421f34..000000000 --- a/main/live-agent-api/templates/loader.py +++ /dev/null @@ -1,118 +0,0 @@ -""" -Template Loader - -Utility for loading agent templates from YAML files. -""" - -import yaml -import logging -from typing import Optional -from pathlib import Path -from pydantic import BaseModel, Field - -logger = logging.getLogger(__name__) - - -class AgentTemplate(BaseModel): - """ - Agent template data structure - - Pydantic model for validating and handling agent template data. - """ - - wake_word: str = Field(..., description="Wake word to activate agent") - language: str = Field(..., description="Language code (e.g., en, zh)") - greeting: str = Field(..., description="Greeting message (maps to first_message)") - profile: str = Field(..., description="System prompt (maps to system_prompt)") - timezone: str = Field(default="UTC+8", description="Timezone") - - model_config = { - "json_schema_extra": { - "example": { - "wake_word": "Hey Assistant", - "language": "en", - "greeting": "Hello! How can I help you?", - "profile": "You are a helpful assistant...", - "timezone": "UTC+8" - } - } - } - - -class TemplateLoader: - """ - Template loader class with static methods for loading agent templates - - All methods are static, no instance needed. - """ - - # Template directory path (relative to this file) - TEMPLATE_DIR = Path(__file__).parent - - @staticmethod - def load(template_name: str) -> Optional[AgentTemplate]: - """ - Load agent template from YAML file - - Args: - template_name: Template name (e.g., "personal_assistant", "learning_companion") - - Returns: - AgentTemplate instance or None if template is "blank" - - Raises: - ValueError: If template file is invalid or missing required fields - """ - # Special case: blank template - if template_name == "blank": - return None - - # Construct template file path - template_file = TemplateLoader.TEMPLATE_DIR / f"{template_name}.yaml" - - # Check if template exists - if not template_file.exists(): - logger.error(f"Template file not found: {template_file}") - raise ValueError(f"Template '{template_name}' does not exist") - - try: - # Load YAML file - with open(template_file, 'r', encoding='utf-8') as f: - data = yaml.safe_load(f) - - # Validate and create template using Pydantic - template = AgentTemplate(**data) - - logger.info(f"Loaded template: {template_name}") - return template - - except yaml.YAMLError as e: - logger.error(f"Error parsing YAML file {template_file}: {e}") - raise ValueError(f"Template '{template_name}' has invalid YAML format: {e}") - - except Exception as e: - logger.error(f"Error loading template {template_name}: {e}") - raise - - @staticmethod - def list_available() -> list[str]: - """ - List all available template names - - Returns: - List of template names (without .yaml extension) - """ - if not TemplateLoader.TEMPLATE_DIR.exists(): - logger.warning(f"Template directory not found: {TemplateLoader.TEMPLATE_DIR}") - return [] - - templates = [] - for file in TemplateLoader.TEMPLATE_DIR.glob("*.yaml"): - templates.append(file.stem) - - # Always include blank template - templates.append("blank") - - logger.info(f"Available templates: {templates}") - return sorted(templates) - diff --git a/main/live-agent-api/templates/personal_assistant.yaml b/main/live-agent-api/templates/personal_assistant.yaml deleted file mode 100644 index 926785e77..000000000 --- a/main/live-agent-api/templates/personal_assistant.yaml +++ /dev/null @@ -1,62 +0,0 @@ -wake_word: Charlie -language: en -greeting: Hello! I'm your personal assistant. How can I help you today? -profile: | - # Personality - - You are a versatile personal assistant designed to help users manage their daily tasks and activities. - You are friendly, proactive, and highly organized. - You anticipate user needs and offer helpful suggestions. - - # Environment - - You are assisting the user via voice interaction. - The user relies on you for various personal and professional tasks. - You have access to the user's schedule, reminders, and preferences. - - # Tone - - Your responses are warm, conversational, and supportive. - You use clear language and explain things in a way that's easy to understand. - You are encouraging and positive, helping the user stay motivated and productive. - - # Goal - - Your primary goal is to help the user manage their daily life efficiently: - - 1. Task Management: - - - Help create, organize, and prioritize tasks. - - Set reminders for important deadlines and appointments. - - Suggest optimal times for task completion based on the user's schedule. - - 2. Information Assistance: - - - Answer questions on a wide range of topics. - - Provide quick facts, definitions, and explanations. - - Help with research and information gathering. - - 3. Productivity Support: - - - Offer time management tips and strategies. - - Help break down complex projects into manageable steps. - - Suggest productivity techniques like Pomodoro or time blocking. - - 4. Personal Organization: - - - Manage calendar events and appointments. - - Keep track of shopping lists and to-dos. - - Help organize notes and ideas. - - # Guardrails - - Respect user privacy and confidentiality at all times. - Stay within the scope of general assistance and avoid specialized professional advice. - If you're unsure about something, admit it and offer to help find accurate information. - Never make decisions that could have serious consequences without user confirmation. - - # Tools - - No tools provided. -timezone: UTC+8 - diff --git a/main/live-agent-api/utils/__init__.py b/main/live-agent-api/utils/__init__.py deleted file mode 100644 index dac88be9b..000000000 --- a/main/live-agent-api/utils/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -""" -Utils package for live-agent-api - -This package provides utility modules for the application, -including ID generation and response formatting. - -Usage: - from utils import id_generator - - # Generate ID using the global singleton instance - new_id = id_generator.generate() -""" - -from .id_generator import id_generator - -__all__ = [ - "id_generator", # Global singleton instance (recommended usage) -] diff --git a/main/live-agent-api/utils/id_generator.py b/main/live-agent-api/utils/id_generator.py deleted file mode 100644 index 5b1035095..000000000 --- a/main/live-agent-api/utils/id_generator.py +++ /dev/null @@ -1,75 +0,0 @@ -""" -ULID ID Generator - -ULID (Universally Unique Lexicographically Sortable Identifier) generator. -- Zero configuration: No instance ID or epoch setup needed -- Time-sortable: IDs are naturally ordered by creation time -- URL-safe: Base32 encoded -- 128-bit: Extremely low collision probability -- Format: 26 characters (e.g., 01ARZ3NDEKTSV4RRFFQ69G5FAV) -""" -from __future__ import annotations -from typing import Optional -from ulid import ULID -import logging - -logger = logging.getLogger(__name__) - - -class ULIDGenerator: - """ - ULID ID Generator - - A singleton class for generating distributed unique IDs using ULID. - Thread-safe and requires no configuration. - - Usage: - generator = ULIDGenerator() - id_str = generator.generate() - id_int = generator.generate_int() - id_uuid = generator.generate_uuid() - """ - - _instance: Optional['ULIDGenerator'] = None - _initialized: bool = False - - def __new__(cls) -> ULIDGenerator: - """Ensure singleton pattern""" - if cls._instance is None: - cls._instance = super().__new__(cls) - return cls._instance - - def __init__(self): - """ - Initialize ULID generator - - Note: Due to singleton pattern, __init__ is called every time - ULIDGenerator() is invoked, but initialization only happens once. - """ - if not self._initialized: - logger.info("Initializing ULID generator (singleton)") - self.__class__._initialized = True - logger.info("ULID generator initialized successfully") - - def generate(self) -> str: - """ - Generate a unique ULID as string - - Returns: - 26-character ULID string (e.g., '01ARZ3NDEKTSV4RRFFQ69G5FAV') - - Example: - >>> generator = ULIDGenerator() - >>> id_str = generator.generate() - >>> print(id_str) - '01ARZ3NDEKTSV4RRFFQ69G5FAV' - """ - return str(ULID()) - - def __repr__(self) -> str: - """String representation""" - return f"" - - -# Create global singleton instance -id_generator = ULIDGenerator() diff --git a/main/live-agent-api/utils/response.py b/main/live-agent-api/utils/response.py deleted file mode 100644 index 2a4fbf257..000000000 --- a/main/live-agent-api/utils/response.py +++ /dev/null @@ -1,126 +0,0 @@ -""" -API Response Wrapper - -Provides standardized response format for all API endpoints. -""" - -from typing import Any, Optional, TypeVar, Generic -from pydantic import BaseModel, Field - - -T = TypeVar('T') - - -class ApiResponse(BaseModel, Generic[T]): - """ - Standard API response format - - Attributes: - code: HTTP status code - message: Response message - data: Response data payload - """ - code: int = Field(..., description="HTTP status code") - message: str = Field(..., description="Response message") - data: Optional[T] = Field(None, description="Response data") - - class Config: - json_schema_extra = { - "example": { - "code": 200, - "message": "success", - "data": {"id": "123", "name": "Example"} - } - } - - -class PaginatedResponse(BaseModel, Generic[T]): - """ - Paginated list response format - - Attributes: - total: Total number of items - page: Current page number - pageSize: Number of items per page - items: List of items - """ - total: int = Field(..., description="Total number of items") - page: int = Field(..., description="Current page number") - pageSize: int = Field(..., alias="pageSize", description="Number of items per page") - items: list[T] = Field(..., description="List of items") - - class Config: - populate_by_name = True - json_schema_extra = { - "example": { - "total": 100, - "page": 1, - "pageSize": 20, - "items": [] - } - } - - -def success_response( - data: Any = None, - message: str = "success", - code: int = 200 -) -> ApiResponse: - """ - Create a success response - - Args: - data: Response data payload - message: Success message - code: HTTP status code - - Returns: - Standardized success response - """ - return ApiResponse(code=code, message=message, data=data) - - -def error_response( - message: str, - code: int = 400, - data: Any = None -) -> ApiResponse: - """ - Create an error response - - Args: - message: Error message - code: HTTP status code - data: Additional error data - - Returns: - Standardized error response - """ - return ApiResponse(code=code, message=message, data=data) - - -def paginated_response( - items: list[Any], - total: int, - page: int, - page_size: int -) -> PaginatedResponse: - """ - Create a paginated response - - Args: - items: List of items - total: Total number of items - page: Current page number - page_size: Number of items per page - - Returns: - Paginated response - """ - return PaginatedResponse( - total=total, - page=page, - pageSize=page_size, - items=items - ) - diff --git a/main/live-agent-api/uv.lock b/main/live-agent-api/uv.lock deleted file mode 100644 index 16f40fab6..000000000 --- a/main/live-agent-api/uv.lock +++ /dev/null @@ -1,910 +0,0 @@ -version = 1 -revision = 3 -requires-python = ">=3.12" - -[[package]] -name = "annotated-doc" -version = "0.0.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d7/a6/dc46877b911e40c00d395771ea710d5e77b6de7bacd5fdcd78d70cc5a48f/annotated_doc-0.0.3.tar.gz", hash = "sha256:e18370014c70187422c33e945053ff4c286f453a984eba84d0dbfa0c935adeda", size = 5535, upload-time = "2025-10-24T14:57:10.718Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/02/b7/cf592cb5de5cb3bade3357f8d2cf42bf103bbe39f459824b4939fd212911/annotated_doc-0.0.3-py3-none-any.whl", hash = "sha256:348ec6664a76f1fd3be81f43dffbee4c7e8ce931ba71ec67cc7f4ade7fbbb580", size = 5488, upload-time = "2025-10-24T14:57:09.462Z" }, -] - -[[package]] -name = "annotated-types" -version = "0.7.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, -] - -[[package]] -name = "anyio" -version = "4.11.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "idna" }, - { name = "sniffio" }, - { name = "typing-extensions", marker = "python_full_version < '3.13'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/c6/78/7d432127c41b50bccba979505f272c16cbcadcc33645d5fa3a738110ae75/anyio-4.11.0.tar.gz", hash = "sha256:82a8d0b81e318cc5ce71a5f1f8b5c4e63619620b63141ef8c995fa0db95a57c4", size = 219094, upload-time = "2025-09-23T09:19:12.58Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/15/b3/9b1a8074496371342ec1e796a96f99c82c945a339cd81a8e73de28b4cf9e/anyio-4.11.0-py3-none-any.whl", hash = "sha256:0287e96f4d26d4149305414d4e3bc32f0dcd0862365a4bddea19d7a1ec38c4fc", size = 109097, upload-time = "2025-09-23T09:19:10.601Z" }, -] - -[[package]] -name = "asyncpg" -version = "0.30.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/2f/4c/7c991e080e106d854809030d8584e15b2e996e26f16aee6d757e387bc17d/asyncpg-0.30.0.tar.gz", hash = "sha256:c551e9928ab6707602f44811817f82ba3c446e018bfe1d3abecc8ba5f3eac851", size = 957746, upload-time = "2024-10-20T00:30:41.127Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/4b/64/9d3e887bb7b01535fdbc45fbd5f0a8447539833b97ee69ecdbb7a79d0cb4/asyncpg-0.30.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:c902a60b52e506d38d7e80e0dd5399f657220f24635fee368117b8b5fce1142e", size = 673162, upload-time = "2024-10-20T00:29:41.88Z" }, - { url = "https://files.pythonhosted.org/packages/6e/eb/8b236663f06984f212a087b3e849731f917ab80f84450e943900e8ca4052/asyncpg-0.30.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:aca1548e43bbb9f0f627a04666fedaca23db0a31a84136ad1f868cb15deb6e3a", size = 637025, upload-time = "2024-10-20T00:29:43.352Z" }, - { url = "https://files.pythonhosted.org/packages/cc/57/2dc240bb263d58786cfaa60920779af6e8d32da63ab9ffc09f8312bd7a14/asyncpg-0.30.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6c2a2ef565400234a633da0eafdce27e843836256d40705d83ab7ec42074efb3", size = 3496243, upload-time = "2024-10-20T00:29:44.922Z" }, - { url = "https://files.pythonhosted.org/packages/f4/40/0ae9d061d278b10713ea9021ef6b703ec44698fe32178715a501ac696c6b/asyncpg-0.30.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1292b84ee06ac8a2ad8e51c7475aa309245874b61333d97411aab835c4a2f737", size = 3575059, upload-time = "2024-10-20T00:29:46.891Z" }, - { url = "https://files.pythonhosted.org/packages/c3/75/d6b895a35a2c6506952247640178e5f768eeb28b2e20299b6a6f1d743ba0/asyncpg-0.30.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:0f5712350388d0cd0615caec629ad53c81e506b1abaaf8d14c93f54b35e3595a", size = 3473596, upload-time = "2024-10-20T00:29:49.201Z" }, - { url = "https://files.pythonhosted.org/packages/c8/e7/3693392d3e168ab0aebb2d361431375bd22ffc7b4a586a0fc060d519fae7/asyncpg-0.30.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:db9891e2d76e6f425746c5d2da01921e9a16b5a71a1c905b13f30e12a257c4af", size = 3641632, upload-time = "2024-10-20T00:29:50.768Z" }, - { url = "https://files.pythonhosted.org/packages/32/ea/15670cea95745bba3f0352341db55f506a820b21c619ee66b7d12ea7867d/asyncpg-0.30.0-cp312-cp312-win32.whl", hash = "sha256:68d71a1be3d83d0570049cd1654a9bdfe506e794ecc98ad0873304a9f35e411e", size = 560186, upload-time = "2024-10-20T00:29:52.394Z" }, - { url = "https://files.pythonhosted.org/packages/7e/6b/fe1fad5cee79ca5f5c27aed7bd95baee529c1bf8a387435c8ba4fe53d5c1/asyncpg-0.30.0-cp312-cp312-win_amd64.whl", hash = "sha256:9a0292c6af5c500523949155ec17b7fe01a00ace33b68a476d6b5059f9630305", size = 621064, upload-time = "2024-10-20T00:29:53.757Z" }, - { url = "https://files.pythonhosted.org/packages/3a/22/e20602e1218dc07692acf70d5b902be820168d6282e69ef0d3cb920dc36f/asyncpg-0.30.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:05b185ebb8083c8568ea8a40e896d5f7af4b8554b64d7719c0eaa1eb5a5c3a70", size = 670373, upload-time = "2024-10-20T00:29:55.165Z" }, - { url = "https://files.pythonhosted.org/packages/3d/b3/0cf269a9d647852a95c06eb00b815d0b95a4eb4b55aa2d6ba680971733b9/asyncpg-0.30.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:c47806b1a8cbb0a0db896f4cd34d89942effe353a5035c62734ab13b9f938da3", size = 634745, upload-time = "2024-10-20T00:29:57.14Z" }, - { url = "https://files.pythonhosted.org/packages/8e/6d/a4f31bf358ce8491d2a31bfe0d7bcf25269e80481e49de4d8616c4295a34/asyncpg-0.30.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b6fde867a74e8c76c71e2f64f80c64c0f3163e687f1763cfaf21633ec24ec33", size = 3512103, upload-time = "2024-10-20T00:29:58.499Z" }, - { url = "https://files.pythonhosted.org/packages/96/19/139227a6e67f407b9c386cb594d9628c6c78c9024f26df87c912fabd4368/asyncpg-0.30.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46973045b567972128a27d40001124fbc821c87a6cade040cfcd4fa8a30bcdc4", size = 3592471, upload-time = "2024-10-20T00:30:00.354Z" }, - { url = "https://files.pythonhosted.org/packages/67/e4/ab3ca38f628f53f0fd28d3ff20edff1c975dd1cb22482e0061916b4b9a74/asyncpg-0.30.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:9110df111cabc2ed81aad2f35394a00cadf4f2e0635603db6ebbd0fc896f46a4", size = 3496253, upload-time = "2024-10-20T00:30:02.794Z" }, - { url = "https://files.pythonhosted.org/packages/ef/5f/0bf65511d4eeac3a1f41c54034a492515a707c6edbc642174ae79034d3ba/asyncpg-0.30.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:04ff0785ae7eed6cc138e73fc67b8e51d54ee7a3ce9b63666ce55a0bf095f7ba", size = 3662720, upload-time = "2024-10-20T00:30:04.501Z" }, - { url = "https://files.pythonhosted.org/packages/e7/31/1513d5a6412b98052c3ed9158d783b1e09d0910f51fbe0e05f56cc370bc4/asyncpg-0.30.0-cp313-cp313-win32.whl", hash = "sha256:ae374585f51c2b444510cdf3595b97ece4f233fde739aa14b50e0d64e8a7a590", size = 560404, upload-time = "2024-10-20T00:30:06.537Z" }, - { url = "https://files.pythonhosted.org/packages/c8/a4/cec76b3389c4c5ff66301cd100fe88c318563ec8a520e0b2e792b5b84972/asyncpg-0.30.0-cp313-cp313-win_amd64.whl", hash = "sha256:f59b430b8e27557c3fb9869222559f7417ced18688375825f8f12302c34e915e", size = 621623, upload-time = "2024-10-20T00:30:09.024Z" }, -] - -[[package]] -name = "black" -version = "25.9.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "click" }, - { name = "mypy-extensions" }, - { name = "packaging" }, - { name = "pathspec" }, - { name = "platformdirs" }, - { name = "pytokens" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/4b/43/20b5c90612d7bdb2bdbcceeb53d588acca3bb8f0e4c5d5c751a2c8fdd55a/black-25.9.0.tar.gz", hash = "sha256:0474bca9a0dd1b51791fcc507a4e02078a1c63f6d4e4ae5544b9848c7adfb619", size = 648393, upload-time = "2025-09-19T00:27:37.758Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/fb/8e/319cfe6c82f7e2d5bfb4d3353c6cc85b523d677ff59edc61fdb9ee275234/black-25.9.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1b9dc70c21ef8b43248f1d86aedd2aaf75ae110b958a7909ad8463c4aa0880b0", size = 1742012, upload-time = "2025-09-19T00:33:08.678Z" }, - { url = "https://files.pythonhosted.org/packages/94/cc/f562fe5d0a40cd2a4e6ae3f685e4c36e365b1f7e494af99c26ff7f28117f/black-25.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:8e46eecf65a095fa62e53245ae2795c90bdecabd53b50c448d0a8bcd0d2e74c4", size = 1581421, upload-time = "2025-09-19T00:35:25.937Z" }, - { url = "https://files.pythonhosted.org/packages/84/67/6db6dff1ebc8965fd7661498aea0da5d7301074b85bba8606a28f47ede4d/black-25.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9101ee58ddc2442199a25cb648d46ba22cd580b00ca4b44234a324e3ec7a0f7e", size = 1655619, upload-time = "2025-09-19T00:30:49.241Z" }, - { url = "https://files.pythonhosted.org/packages/10/10/3faef9aa2a730306cf469d76f7f155a8cc1f66e74781298df0ba31f8b4c8/black-25.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:77e7060a00c5ec4b3367c55f39cf9b06e68965a4f2e61cecacd6d0d9b7ec945a", size = 1342481, upload-time = "2025-09-19T00:31:29.625Z" }, - { url = "https://files.pythonhosted.org/packages/48/99/3acfea65f5e79f45472c45f87ec13037b506522719cd9d4ac86484ff51ac/black-25.9.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:0172a012f725b792c358d57fe7b6b6e8e67375dd157f64fa7a3097b3ed3e2175", size = 1742165, upload-time = "2025-09-19T00:34:10.402Z" }, - { url = "https://files.pythonhosted.org/packages/3a/18/799285282c8236a79f25d590f0222dbd6850e14b060dfaa3e720241fd772/black-25.9.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:3bec74ee60f8dfef564b573a96b8930f7b6a538e846123d5ad77ba14a8d7a64f", size = 1581259, upload-time = "2025-09-19T00:32:49.685Z" }, - { url = "https://files.pythonhosted.org/packages/f1/ce/883ec4b6303acdeca93ee06b7622f1fa383c6b3765294824165d49b1a86b/black-25.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b756fc75871cb1bcac5499552d771822fd9db5a2bb8db2a7247936ca48f39831", size = 1655583, upload-time = "2025-09-19T00:30:44.505Z" }, - { url = "https://files.pythonhosted.org/packages/21/17/5c253aa80a0639ccc427a5c7144534b661505ae2b5a10b77ebe13fa25334/black-25.9.0-cp313-cp313-win_amd64.whl", hash = "sha256:846d58e3ce7879ec1ffe816bb9df6d006cd9590515ed5d17db14e17666b2b357", size = 1343428, upload-time = "2025-09-19T00:32:13.839Z" }, - { url = "https://files.pythonhosted.org/packages/1b/46/863c90dcd3f9d41b109b7f19032ae0db021f0b2a81482ba0a1e28c84de86/black-25.9.0-py3-none-any.whl", hash = "sha256:474b34c1342cdc157d307b56c4c65bce916480c4a8f6551fdc6bf9b486a7c4ae", size = 203363, upload-time = "2025-09-19T00:27:35.724Z" }, -] - -[[package]] -name = "certifi" -version = "2025.10.5" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/4c/5b/b6ce21586237c77ce67d01dc5507039d444b630dd76611bbca2d8e5dcd91/certifi-2025.10.5.tar.gz", hash = "sha256:47c09d31ccf2acf0be3f701ea53595ee7e0b8fa08801c6624be771df09ae7b43", size = 164519, upload-time = "2025-10-05T04:12:15.808Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/e4/37/af0d2ef3967ac0d6113837b44a4f0bfe1328c2b9763bd5b1744520e5cfed/certifi-2025.10.5-py3-none-any.whl", hash = "sha256:0f212c2744a9bb6de0c56639a6f68afe01ecd92d91f14ae897c4fe7bbeeef0de", size = 163286, upload-time = "2025-10-05T04:12:14.03Z" }, -] - -[[package]] -name = "click" -version = "8.3.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/46/61/de6cd827efad202d7057d93e0fed9294b96952e188f7384832791c7b2254/click-8.3.0.tar.gz", hash = "sha256:e7b8232224eba16f4ebe410c25ced9f7875cb5f3263ffc93cc3e8da705e229c4", size = 276943, upload-time = "2025-09-18T17:32:23.696Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/db/d3/9dcc0f5797f070ec8edf30fbadfb200e71d9db6b84d211e3b2085a7589a0/click-8.3.0-py3-none-any.whl", hash = "sha256:9b9f285302c6e3064f4330c05f05b81945b2a39544279343e6e7c5f27a9baddc", size = 107295, upload-time = "2025-09-18T17:32:22.42Z" }, -] - -[[package]] -name = "colorama" -version = "0.4.6" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, -] - -[[package]] -name = "distro" -version = "1.9.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, -] - -[[package]] -name = "fastapi" -version = "0.120.4" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "annotated-doc" }, - { name = "pydantic" }, - { name = "starlette" }, - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/3f/3a/0bf90d5189d7f62dc2bd0523899629ca59b58ff4290d631cd3bb5c8889d4/fastapi-0.120.4.tar.gz", hash = "sha256:2d856bc847893ca4d77896d4504ffdec0fb04312b705065fca9104428eca3868", size = 339716, upload-time = "2025-10-31T18:37:28.81Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/ed/47/14a76b926edc3957c8a8258423db789d3fa925d2fed800102fce58959413/fastapi-0.120.4-py3-none-any.whl", hash = "sha256:9bdf192308676480d3593e10fd05094e56d6fdc7d9283db26053d8104d5f82a0", size = 108235, upload-time = "2025-10-31T18:37:27.038Z" }, -] - -[[package]] -name = "greenlet" -version = "3.2.4" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/03/b8/704d753a5a45507a7aab61f18db9509302ed3d0a27ac7e0359ec2905b1a6/greenlet-3.2.4.tar.gz", hash = "sha256:0dca0d95ff849f9a364385f36ab49f50065d76964944638be9691e1832e9f86d", size = 188260, upload-time = "2025-08-07T13:24:33.51Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/44/69/9b804adb5fd0671f367781560eb5eb586c4d495277c93bde4307b9e28068/greenlet-3.2.4-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:3b67ca49f54cede0186854a008109d6ee71f66bd57bb36abd6d0a0267b540cdd", size = 274079, upload-time = "2025-08-07T13:15:45.033Z" }, - { url = "https://files.pythonhosted.org/packages/46/e9/d2a80c99f19a153eff70bc451ab78615583b8dac0754cfb942223d2c1a0d/greenlet-3.2.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddf9164e7a5b08e9d22511526865780a576f19ddd00d62f8a665949327fde8bb", size = 640997, upload-time = "2025-08-07T13:42:56.234Z" }, - { url = "https://files.pythonhosted.org/packages/3b/16/035dcfcc48715ccd345f3a93183267167cdd162ad123cd93067d86f27ce4/greenlet-3.2.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:f28588772bb5fb869a8eb331374ec06f24a83a9c25bfa1f38b6993afe9c1e968", size = 655185, upload-time = "2025-08-07T13:45:27.624Z" }, - { url = "https://files.pythonhosted.org/packages/31/da/0386695eef69ffae1ad726881571dfe28b41970173947e7c558d9998de0f/greenlet-3.2.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:5c9320971821a7cb77cfab8d956fa8e39cd07ca44b6070db358ceb7f8797c8c9", size = 649926, upload-time = "2025-08-07T13:53:15.251Z" }, - { url = "https://files.pythonhosted.org/packages/68/88/69bf19fd4dc19981928ceacbc5fd4bb6bc2215d53199e367832e98d1d8fe/greenlet-3.2.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c60a6d84229b271d44b70fb6e5fa23781abb5d742af7b808ae3f6efd7c9c60f6", size = 651839, upload-time = "2025-08-07T13:18:30.281Z" }, - { url = "https://files.pythonhosted.org/packages/19/0d/6660d55f7373b2ff8152401a83e02084956da23ae58cddbfb0b330978fe9/greenlet-3.2.4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3b3812d8d0c9579967815af437d96623f45c0f2ae5f04e366de62a12d83a8fb0", size = 607586, upload-time = "2025-08-07T13:18:28.544Z" }, - { url = "https://files.pythonhosted.org/packages/8e/1a/c953fdedd22d81ee4629afbb38d2f9d71e37d23caace44775a3a969147d4/greenlet-3.2.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:abbf57b5a870d30c4675928c37278493044d7c14378350b3aa5d484fa65575f0", size = 1123281, upload-time = "2025-08-07T13:42:39.858Z" }, - { url = "https://files.pythonhosted.org/packages/3f/c7/12381b18e21aef2c6bd3a636da1088b888b97b7a0362fac2e4de92405f97/greenlet-3.2.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:20fb936b4652b6e307b8f347665e2c615540d4b42b3b4c8a321d8286da7e520f", size = 1151142, upload-time = "2025-08-07T13:18:22.981Z" }, - { url = "https://files.pythonhosted.org/packages/e9/08/b0814846b79399e585f974bbeebf5580fbe59e258ea7be64d9dfb253c84f/greenlet-3.2.4-cp312-cp312-win_amd64.whl", hash = "sha256:a7d4e128405eea3814a12cc2605e0e6aedb4035bf32697f72deca74de4105e02", size = 299899, upload-time = "2025-08-07T13:38:53.448Z" }, - { url = "https://files.pythonhosted.org/packages/49/e8/58c7f85958bda41dafea50497cbd59738c5c43dbbea5ee83d651234398f4/greenlet-3.2.4-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:1a921e542453fe531144e91e1feedf12e07351b1cf6c9e8a3325ea600a715a31", size = 272814, upload-time = "2025-08-07T13:15:50.011Z" }, - { url = "https://files.pythonhosted.org/packages/62/dd/b9f59862e9e257a16e4e610480cfffd29e3fae018a68c2332090b53aac3d/greenlet-3.2.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:cd3c8e693bff0fff6ba55f140bf390fa92c994083f838fece0f63be121334945", size = 641073, upload-time = "2025-08-07T13:42:57.23Z" }, - { url = "https://files.pythonhosted.org/packages/f7/0b/bc13f787394920b23073ca3b6c4a7a21396301ed75a655bcb47196b50e6e/greenlet-3.2.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:710638eb93b1fa52823aa91bf75326f9ecdfd5e0466f00789246a5280f4ba0fc", size = 655191, upload-time = "2025-08-07T13:45:29.752Z" }, - { url = "https://files.pythonhosted.org/packages/f2/d6/6adde57d1345a8d0f14d31e4ab9c23cfe8e2cd39c3baf7674b4b0338d266/greenlet-3.2.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:c5111ccdc9c88f423426df3fd1811bfc40ed66264d35aa373420a34377efc98a", size = 649516, upload-time = "2025-08-07T13:53:16.314Z" }, - { url = "https://files.pythonhosted.org/packages/7f/3b/3a3328a788d4a473889a2d403199932be55b1b0060f4ddd96ee7cdfcad10/greenlet-3.2.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:d76383238584e9711e20ebe14db6c88ddcedc1829a9ad31a584389463b5aa504", size = 652169, upload-time = "2025-08-07T13:18:32.861Z" }, - { url = "https://files.pythonhosted.org/packages/ee/43/3cecdc0349359e1a527cbf2e3e28e5f8f06d3343aaf82ca13437a9aa290f/greenlet-3.2.4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:23768528f2911bcd7e475210822ffb5254ed10d71f4028387e5a99b4c6699671", size = 610497, upload-time = "2025-08-07T13:18:31.636Z" }, - { url = "https://files.pythonhosted.org/packages/b8/19/06b6cf5d604e2c382a6f31cafafd6f33d5dea706f4db7bdab184bad2b21d/greenlet-3.2.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:00fadb3fedccc447f517ee0d3fd8fe49eae949e1cd0f6a611818f4f6fb7dc83b", size = 1121662, upload-time = "2025-08-07T13:42:41.117Z" }, - { url = "https://files.pythonhosted.org/packages/a2/15/0d5e4e1a66fab130d98168fe984c509249c833c1a3c16806b90f253ce7b9/greenlet-3.2.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:d25c5091190f2dc0eaa3f950252122edbbadbb682aa7b1ef2f8af0f8c0afefae", size = 1149210, upload-time = "2025-08-07T13:18:24.072Z" }, - { url = "https://files.pythonhosted.org/packages/0b/55/2321e43595e6801e105fcfdee02b34c0f996eb71e6ddffca6b10b7e1d771/greenlet-3.2.4-cp313-cp313-win_amd64.whl", hash = "sha256:554b03b6e73aaabec3745364d6239e9e012d64c68ccd0b8430c64ccc14939a8b", size = 299685, upload-time = "2025-08-07T13:24:38.824Z" }, - { url = "https://files.pythonhosted.org/packages/22/5c/85273fd7cc388285632b0498dbbab97596e04b154933dfe0f3e68156c68c/greenlet-3.2.4-cp314-cp314-macosx_11_0_universal2.whl", hash = "sha256:49a30d5fda2507ae77be16479bdb62a660fa51b1eb4928b524975b3bde77b3c0", size = 273586, upload-time = "2025-08-07T13:16:08.004Z" }, - { url = "https://files.pythonhosted.org/packages/d1/75/10aeeaa3da9332c2e761e4c50d4c3556c21113ee3f0afa2cf5769946f7a3/greenlet-3.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:299fd615cd8fc86267b47597123e3f43ad79c9d8a22bebdce535e53550763e2f", size = 686346, upload-time = "2025-08-07T13:42:59.944Z" }, - { url = "https://files.pythonhosted.org/packages/c0/aa/687d6b12ffb505a4447567d1f3abea23bd20e73a5bed63871178e0831b7a/greenlet-3.2.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:c17b6b34111ea72fc5a4e4beec9711d2226285f0386ea83477cbb97c30a3f3a5", size = 699218, upload-time = "2025-08-07T13:45:30.969Z" }, - { url = "https://files.pythonhosted.org/packages/dc/8b/29aae55436521f1d6f8ff4e12fb676f3400de7fcf27fccd1d4d17fd8fecd/greenlet-3.2.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:b4a1870c51720687af7fa3e7cda6d08d801dae660f75a76f3845b642b4da6ee1", size = 694659, upload-time = "2025-08-07T13:53:17.759Z" }, - { url = "https://files.pythonhosted.org/packages/92/2e/ea25914b1ebfde93b6fc4ff46d6864564fba59024e928bdc7de475affc25/greenlet-3.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:061dc4cf2c34852b052a8620d40f36324554bc192be474b9e9770e8c042fd735", size = 695355, upload-time = "2025-08-07T13:18:34.517Z" }, - { url = "https://files.pythonhosted.org/packages/72/60/fc56c62046ec17f6b0d3060564562c64c862948c9d4bc8aa807cf5bd74f4/greenlet-3.2.4-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:44358b9bf66c8576a9f57a590d5f5d6e72fa4228b763d0e43fee6d3b06d3a337", size = 657512, upload-time = "2025-08-07T13:18:33.969Z" }, - { url = "https://files.pythonhosted.org/packages/e3/a5/6ddab2b4c112be95601c13428db1d8b6608a8b6039816f2ba09c346c08fc/greenlet-3.2.4-cp314-cp314-win_amd64.whl", hash = "sha256:e37ab26028f12dbb0ff65f29a8d3d44a765c61e729647bf2ddfbbed621726f01", size = 303425, upload-time = "2025-08-07T13:32:27.59Z" }, -] - -[[package]] -name = "h11" -version = "0.16.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, -] - -[[package]] -name = "httpcore" -version = "1.0.9" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "certifi" }, - { name = "h11" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, -] - -[[package]] -name = "httptools" -version = "0.7.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/b5/46/120a669232c7bdedb9d52d4aeae7e6c7dfe151e99dc70802e2fc7a5e1993/httptools-0.7.1.tar.gz", hash = "sha256:abd72556974f8e7c74a259655924a717a2365b236c882c3f6f8a45fe94703ac9", size = 258961, upload-time = "2025-10-10T03:55:08.559Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/53/7f/403e5d787dc4942316e515e949b0c8a013d84078a915910e9f391ba9b3ed/httptools-0.7.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:38e0c83a2ea9746ebbd643bdfb521b9aa4a91703e2cd705c20443405d2fd16a5", size = 206280, upload-time = "2025-10-10T03:54:39.274Z" }, - { url = "https://files.pythonhosted.org/packages/2a/0d/7f3fd28e2ce311ccc998c388dd1c53b18120fda3b70ebb022b135dc9839b/httptools-0.7.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f25bbaf1235e27704f1a7b86cd3304eabc04f569c828101d94a0e605ef7205a5", size = 110004, upload-time = "2025-10-10T03:54:40.403Z" }, - { url = "https://files.pythonhosted.org/packages/84/a6/b3965e1e146ef5762870bbe76117876ceba51a201e18cc31f5703e454596/httptools-0.7.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:2c15f37ef679ab9ecc06bfc4e6e8628c32a8e4b305459de7cf6785acd57e4d03", size = 517655, upload-time = "2025-10-10T03:54:41.347Z" }, - { url = "https://files.pythonhosted.org/packages/11/7d/71fee6f1844e6fa378f2eddde6c3e41ce3a1fb4b2d81118dd544e3441ec0/httptools-0.7.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7fe6e96090df46b36ccfaf746f03034e5ab723162bc51b0a4cf58305324036f2", size = 511440, upload-time = "2025-10-10T03:54:42.452Z" }, - { url = "https://files.pythonhosted.org/packages/22/a5/079d216712a4f3ffa24af4a0381b108aa9c45b7a5cc6eb141f81726b1823/httptools-0.7.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f72fdbae2dbc6e68b8239defb48e6a5937b12218e6ffc2c7846cc37befa84362", size = 495186, upload-time = "2025-10-10T03:54:43.937Z" }, - { url = "https://files.pythonhosted.org/packages/e9/9e/025ad7b65278745dee3bd0ebf9314934c4592560878308a6121f7f812084/httptools-0.7.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e99c7b90a29fd82fea9ef57943d501a16f3404d7b9ee81799d41639bdaae412c", size = 499192, upload-time = "2025-10-10T03:54:45.003Z" }, - { url = "https://files.pythonhosted.org/packages/6d/de/40a8f202b987d43afc4d54689600ff03ce65680ede2f31df348d7f368b8f/httptools-0.7.1-cp312-cp312-win_amd64.whl", hash = "sha256:3e14f530fefa7499334a79b0cf7e7cd2992870eb893526fb097d51b4f2d0f321", size = 86694, upload-time = "2025-10-10T03:54:45.923Z" }, - { url = "https://files.pythonhosted.org/packages/09/8f/c77b1fcbfd262d422f12da02feb0d218fa228d52485b77b953832105bb90/httptools-0.7.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:6babce6cfa2a99545c60bfef8bee0cc0545413cb0018f617c8059a30ad985de3", size = 202889, upload-time = "2025-10-10T03:54:47.089Z" }, - { url = "https://files.pythonhosted.org/packages/0a/1a/22887f53602feaa066354867bc49a68fc295c2293433177ee90870a7d517/httptools-0.7.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:601b7628de7504077dd3dcb3791c6b8694bbd967148a6d1f01806509254fb1ca", size = 108180, upload-time = "2025-10-10T03:54:48.052Z" }, - { url = "https://files.pythonhosted.org/packages/32/6a/6aaa91937f0010d288d3d124ca2946d48d60c3a5ee7ca62afe870e3ea011/httptools-0.7.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:04c6c0e6c5fb0739c5b8a9eb046d298650a0ff38cf42537fc372b28dc7e4472c", size = 478596, upload-time = "2025-10-10T03:54:48.919Z" }, - { url = "https://files.pythonhosted.org/packages/6d/70/023d7ce117993107be88d2cbca566a7c1323ccbaf0af7eabf2064fe356f6/httptools-0.7.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:69d4f9705c405ae3ee83d6a12283dc9feba8cc6aaec671b412917e644ab4fa66", size = 473268, upload-time = "2025-10-10T03:54:49.993Z" }, - { url = "https://files.pythonhosted.org/packages/32/4d/9dd616c38da088e3f436e9a616e1d0cc66544b8cdac405cc4e81c8679fc7/httptools-0.7.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:44c8f4347d4b31269c8a9205d8a5ee2df5322b09bbbd30f8f862185bb6b05346", size = 455517, upload-time = "2025-10-10T03:54:51.066Z" }, - { url = "https://files.pythonhosted.org/packages/1d/3a/a6c595c310b7df958e739aae88724e24f9246a514d909547778d776799be/httptools-0.7.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:465275d76db4d554918aba40bf1cbebe324670f3dfc979eaffaa5d108e2ed650", size = 458337, upload-time = "2025-10-10T03:54:52.196Z" }, - { url = "https://files.pythonhosted.org/packages/fd/82/88e8d6d2c51edc1cc391b6e044c6c435b6aebe97b1abc33db1b0b24cd582/httptools-0.7.1-cp313-cp313-win_amd64.whl", hash = "sha256:322d00c2068d125bd570f7bf78b2d367dad02b919d8581d7476d8b75b294e3e6", size = 85743, upload-time = "2025-10-10T03:54:53.448Z" }, - { url = "https://files.pythonhosted.org/packages/34/50/9d095fcbb6de2d523e027a2f304d4551855c2f46e0b82befd718b8b20056/httptools-0.7.1-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:c08fe65728b8d70b6923ce31e3956f859d5e1e8548e6f22ec520a962c6757270", size = 203619, upload-time = "2025-10-10T03:54:54.321Z" }, - { url = "https://files.pythonhosted.org/packages/07/f0/89720dc5139ae54b03f861b5e2c55a37dba9a5da7d51e1e824a1f343627f/httptools-0.7.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:7aea2e3c3953521c3c51106ee11487a910d45586e351202474d45472db7d72d3", size = 108714, upload-time = "2025-10-10T03:54:55.163Z" }, - { url = "https://files.pythonhosted.org/packages/b3/cb/eea88506f191fb552c11787c23f9a405f4c7b0c5799bf73f2249cd4f5228/httptools-0.7.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:0e68b8582f4ea9166be62926077a3334064d422cf08ab87d8b74664f8e9058e1", size = 472909, upload-time = "2025-10-10T03:54:56.056Z" }, - { url = "https://files.pythonhosted.org/packages/e0/4a/a548bdfae6369c0d078bab5769f7b66f17f1bfaa6fa28f81d6be6959066b/httptools-0.7.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:df091cf961a3be783d6aebae963cc9b71e00d57fa6f149025075217bc6a55a7b", size = 470831, upload-time = "2025-10-10T03:54:57.219Z" }, - { url = "https://files.pythonhosted.org/packages/4d/31/14df99e1c43bd132eec921c2e7e11cda7852f65619bc0fc5bdc2d0cb126c/httptools-0.7.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:f084813239e1eb403ddacd06a30de3d3e09a9b76e7894dcda2b22f8a726e9c60", size = 452631, upload-time = "2025-10-10T03:54:58.219Z" }, - { url = "https://files.pythonhosted.org/packages/22/d2/b7e131f7be8d854d48cb6d048113c30f9a46dca0c9a8b08fcb3fcd588cdc/httptools-0.7.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:7347714368fb2b335e9063bc2b96f2f87a9ceffcd9758ac295f8bbcd3ffbc0ca", size = 452910, upload-time = "2025-10-10T03:54:59.366Z" }, - { url = "https://files.pythonhosted.org/packages/53/cf/878f3b91e4e6e011eff6d1fa9ca39f7eb17d19c9d7971b04873734112f30/httptools-0.7.1-cp314-cp314-win_amd64.whl", hash = "sha256:cfabda2a5bb85aa2a904ce06d974a3f30fb36cc63d7feaddec05d2050acede96", size = 88205, upload-time = "2025-10-10T03:55:00.389Z" }, -] - -[[package]] -name = "httpx" -version = "0.28.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "anyio" }, - { name = "certifi" }, - { name = "httpcore" }, - { name = "idna" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, -] - -[[package]] -name = "idna" -version = "3.11" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, -] - -[[package]] -name = "iniconfig" -version = "2.3.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" }, -] - -[[package]] -name = "jiter" -version = "0.11.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a3/68/0357982493a7b20925aece061f7fb7a2678e3b232f8d73a6edb7e5304443/jiter-0.11.1.tar.gz", hash = "sha256:849dcfc76481c0ea0099391235b7ca97d7279e0fa4c86005457ac7c88e8b76dc", size = 168385, upload-time = "2025-10-17T11:31:15.186Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/15/8b/318e8af2c904a9d29af91f78c1e18f0592e189bbdb8a462902d31fe20682/jiter-0.11.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:c92148eec91052538ce6823dfca9525f5cfc8b622d7f07e9891a280f61b8c96c", size = 305655, upload-time = "2025-10-17T11:29:18.859Z" }, - { url = "https://files.pythonhosted.org/packages/f7/29/6c7de6b5d6e511d9e736312c0c9bfcee8f9b6bef68182a08b1d78767e627/jiter-0.11.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ecd4da91b5415f183a6be8f7158d127bdd9e6a3174138293c0d48d6ea2f2009d", size = 315645, upload-time = "2025-10-17T11:29:20.889Z" }, - { url = "https://files.pythonhosted.org/packages/ac/5f/ef9e5675511ee0eb7f98dd8c90509e1f7743dbb7c350071acae87b0145f3/jiter-0.11.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7e3ac25c00b9275684d47aa42febaa90a9958e19fd1726c4ecf755fbe5e553b", size = 348003, upload-time = "2025-10-17T11:29:22.712Z" }, - { url = "https://files.pythonhosted.org/packages/56/1b/abe8c4021010b0a320d3c62682769b700fb66f92c6db02d1a1381b3db025/jiter-0.11.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:57d7305c0a841858f866cd459cd9303f73883fb5e097257f3d4a3920722c69d4", size = 365122, upload-time = "2025-10-17T11:29:24.408Z" }, - { url = "https://files.pythonhosted.org/packages/2a/2d/4a18013939a4f24432f805fbd5a19893e64650b933edb057cd405275a538/jiter-0.11.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e86fa10e117dce22c547f31dd6d2a9a222707d54853d8de4e9a2279d2c97f239", size = 488360, upload-time = "2025-10-17T11:29:25.724Z" }, - { url = "https://files.pythonhosted.org/packages/f0/77/38124f5d02ac4131f0dfbcfd1a19a0fac305fa2c005bc4f9f0736914a1a4/jiter-0.11.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:ae5ef1d48aec7e01ee8420155d901bb1d192998fa811a65ebb82c043ee186711", size = 376884, upload-time = "2025-10-17T11:29:27.056Z" }, - { url = "https://files.pythonhosted.org/packages/7b/43/59fdc2f6267959b71dd23ce0bd8d4aeaf55566aa435a5d00f53d53c7eb24/jiter-0.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb68e7bf65c990531ad8715e57d50195daf7c8e6f1509e617b4e692af1108939", size = 358827, upload-time = "2025-10-17T11:29:28.698Z" }, - { url = "https://files.pythonhosted.org/packages/7d/d0/b3cc20ff5340775ea3bbaa0d665518eddecd4266ba7244c9cb480c0c82ec/jiter-0.11.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43b30c8154ded5845fa454ef954ee67bfccce629b2dea7d01f795b42bc2bda54", size = 385171, upload-time = "2025-10-17T11:29:30.078Z" }, - { url = "https://files.pythonhosted.org/packages/d2/bc/94dd1f3a61f4dc236f787a097360ec061ceeebebf4ea120b924d91391b10/jiter-0.11.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:586cafbd9dd1f3ce6a22b4a085eaa6be578e47ba9b18e198d4333e598a91db2d", size = 518359, upload-time = "2025-10-17T11:29:31.464Z" }, - { url = "https://files.pythonhosted.org/packages/7e/8c/12ee132bd67e25c75f542c227f5762491b9a316b0dad8e929c95076f773c/jiter-0.11.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:677cc2517d437a83bb30019fd4cf7cad74b465914c56ecac3440d597ac135250", size = 509205, upload-time = "2025-10-17T11:29:32.895Z" }, - { url = "https://files.pythonhosted.org/packages/39/d5/9de848928ce341d463c7e7273fce90ea6d0ea4343cd761f451860fa16b59/jiter-0.11.1-cp312-cp312-win32.whl", hash = "sha256:fa992af648fcee2b850a3286a35f62bbbaeddbb6dbda19a00d8fbc846a947b6e", size = 205448, upload-time = "2025-10-17T11:29:34.217Z" }, - { url = "https://files.pythonhosted.org/packages/ee/b0/8002d78637e05009f5e3fb5288f9d57d65715c33b5d6aa20fd57670feef5/jiter-0.11.1-cp312-cp312-win_amd64.whl", hash = "sha256:88b5cae9fa51efeb3d4bd4e52bfd4c85ccc9cac44282e2a9640893a042ba4d87", size = 204285, upload-time = "2025-10-17T11:29:35.446Z" }, - { url = "https://files.pythonhosted.org/packages/9f/a2/bb24d5587e4dff17ff796716542f663deee337358006a80c8af43ddc11e5/jiter-0.11.1-cp312-cp312-win_arm64.whl", hash = "sha256:9a6cae1ab335551917f882f2c3c1efe7617b71b4c02381e4382a8fc80a02588c", size = 188712, upload-time = "2025-10-17T11:29:37.027Z" }, - { url = "https://files.pythonhosted.org/packages/7c/4b/e4dd3c76424fad02a601d570f4f2a8438daea47ba081201a721a903d3f4c/jiter-0.11.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:71b6a920a5550f057d49d0e8bcc60945a8da998019e83f01adf110e226267663", size = 305272, upload-time = "2025-10-17T11:29:39.249Z" }, - { url = "https://files.pythonhosted.org/packages/67/83/2cd3ad5364191130f4de80eacc907f693723beaab11a46c7d155b07a092c/jiter-0.11.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0b3de72e925388453a5171be83379549300db01284f04d2a6f244d1d8de36f94", size = 314038, upload-time = "2025-10-17T11:29:40.563Z" }, - { url = "https://files.pythonhosted.org/packages/d3/3c/8e67d9ba524e97d2f04c8f406f8769a23205026b13b0938d16646d6e2d3e/jiter-0.11.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc19dd65a2bd3d9c044c5b4ebf657ca1e6003a97c0fc10f555aa4f7fb9821c00", size = 345977, upload-time = "2025-10-17T11:29:42.009Z" }, - { url = "https://files.pythonhosted.org/packages/8d/a5/489ce64d992c29bccbffabb13961bbb0435e890d7f2d266d1f3df5e917d2/jiter-0.11.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d58faaa936743cd1464540562f60b7ce4fd927e695e8bc31b3da5b914baa9abd", size = 364503, upload-time = "2025-10-17T11:29:43.459Z" }, - { url = "https://files.pythonhosted.org/packages/d4/c0/e321dd83ee231d05c8fe4b1a12caf1f0e8c7a949bf4724d58397104f10f2/jiter-0.11.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:902640c3103625317291cb73773413b4d71847cdf9383ba65528745ff89f1d14", size = 487092, upload-time = "2025-10-17T11:29:44.835Z" }, - { url = "https://files.pythonhosted.org/packages/f9/5e/8f24ec49c8d37bd37f34ec0112e0b1a3b4b5a7b456c8efff1df5e189ad43/jiter-0.11.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:30405f726e4c2ed487b176c09f8b877a957f535d60c1bf194abb8dadedb5836f", size = 376328, upload-time = "2025-10-17T11:29:46.175Z" }, - { url = "https://files.pythonhosted.org/packages/7f/70/ded107620e809327cf7050727e17ccfa79d6385a771b7fe38fb31318ef00/jiter-0.11.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3217f61728b0baadd2551844870f65219ac4a1285d5e1a4abddff3d51fdabe96", size = 356632, upload-time = "2025-10-17T11:29:47.454Z" }, - { url = "https://files.pythonhosted.org/packages/19/53/c26f7251613f6a9079275ee43c89b8a973a95ff27532c421abc2a87afb04/jiter-0.11.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b1364cc90c03a8196f35f396f84029f12abe925415049204446db86598c8b72c", size = 384358, upload-time = "2025-10-17T11:29:49.377Z" }, - { url = "https://files.pythonhosted.org/packages/84/16/e0f2cc61e9c4d0b62f6c1bd9b9781d878a427656f88293e2a5335fa8ff07/jiter-0.11.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:53a54bf8e873820ab186b2dca9f6c3303f00d65ae5e7b7d6bda1b95aa472d646", size = 517279, upload-time = "2025-10-17T11:29:50.968Z" }, - { url = "https://files.pythonhosted.org/packages/60/5c/4cd095eaee68961bca3081acbe7c89e12ae24a5dae5fd5d2a13e01ed2542/jiter-0.11.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7e29aca023627b0e0c2392d4248f6414d566ff3974fa08ff2ac8dbb96dfee92a", size = 508276, upload-time = "2025-10-17T11:29:52.619Z" }, - { url = "https://files.pythonhosted.org/packages/4f/25/f459240e69b0e09a7706d96ce203ad615ca36b0fe832308d2b7123abf2d0/jiter-0.11.1-cp313-cp313-win32.whl", hash = "sha256:f153e31d8bca11363751e875c0a70b3d25160ecbaee7b51e457f14498fb39d8b", size = 205593, upload-time = "2025-10-17T11:29:53.938Z" }, - { url = "https://files.pythonhosted.org/packages/7c/16/461bafe22bae79bab74e217a09c907481a46d520c36b7b9fe71ee8c9e983/jiter-0.11.1-cp313-cp313-win_amd64.whl", hash = "sha256:f773f84080b667c69c4ea0403fc67bb08b07e2b7ce1ef335dea5868451e60fed", size = 203518, upload-time = "2025-10-17T11:29:55.216Z" }, - { url = "https://files.pythonhosted.org/packages/7b/72/c45de6e320edb4fa165b7b1a414193b3cae302dd82da2169d315dcc78b44/jiter-0.11.1-cp313-cp313-win_arm64.whl", hash = "sha256:635ecd45c04e4c340d2187bcb1cea204c7cc9d32c1364d251564bf42e0e39c2d", size = 188062, upload-time = "2025-10-17T11:29:56.631Z" }, - { url = "https://files.pythonhosted.org/packages/65/9b/4a57922437ca8753ef823f434c2dec5028b237d84fa320f06a3ba1aec6e8/jiter-0.11.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:d892b184da4d94d94ddb4031296931c74ec8b325513a541ebfd6dfb9ae89904b", size = 313814, upload-time = "2025-10-17T11:29:58.509Z" }, - { url = "https://files.pythonhosted.org/packages/76/50/62a0683dadca25490a4bedc6a88d59de9af2a3406dd5a576009a73a1d392/jiter-0.11.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aa22c223a3041dacb2fcd37c70dfd648b44662b4a48e242592f95bda5ab09d58", size = 344987, upload-time = "2025-10-17T11:30:00.208Z" }, - { url = "https://files.pythonhosted.org/packages/da/00/2355dbfcbf6cdeaddfdca18287f0f38ae49446bb6378e4a5971e9356fc8a/jiter-0.11.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:330e8e6a11ad4980cd66a0f4a3e0e2e0f646c911ce047014f984841924729789", size = 356399, upload-time = "2025-10-17T11:30:02.084Z" }, - { url = "https://files.pythonhosted.org/packages/c9/07/c2bd748d578fa933d894a55bff33f983bc27f75fc4e491b354bef7b78012/jiter-0.11.1-cp313-cp313t-win_amd64.whl", hash = "sha256:09e2e386ebf298547ca3a3704b729471f7ec666c2906c5c26c1a915ea24741ec", size = 203289, upload-time = "2025-10-17T11:30:03.656Z" }, - { url = "https://files.pythonhosted.org/packages/e6/ee/ace64a853a1acbd318eb0ca167bad1cf5ee037207504b83a868a5849747b/jiter-0.11.1-cp313-cp313t-win_arm64.whl", hash = "sha256:fe4a431c291157e11cee7c34627990ea75e8d153894365a3bc84b7a959d23ca8", size = 188284, upload-time = "2025-10-17T11:30:05.046Z" }, - { url = "https://files.pythonhosted.org/packages/8d/00/d6006d069e7b076e4c66af90656b63da9481954f290d5eca8c715f4bf125/jiter-0.11.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:0fa1f70da7a8a9713ff8e5f75ec3f90c0c870be6d526aa95e7c906f6a1c8c676", size = 304624, upload-time = "2025-10-17T11:30:06.678Z" }, - { url = "https://files.pythonhosted.org/packages/fc/45/4a0e31eb996b9ccfddbae4d3017b46f358a599ccf2e19fbffa5e531bd304/jiter-0.11.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:569ee559e5046a42feb6828c55307cf20fe43308e3ae0d8e9e4f8d8634d99944", size = 315042, upload-time = "2025-10-17T11:30:08.87Z" }, - { url = "https://files.pythonhosted.org/packages/e7/91/22f5746f5159a28c76acdc0778801f3c1181799aab196dbea2d29e064968/jiter-0.11.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f69955fa1d92e81987f092b233f0be49d4c937da107b7f7dcf56306f1d3fcce9", size = 346357, upload-time = "2025-10-17T11:30:10.222Z" }, - { url = "https://files.pythonhosted.org/packages/f5/4f/57620857d4e1dc75c8ff4856c90cb6c135e61bff9b4ebfb5dc86814e82d7/jiter-0.11.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:090f4c9d4a825e0fcbd0a2647c9a88a0f366b75654d982d95a9590745ff0c48d", size = 365057, upload-time = "2025-10-17T11:30:11.585Z" }, - { url = "https://files.pythonhosted.org/packages/ce/34/caf7f9cc8ae0a5bb25a5440cc76c7452d264d1b36701b90fdadd28fe08ec/jiter-0.11.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bbf3d8cedf9e9d825233e0dcac28ff15c47b7c5512fdfe2e25fd5bbb6e6b0cee", size = 487086, upload-time = "2025-10-17T11:30:13.052Z" }, - { url = "https://files.pythonhosted.org/packages/50/17/85b5857c329d533d433fedf98804ebec696004a1f88cabad202b2ddc55cf/jiter-0.11.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2aa9b1958f9c30d3d1a558b75f0626733c60eb9b7774a86b34d88060be1e67fe", size = 376083, upload-time = "2025-10-17T11:30:14.416Z" }, - { url = "https://files.pythonhosted.org/packages/85/d3/2d9f973f828226e6faebdef034097a2918077ea776fb4d88489949024787/jiter-0.11.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e42d1ca16590b768c5e7d723055acd2633908baacb3628dd430842e2e035aa90", size = 357825, upload-time = "2025-10-17T11:30:15.765Z" }, - { url = "https://files.pythonhosted.org/packages/f4/55/848d4dabf2c2c236a05468c315c2cb9dc736c5915e65449ccecdba22fb6f/jiter-0.11.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5db4c2486a023820b701a17aec9c5a6173c5ba4393f26662f032f2de9c848b0f", size = 383933, upload-time = "2025-10-17T11:30:17.34Z" }, - { url = "https://files.pythonhosted.org/packages/0b/6c/204c95a4fbb0e26dfa7776c8ef4a878d0c0b215868011cc904bf44f707e2/jiter-0.11.1-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:4573b78777ccfac954859a6eff45cbd9d281d80c8af049d0f1a3d9fc323d5c3a", size = 517118, upload-time = "2025-10-17T11:30:18.684Z" }, - { url = "https://files.pythonhosted.org/packages/88/25/09956644ea5a2b1e7a2a0f665cb69a973b28f4621fa61fc0c0f06ff40a31/jiter-0.11.1-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:7593ac6f40831d7961cb67633c39b9fef6689a211d7919e958f45710504f52d3", size = 508194, upload-time = "2025-10-17T11:30:20.719Z" }, - { url = "https://files.pythonhosted.org/packages/09/49/4d1657355d7f5c9e783083a03a3f07d5858efa6916a7d9634d07db1c23bd/jiter-0.11.1-cp314-cp314-win32.whl", hash = "sha256:87202ec6ff9626ff5f9351507def98fcf0df60e9a146308e8ab221432228f4ea", size = 203961, upload-time = "2025-10-17T11:30:22.073Z" }, - { url = "https://files.pythonhosted.org/packages/76/bd/f063bd5cc2712e7ca3cf6beda50894418fc0cfeb3f6ff45a12d87af25996/jiter-0.11.1-cp314-cp314-win_amd64.whl", hash = "sha256:a5dd268f6531a182c89d0dd9a3f8848e86e92dfff4201b77a18e6b98aa59798c", size = 202804, upload-time = "2025-10-17T11:30:23.452Z" }, - { url = "https://files.pythonhosted.org/packages/52/ca/4d84193dfafef1020bf0bedd5e1a8d0e89cb67c54b8519040effc694964b/jiter-0.11.1-cp314-cp314-win_arm64.whl", hash = "sha256:5d761f863f912a44748a21b5c4979c04252588ded8d1d2760976d2e42cd8d991", size = 188001, upload-time = "2025-10-17T11:30:24.915Z" }, - { url = "https://files.pythonhosted.org/packages/d5/fa/3b05e5c9d32efc770a8510eeb0b071c42ae93a5b576fd91cee9af91689a1/jiter-0.11.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2cc5a3965285ddc33e0cab933e96b640bc9ba5940cea27ebbbf6695e72d6511c", size = 312561, upload-time = "2025-10-17T11:30:26.742Z" }, - { url = "https://files.pythonhosted.org/packages/50/d3/335822eb216154ddb79a130cbdce88fdf5c3e2b43dc5dba1fd95c485aaf5/jiter-0.11.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6b572b3636a784c2768b2342f36a23078c8d3aa6d8a30745398b1bab58a6f1a8", size = 344551, upload-time = "2025-10-17T11:30:28.252Z" }, - { url = "https://files.pythonhosted.org/packages/31/6d/a0bed13676b1398f9b3ba61f32569f20a3ff270291161100956a577b2dd3/jiter-0.11.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ad93e3d67a981f96596d65d2298fe8d1aa649deb5374a2fb6a434410ee11915e", size = 363051, upload-time = "2025-10-17T11:30:30.009Z" }, - { url = "https://files.pythonhosted.org/packages/a4/03/313eda04aa08545a5a04ed5876e52f49ab76a4d98e54578896ca3e16313e/jiter-0.11.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a83097ce379e202dcc3fe3fc71a16d523d1ee9192c8e4e854158f96b3efe3f2f", size = 485897, upload-time = "2025-10-17T11:30:31.429Z" }, - { url = "https://files.pythonhosted.org/packages/5f/13/a1011b9d325e40b53b1b96a17c010b8646013417f3902f97a86325b19299/jiter-0.11.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7042c51e7fbeca65631eb0c332f90c0c082eab04334e7ccc28a8588e8e2804d9", size = 375224, upload-time = "2025-10-17T11:30:33.18Z" }, - { url = "https://files.pythonhosted.org/packages/92/da/1b45026b19dd39b419e917165ff0ea629dbb95f374a3a13d2df95e40a6ac/jiter-0.11.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0a68d679c0e47649a61df591660507608adc2652442de7ec8276538ac46abe08", size = 356606, upload-time = "2025-10-17T11:30:34.572Z" }, - { url = "https://files.pythonhosted.org/packages/7a/0c/9acb0e54d6a8ba59ce923a180ebe824b4e00e80e56cefde86cc8e0a948be/jiter-0.11.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a1b0da75dbf4b6ec0b3c9e604d1ee8beaf15bc046fff7180f7d89e3cdbd3bb51", size = 384003, upload-time = "2025-10-17T11:30:35.987Z" }, - { url = "https://files.pythonhosted.org/packages/3f/2b/e5a5fe09d6da2145e4eed651e2ce37f3c0cf8016e48b1d302e21fb1628b7/jiter-0.11.1-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:69dd514bf0fa31c62147d6002e5ca2b3e7ef5894f5ac6f0a19752385f4e89437", size = 516946, upload-time = "2025-10-17T11:30:37.425Z" }, - { url = "https://files.pythonhosted.org/packages/5f/fe/db936e16e0228d48eb81f9934e8327e9fde5185e84f02174fcd22a01be87/jiter-0.11.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:bb31ac0b339efa24c0ca606febd8b77ef11c58d09af1b5f2be4c99e907b11111", size = 507614, upload-time = "2025-10-17T11:30:38.977Z" }, - { url = "https://files.pythonhosted.org/packages/86/db/c4438e8febfb303486d13c6b72f5eb71cf851e300a0c1f0b4140018dd31f/jiter-0.11.1-cp314-cp314t-win32.whl", hash = "sha256:b2ce0d6156a1d3ad41da3eec63b17e03e296b78b0e0da660876fccfada86d2f7", size = 204043, upload-time = "2025-10-17T11:30:40.308Z" }, - { url = "https://files.pythonhosted.org/packages/36/59/81badb169212f30f47f817dfaabf965bc9b8204fed906fab58104ee541f9/jiter-0.11.1-cp314-cp314t-win_amd64.whl", hash = "sha256:f4db07d127b54c4a2d43b4cf05ff0193e4f73e0dd90c74037e16df0b29f666e1", size = 204046, upload-time = "2025-10-17T11:30:41.692Z" }, - { url = "https://files.pythonhosted.org/packages/dd/01/43f7b4eb61db3e565574c4c5714685d042fb652f9eef7e5a3de6aafa943a/jiter-0.11.1-cp314-cp314t-win_arm64.whl", hash = "sha256:28e4fdf2d7ebfc935523e50d1efa3970043cfaa161674fe66f9642409d001dfe", size = 188069, upload-time = "2025-10-17T11:30:43.23Z" }, - { url = "https://files.pythonhosted.org/packages/a6/bc/950dd7f170c6394b6fdd73f989d9e729bd98907bcc4430ef080a72d06b77/jiter-0.11.1-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:0d4d6993edc83cf75e8c6828a8d6ce40a09ee87e38c7bfba6924f39e1337e21d", size = 302626, upload-time = "2025-10-17T11:31:09.645Z" }, - { url = "https://files.pythonhosted.org/packages/3a/65/43d7971ca82ee100b7b9b520573eeef7eabc0a45d490168ebb9a9b5bb8b2/jiter-0.11.1-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:f78d151c83a87a6cf5461d5ee55bc730dd9ae227377ac6f115b922989b95f838", size = 297034, upload-time = "2025-10-17T11:31:10.975Z" }, - { url = "https://files.pythonhosted.org/packages/19/4c/000e1e0c0c67e96557a279f8969487ea2732d6c7311698819f977abae837/jiter-0.11.1-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c9022974781155cd5521d5cb10997a03ee5e31e8454c9d999dcdccd253f2353f", size = 337328, upload-time = "2025-10-17T11:31:12.399Z" }, - { url = "https://files.pythonhosted.org/packages/d9/71/71408b02c6133153336d29fa3ba53000f1e1a3f78bb2fc2d1a1865d2e743/jiter-0.11.1-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18c77aaa9117510d5bdc6a946baf21b1f0cfa58ef04d31c8d016f206f2118960", size = 343697, upload-time = "2025-10-17T11:31:13.773Z" }, -] - -[[package]] -name = "live-agent-api" -version = "0.1.0" -source = { editable = "." } -dependencies = [ - { name = "asyncpg" }, - { name = "fastapi" }, - { name = "httpx" }, - { name = "openai" }, - { name = "pydantic" }, - { name = "pydantic-settings" }, - { name = "python-dotenv" }, - { name = "python-ulid" }, - { name = "pyyaml" }, - { name = "sqlalchemy" }, - { name = "uvicorn", extra = ["standard"] }, -] - -[package.dev-dependencies] -dev = [ - { name = "black" }, - { name = "pytest" }, - { name = "pytest-asyncio" }, - { name = "ruff" }, -] - -[package.metadata] -requires-dist = [ - { name = "asyncpg", specifier = ">=0.30.0" }, - { name = "fastapi", specifier = ">=0.115.0" }, - { name = "httpx", specifier = ">=0.27.0" }, - { name = "openai", specifier = ">=1.54.0" }, - { name = "pydantic", specifier = ">=2.9.0" }, - { name = "pydantic-settings", specifier = ">=2.6.0" }, - { name = "python-dotenv", specifier = ">=1.0.0" }, - { name = "python-ulid", specifier = ">=2.7.0" }, - { name = "pyyaml", specifier = ">=6.0.0" }, - { name = "sqlalchemy", specifier = ">=2.0.36" }, - { name = "uvicorn", extras = ["standard"], specifier = ">=0.32.0" }, -] - -[package.metadata.requires-dev] -dev = [ - { name = "black", specifier = ">=24.10.0" }, - { name = "pytest", specifier = ">=8.3.0" }, - { name = "pytest-asyncio", specifier = ">=0.24.0" }, - { name = "ruff", specifier = ">=0.7.0" }, -] - -[[package]] -name = "mypy-extensions" -version = "1.1.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a2/6e/371856a3fb9d31ca8dac321cda606860fa4548858c0cc45d9d1d4ca2628b/mypy_extensions-1.1.0.tar.gz", hash = "sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558", size = 6343, upload-time = "2025-04-22T14:54:24.164Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/79/7b/2c79738432f5c924bef5071f933bcc9efd0473bac3b4aa584a6f7c1c8df8/mypy_extensions-1.1.0-py3-none-any.whl", hash = "sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505", size = 4963, upload-time = "2025-04-22T14:54:22.983Z" }, -] - -[[package]] -name = "openai" -version = "2.6.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "anyio" }, - { name = "distro" }, - { name = "httpx" }, - { name = "jiter" }, - { name = "pydantic" }, - { name = "sniffio" }, - { name = "tqdm" }, - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/c4/44/303deb97be7c1c9b53118b52825cbd1557aeeff510f3a52566b1fa66f6a2/openai-2.6.1.tar.gz", hash = "sha256:27ae704d190615fca0c0fc2b796a38f8b5879645a3a52c9c453b23f97141bb49", size = 593043, upload-time = "2025-10-24T13:29:52.79Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/15/0e/331df43df633e6105ff9cf45e0ce57762bd126a45ac16b25a43f6738d8a2/openai-2.6.1-py3-none-any.whl", hash = "sha256:904e4b5254a8416746a2f05649594fa41b19d799843cd134dac86167e094edef", size = 1005551, upload-time = "2025-10-24T13:29:50.973Z" }, -] - -[[package]] -name = "packaging" -version = "25.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a1/d4/1fc4078c65507b51b96ca8f8c3ba19e6a61c8253c72794544580a7b6c24d/packaging-25.0.tar.gz", hash = "sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f", size = 165727, upload-time = "2025-04-19T11:48:59.673Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" }, -] - -[[package]] -name = "pathspec" -version = "0.12.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/ca/bc/f35b8446f4531a7cb215605d100cd88b7ac6f44ab3fc94870c120ab3adbf/pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712", size = 51043, upload-time = "2023-12-10T22:30:45Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/cc/20/ff623b09d963f88bfde16306a54e12ee5ea43e9b597108672ff3a408aad6/pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08", size = 31191, upload-time = "2023-12-10T22:30:43.14Z" }, -] - -[[package]] -name = "platformdirs" -version = "4.5.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/61/33/9611380c2bdb1225fdef633e2a9610622310fed35ab11dac9620972ee088/platformdirs-4.5.0.tar.gz", hash = "sha256:70ddccdd7c99fc5942e9fc25636a8b34d04c24b335100223152c2803e4063312", size = 21632, upload-time = "2025-10-08T17:44:48.791Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/73/cb/ac7874b3e5d58441674fb70742e6c374b28b0c7cb988d37d991cde47166c/platformdirs-4.5.0-py3-none-any.whl", hash = "sha256:e578a81bb873cbb89a41fcc904c7ef523cc18284b7e3b3ccf06aca1403b7ebd3", size = 18651, upload-time = "2025-10-08T17:44:47.223Z" }, -] - -[[package]] -name = "pluggy" -version = "1.6.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" }, -] - -[[package]] -name = "pydantic" -version = "2.12.3" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "annotated-types" }, - { name = "pydantic-core" }, - { name = "typing-extensions" }, - { name = "typing-inspection" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/f3/1e/4f0a3233767010308f2fd6bd0814597e3f63f1dc98304a9112b8759df4ff/pydantic-2.12.3.tar.gz", hash = "sha256:1da1c82b0fc140bb0103bc1441ffe062154c8d38491189751ee00fd8ca65ce74", size = 819383, upload-time = "2025-10-17T15:04:21.222Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/a1/6b/83661fa77dcefa195ad5f8cd9af3d1a7450fd57cc883ad04d65446ac2029/pydantic-2.12.3-py3-none-any.whl", hash = "sha256:6986454a854bc3bc6e5443e1369e06a3a456af9d339eda45510f517d9ea5c6bf", size = 462431, upload-time = "2025-10-17T15:04:19.346Z" }, -] - -[[package]] -name = "pydantic-core" -version = "2.41.4" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/df/18/d0944e8eaaa3efd0a91b0f1fc537d3be55ad35091b6a87638211ba691964/pydantic_core-2.41.4.tar.gz", hash = "sha256:70e47929a9d4a1905a67e4b687d5946026390568a8e952b92824118063cee4d5", size = 457557, upload-time = "2025-10-14T10:23:47.909Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/e9/81/d3b3e95929c4369d30b2a66a91db63c8ed0a98381ae55a45da2cd1cc1288/pydantic_core-2.41.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:ab06d77e053d660a6faaf04894446df7b0a7e7aba70c2797465a0a1af00fc887", size = 2099043, upload-time = "2025-10-14T10:20:28.561Z" }, - { url = "https://files.pythonhosted.org/packages/58/da/46fdac49e6717e3a94fc9201403e08d9d61aa7a770fab6190b8740749047/pydantic_core-2.41.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c53ff33e603a9c1179a9364b0a24694f183717b2e0da2b5ad43c316c956901b2", size = 1910699, upload-time = "2025-10-14T10:20:30.217Z" }, - { url = "https://files.pythonhosted.org/packages/1e/63/4d948f1b9dd8e991a5a98b77dd66c74641f5f2e5225fee37994b2e07d391/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:304c54176af2c143bd181d82e77c15c41cbacea8872a2225dd37e6544dce9999", size = 1952121, upload-time = "2025-10-14T10:20:32.246Z" }, - { url = "https://files.pythonhosted.org/packages/b2/a7/e5fc60a6f781fc634ecaa9ecc3c20171d238794cef69ae0af79ac11b89d7/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:025ba34a4cf4fb32f917d5d188ab5e702223d3ba603be4d8aca2f82bede432a4", size = 2041590, upload-time = "2025-10-14T10:20:34.332Z" }, - { url = "https://files.pythonhosted.org/packages/70/69/dce747b1d21d59e85af433428978a1893c6f8a7068fa2bb4a927fba7a5ff/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b9f5f30c402ed58f90c70e12eff65547d3ab74685ffe8283c719e6bead8ef53f", size = 2219869, upload-time = "2025-10-14T10:20:35.965Z" }, - { url = "https://files.pythonhosted.org/packages/83/6a/c070e30e295403bf29c4df1cb781317b6a9bac7cd07b8d3acc94d501a63c/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dd96e5d15385d301733113bcaa324c8bcf111275b7675a9c6e88bfb19fc05e3b", size = 2345169, upload-time = "2025-10-14T10:20:37.627Z" }, - { url = "https://files.pythonhosted.org/packages/f0/83/06d001f8043c336baea7fd202a9ac7ad71f87e1c55d8112c50b745c40324/pydantic_core-2.41.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:98f348cbb44fae6e9653c1055db7e29de67ea6a9ca03a5fa2c2e11a47cff0e47", size = 2070165, upload-time = "2025-10-14T10:20:39.246Z" }, - { url = "https://files.pythonhosted.org/packages/14/0a/e567c2883588dd12bcbc110232d892cf385356f7c8a9910311ac997ab715/pydantic_core-2.41.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ec22626a2d14620a83ca583c6f5a4080fa3155282718b6055c2ea48d3ef35970", size = 2189067, upload-time = "2025-10-14T10:20:41.015Z" }, - { url = "https://files.pythonhosted.org/packages/f4/1d/3d9fca34273ba03c9b1c5289f7618bc4bd09c3ad2289b5420481aa051a99/pydantic_core-2.41.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:3a95d4590b1f1a43bf33ca6d647b990a88f4a3824a8c4572c708f0b45a5290ed", size = 2132997, upload-time = "2025-10-14T10:20:43.106Z" }, - { url = "https://files.pythonhosted.org/packages/52/70/d702ef7a6cd41a8afc61f3554922b3ed8d19dd54c3bd4bdbfe332e610827/pydantic_core-2.41.4-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:f9672ab4d398e1b602feadcffcdd3af44d5f5e6ddc15bc7d15d376d47e8e19f8", size = 2307187, upload-time = "2025-10-14T10:20:44.849Z" }, - { url = "https://files.pythonhosted.org/packages/68/4c/c06be6e27545d08b802127914156f38d10ca287a9e8489342793de8aae3c/pydantic_core-2.41.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:84d8854db5f55fead3b579f04bda9a36461dab0730c5d570e1526483e7bb8431", size = 2305204, upload-time = "2025-10-14T10:20:46.781Z" }, - { url = "https://files.pythonhosted.org/packages/b0/e5/35ae4919bcd9f18603419e23c5eaf32750224a89d41a8df1a3704b69f77e/pydantic_core-2.41.4-cp312-cp312-win32.whl", hash = "sha256:9be1c01adb2ecc4e464392c36d17f97e9110fbbc906bcbe1c943b5b87a74aabd", size = 1972536, upload-time = "2025-10-14T10:20:48.39Z" }, - { url = "https://files.pythonhosted.org/packages/1e/c2/49c5bb6d2a49eb2ee3647a93e3dae7080c6409a8a7558b075027644e879c/pydantic_core-2.41.4-cp312-cp312-win_amd64.whl", hash = "sha256:d682cf1d22bab22a5be08539dca3d1593488a99998f9f412137bc323179067ff", size = 2031132, upload-time = "2025-10-14T10:20:50.421Z" }, - { url = "https://files.pythonhosted.org/packages/06/23/936343dbcba6eec93f73e95eb346810fc732f71ba27967b287b66f7b7097/pydantic_core-2.41.4-cp312-cp312-win_arm64.whl", hash = "sha256:833eebfd75a26d17470b58768c1834dfc90141b7afc6eb0429c21fc5a21dcfb8", size = 1969483, upload-time = "2025-10-14T10:20:52.35Z" }, - { url = "https://files.pythonhosted.org/packages/13/d0/c20adabd181a029a970738dfe23710b52a31f1258f591874fcdec7359845/pydantic_core-2.41.4-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:85e050ad9e5f6fe1004eec65c914332e52f429bc0ae12d6fa2092407a462c746", size = 2105688, upload-time = "2025-10-14T10:20:54.448Z" }, - { url = "https://files.pythonhosted.org/packages/00/b6/0ce5c03cec5ae94cca220dfecddc453c077d71363b98a4bbdb3c0b22c783/pydantic_core-2.41.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e7393f1d64792763a48924ba31d1e44c2cfbc05e3b1c2c9abb4ceeadd912cced", size = 1910807, upload-time = "2025-10-14T10:20:56.115Z" }, - { url = "https://files.pythonhosted.org/packages/68/3e/800d3d02c8beb0b5c069c870cbb83799d085debf43499c897bb4b4aaff0d/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:94dab0940b0d1fb28bcab847adf887c66a27a40291eedf0b473be58761c9799a", size = 1956669, upload-time = "2025-10-14T10:20:57.874Z" }, - { url = "https://files.pythonhosted.org/packages/60/a4/24271cc71a17f64589be49ab8bd0751f6a0a03046c690df60989f2f95c2c/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:de7c42f897e689ee6f9e93c4bec72b99ae3b32a2ade1c7e4798e690ff5246e02", size = 2051629, upload-time = "2025-10-14T10:21:00.006Z" }, - { url = "https://files.pythonhosted.org/packages/68/de/45af3ca2f175d91b96bfb62e1f2d2f1f9f3b14a734afe0bfeff079f78181/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:664b3199193262277b8b3cd1e754fb07f2c6023289c815a1e1e8fb415cb247b1", size = 2224049, upload-time = "2025-10-14T10:21:01.801Z" }, - { url = "https://files.pythonhosted.org/packages/af/8f/ae4e1ff84672bf869d0a77af24fd78387850e9497753c432875066b5d622/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d95b253b88f7d308b1c0b417c4624f44553ba4762816f94e6986819b9c273fb2", size = 2342409, upload-time = "2025-10-14T10:21:03.556Z" }, - { url = "https://files.pythonhosted.org/packages/18/62/273dd70b0026a085c7b74b000394e1ef95719ea579c76ea2f0cc8893736d/pydantic_core-2.41.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1351f5bbdbbabc689727cb91649a00cb9ee7203e0a6e54e9f5ba9e22e384b84", size = 2069635, upload-time = "2025-10-14T10:21:05.385Z" }, - { url = "https://files.pythonhosted.org/packages/30/03/cf485fff699b4cdaea469bc481719d3e49f023241b4abb656f8d422189fc/pydantic_core-2.41.4-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1affa4798520b148d7182da0615d648e752de4ab1a9566b7471bc803d88a062d", size = 2194284, upload-time = "2025-10-14T10:21:07.122Z" }, - { url = "https://files.pythonhosted.org/packages/f9/7e/c8e713db32405dfd97211f2fc0a15d6bf8adb7640f3d18544c1f39526619/pydantic_core-2.41.4-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:7b74e18052fea4aa8dea2fb7dbc23d15439695da6cbe6cfc1b694af1115df09d", size = 2137566, upload-time = "2025-10-14T10:21:08.981Z" }, - { url = "https://files.pythonhosted.org/packages/04/f7/db71fd4cdccc8b75990f79ccafbbd66757e19f6d5ee724a6252414483fb4/pydantic_core-2.41.4-cp313-cp313-musllinux_1_1_armv7l.whl", hash = "sha256:285b643d75c0e30abda9dc1077395624f314a37e3c09ca402d4015ef5979f1a2", size = 2316809, upload-time = "2025-10-14T10:21:10.805Z" }, - { url = "https://files.pythonhosted.org/packages/76/63/a54973ddb945f1bca56742b48b144d85c9fc22f819ddeb9f861c249d5464/pydantic_core-2.41.4-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:f52679ff4218d713b3b33f88c89ccbf3a5c2c12ba665fb80ccc4192b4608dbab", size = 2311119, upload-time = "2025-10-14T10:21:12.583Z" }, - { url = "https://files.pythonhosted.org/packages/f8/03/5d12891e93c19218af74843a27e32b94922195ded2386f7b55382f904d2f/pydantic_core-2.41.4-cp313-cp313-win32.whl", hash = "sha256:ecde6dedd6fff127c273c76821bb754d793be1024bc33314a120f83a3c69460c", size = 1981398, upload-time = "2025-10-14T10:21:14.584Z" }, - { url = "https://files.pythonhosted.org/packages/be/d8/fd0de71f39db91135b7a26996160de71c073d8635edfce8b3c3681be0d6d/pydantic_core-2.41.4-cp313-cp313-win_amd64.whl", hash = "sha256:d081a1f3800f05409ed868ebb2d74ac39dd0c1ff6c035b5162356d76030736d4", size = 2030735, upload-time = "2025-10-14T10:21:16.432Z" }, - { url = "https://files.pythonhosted.org/packages/72/86/c99921c1cf6650023c08bfab6fe2d7057a5142628ef7ccfa9921f2dda1d5/pydantic_core-2.41.4-cp313-cp313-win_arm64.whl", hash = "sha256:f8e49c9c364a7edcbe2a310f12733aad95b022495ef2a8d653f645e5d20c1564", size = 1973209, upload-time = "2025-10-14T10:21:18.213Z" }, - { url = "https://files.pythonhosted.org/packages/36/0d/b5706cacb70a8414396efdda3d72ae0542e050b591119e458e2490baf035/pydantic_core-2.41.4-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ed97fd56a561f5eb5706cebe94f1ad7c13b84d98312a05546f2ad036bafe87f4", size = 1877324, upload-time = "2025-10-14T10:21:20.363Z" }, - { url = "https://files.pythonhosted.org/packages/de/2d/cba1fa02cfdea72dfb3a9babb067c83b9dff0bbcb198368e000a6b756ea7/pydantic_core-2.41.4-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a870c307bf1ee91fc58a9a61338ff780d01bfae45922624816878dce784095d2", size = 1884515, upload-time = "2025-10-14T10:21:22.339Z" }, - { url = "https://files.pythonhosted.org/packages/07/ea/3df927c4384ed9b503c9cc2d076cf983b4f2adb0c754578dfb1245c51e46/pydantic_core-2.41.4-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d25e97bc1f5f8f7985bdc2335ef9e73843bb561eb1fa6831fdfc295c1c2061cf", size = 2042819, upload-time = "2025-10-14T10:21:26.683Z" }, - { url = "https://files.pythonhosted.org/packages/6a/ee/df8e871f07074250270a3b1b82aad4cd0026b588acd5d7d3eb2fcb1471a3/pydantic_core-2.41.4-cp313-cp313t-win_amd64.whl", hash = "sha256:d405d14bea042f166512add3091c1af40437c2e7f86988f3915fabd27b1e9cd2", size = 1995866, upload-time = "2025-10-14T10:21:28.951Z" }, - { url = "https://files.pythonhosted.org/packages/fc/de/b20f4ab954d6d399499c33ec4fafc46d9551e11dc1858fb7f5dca0748ceb/pydantic_core-2.41.4-cp313-cp313t-win_arm64.whl", hash = "sha256:19f3684868309db5263a11bace3c45d93f6f24afa2ffe75a647583df22a2ff89", size = 1970034, upload-time = "2025-10-14T10:21:30.869Z" }, - { url = "https://files.pythonhosted.org/packages/54/28/d3325da57d413b9819365546eb9a6e8b7cbd9373d9380efd5f74326143e6/pydantic_core-2.41.4-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:e9205d97ed08a82ebb9a307e92914bb30e18cdf6f6b12ca4bedadb1588a0bfe1", size = 2102022, upload-time = "2025-10-14T10:21:32.809Z" }, - { url = "https://files.pythonhosted.org/packages/9e/24/b58a1bc0d834bf1acc4361e61233ee217169a42efbdc15a60296e13ce438/pydantic_core-2.41.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:82df1f432b37d832709fbcc0e24394bba04a01b6ecf1ee87578145c19cde12ac", size = 1905495, upload-time = "2025-10-14T10:21:34.812Z" }, - { url = "https://files.pythonhosted.org/packages/fb/a4/71f759cc41b7043e8ecdaab81b985a9b6cad7cec077e0b92cff8b71ecf6b/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fc3b4cc4539e055cfa39a3763c939f9d409eb40e85813257dcd761985a108554", size = 1956131, upload-time = "2025-10-14T10:21:36.924Z" }, - { url = "https://files.pythonhosted.org/packages/b0/64/1e79ac7aa51f1eec7c4cda8cbe456d5d09f05fdd68b32776d72168d54275/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b1eb1754fce47c63d2ff57fdb88c351a6c0150995890088b33767a10218eaa4e", size = 2052236, upload-time = "2025-10-14T10:21:38.927Z" }, - { url = "https://files.pythonhosted.org/packages/e9/e3/a3ffc363bd4287b80f1d43dc1c28ba64831f8dfc237d6fec8f2661138d48/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e6ab5ab30ef325b443f379ddb575a34969c333004fca5a1daa0133a6ffaad616", size = 2223573, upload-time = "2025-10-14T10:21:41.574Z" }, - { url = "https://files.pythonhosted.org/packages/28/27/78814089b4d2e684a9088ede3790763c64693c3d1408ddc0a248bc789126/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:31a41030b1d9ca497634092b46481b937ff9397a86f9f51bd41c4767b6fc04af", size = 2342467, upload-time = "2025-10-14T10:21:44.018Z" }, - { url = "https://files.pythonhosted.org/packages/92/97/4de0e2a1159cb85ad737e03306717637842c88c7fd6d97973172fb183149/pydantic_core-2.41.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a44ac1738591472c3d020f61c6df1e4015180d6262ebd39bf2aeb52571b60f12", size = 2063754, upload-time = "2025-10-14T10:21:46.466Z" }, - { url = "https://files.pythonhosted.org/packages/0f/50/8cb90ce4b9efcf7ae78130afeb99fd1c86125ccdf9906ef64b9d42f37c25/pydantic_core-2.41.4-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d72f2b5e6e82ab8f94ea7d0d42f83c487dc159c5240d8f83beae684472864e2d", size = 2196754, upload-time = "2025-10-14T10:21:48.486Z" }, - { url = "https://files.pythonhosted.org/packages/34/3b/ccdc77af9cd5082723574a1cc1bcae7a6acacc829d7c0a06201f7886a109/pydantic_core-2.41.4-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:c4d1e854aaf044487d31143f541f7aafe7b482ae72a022c664b2de2e466ed0ad", size = 2137115, upload-time = "2025-10-14T10:21:50.63Z" }, - { url = "https://files.pythonhosted.org/packages/ca/ba/e7c7a02651a8f7c52dc2cff2b64a30c313e3b57c7d93703cecea76c09b71/pydantic_core-2.41.4-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:b568af94267729d76e6ee5ececda4e283d07bbb28e8148bb17adad93d025d25a", size = 2317400, upload-time = "2025-10-14T10:21:52.959Z" }, - { url = "https://files.pythonhosted.org/packages/2c/ba/6c533a4ee8aec6b812c643c49bb3bd88d3f01e3cebe451bb85512d37f00f/pydantic_core-2.41.4-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:6d55fb8b1e8929b341cc313a81a26e0d48aa3b519c1dbaadec3a6a2b4fcad025", size = 2312070, upload-time = "2025-10-14T10:21:55.419Z" }, - { url = "https://files.pythonhosted.org/packages/22/ae/f10524fcc0ab8d7f96cf9a74c880243576fd3e72bd8ce4f81e43d22bcab7/pydantic_core-2.41.4-cp314-cp314-win32.whl", hash = "sha256:5b66584e549e2e32a1398df11da2e0a7eff45d5c2d9db9d5667c5e6ac764d77e", size = 1982277, upload-time = "2025-10-14T10:21:57.474Z" }, - { url = "https://files.pythonhosted.org/packages/b4/dc/e5aa27aea1ad4638f0c3fb41132f7eb583bd7420ee63204e2d4333a3bbf9/pydantic_core-2.41.4-cp314-cp314-win_amd64.whl", hash = "sha256:557a0aab88664cc552285316809cab897716a372afaf8efdbef756f8b890e894", size = 2024608, upload-time = "2025-10-14T10:21:59.557Z" }, - { url = "https://files.pythonhosted.org/packages/3e/61/51d89cc2612bd147198e120a13f150afbf0bcb4615cddb049ab10b81b79e/pydantic_core-2.41.4-cp314-cp314-win_arm64.whl", hash = "sha256:3f1ea6f48a045745d0d9f325989d8abd3f1eaf47dd00485912d1a3a63c623a8d", size = 1967614, upload-time = "2025-10-14T10:22:01.847Z" }, - { url = "https://files.pythonhosted.org/packages/0d/c2/472f2e31b95eff099961fa050c376ab7156a81da194f9edb9f710f68787b/pydantic_core-2.41.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:6c1fe4c5404c448b13188dd8bd2ebc2bdd7e6727fa61ff481bcc2cca894018da", size = 1876904, upload-time = "2025-10-14T10:22:04.062Z" }, - { url = "https://files.pythonhosted.org/packages/4a/07/ea8eeb91173807ecdae4f4a5f4b150a520085b35454350fc219ba79e66a3/pydantic_core-2.41.4-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:523e7da4d43b113bf8e7b49fa4ec0c35bf4fe66b2230bfc5c13cc498f12c6c3e", size = 1882538, upload-time = "2025-10-14T10:22:06.39Z" }, - { url = "https://files.pythonhosted.org/packages/1e/29/b53a9ca6cd366bfc928823679c6a76c7a4c69f8201c0ba7903ad18ebae2f/pydantic_core-2.41.4-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5729225de81fb65b70fdb1907fcf08c75d498f4a6f15af005aabb1fdadc19dfa", size = 2041183, upload-time = "2025-10-14T10:22:08.812Z" }, - { url = "https://files.pythonhosted.org/packages/c7/3d/f8c1a371ceebcaf94d6dd2d77c6cf4b1c078e13a5837aee83f760b4f7cfd/pydantic_core-2.41.4-cp314-cp314t-win_amd64.whl", hash = "sha256:de2cfbb09e88f0f795fd90cf955858fc2c691df65b1f21f0aa00b99f3fbc661d", size = 1993542, upload-time = "2025-10-14T10:22:11.332Z" }, - { url = "https://files.pythonhosted.org/packages/8a/ac/9fc61b4f9d079482a290afe8d206b8f490e9fd32d4fc03ed4fc698214e01/pydantic_core-2.41.4-cp314-cp314t-win_arm64.whl", hash = "sha256:d34f950ae05a83e0ede899c595f312ca976023ea1db100cd5aa188f7005e3ab0", size = 1973897, upload-time = "2025-10-14T10:22:13.444Z" }, - { url = "https://files.pythonhosted.org/packages/c4/48/ae937e5a831b7c0dc646b2ef788c27cd003894882415300ed21927c21efa/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:4f5d640aeebb438517150fdeec097739614421900e4a08db4a3ef38898798537", size = 2112087, upload-time = "2025-10-14T10:22:56.818Z" }, - { url = "https://files.pythonhosted.org/packages/5e/db/6db8073e3d32dae017da7e0d16a9ecb897d0a4d92e00634916e486097961/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:4a9ab037b71927babc6d9e7fc01aea9e66dc2a4a34dff06ef0724a4049629f94", size = 1920387, upload-time = "2025-10-14T10:22:59.342Z" }, - { url = "https://files.pythonhosted.org/packages/0d/c1/dd3542d072fcc336030d66834872f0328727e3b8de289c662faa04aa270e/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e4dab9484ec605c3016df9ad4fd4f9a390bc5d816a3b10c6550f8424bb80b18c", size = 1951495, upload-time = "2025-10-14T10:23:02.089Z" }, - { url = "https://files.pythonhosted.org/packages/2b/c6/db8d13a1f8ab3f1eb08c88bd00fd62d44311e3456d1e85c0e59e0a0376e7/pydantic_core-2.41.4-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bd8a5028425820731d8c6c098ab642d7b8b999758e24acae03ed38a66eca8335", size = 2139008, upload-time = "2025-10-14T10:23:04.539Z" }, -] - -[[package]] -name = "pydantic-settings" -version = "2.11.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "pydantic" }, - { name = "python-dotenv" }, - { name = "typing-inspection" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/20/c5/dbbc27b814c71676593d1c3f718e6cd7d4f00652cefa24b75f7aa3efb25e/pydantic_settings-2.11.0.tar.gz", hash = "sha256:d0e87a1c7d33593beb7194adb8470fc426e95ba02af83a0f23474a04c9a08180", size = 188394, upload-time = "2025-09-24T14:19:11.764Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/83/d6/887a1ff844e64aa823fb4905978d882a633cfe295c32eacad582b78a7d8b/pydantic_settings-2.11.0-py3-none-any.whl", hash = "sha256:fe2cea3413b9530d10f3a5875adffb17ada5c1e1bab0b2885546d7310415207c", size = 48608, upload-time = "2025-09-24T14:19:10.015Z" }, -] - -[[package]] -name = "pygments" -version = "2.19.2" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887", size = 4968631, upload-time = "2025-06-21T13:39:12.283Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, -] - -[[package]] -name = "pytest" -version = "8.4.2" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, - { name = "iniconfig" }, - { name = "packaging" }, - { name = "pluggy" }, - { name = "pygments" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/a3/5c/00a0e072241553e1a7496d638deababa67c5058571567b92a7eaa258397c/pytest-8.4.2.tar.gz", hash = "sha256:86c0d0b93306b961d58d62a4db4879f27fe25513d4b969df351abdddb3c30e01", size = 1519618, upload-time = "2025-09-04T14:34:22.711Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/a8/a4/20da314d277121d6534b3a980b29035dcd51e6744bd79075a6ce8fa4eb8d/pytest-8.4.2-py3-none-any.whl", hash = "sha256:872f880de3fc3a5bdc88a11b39c9710c3497a547cfa9320bc3c5e62fbf272e79", size = 365750, upload-time = "2025-09-04T14:34:20.226Z" }, -] - -[[package]] -name = "pytest-asyncio" -version = "1.2.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "pytest" }, - { name = "typing-extensions", marker = "python_full_version < '3.13'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/42/86/9e3c5f48f7b7b638b216e4b9e645f54d199d7abbbab7a64a13b4e12ba10f/pytest_asyncio-1.2.0.tar.gz", hash = "sha256:c609a64a2a8768462d0c99811ddb8bd2583c33fd33cf7f21af1c142e824ffb57", size = 50119, upload-time = "2025-09-12T07:33:53.816Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/04/93/2fa34714b7a4ae72f2f8dad66ba17dd9a2c793220719e736dda28b7aec27/pytest_asyncio-1.2.0-py3-none-any.whl", hash = "sha256:8e17ae5e46d8e7efe51ab6494dd2010f4ca8dae51652aa3c8d55acf50bfb2e99", size = 15095, upload-time = "2025-09-12T07:33:52.639Z" }, -] - -[[package]] -name = "python-dotenv" -version = "1.2.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" }, -] - -[[package]] -name = "python-ulid" -version = "3.1.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/40/7e/0d6c82b5ccc71e7c833aed43d9e8468e1f2ff0be1b3f657a6fcafbb8433d/python_ulid-3.1.0.tar.gz", hash = "sha256:ff0410a598bc5f6b01b602851a3296ede6f91389f913a5d5f8c496003836f636", size = 93175, upload-time = "2025-08-18T16:09:26.305Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/6c/a0/4ed6632b70a52de845df056654162acdebaf97c20e3212c559ac43e7216e/python_ulid-3.1.0-py3-none-any.whl", hash = "sha256:e2cdc979c8c877029b4b7a38a6fba3bc4578e4f109a308419ff4d3ccf0a46619", size = 11577, upload-time = "2025-08-18T16:09:25.047Z" }, -] - -[[package]] -name = "pytokens" -version = "0.2.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d4/c2/dbadcdddb412a267585459142bfd7cc241e6276db69339353ae6e241ab2b/pytokens-0.2.0.tar.gz", hash = "sha256:532d6421364e5869ea57a9523bf385f02586d4662acbcc0342afd69511b4dd43", size = 15368, upload-time = "2025-10-15T08:02:42.738Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/89/5a/c269ea6b348b6f2c32686635df89f32dbe05df1088dd4579302a6f8f99af/pytokens-0.2.0-py3-none-any.whl", hash = "sha256:74d4b318c67f4295c13782ddd9abcb7e297ec5630ad060eb90abf7ebbefe59f8", size = 12038, upload-time = "2025-10-15T08:02:41.694Z" }, -] - -[[package]] -name = "pyyaml" -version = "6.0.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" }, - { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" }, - { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" }, - { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" }, - { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" }, - { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" }, - { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" }, - { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" }, - { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" }, - { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" }, - { url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" }, - { url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" }, - { url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" }, - { url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" }, - { url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" }, - { url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" }, - { url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" }, - { url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" }, - { url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" }, - { url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" }, - { url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" }, - { url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" }, - { url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" }, - { url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" }, - { url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" }, - { url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" }, - { url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" }, - { url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" }, - { url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" }, - { url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" }, - { url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" }, - { url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" }, - { url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" }, - { url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" }, - { url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" }, - { url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" }, - { url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" }, - { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, -] - -[[package]] -name = "ruff" -version = "0.14.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/75/62/50b7727004dfe361104dfbf898c45a9a2fdfad8c72c04ae62900224d6ecf/ruff-0.14.3.tar.gz", hash = "sha256:4ff876d2ab2b161b6de0aa1f5bd714e8e9b4033dc122ee006925fbacc4f62153", size = 5558687, upload-time = "2025-10-31T00:26:26.878Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/ce/8e/0c10ff1ea5d4360ab8bfca4cb2c9d979101a391f3e79d2616c9bf348cd26/ruff-0.14.3-py3-none-linux_armv6l.whl", hash = "sha256:876b21e6c824f519446715c1342b8e60f97f93264012de9d8d10314f8a79c371", size = 12535613, upload-time = "2025-10-31T00:25:44.302Z" }, - { url = "https://files.pythonhosted.org/packages/d3/c8/6724f4634c1daf52409fbf13fefda64aa9c8f81e44727a378b7b73dc590b/ruff-0.14.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b6fd8c79b457bedd2abf2702b9b472147cd860ed7855c73a5247fa55c9117654", size = 12855812, upload-time = "2025-10-31T00:25:47.793Z" }, - { url = "https://files.pythonhosted.org/packages/de/03/db1bce591d55fd5f8a08bb02517fa0b5097b2ccabd4ea1ee29aa72b67d96/ruff-0.14.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:71ff6edca490c308f083156938c0c1a66907151263c4abdcb588602c6e696a14", size = 11944026, upload-time = "2025-10-31T00:25:49.657Z" }, - { url = "https://files.pythonhosted.org/packages/0b/75/4f8dbd48e03272715d12c87dc4fcaaf21b913f0affa5f12a4e9c6f8a0582/ruff-0.14.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:786ee3ce6139772ff9272aaf43296d975c0217ee1b97538a98171bf0d21f87ed", size = 12356818, upload-time = "2025-10-31T00:25:51.949Z" }, - { url = "https://files.pythonhosted.org/packages/ec/9b/506ec5b140c11d44a9a4f284ea7c14ebf6f8b01e6e8917734a3325bff787/ruff-0.14.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cd6291d0061811c52b8e392f946889916757610d45d004e41140d81fb6cd5ddc", size = 12336745, upload-time = "2025-10-31T00:25:54.248Z" }, - { url = "https://files.pythonhosted.org/packages/c7/e1/c560d254048c147f35e7f8131d30bc1f63a008ac61595cf3078a3e93533d/ruff-0.14.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a497ec0c3d2c88561b6d90f9c29f5ae68221ac00d471f306fa21fa4264ce5fcd", size = 13101684, upload-time = "2025-10-31T00:25:56.253Z" }, - { url = "https://files.pythonhosted.org/packages/a5/32/e310133f8af5cd11f8cc30f52522a3ebccc5ea5bff4b492f94faceaca7a8/ruff-0.14.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:e231e1be58fc568950a04fbe6887c8e4b85310e7889727e2b81db205c45059eb", size = 14535000, upload-time = "2025-10-31T00:25:58.397Z" }, - { url = "https://files.pythonhosted.org/packages/a2/a1/7b0470a22158c6d8501eabc5e9b6043c99bede40fa1994cadf6b5c2a61c7/ruff-0.14.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:469e35872a09c0e45fecf48dd960bfbce056b5db2d5e6b50eca329b4f853ae20", size = 14156450, upload-time = "2025-10-31T00:26:00.889Z" }, - { url = "https://files.pythonhosted.org/packages/0a/96/24bfd9d1a7f532b560dcee1a87096332e461354d3882124219bcaff65c09/ruff-0.14.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d6bc90307c469cb9d28b7cfad90aaa600b10d67c6e22026869f585e1e8a2db0", size = 13568414, upload-time = "2025-10-31T00:26:03.291Z" }, - { url = "https://files.pythonhosted.org/packages/a7/e7/138b883f0dfe4ad5b76b58bf4ae675f4d2176ac2b24bdd81b4d966b28c61/ruff-0.14.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e2f8a0bbcffcfd895df39c9a4ecd59bb80dca03dc43f7fb63e647ed176b741e", size = 13315293, upload-time = "2025-10-31T00:26:05.708Z" }, - { url = "https://files.pythonhosted.org/packages/33/f4/c09bb898be97b2eb18476b7c950df8815ef14cf956074177e9fbd40b7719/ruff-0.14.3-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:678fdd7c7d2d94851597c23ee6336d25f9930b460b55f8598e011b57c74fd8c5", size = 13539444, upload-time = "2025-10-31T00:26:08.09Z" }, - { url = "https://files.pythonhosted.org/packages/9c/aa/b30a1db25fc6128b1dd6ff0741fa4abf969ded161599d07ca7edd0739cc0/ruff-0.14.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1ec1ac071e7e37e0221d2f2dbaf90897a988c531a8592a6a5959f0603a1ecf5e", size = 12252581, upload-time = "2025-10-31T00:26:10.297Z" }, - { url = "https://files.pythonhosted.org/packages/da/13/21096308f384d796ffe3f2960b17054110a9c3828d223ca540c2b7cc670b/ruff-0.14.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:afcdc4b5335ef440d19e7df9e8ae2ad9f749352190e96d481dc501b753f0733e", size = 12307503, upload-time = "2025-10-31T00:26:12.646Z" }, - { url = "https://files.pythonhosted.org/packages/cb/cc/a350bac23f03b7dbcde3c81b154706e80c6f16b06ff1ce28ed07dc7b07b0/ruff-0.14.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:7bfc42f81862749a7136267a343990f865e71fe2f99cf8d2958f684d23ce3dfa", size = 12675457, upload-time = "2025-10-31T00:26:15.044Z" }, - { url = "https://files.pythonhosted.org/packages/cb/76/46346029fa2f2078826bc88ef7167e8c198e58fe3126636e52f77488cbba/ruff-0.14.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a65e448cfd7e9c59fae8cf37f9221585d3354febaad9a07f29158af1528e165f", size = 13403980, upload-time = "2025-10-31T00:26:17.81Z" }, - { url = "https://files.pythonhosted.org/packages/9f/a4/35f1ef68c4e7b236d4a5204e3669efdeefaef21f0ff6a456792b3d8be438/ruff-0.14.3-py3-none-win32.whl", hash = "sha256:f3d91857d023ba93e14ed2d462ab62c3428f9bbf2b4fbac50a03ca66d31991f7", size = 12500045, upload-time = "2025-10-31T00:26:20.503Z" }, - { url = "https://files.pythonhosted.org/packages/03/15/51960ae340823c9859fb60c63301d977308735403e2134e17d1d2858c7fb/ruff-0.14.3-py3-none-win_amd64.whl", hash = "sha256:d7b7006ac0756306db212fd37116cce2bd307e1e109375e1c6c106002df0ae5f", size = 13594005, upload-time = "2025-10-31T00:26:22.533Z" }, - { url = "https://files.pythonhosted.org/packages/b7/73/4de6579bac8e979fca0a77e54dec1f1e011a0d268165eb8a9bc0982a6564/ruff-0.14.3-py3-none-win_arm64.whl", hash = "sha256:26eb477ede6d399d898791d01961e16b86f02bc2486d0d1a7a9bb2379d055dc1", size = 12590017, upload-time = "2025-10-31T00:26:24.52Z" }, -] - -[[package]] -name = "sniffio" -version = "1.3.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" }, -] - -[[package]] -name = "sqlalchemy" -version = "2.0.44" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" }, - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/f0/f2/840d7b9496825333f532d2e3976b8eadbf52034178aac53630d09fe6e1ef/sqlalchemy-2.0.44.tar.gz", hash = "sha256:0ae7454e1ab1d780aee69fd2aae7d6b8670a581d8847f2d1e0f7ddfbf47e5a22", size = 9819830, upload-time = "2025-10-10T14:39:12.935Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/62/c4/59c7c9b068e6813c898b771204aad36683c96318ed12d4233e1b18762164/sqlalchemy-2.0.44-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:72fea91746b5890f9e5e0997f16cbf3d53550580d76355ba2d998311b17b2250", size = 2139675, upload-time = "2025-10-10T16:03:31.064Z" }, - { url = "https://files.pythonhosted.org/packages/d6/ae/eeb0920537a6f9c5a3708e4a5fc55af25900216bdb4847ec29cfddf3bf3a/sqlalchemy-2.0.44-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:585c0c852a891450edbb1eaca8648408a3cc125f18cf433941fa6babcc359e29", size = 2127726, upload-time = "2025-10-10T16:03:35.934Z" }, - { url = "https://files.pythonhosted.org/packages/d8/d5/2ebbabe0379418eda8041c06b0b551f213576bfe4c2f09d77c06c07c8cc5/sqlalchemy-2.0.44-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b94843a102efa9ac68a7a30cd46df3ff1ed9c658100d30a725d10d9c60a2f44", size = 3327603, upload-time = "2025-10-10T15:35:28.322Z" }, - { url = "https://files.pythonhosted.org/packages/45/e5/5aa65852dadc24b7d8ae75b7efb8d19303ed6ac93482e60c44a585930ea5/sqlalchemy-2.0.44-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:119dc41e7a7defcefc57189cfa0e61b1bf9c228211aba432b53fb71ef367fda1", size = 3337842, upload-time = "2025-10-10T15:43:45.431Z" }, - { url = "https://files.pythonhosted.org/packages/41/92/648f1afd3f20b71e880ca797a960f638d39d243e233a7082c93093c22378/sqlalchemy-2.0.44-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:0765e318ee9179b3718c4fd7ba35c434f4dd20332fbc6857a5e8df17719c24d7", size = 3264558, upload-time = "2025-10-10T15:35:29.93Z" }, - { url = "https://files.pythonhosted.org/packages/40/cf/e27d7ee61a10f74b17740918e23cbc5bc62011b48282170dc4c66da8ec0f/sqlalchemy-2.0.44-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:2e7b5b079055e02d06a4308d0481658e4f06bc7ef211567edc8f7d5dce52018d", size = 3301570, upload-time = "2025-10-10T15:43:48.407Z" }, - { url = "https://files.pythonhosted.org/packages/3b/3d/3116a9a7b63e780fb402799b6da227435be878b6846b192f076d2f838654/sqlalchemy-2.0.44-cp312-cp312-win32.whl", hash = "sha256:846541e58b9a81cce7dee8329f352c318de25aa2f2bbe1e31587eb1f057448b4", size = 2103447, upload-time = "2025-10-10T15:03:21.678Z" }, - { url = "https://files.pythonhosted.org/packages/25/83/24690e9dfc241e6ab062df82cc0df7f4231c79ba98b273fa496fb3dd78ed/sqlalchemy-2.0.44-cp312-cp312-win_amd64.whl", hash = "sha256:7cbcb47fd66ab294703e1644f78971f6f2f1126424d2b300678f419aa73c7b6e", size = 2130912, upload-time = "2025-10-10T15:03:24.656Z" }, - { url = "https://files.pythonhosted.org/packages/45/d3/c67077a2249fdb455246e6853166360054c331db4613cda3e31ab1cadbef/sqlalchemy-2.0.44-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ff486e183d151e51b1d694c7aa1695747599bb00b9f5f604092b54b74c64a8e1", size = 2135479, upload-time = "2025-10-10T16:03:37.671Z" }, - { url = "https://files.pythonhosted.org/packages/2b/91/eabd0688330d6fd114f5f12c4f89b0d02929f525e6bf7ff80aa17ca802af/sqlalchemy-2.0.44-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0b1af8392eb27b372ddb783b317dea0f650241cea5bd29199b22235299ca2e45", size = 2123212, upload-time = "2025-10-10T16:03:41.755Z" }, - { url = "https://files.pythonhosted.org/packages/b0/bb/43e246cfe0e81c018076a16036d9b548c4cc649de241fa27d8d9ca6f85ab/sqlalchemy-2.0.44-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2b61188657e3a2b9ac4e8f04d6cf8e51046e28175f79464c67f2fd35bceb0976", size = 3255353, upload-time = "2025-10-10T15:35:31.221Z" }, - { url = "https://files.pythonhosted.org/packages/b9/96/c6105ed9a880abe346b64d3b6ddef269ddfcab04f7f3d90a0bf3c5a88e82/sqlalchemy-2.0.44-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b87e7b91a5d5973dda5f00cd61ef72ad75a1db73a386b62877d4875a8840959c", size = 3260222, upload-time = "2025-10-10T15:43:50.124Z" }, - { url = "https://files.pythonhosted.org/packages/44/16/1857e35a47155b5ad927272fee81ae49d398959cb749edca6eaa399b582f/sqlalchemy-2.0.44-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:15f3326f7f0b2bfe406ee562e17f43f36e16167af99c4c0df61db668de20002d", size = 3189614, upload-time = "2025-10-10T15:35:32.578Z" }, - { url = "https://files.pythonhosted.org/packages/88/ee/4afb39a8ee4fc786e2d716c20ab87b5b1fb33d4ac4129a1aaa574ae8a585/sqlalchemy-2.0.44-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1e77faf6ff919aa8cd63f1c4e561cac1d9a454a191bb864d5dd5e545935e5a40", size = 3226248, upload-time = "2025-10-10T15:43:51.862Z" }, - { url = "https://files.pythonhosted.org/packages/32/d5/0e66097fc64fa266f29a7963296b40a80d6a997b7ac13806183700676f86/sqlalchemy-2.0.44-cp313-cp313-win32.whl", hash = "sha256:ee51625c2d51f8baadf2829fae817ad0b66b140573939dd69284d2ba3553ae73", size = 2101275, upload-time = "2025-10-10T15:03:26.096Z" }, - { url = "https://files.pythonhosted.org/packages/03/51/665617fe4f8c6450f42a6d8d69243f9420f5677395572c2fe9d21b493b7b/sqlalchemy-2.0.44-cp313-cp313-win_amd64.whl", hash = "sha256:c1c80faaee1a6c3428cecf40d16a2365bcf56c424c92c2b6f0f9ad204b899e9e", size = 2127901, upload-time = "2025-10-10T15:03:27.548Z" }, - { url = "https://files.pythonhosted.org/packages/9c/5e/6a29fa884d9fb7ddadf6b69490a9d45fded3b38541713010dad16b77d015/sqlalchemy-2.0.44-py3-none-any.whl", hash = "sha256:19de7ca1246fbef9f9d1bff8f1ab25641569df226364a0e40457dc5457c54b05", size = 1928718, upload-time = "2025-10-10T15:29:45.32Z" }, -] - -[[package]] -name = "starlette" -version = "0.49.3" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "anyio" }, - { name = "typing-extensions", marker = "python_full_version < '3.13'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/de/1a/608df0b10b53b0beb96a37854ee05864d182ddd4b1156a22f1ad3860425a/starlette-0.49.3.tar.gz", hash = "sha256:1c14546f299b5901a1ea0e34410575bc33bbd741377a10484a54445588d00284", size = 2655031, upload-time = "2025-11-01T15:12:26.13Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/a3/e0/021c772d6a662f43b63044ab481dc6ac7592447605b5b35a957785363122/starlette-0.49.3-py3-none-any.whl", hash = "sha256:b579b99715fdc2980cf88c8ec96d3bf1ce16f5a8051a7c2b84ef9b1cdecaea2f", size = 74340, upload-time = "2025-11-01T15:12:24.387Z" }, -] - -[[package]] -name = "tqdm" -version = "4.67.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/a8/4b/29b4ef32e036bb34e4ab51796dd745cdba7ed47ad142a9f4a1eb8e0c744d/tqdm-4.67.1.tar.gz", hash = "sha256:f8aef9c52c08c13a65f30ea34f4e5aac3fd1a34959879d7e59e63027286627f2", size = 169737, upload-time = "2024-11-24T20:12:22.481Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/d0/30/dc54f88dd4a2b5dc8a0279bdd7270e735851848b762aeb1c1184ed1f6b14/tqdm-4.67.1-py3-none-any.whl", hash = "sha256:26445eca388f82e72884e0d580d5464cd801a3ea01e63e5601bdff9ba6a48de2", size = 78540, upload-time = "2024-11-24T20:12:19.698Z" }, -] - -[[package]] -name = "typing-extensions" -version = "4.15.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, -] - -[[package]] -name = "typing-inspection" -version = "0.4.2" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" }, -] - -[[package]] -name = "uvicorn" -version = "0.38.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "click" }, - { name = "h11" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/cb/ce/f06b84e2697fef4688ca63bdb2fdf113ca0a3be33f94488f2cadb690b0cf/uvicorn-0.38.0.tar.gz", hash = "sha256:fd97093bdd120a2609fc0d3afe931d4d4ad688b6e75f0f929fde1bc36fe0e91d", size = 80605, upload-time = "2025-10-18T13:46:44.63Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/ee/d9/d88e73ca598f4f6ff671fb5fde8a32925c2e08a637303a1d12883c7305fa/uvicorn-0.38.0-py3-none-any.whl", hash = "sha256:48c0afd214ceb59340075b4a052ea1ee91c16fbc2a9b1469cca0e54566977b02", size = 68109, upload-time = "2025-10-18T13:46:42.958Z" }, -] - -[package.optional-dependencies] -standard = [ - { name = "colorama", marker = "sys_platform == 'win32'" }, - { name = "httptools" }, - { name = "python-dotenv" }, - { name = "pyyaml" }, - { name = "uvloop", marker = "platform_python_implementation != 'PyPy' and sys_platform != 'cygwin' and sys_platform != 'win32'" }, - { name = "watchfiles" }, - { name = "websockets" }, -] - -[[package]] -name = "uvloop" -version = "0.22.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/06/f0/18d39dbd1971d6d62c4629cc7fa67f74821b0dc1f5a77af43719de7936a7/uvloop-0.22.1.tar.gz", hash = "sha256:6c84bae345b9147082b17371e3dd5d42775bddce91f885499017f4607fdaf39f", size = 2443250, upload-time = "2025-10-16T22:17:19.342Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/3d/ff/7f72e8170be527b4977b033239a83a68d5c881cc4775fca255c677f7ac5d/uvloop-0.22.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:fe94b4564e865d968414598eea1a6de60adba0c040ba4ed05ac1300de402cd42", size = 1359936, upload-time = "2025-10-16T22:16:29.436Z" }, - { url = "https://files.pythonhosted.org/packages/c3/c6/e5d433f88fd54d81ef4be58b2b7b0cea13c442454a1db703a1eea0db1a59/uvloop-0.22.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:51eb9bd88391483410daad430813d982010f9c9c89512321f5b60e2cddbdddd6", size = 752769, upload-time = "2025-10-16T22:16:30.493Z" }, - { url = "https://files.pythonhosted.org/packages/24/68/a6ac446820273e71aa762fa21cdcc09861edd3536ff47c5cd3b7afb10eeb/uvloop-0.22.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:700e674a166ca5778255e0e1dc4e9d79ab2acc57b9171b79e65feba7184b3370", size = 4317413, upload-time = "2025-10-16T22:16:31.644Z" }, - { url = "https://files.pythonhosted.org/packages/5f/6f/e62b4dfc7ad6518e7eff2516f680d02a0f6eb62c0c212e152ca708a0085e/uvloop-0.22.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b5b1ac819a3f946d3b2ee07f09149578ae76066d70b44df3fa990add49a82e4", size = 4426307, upload-time = "2025-10-16T22:16:32.917Z" }, - { url = "https://files.pythonhosted.org/packages/90/60/97362554ac21e20e81bcef1150cb2a7e4ffdaf8ea1e5b2e8bf7a053caa18/uvloop-0.22.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e047cc068570bac9866237739607d1313b9253c3051ad84738cbb095be0537b2", size = 4131970, upload-time = "2025-10-16T22:16:34.015Z" }, - { url = "https://files.pythonhosted.org/packages/99/39/6b3f7d234ba3964c428a6e40006340f53ba37993f46ed6e111c6e9141d18/uvloop-0.22.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:512fec6815e2dd45161054592441ef76c830eddaad55c8aa30952e6fe1ed07c0", size = 4296343, upload-time = "2025-10-16T22:16:35.149Z" }, - { url = "https://files.pythonhosted.org/packages/89/8c/182a2a593195bfd39842ea68ebc084e20c850806117213f5a299dfc513d9/uvloop-0.22.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:561577354eb94200d75aca23fbde86ee11be36b00e52a4eaf8f50fb0c86b7705", size = 1358611, upload-time = "2025-10-16T22:16:36.833Z" }, - { url = "https://files.pythonhosted.org/packages/d2/14/e301ee96a6dc95224b6f1162cd3312f6d1217be3907b79173b06785f2fe7/uvloop-0.22.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1cdf5192ab3e674ca26da2eada35b288d2fa49fdd0f357a19f0e7c4e7d5077c8", size = 751811, upload-time = "2025-10-16T22:16:38.275Z" }, - { url = "https://files.pythonhosted.org/packages/b7/02/654426ce265ac19e2980bfd9ea6590ca96a56f10c76e63801a2df01c0486/uvloop-0.22.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e2ea3d6190a2968f4a14a23019d3b16870dd2190cd69c8180f7c632d21de68d", size = 4288562, upload-time = "2025-10-16T22:16:39.375Z" }, - { url = "https://files.pythonhosted.org/packages/15/c0/0be24758891ef825f2065cd5db8741aaddabe3e248ee6acc5e8a80f04005/uvloop-0.22.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0530a5fbad9c9e4ee3f2b33b148c6a64d47bbad8000ea63704fa8260f4cf728e", size = 4366890, upload-time = "2025-10-16T22:16:40.547Z" }, - { url = "https://files.pythonhosted.org/packages/d2/53/8369e5219a5855869bcee5f4d317f6da0e2c669aecf0ef7d371e3d084449/uvloop-0.22.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:bc5ef13bbc10b5335792360623cc378d52d7e62c2de64660616478c32cd0598e", size = 4119472, upload-time = "2025-10-16T22:16:41.694Z" }, - { url = "https://files.pythonhosted.org/packages/f8/ba/d69adbe699b768f6b29a5eec7b47dd610bd17a69de51b251126a801369ea/uvloop-0.22.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:1f38ec5e3f18c8a10ded09742f7fb8de0108796eb673f30ce7762ce1b8550cad", size = 4239051, upload-time = "2025-10-16T22:16:43.224Z" }, - { url = "https://files.pythonhosted.org/packages/90/cd/b62bdeaa429758aee8de8b00ac0dd26593a9de93d302bff3d21439e9791d/uvloop-0.22.1-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:3879b88423ec7e97cd4eba2a443aa26ed4e59b45e6b76aabf13fe2f27023a142", size = 1362067, upload-time = "2025-10-16T22:16:44.503Z" }, - { url = "https://files.pythonhosted.org/packages/0d/f8/a132124dfda0777e489ca86732e85e69afcd1ff7686647000050ba670689/uvloop-0.22.1-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:4baa86acedf1d62115c1dc6ad1e17134476688f08c6efd8a2ab076e815665c74", size = 752423, upload-time = "2025-10-16T22:16:45.968Z" }, - { url = "https://files.pythonhosted.org/packages/a3/94/94af78c156f88da4b3a733773ad5ba0b164393e357cc4bd0ab2e2677a7d6/uvloop-0.22.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:297c27d8003520596236bdb2335e6b3f649480bd09e00d1e3a99144b691d2a35", size = 4272437, upload-time = "2025-10-16T22:16:47.451Z" }, - { url = "https://files.pythonhosted.org/packages/b5/35/60249e9fd07b32c665192cec7af29e06c7cd96fa1d08b84f012a56a0b38e/uvloop-0.22.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c1955d5a1dd43198244d47664a5858082a3239766a839b2102a269aaff7a4e25", size = 4292101, upload-time = "2025-10-16T22:16:49.318Z" }, - { url = "https://files.pythonhosted.org/packages/02/62/67d382dfcb25d0a98ce73c11ed1a6fba5037a1a1d533dcbb7cab033a2636/uvloop-0.22.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:b31dc2fccbd42adc73bc4e7cdbae4fc5086cf378979e53ca5d0301838c5682c6", size = 4114158, upload-time = "2025-10-16T22:16:50.517Z" }, - { url = "https://files.pythonhosted.org/packages/f0/7a/f1171b4a882a5d13c8b7576f348acfe6074d72eaf52cccef752f748d4a9f/uvloop-0.22.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:93f617675b2d03af4e72a5333ef89450dfaa5321303ede6e67ba9c9d26878079", size = 4177360, upload-time = "2025-10-16T22:16:52.646Z" }, - { url = "https://files.pythonhosted.org/packages/79/7b/b01414f31546caf0919da80ad57cbfe24c56b151d12af68cee1b04922ca8/uvloop-0.22.1-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:37554f70528f60cad66945b885eb01f1bb514f132d92b6eeed1c90fd54ed6289", size = 1454790, upload-time = "2025-10-16T22:16:54.355Z" }, - { url = "https://files.pythonhosted.org/packages/d4/31/0bb232318dd838cad3fa8fb0c68c8b40e1145b32025581975e18b11fab40/uvloop-0.22.1-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:b76324e2dc033a0b2f435f33eb88ff9913c156ef78e153fb210e03c13da746b3", size = 796783, upload-time = "2025-10-16T22:16:55.906Z" }, - { url = "https://files.pythonhosted.org/packages/42/38/c9b09f3271a7a723a5de69f8e237ab8e7803183131bc57c890db0b6bb872/uvloop-0.22.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:badb4d8e58ee08dad957002027830d5c3b06aea446a6a3744483c2b3b745345c", size = 4647548, upload-time = "2025-10-16T22:16:57.008Z" }, - { url = "https://files.pythonhosted.org/packages/c1/37/945b4ca0ac27e3dc4952642d4c900edd030b3da6c9634875af6e13ae80e5/uvloop-0.22.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b91328c72635f6f9e0282e4a57da7470c7350ab1c9f48546c0f2866205349d21", size = 4467065, upload-time = "2025-10-16T22:16:58.206Z" }, - { url = "https://files.pythonhosted.org/packages/97/cc/48d232f33d60e2e2e0b42f4e73455b146b76ebe216487e862700457fbf3c/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:daf620c2995d193449393d6c62131b3fbd40a63bf7b307a1527856ace637fe88", size = 4328384, upload-time = "2025-10-16T22:16:59.36Z" }, - { url = "https://files.pythonhosted.org/packages/e4/16/c1fd27e9549f3c4baf1dc9c20c456cd2f822dbf8de9f463824b0c0357e06/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6cde23eeda1a25c75b2e07d39970f3374105d5eafbaab2a4482be82f272d5a5e", size = 4296730, upload-time = "2025-10-16T22:17:00.744Z" }, -] - -[[package]] -name = "watchfiles" -version = "1.1.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "anyio" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/c2/c9/8869df9b2a2d6c59d79220a4db37679e74f807c559ffe5265e08b227a210/watchfiles-1.1.1.tar.gz", hash = "sha256:a173cb5c16c4f40ab19cecf48a534c409f7ea983ab8fed0741304a1c0a31b3f2", size = 94440, upload-time = "2025-10-14T15:06:21.08Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/74/d5/f039e7e3c639d9b1d09b07ea412a6806d38123f0508e5f9b48a87b0a76cc/watchfiles-1.1.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:8c89f9f2f740a6b7dcc753140dd5e1ab9215966f7a3530d0c0705c83b401bd7d", size = 404745, upload-time = "2025-10-14T15:04:46.731Z" }, - { url = "https://files.pythonhosted.org/packages/a5/96/a881a13aa1349827490dab2d363c8039527060cfcc2c92cc6d13d1b1049e/watchfiles-1.1.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:bd404be08018c37350f0d6e34676bd1e2889990117a2b90070b3007f172d0610", size = 391769, upload-time = "2025-10-14T15:04:48.003Z" }, - { url = "https://files.pythonhosted.org/packages/4b/5b/d3b460364aeb8da471c1989238ea0e56bec24b6042a68046adf3d9ddb01c/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8526e8f916bb5b9a0a777c8317c23ce65de259422bba5b31325a6fa6029d33af", size = 449374, upload-time = "2025-10-14T15:04:49.179Z" }, - { url = "https://files.pythonhosted.org/packages/b9/44/5769cb62d4ed055cb17417c0a109a92f007114a4e07f30812a73a4efdb11/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2edc3553362b1c38d9f06242416a5d8e9fe235c204a4072e988ce2e5bb1f69f6", size = 459485, upload-time = "2025-10-14T15:04:50.155Z" }, - { url = "https://files.pythonhosted.org/packages/19/0c/286b6301ded2eccd4ffd0041a1b726afda999926cf720aab63adb68a1e36/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:30f7da3fb3f2844259cba4720c3fc7138eb0f7b659c38f3bfa65084c7fc7abce", size = 488813, upload-time = "2025-10-14T15:04:51.059Z" }, - { url = "https://files.pythonhosted.org/packages/c7/2b/8530ed41112dd4a22f4dcfdb5ccf6a1baad1ff6eed8dc5a5f09e7e8c41c7/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f8979280bdafff686ba5e4d8f97840f929a87ed9cdf133cbbd42f7766774d2aa", size = 594816, upload-time = "2025-10-14T15:04:52.031Z" }, - { url = "https://files.pythonhosted.org/packages/ce/d2/f5f9fb49489f184f18470d4f99f4e862a4b3e9ac2865688eb2099e3d837a/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dcc5c24523771db3a294c77d94771abcfcb82a0e0ee8efd910c37c59ec1b31bb", size = 475186, upload-time = "2025-10-14T15:04:53.064Z" }, - { url = "https://files.pythonhosted.org/packages/cf/68/5707da262a119fb06fbe214d82dd1fe4a6f4af32d2d14de368d0349eb52a/watchfiles-1.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1db5d7ae38ff20153d542460752ff397fcf5c96090c1230803713cf3147a6803", size = 456812, upload-time = "2025-10-14T15:04:55.174Z" }, - { url = "https://files.pythonhosted.org/packages/66/ab/3cbb8756323e8f9b6f9acb9ef4ec26d42b2109bce830cc1f3468df20511d/watchfiles-1.1.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:28475ddbde92df1874b6c5c8aaeb24ad5be47a11f87cde5a28ef3835932e3e94", size = 630196, upload-time = "2025-10-14T15:04:56.22Z" }, - { url = "https://files.pythonhosted.org/packages/78/46/7152ec29b8335f80167928944a94955015a345440f524d2dfe63fc2f437b/watchfiles-1.1.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:36193ed342f5b9842edd3532729a2ad55c4160ffcfa3700e0d54be496b70dd43", size = 622657, upload-time = "2025-10-14T15:04:57.521Z" }, - { url = "https://files.pythonhosted.org/packages/0a/bf/95895e78dd75efe9a7f31733607f384b42eb5feb54bd2eb6ed57cc2e94f4/watchfiles-1.1.1-cp312-cp312-win32.whl", hash = "sha256:859e43a1951717cc8de7f4c77674a6d389b106361585951d9e69572823f311d9", size = 272042, upload-time = "2025-10-14T15:04:59.046Z" }, - { url = "https://files.pythonhosted.org/packages/87/0a/90eb755f568de2688cb220171c4191df932232c20946966c27a59c400850/watchfiles-1.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:91d4c9a823a8c987cce8fa2690923b069966dabb196dd8d137ea2cede885fde9", size = 288410, upload-time = "2025-10-14T15:05:00.081Z" }, - { url = "https://files.pythonhosted.org/packages/36/76/f322701530586922fbd6723c4f91ace21364924822a8772c549483abed13/watchfiles-1.1.1-cp312-cp312-win_arm64.whl", hash = "sha256:a625815d4a2bdca61953dbba5a39d60164451ef34c88d751f6c368c3ea73d404", size = 278209, upload-time = "2025-10-14T15:05:01.168Z" }, - { url = "https://files.pythonhosted.org/packages/bb/f4/f750b29225fe77139f7ae5de89d4949f5a99f934c65a1f1c0b248f26f747/watchfiles-1.1.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:130e4876309e8686a5e37dba7d5e9bc77e6ed908266996ca26572437a5271e18", size = 404321, upload-time = "2025-10-14T15:05:02.063Z" }, - { url = "https://files.pythonhosted.org/packages/2b/f9/f07a295cde762644aa4c4bb0f88921d2d141af45e735b965fb2e87858328/watchfiles-1.1.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5f3bde70f157f84ece3765b42b4a52c6ac1a50334903c6eaf765362f6ccca88a", size = 391783, upload-time = "2025-10-14T15:05:03.052Z" }, - { url = "https://files.pythonhosted.org/packages/bc/11/fc2502457e0bea39a5c958d86d2cb69e407a4d00b85735ca724bfa6e0d1a/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:14e0b1fe858430fc0251737ef3824c54027bedb8c37c38114488b8e131cf8219", size = 449279, upload-time = "2025-10-14T15:05:04.004Z" }, - { url = "https://files.pythonhosted.org/packages/e3/1f/d66bc15ea0b728df3ed96a539c777acfcad0eb78555ad9efcaa1274688f0/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f27db948078f3823a6bb3b465180db8ebecf26dd5dae6f6180bd87383b6b4428", size = 459405, upload-time = "2025-10-14T15:05:04.942Z" }, - { url = "https://files.pythonhosted.org/packages/be/90/9f4a65c0aec3ccf032703e6db02d89a157462fbb2cf20dd415128251cac0/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:059098c3a429f62fc98e8ec62b982230ef2c8df68c79e826e37b895bc359a9c0", size = 488976, upload-time = "2025-10-14T15:05:05.905Z" }, - { url = "https://files.pythonhosted.org/packages/37/57/ee347af605d867f712be7029bb94c8c071732a4b44792e3176fa3c612d39/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bfb5862016acc9b869bb57284e6cb35fdf8e22fe59f7548858e2f971d045f150", size = 595506, upload-time = "2025-10-14T15:05:06.906Z" }, - { url = "https://files.pythonhosted.org/packages/a8/78/cc5ab0b86c122047f75e8fc471c67a04dee395daf847d3e59381996c8707/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:319b27255aacd9923b8a276bb14d21a5f7ff82564c744235fc5eae58d95422ae", size = 474936, upload-time = "2025-10-14T15:05:07.906Z" }, - { url = "https://files.pythonhosted.org/packages/62/da/def65b170a3815af7bd40a3e7010bf6ab53089ef1b75d05dd5385b87cf08/watchfiles-1.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c755367e51db90e75b19454b680903631d41f9e3607fbd941d296a020c2d752d", size = 456147, upload-time = "2025-10-14T15:05:09.138Z" }, - { url = "https://files.pythonhosted.org/packages/57/99/da6573ba71166e82d288d4df0839128004c67d2778d3b566c138695f5c0b/watchfiles-1.1.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:c22c776292a23bfc7237a98f791b9ad3144b02116ff10d820829ce62dff46d0b", size = 630007, upload-time = "2025-10-14T15:05:10.117Z" }, - { url = "https://files.pythonhosted.org/packages/a8/51/7439c4dd39511368849eb1e53279cd3454b4a4dbace80bab88feeb83c6b5/watchfiles-1.1.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:3a476189be23c3686bc2f4321dd501cb329c0a0469e77b7b534ee10129ae6374", size = 622280, upload-time = "2025-10-14T15:05:11.146Z" }, - { url = "https://files.pythonhosted.org/packages/95/9c/8ed97d4bba5db6fdcdb2b298d3898f2dd5c20f6b73aee04eabe56c59677e/watchfiles-1.1.1-cp313-cp313-win32.whl", hash = "sha256:bf0a91bfb5574a2f7fc223cf95eeea79abfefa404bf1ea5e339c0c1560ae99a0", size = 272056, upload-time = "2025-10-14T15:05:12.156Z" }, - { url = "https://files.pythonhosted.org/packages/1f/f3/c14e28429f744a260d8ceae18bf58c1d5fa56b50d006a7a9f80e1882cb0d/watchfiles-1.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:52e06553899e11e8074503c8e716d574adeeb7e68913115c4b3653c53f9bae42", size = 288162, upload-time = "2025-10-14T15:05:13.208Z" }, - { url = "https://files.pythonhosted.org/packages/dc/61/fe0e56c40d5cd29523e398d31153218718c5786b5e636d9ae8ae79453d27/watchfiles-1.1.1-cp313-cp313-win_arm64.whl", hash = "sha256:ac3cc5759570cd02662b15fbcd9d917f7ecd47efe0d6b40474eafd246f91ea18", size = 277909, upload-time = "2025-10-14T15:05:14.49Z" }, - { url = "https://files.pythonhosted.org/packages/79/42/e0a7d749626f1e28c7108a99fb9bf524b501bbbeb9b261ceecde644d5a07/watchfiles-1.1.1-cp313-cp313t-macosx_10_12_x86_64.whl", hash = "sha256:563b116874a9a7ce6f96f87cd0b94f7faf92d08d0021e837796f0a14318ef8da", size = 403389, upload-time = "2025-10-14T15:05:15.777Z" }, - { url = "https://files.pythonhosted.org/packages/15/49/08732f90ce0fbbc13913f9f215c689cfc9ced345fb1bcd8829a50007cc8d/watchfiles-1.1.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:3ad9fe1dae4ab4212d8c91e80b832425e24f421703b5a42ef2e4a1e215aff051", size = 389964, upload-time = "2025-10-14T15:05:16.85Z" }, - { url = "https://files.pythonhosted.org/packages/27/0d/7c315d4bd5f2538910491a0393c56bf70d333d51bc5b34bee8e68e8cea19/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ce70f96a46b894b36eba678f153f052967a0d06d5b5a19b336ab0dbbd029f73e", size = 448114, upload-time = "2025-10-14T15:05:17.876Z" }, - { url = "https://files.pythonhosted.org/packages/c3/24/9e096de47a4d11bc4df41e9d1e61776393eac4cb6eb11b3e23315b78b2cc/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cb467c999c2eff23a6417e58d75e5828716f42ed8289fe6b77a7e5a91036ca70", size = 460264, upload-time = "2025-10-14T15:05:18.962Z" }, - { url = "https://files.pythonhosted.org/packages/cc/0f/e8dea6375f1d3ba5fcb0b3583e2b493e77379834c74fd5a22d66d85d6540/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:836398932192dae4146c8f6f737d74baeac8b70ce14831a239bdb1ca882fc261", size = 487877, upload-time = "2025-10-14T15:05:20.094Z" }, - { url = "https://files.pythonhosted.org/packages/ac/5b/df24cfc6424a12deb41503b64d42fbea6b8cb357ec62ca84a5a3476f654a/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:743185e7372b7bc7c389e1badcc606931a827112fbbd37f14c537320fca08620", size = 595176, upload-time = "2025-10-14T15:05:21.134Z" }, - { url = "https://files.pythonhosted.org/packages/8f/b5/853b6757f7347de4e9b37e8cc3289283fb983cba1ab4d2d7144694871d9c/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:afaeff7696e0ad9f02cbb8f56365ff4686ab205fcf9c4c5b6fdfaaa16549dd04", size = 473577, upload-time = "2025-10-14T15:05:22.306Z" }, - { url = "https://files.pythonhosted.org/packages/e1/f7/0a4467be0a56e80447c8529c9fce5b38eab4f513cb3d9bf82e7392a5696b/watchfiles-1.1.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3f7eb7da0eb23aa2ba036d4f616d46906013a68caf61b7fdbe42fc8b25132e77", size = 455425, upload-time = "2025-10-14T15:05:23.348Z" }, - { url = "https://files.pythonhosted.org/packages/8e/e0/82583485ea00137ddf69bc84a2db88bd92ab4a6e3c405e5fb878ead8d0e7/watchfiles-1.1.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:831a62658609f0e5c64178211c942ace999517f5770fe9436be4c2faeba0c0ef", size = 628826, upload-time = "2025-10-14T15:05:24.398Z" }, - { url = "https://files.pythonhosted.org/packages/28/9a/a785356fccf9fae84c0cc90570f11702ae9571036fb25932f1242c82191c/watchfiles-1.1.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:f9a2ae5c91cecc9edd47e041a930490c31c3afb1f5e6d71de3dc671bfaca02bf", size = 622208, upload-time = "2025-10-14T15:05:25.45Z" }, - { url = "https://files.pythonhosted.org/packages/c3/f4/0872229324ef69b2c3edec35e84bd57a1289e7d3fe74588048ed8947a323/watchfiles-1.1.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:d1715143123baeeaeadec0528bb7441103979a1d5f6fd0e1f915383fea7ea6d5", size = 404315, upload-time = "2025-10-14T15:05:26.501Z" }, - { url = "https://files.pythonhosted.org/packages/7b/22/16d5331eaed1cb107b873f6ae1b69e9ced582fcf0c59a50cd84f403b1c32/watchfiles-1.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:39574d6370c4579d7f5d0ad940ce5b20db0e4117444e39b6d8f99db5676c52fd", size = 390869, upload-time = "2025-10-14T15:05:27.649Z" }, - { url = "https://files.pythonhosted.org/packages/b2/7e/5643bfff5acb6539b18483128fdc0ef2cccc94a5b8fbda130c823e8ed636/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7365b92c2e69ee952902e8f70f3ba6360d0d596d9299d55d7d386df84b6941fb", size = 449919, upload-time = "2025-10-14T15:05:28.701Z" }, - { url = "https://files.pythonhosted.org/packages/51/2e/c410993ba5025a9f9357c376f48976ef0e1b1aefb73b97a5ae01a5972755/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bfff9740c69c0e4ed32416f013f3c45e2ae42ccedd1167ef2d805c000b6c71a5", size = 460845, upload-time = "2025-10-14T15:05:30.064Z" }, - { url = "https://files.pythonhosted.org/packages/8e/a4/2df3b404469122e8680f0fcd06079317e48db58a2da2950fb45020947734/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b27cf2eb1dda37b2089e3907d8ea92922b673c0c427886d4edc6b94d8dfe5db3", size = 489027, upload-time = "2025-10-14T15:05:31.064Z" }, - { url = "https://files.pythonhosted.org/packages/ea/84/4587ba5b1f267167ee715b7f66e6382cca6938e0a4b870adad93e44747e6/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:526e86aced14a65a5b0ec50827c745597c782ff46b571dbfe46192ab9e0b3c33", size = 595615, upload-time = "2025-10-14T15:05:32.074Z" }, - { url = "https://files.pythonhosted.org/packages/6a/0f/c6988c91d06e93cd0bb3d4a808bcf32375ca1904609835c3031799e3ecae/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:04e78dd0b6352db95507fd8cb46f39d185cf8c74e4cf1e4fbad1d3df96faf510", size = 474836, upload-time = "2025-10-14T15:05:33.209Z" }, - { url = "https://files.pythonhosted.org/packages/b4/36/ded8aebea91919485b7bbabbd14f5f359326cb5ec218cd67074d1e426d74/watchfiles-1.1.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5c85794a4cfa094714fb9c08d4a218375b2b95b8ed1666e8677c349906246c05", size = 455099, upload-time = "2025-10-14T15:05:34.189Z" }, - { url = "https://files.pythonhosted.org/packages/98/e0/8c9bdba88af756a2fce230dd365fab2baf927ba42cd47521ee7498fd5211/watchfiles-1.1.1-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:74d5012b7630714b66be7b7b7a78855ef7ad58e8650c73afc4c076a1f480a8d6", size = 630626, upload-time = "2025-10-14T15:05:35.216Z" }, - { url = "https://files.pythonhosted.org/packages/2a/84/a95db05354bf2d19e438520d92a8ca475e578c647f78f53197f5a2f17aaf/watchfiles-1.1.1-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:8fbe85cb3201c7d380d3d0b90e63d520f15d6afe217165d7f98c9c649654db81", size = 622519, upload-time = "2025-10-14T15:05:36.259Z" }, - { url = "https://files.pythonhosted.org/packages/1d/ce/d8acdc8de545de995c339be67711e474c77d643555a9bb74a9334252bd55/watchfiles-1.1.1-cp314-cp314-win32.whl", hash = "sha256:3fa0b59c92278b5a7800d3ee7733da9d096d4aabcfabb9a928918bd276ef9b9b", size = 272078, upload-time = "2025-10-14T15:05:37.63Z" }, - { url = "https://files.pythonhosted.org/packages/c4/c9/a74487f72d0451524be827e8edec251da0cc1fcf111646a511ae752e1a3d/watchfiles-1.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:c2047d0b6cea13b3316bdbafbfa0c4228ae593d995030fda39089d36e64fc03a", size = 287664, upload-time = "2025-10-14T15:05:38.95Z" }, - { url = "https://files.pythonhosted.org/packages/df/b8/8ac000702cdd496cdce998c6f4ee0ca1f15977bba51bdf07d872ebdfc34c/watchfiles-1.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:842178b126593addc05acf6fce960d28bc5fae7afbaa2c6c1b3a7b9460e5be02", size = 277154, upload-time = "2025-10-14T15:05:39.954Z" }, - { url = "https://files.pythonhosted.org/packages/47/a8/e3af2184707c29f0f14b1963c0aace6529f9d1b8582d5b99f31bbf42f59e/watchfiles-1.1.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:88863fbbc1a7312972f1c511f202eb30866370ebb8493aef2812b9ff28156a21", size = 403820, upload-time = "2025-10-14T15:05:40.932Z" }, - { url = "https://files.pythonhosted.org/packages/c0/ec/e47e307c2f4bd75f9f9e8afbe3876679b18e1bcec449beca132a1c5ffb2d/watchfiles-1.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:55c7475190662e202c08c6c0f4d9e345a29367438cf8e8037f3155e10a88d5a5", size = 390510, upload-time = "2025-10-14T15:05:41.945Z" }, - { url = "https://files.pythonhosted.org/packages/d5/a0/ad235642118090f66e7b2f18fd5c42082418404a79205cdfca50b6309c13/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f53fa183d53a1d7a8852277c92b967ae99c2d4dcee2bfacff8868e6e30b15f7", size = 448408, upload-time = "2025-10-14T15:05:43.385Z" }, - { url = "https://files.pythonhosted.org/packages/df/85/97fa10fd5ff3332ae17e7e40e20784e419e28521549780869f1413742e9d/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:6aae418a8b323732fa89721d86f39ec8f092fc2af67f4217a2b07fd3e93c6101", size = 458968, upload-time = "2025-10-14T15:05:44.404Z" }, - { url = "https://files.pythonhosted.org/packages/47/c2/9059c2e8966ea5ce678166617a7f75ecba6164375f3b288e50a40dc6d489/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f096076119da54a6080e8920cbdaac3dbee667eb91dcc5e5b78840b87415bd44", size = 488096, upload-time = "2025-10-14T15:05:45.398Z" }, - { url = "https://files.pythonhosted.org/packages/94/44/d90a9ec8ac309bc26db808a13e7bfc0e4e78b6fc051078a554e132e80160/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:00485f441d183717038ed2e887a7c868154f216877653121068107b227a2f64c", size = 596040, upload-time = "2025-10-14T15:05:46.502Z" }, - { url = "https://files.pythonhosted.org/packages/95/68/4e3479b20ca305cfc561db3ed207a8a1c745ee32bf24f2026a129d0ddb6e/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a55f3e9e493158d7bfdb60a1165035f1cf7d320914e7b7ea83fe22c6023b58fc", size = 473847, upload-time = "2025-10-14T15:05:47.484Z" }, - { url = "https://files.pythonhosted.org/packages/4f/55/2af26693fd15165c4ff7857e38330e1b61ab8c37d15dc79118cdba115b7a/watchfiles-1.1.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c91ed27800188c2ae96d16e3149f199d62f86c7af5f5f4d2c61a3ed8cd3666c", size = 455072, upload-time = "2025-10-14T15:05:48.928Z" }, - { url = "https://files.pythonhosted.org/packages/66/1d/d0d200b10c9311ec25d2273f8aad8c3ef7cc7ea11808022501811208a750/watchfiles-1.1.1-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:311ff15a0bae3714ffb603e6ba6dbfba4065ab60865d15a6ec544133bdb21099", size = 629104, upload-time = "2025-10-14T15:05:49.908Z" }, - { url = "https://files.pythonhosted.org/packages/e3/bd/fa9bb053192491b3867ba07d2343d9f2252e00811567d30ae8d0f78136fe/watchfiles-1.1.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:a916a2932da8f8ab582f242c065f5c81bed3462849ca79ee357dd9551b0e9b01", size = 622112, upload-time = "2025-10-14T15:05:50.941Z" }, -] - -[[package]] -name = "websockets" -version = "15.0.1" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/21/e6/26d09fab466b7ca9c7737474c52be4f76a40301b08362eb2dbc19dcc16c1/websockets-15.0.1.tar.gz", hash = "sha256:82544de02076bafba038ce055ee6412d68da13ab47f0c60cab827346de828dee", size = 177016, upload-time = "2025-03-05T20:03:41.606Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/51/6b/4545a0d843594f5d0771e86463606a3988b5a09ca5123136f8a76580dd63/websockets-15.0.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:3e90baa811a5d73f3ca0bcbf32064d663ed81318ab225ee4f427ad4e26e5aff3", size = 175437, upload-time = "2025-03-05T20:02:16.706Z" }, - { url = "https://files.pythonhosted.org/packages/f4/71/809a0f5f6a06522af902e0f2ea2757f71ead94610010cf570ab5c98e99ed/websockets-15.0.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:592f1a9fe869c778694f0aa806ba0374e97648ab57936f092fd9d87f8bc03665", size = 173096, upload-time = "2025-03-05T20:02:18.832Z" }, - { url = "https://files.pythonhosted.org/packages/3d/69/1a681dd6f02180916f116894181eab8b2e25b31e484c5d0eae637ec01f7c/websockets-15.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0701bc3cfcb9164d04a14b149fd74be7347a530ad3bbf15ab2c678a2cd3dd9a2", size = 173332, upload-time = "2025-03-05T20:02:20.187Z" }, - { url = "https://files.pythonhosted.org/packages/a6/02/0073b3952f5bce97eafbb35757f8d0d54812b6174ed8dd952aa08429bcc3/websockets-15.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8b56bdcdb4505c8078cb6c7157d9811a85790f2f2b3632c7d1462ab5783d215", size = 183152, upload-time = "2025-03-05T20:02:22.286Z" }, - { url = "https://files.pythonhosted.org/packages/74/45/c205c8480eafd114b428284840da0b1be9ffd0e4f87338dc95dc6ff961a1/websockets-15.0.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0af68c55afbd5f07986df82831c7bff04846928ea8d1fd7f30052638788bc9b5", size = 182096, upload-time = "2025-03-05T20:02:24.368Z" }, - { url = "https://files.pythonhosted.org/packages/14/8f/aa61f528fba38578ec553c145857a181384c72b98156f858ca5c8e82d9d3/websockets-15.0.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:64dee438fed052b52e4f98f76c5790513235efaa1ef7f3f2192c392cd7c91b65", size = 182523, upload-time = "2025-03-05T20:02:25.669Z" }, - { url = "https://files.pythonhosted.org/packages/ec/6d/0267396610add5bc0d0d3e77f546d4cd287200804fe02323797de77dbce9/websockets-15.0.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:d5f6b181bb38171a8ad1d6aa58a67a6aa9d4b38d0f8c5f496b9e42561dfc62fe", size = 182790, upload-time = "2025-03-05T20:02:26.99Z" }, - { url = "https://files.pythonhosted.org/packages/02/05/c68c5adbf679cf610ae2f74a9b871ae84564462955d991178f95a1ddb7dd/websockets-15.0.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:5d54b09eba2bada6011aea5375542a157637b91029687eb4fdb2dab11059c1b4", size = 182165, upload-time = "2025-03-05T20:02:30.291Z" }, - { url = "https://files.pythonhosted.org/packages/29/93/bb672df7b2f5faac89761cb5fa34f5cec45a4026c383a4b5761c6cea5c16/websockets-15.0.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3be571a8b5afed347da347bfcf27ba12b069d9d7f42cb8c7028b5e98bbb12597", size = 182160, upload-time = "2025-03-05T20:02:31.634Z" }, - { url = "https://files.pythonhosted.org/packages/ff/83/de1f7709376dc3ca9b7eeb4b9a07b4526b14876b6d372a4dc62312bebee0/websockets-15.0.1-cp312-cp312-win32.whl", hash = "sha256:c338ffa0520bdb12fbc527265235639fb76e7bc7faafbb93f6ba80d9c06578a9", size = 176395, upload-time = "2025-03-05T20:02:33.017Z" }, - { url = "https://files.pythonhosted.org/packages/7d/71/abf2ebc3bbfa40f391ce1428c7168fb20582d0ff57019b69ea20fa698043/websockets-15.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:fcd5cf9e305d7b8338754470cf69cf81f420459dbae8a3b40cee57417f4614a7", size = 176841, upload-time = "2025-03-05T20:02:34.498Z" }, - { url = "https://files.pythonhosted.org/packages/cb/9f/51f0cf64471a9d2b4d0fc6c534f323b664e7095640c34562f5182e5a7195/websockets-15.0.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:ee443ef070bb3b6ed74514f5efaa37a252af57c90eb33b956d35c8e9c10a1931", size = 175440, upload-time = "2025-03-05T20:02:36.695Z" }, - { url = "https://files.pythonhosted.org/packages/8a/05/aa116ec9943c718905997412c5989f7ed671bc0188ee2ba89520e8765d7b/websockets-15.0.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:5a939de6b7b4e18ca683218320fc67ea886038265fd1ed30173f5ce3f8e85675", size = 173098, upload-time = "2025-03-05T20:02:37.985Z" }, - { url = "https://files.pythonhosted.org/packages/ff/0b/33cef55ff24f2d92924923c99926dcce78e7bd922d649467f0eda8368923/websockets-15.0.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:746ee8dba912cd6fc889a8147168991d50ed70447bf18bcda7039f7d2e3d9151", size = 173329, upload-time = "2025-03-05T20:02:39.298Z" }, - { url = "https://files.pythonhosted.org/packages/31/1d/063b25dcc01faa8fada1469bdf769de3768b7044eac9d41f734fd7b6ad6d/websockets-15.0.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:595b6c3969023ecf9041b2936ac3827e4623bfa3ccf007575f04c5a6aa318c22", size = 183111, upload-time = "2025-03-05T20:02:40.595Z" }, - { url = "https://files.pythonhosted.org/packages/93/53/9a87ee494a51bf63e4ec9241c1ccc4f7c2f45fff85d5bde2ff74fcb68b9e/websockets-15.0.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3c714d2fc58b5ca3e285461a4cc0c9a66bd0e24c5da9911e30158286c9b5be7f", size = 182054, upload-time = "2025-03-05T20:02:41.926Z" }, - { url = "https://files.pythonhosted.org/packages/ff/b2/83a6ddf56cdcbad4e3d841fcc55d6ba7d19aeb89c50f24dd7e859ec0805f/websockets-15.0.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0f3c1e2ab208db911594ae5b4f79addeb3501604a165019dd221c0bdcabe4db8", size = 182496, upload-time = "2025-03-05T20:02:43.304Z" }, - { url = "https://files.pythonhosted.org/packages/98/41/e7038944ed0abf34c45aa4635ba28136f06052e08fc2168520bb8b25149f/websockets-15.0.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:229cf1d3ca6c1804400b0a9790dc66528e08a6a1feec0d5040e8b9eb14422375", size = 182829, upload-time = "2025-03-05T20:02:48.812Z" }, - { url = "https://files.pythonhosted.org/packages/e0/17/de15b6158680c7623c6ef0db361da965ab25d813ae54fcfeae2e5b9ef910/websockets-15.0.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:756c56e867a90fb00177d530dca4b097dd753cde348448a1012ed6c5131f8b7d", size = 182217, upload-time = "2025-03-05T20:02:50.14Z" }, - { url = "https://files.pythonhosted.org/packages/33/2b/1f168cb6041853eef0362fb9554c3824367c5560cbdaad89ac40f8c2edfc/websockets-15.0.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:558d023b3df0bffe50a04e710bc87742de35060580a293c2a984299ed83bc4e4", size = 182195, upload-time = "2025-03-05T20:02:51.561Z" }, - { url = "https://files.pythonhosted.org/packages/86/eb/20b6cdf273913d0ad05a6a14aed4b9a85591c18a987a3d47f20fa13dcc47/websockets-15.0.1-cp313-cp313-win32.whl", hash = "sha256:ba9e56e8ceeeedb2e080147ba85ffcd5cd0711b89576b83784d8605a7df455fa", size = 176393, upload-time = "2025-03-05T20:02:53.814Z" }, - { url = "https://files.pythonhosted.org/packages/1b/6c/c65773d6cab416a64d191d6ee8a8b1c68a09970ea6909d16965d26bfed1e/websockets-15.0.1-cp313-cp313-win_amd64.whl", hash = "sha256:e09473f095a819042ecb2ab9465aee615bd9c2028e4ef7d933600a8401c79561", size = 176837, upload-time = "2025-03-05T20:02:55.237Z" }, - { url = "https://files.pythonhosted.org/packages/fa/a8/5b41e0da817d64113292ab1f8247140aac61cbf6cfd085d6a0fa77f4984f/websockets-15.0.1-py3-none-any.whl", hash = "sha256:f7a866fbc1e97b5c617ee4116daaa09b722101d4a3c170c787450ba409f9736f", size = 169743, upload-time = "2025-03-05T20:03:39.41Z" }, -] From bffdbdbc72f25fcad007bdbb8683e50296810fc0 Mon Sep 17 00:00:00 2001 From: Harold Date: Thu, 6 Nov 2025 11:55:51 +0800 Subject: [PATCH 25/31] feat: remove language specific system prompt --- .../core/roles/prompts/builder.py | 55 ++++++------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/main/xiaozhi-server/core/roles/prompts/builder.py b/main/xiaozhi-server/core/roles/prompts/builder.py index 1b1ed4d8f..f5f4e444d 100644 --- a/main/xiaozhi-server/core/roles/prompts/builder.py +++ b/main/xiaozhi-server/core/roles/prompts/builder.py @@ -61,6 +61,7 @@ def _build_system_context( Returns: 格式化的系统上下文字符串 """ + # TODO: Here, we need to use the client ip to figure out the timezone try: tz = ZoneInfo(timezone) except Exception: @@ -72,14 +73,10 @@ def _build_system_context( # 如果未提供日期信息,则自动计算 if not today_date: - # 根据语言格式化日期 - if language == "zh": - today_date = now.strftime("%Y年%m月%d日") - else: - day = now.strftime("%d") - month = now.strftime("%B") - year = now.strftime("%Y") - today_date = f"{day} {month} {year}" + day = now.strftime("%d") + month = now.strftime("%B") + year = now.strftime("%Y") + today_date = f"{day} {month} {year}" if not today_weekday: day_of_week = now.strftime("%A") @@ -94,29 +91,15 @@ def _build_system_context( # 构建系统上下文规则 system_rules = [] - if language == "zh": - system_rules.append(f"- 用户开始对话的时间:{time_str}") - system_rules.append(f"- 今天日期:{today_date} ({today_weekday})") - if lunar_date: - system_rules.append(f"- 今天农历:{lunar_date}") - if local_address: - system_rules.append(f"- 用户所在城市:{local_address}") - if weather_info: - system_rules.append(f"- 当地未来7天天气:{weather_info}") - if device_id: - system_rules.append(f"- 设备ID:{device_id}") - system_rules.append(f"- 当前语言:**{language}**") - system_rules.append(f"- 时区:{timezone}") - else: - formatted_datetime = f"{now.strftime('%A')}, {time_str} {today_date} ({timezone})" - system_rules.append(f"- The user started this conversation on {formatted_datetime}") - if local_address: - system_rules.append(f"- User location: {local_address}") - if weather_info: - system_rules.append(f"- Local weather forecast: {weather_info}") - if device_id: - system_rules.append(f"- Device ID: {device_id}") - system_rules.append(f"- Your current language is: **{language}**") + formatted_datetime = f"{now.strftime('%A')}, {time_str} {today_date} ({timezone})" + system_rules.append(f"- The user started this conversation on {formatted_datetime}") + if local_address: + system_rules.append(f"- User location: {local_address}") + if weather_info: + system_rules.append(f"- Local weather forecast: {weather_info}") + if device_id: + system_rules.append(f"- Device ID: {device_id}") + system_rules.append(f"- Your current language is: **{language}**") return "\n".join(system_rules) @@ -200,15 +183,9 @@ def build_system_prompt( # Step 7: 填充模板(不包含 profile) try: - template_content = ROLE_TEXT.format(**template_vars) + system_prompt= ROLE_TEXT.format(**template_vars) except KeyError as e: logger.bind(tag=TAG).error(f"模板变量缺失: {e}") - template_content = "" - - # Step 8: 如果有 profile,将其放在最前面;否则只返回模板内容 - if profile_content and profile_content.strip(): - system_prompt = f"{profile_content.strip()}\n\n{template_content}" - else: - system_prompt = template_content + system_prompt = profile_content return system_prompt From 5d9e63f89b36aa7b70c5c5b0aec2d87ae1326552 Mon Sep 17 00:00:00 2001 From: pany-05 Date: Thu, 6 Nov 2025 11:04:58 +0800 Subject: [PATCH 26/31] [bugfix] fix elevenlabs&&cartesia using in docker --- .../core/providers/tts/cartesia.py | 159 ++++-------------- .../core/providers/tts/elevenlabs.py | 114 ++++--------- main/xiaozhi-server/custom_config.yaml | 2 +- 3 files changed, 68 insertions(+), 207 deletions(-) diff --git a/main/xiaozhi-server/core/providers/tts/cartesia.py b/main/xiaozhi-server/core/providers/tts/cartesia.py index 8017c5876..38b1f1682 100644 --- a/main/xiaozhi-server/core/providers/tts/cartesia.py +++ b/main/xiaozhi-server/core/providers/tts/cartesia.py @@ -38,7 +38,7 @@ class TTSProvider(TTSProviderBase): type: cartesia_sdk api_key: your_api_key voice_id: your_voice_id # 或 voice_embedding - model: sonic-english + model: sonic-3 language: en encoding: pcm_s16le sample_rate: 24000 @@ -50,6 +50,8 @@ class TTSProvider(TTSProviderBase): # 标记为单流式接口 self.interface_type = InterfaceType.SINGLE_STREAM + # 设置音频文件类型为 WAV + self.audio_file_type = "wav" # 获取 API Key self.api_key = config.get("api_key") or os.environ.get("CARTESIA_API_KEY") @@ -73,12 +75,14 @@ class TTSProvider(TTSProviderBase): self.voice_id = voice_config # 模型和语言配置 - self.model = config.get("model", "sonic-english") + self.model = config.get("model", "sonic-3") self.language = config.get("language", "en") # 音频配置 self.encoding = config.get("encoding", "pcm_s16le") - self.sample_rate = config.get("sample_rate", 24000) + # 确保 sample_rate 是整数类型(配置文件可能返回字符串) + sample_rate_value = config.get("sample_rate", 24000) + self.sample_rate = int(sample_rate_value) if isinstance(sample_rate_value, str) else sample_rate_value # 验证至少有一个 voice 配置 if not self.voice_id and not self.voice_embedding: @@ -121,18 +125,25 @@ class TTSProvider(TTSProviderBase): async def text_to_speak(self, text: str, output_file: Optional[str] = None) -> Optional[bytes]: """ - 非流式方法:将完整文本转换为音频 + 将文本转换为 WAV 格式音频(完整音频,非流式) - 注意:Cartesia 主要设计为流式使用,此方法会等待完整音频生成 - 建议使用 to_tts_stream() 方法以获得更低的延迟 + Args: + text: 要合成的文本 + output_file: 输出文件路径(未使用,保留兼容性) + + Returns: + WAV 格式的完整音频字节数据 """ + import io + import wave + try: ws = await self._get_ws_client() - audio_chunks = [] + pcm_chunks = [] voice = self._prepare_voice_param() - # 发送流式请求 + # 发送流式请求,获取 PCM 数据 for output in ws.send( model_id=self.model, transcript=text, @@ -140,131 +151,35 @@ class TTSProvider(TTSProviderBase): stream=True, output_format={ "container": "raw", - "encoding": self.encoding, - "sample_rate": self.sample_rate + "encoding": self.encoding, # pcm_s16le + "sample_rate": self.sample_rate # 16000 or 24000 } ): # Cartesia SDK 返回 WebSocketTtsOutput 对象 - # 从 output.audio 获取音频数据 + # 从 output.audio 获取 PCM 音频数据 if output and hasattr(output, 'audio') and output.audio: - audio_chunks.append(output.audio) + pcm_chunks.append(output.audio) - # 合并所有音频块 - audio_data = b''.join(audio_chunks) + # 合并所有 PCM 音频块 + pcm_data = b''.join(pcm_chunks) - # 保存到文件或返回 - if output_file: - with open(output_file, 'wb') as f: - f.write(audio_data) - logger.bind(tag=TAG).info(f"Audio saved to {output_file}, size: {len(audio_data)} bytes") - return None - else: - return audio_data + # 将 PCM 转换为 WAV 格式 + wav_buffer = io.BytesIO() + with wave.open(wav_buffer, 'wb') as wav_file: + wav_file.setnchannels(1) # 单声道 + wav_file.setsampwidth(2) # 16-bit = 2 bytes + wav_file.setframerate(self.sample_rate) # 使用配置的采样率 + wav_file.writeframes(pcm_data) + + wav_bytes = wav_buffer.getvalue() + + # 返回完整的 WAV 字节数据 + return wav_bytes except Exception as e: logger.bind(tag=TAG).error(f"Cartesia TTS failed: {e}", exc_info=True) raise - def to_tts_stream(self, text: str, opus_handler: Optional[Callable] = None): - """ - 流式生成音频(核心方法) - - 注意:浏览器端使用 Web Audio API 播放,直接发送 PCM 数据 - ESP32 等嵌入式设备使用 Opus,需要编码 - - Args: - text: 要合成的文本 - opus_handler: 音频数据回调函数 (接收 bytes) - """ - try: - from core.providers.tts.dto.dto import SentenceType - - start_time = time.time() - text_preview = text[:30] + "..." if len(text) > 30 else text - logger.bind(tag=TAG).info(f"🎙️ TTS开始: [{text_preview}]") - - # 发送句子开始标记 - self.tts_audio_queue.put((SentenceType.FIRST, None, text)) - - # 在异步事件循环中运行 - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - - try: - # 运行异步合成 - chunk_count = loop.run_until_complete( - self._stream_synthesis(text, opus_handler, start_time) - ) - finally: - loop.close() - - # 发送句子结束标记 - self.tts_audio_queue.put((SentenceType.LAST, None, text)) - - end_time = time.time() - total_time = (end_time - start_time) * 1000 - logger.bind(tag=TAG).info( - f"✅ TTS完成: {chunk_count}块, 耗时 {total_time:.0f}ms" - ) - - except Exception as e: - logger.bind(tag=TAG).error(f"TTS 合成失败: {e}", exc_info=True) - raise - - async def _stream_synthesis(self, text: str, opus_handler: Optional[Callable], start_time: float) -> int: - """ - 异步流式合成实现 - - Args: - text: 要合成的文本 - opus_handler: 音频数据回调函数 - start_time: 开始时间(用于计算首包延迟) - - Returns: - 生成的音频块数量 - """ - try: - ws = await self._get_ws_client() - voice = self._prepare_voice_param() - - first_chunk_time = None - chunk_count = 0 - - # 发送流式请求并处理响应 - for output in ws.send( - model_id=self.model, - transcript=text, - voice=voice, - stream=True, - output_format={ - "container": "raw", - "encoding": self.encoding, - "sample_rate": self.sample_rate - }, - language=self.language - ): - # Cartesia SDK 返回 WebSocketTtsOutput 对象 - # 需要从 output.audio 获取实际的音频数据 - if output and hasattr(output, 'audio'): - audio_data = output.audio - - if audio_data: - if first_chunk_time is None: - first_chunk_time = time.time() - ttfb = (first_chunk_time - start_time) * 1000 - logger.bind(tag=TAG).info(f"⚡ 首包延迟: {ttfb:.0f}ms") - - # 发送音频数据(bytes) - if opus_handler: - opus_handler(audio_data) - chunk_count += 1 - - return chunk_count - - except Exception as e: - logger.bind(tag=TAG).error(f"Stream synthesis error: {e}", exc_info=True) - raise - async def close(self): """关闭 WebSocket 连接(Cartesia SDK 会自动管理)""" self._ws_client = None diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs.py b/main/xiaozhi-server/core/providers/tts/elevenlabs.py index c99efa622..43d7c6ddc 100644 --- a/main/xiaozhi-server/core/providers/tts/elevenlabs.py +++ b/main/xiaozhi-server/core/providers/tts/elevenlabs.py @@ -11,7 +11,6 @@ from typing import Optional, Callable from config.logger import setup_logging from core.providers.tts.base import TTSProviderBase from core.providers.tts.dto.dto import InterfaceType -from core.utils import opus_encoder_utils try: from elevenlabs.client import ElevenLabs @@ -53,6 +52,8 @@ class TTSProvider(TTSProviderBase): # 标记为单流式接口 self.interface_type = InterfaceType.SINGLE_STREAM + # 设置音频文件类型为 MP3 + self.audio_file_type = "mp3" # 获取 API Key self.api_key = config.get("api_key") or os.environ.get("ELEVEN_API_KEY") @@ -91,107 +92,52 @@ class TTSProvider(TTSProviderBase): use_speaker_boost=self.use_speaker_boost ) - # 初始化 Opus 编码器(ElevenLabs pcm_16000 是 16kHz PCM) - self.opus_encoder = opus_encoder_utils.OpusEncoderUtils( - sample_rate=16000, channels=1, frame_size_ms=60 - ) - - # PCM 缓冲区(用于累积不完整的帧) - self.pcm_buffer = bytearray() - logger.bind(tag=TAG).info( f"ElevenLabs SDK initialized: model={self.model}, " f"voice_id={self.voice_id[:8]}..., " - f"format={self.output_format}" + f"format=mp3_44100" ) async def text_to_speak(self, text: str, output_file: Optional[str] = None) -> Optional[bytes]: """ - 非流式方法:将完整文本转换为音频 - - 注意:此方法会等待完整音频生成 - 建议使用 to_tts_stream() 方法以获得更低的延迟 - """ - try: - # 使用 SDK 的 convert 方法生成完整音频 - audio_data = self.client.text_to_speech.convert( - voice_id=self.voice_id, - text=text, - model_id=self.model, - output_format=self.output_format, - voice_settings=self.voice_settings - ) - - # 保存到文件或返回 - if output_file: - with open(output_file, 'wb') as f: - f.write(audio_data) - logger.bind(tag=TAG).info(f"Audio saved to {output_file}, size: {len(audio_data)} bytes") - return None - else: - return audio_data - - except Exception as e: - logger.bind(tag=TAG).error(f"ElevenLabs TTS failed: {e}", exc_info=True) - raise - - def to_tts_stream(self, text: str, opus_handler: Optional[Callable] = None): - """ - 流式生成音频(核心方法) - - 注意:浏览器端使用 Web Audio API 播放,直接发送 PCM 数据 - ESP32 等嵌入式设备使用 Opus,需要编码 + 将文本转换为 MP3 格式音频(完整音频,非流式) Args: text: 要合成的文本 - opus_handler: 音频数据回调函数 (接收 bytes) + output_file: 输出文件路径(未使用,保留兼容性) + + Returns: + MP3 格式的完整音频字节数据 """ - import time try: - from core.providers.tts.dto.dto import SentenceType - - start_time = time.time() - text_preview = text[:30] + "..." if len(text) > 30 else text - logger.bind(tag=TAG).info(f"🎙️ TTS开始: [{text_preview}]") - - # 发送句子开始标记 - self.tts_audio_queue.put((SentenceType.FIRST, None, text)) - - # 使用 SDK 的 stream 方法(返回 Iterator[bytes] PCM 数据) - audio_stream = self.client.text_to_speech.stream( + # 使用 SDK 的 convert 方法生成完整音频(返回 generator) + # 强制使用 mp3_44100 格式(忽略配置中的 output_format) + # 因为 base.py 需要完整的音频文件格式(MP3/WAV),而不是原始 PCM + audio_result = self.client.text_to_speech.convert( voice_id=self.voice_id, text=text, model_id=self.model, - output_format=self.output_format, - voice_settings=self.voice_settings, - optimize_streaming_latency=self.optimize_streaming_latency - ) - - first_chunk_time = None - chunk_count = 0 - - # 直接发送 PCM 数据(浏览器端可以直接播放) - for pcm_chunk in audio_stream: - if pcm_chunk and opus_handler: - if first_chunk_time is None: - first_chunk_time = time.time() - ttfb = (first_chunk_time - start_time) * 1000 - logger.bind(tag=TAG).info(f"⚡ 首包延迟: {ttfb:.0f}ms") - chunk_count += 1 - opus_handler(pcm_chunk) - - # 发送句子结束标记 - self.tts_audio_queue.put((SentenceType.LAST, None, text)) - - end_time = time.time() - total_time = (end_time - start_time) * 1000 - logger.bind(tag=TAG).info( - f"✅ TTS完成: {chunk_count}块, 耗时 {total_time:.0f}ms" + output_format="mp3_44100", # 强制 MP3 格式,44.1kHz + voice_settings=self.voice_settings ) + # 检查返回类型 + if isinstance(audio_result, bytes): + # 直接返回 bytes + return audio_result + else: + # 是 generator,需要收集所有音频块 + audio_chunks = [] + for chunk in audio_result: + if chunk: + audio_chunks.append(chunk) + + # 合并为完整的 MP3 数据 + mp3_data = b''.join(audio_chunks) + return mp3_data + except Exception as e: - error_msg = str(e).replace("{", "{{").replace("}", "}}") - logger.bind(tag=TAG).error(f"TTS 合成失败: {error_msg}", exc_info=True) + logger.bind(tag=TAG).error(f"ElevenLabs TTS failed: {e}", exc_info=True) raise async def close(self): diff --git a/main/xiaozhi-server/custom_config.yaml b/main/xiaozhi-server/custom_config.yaml index 416f6e209..ad2b51d4e 100644 --- a/main/xiaozhi-server/custom_config.yaml +++ b/main/xiaozhi-server/custom_config.yaml @@ -38,7 +38,7 @@ server: manager-api: url: http://xiaozhi-esp32-server-web:8002/xiaozhi # This secret is used for local development, it will be replaced by the actual secret when the server is deployed - secret: 613be043-dc7e-4f5e-b775-e318e5bc87a3 + secret: e8f02a3c-0d93-4824-9346-a813e56d6895 log: # 设置控制台输出的日志格式,时间、日志级别、标签、消息 From e24490880aa904d7660cf7fa19c9547ce7133721 Mon Sep 17 00:00:00 2001 From: Harold Date: Fri, 7 Nov 2025 15:55:15 +0800 Subject: [PATCH 27/31] feat: minimax && deepgram && elevenlabs && cartesia --- .../resources/db/changelog/202511071245.sql | 43 ++++ .../db/changelog/db.changelog-master.yaml | 7 + .../core/providers/tts/cartesia.py | 35 +-- .../core/providers/tts/deepgram.py | 66 ++++++ .../core/providers/tts/elevenlabs.py | 26 +-- .../core/providers/tts/minimax_httpstream.py | 7 +- .../core/providers/tts/test/QUICKSTART.txt | 68 ++++++ .../core/providers/tts/test/__init__.py | 0 .../core/providers/tts/test/test_cartesia.py | 112 ++++++++++ .../core/providers/tts/test/test_deepgram.py | 95 ++++++++ .../providers/tts/test/test_elevenlabs.py | 83 +++++++ .../core/providers/tts/test/test_minimax.py | 208 ++++++++++++++++++ main/xiaozhi-server/requirements.txt | 1 + 13 files changed, 704 insertions(+), 47 deletions(-) create mode 100644 main/manager-api/src/main/resources/db/changelog/202511071245.sql create mode 100644 main/xiaozhi-server/core/providers/tts/deepgram.py create mode 100644 main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt create mode 100644 main/xiaozhi-server/core/providers/tts/test/__init__.py create mode 100644 main/xiaozhi-server/core/providers/tts/test/test_cartesia.py create mode 100644 main/xiaozhi-server/core/providers/tts/test/test_deepgram.py create mode 100644 main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py create mode 100644 main/xiaozhi-server/core/providers/tts/test/test_minimax.py diff --git a/main/manager-api/src/main/resources/db/changelog/202511071245.sql b/main/manager-api/src/main/resources/db/changelog/202511071245.sql new file mode 100644 index 000000000..ab09b80bc --- /dev/null +++ b/main/manager-api/src/main/resources/db/changelog/202511071245.sql @@ -0,0 +1,43 @@ +-- Add Deepgram TTS Provider and Model Configuration + +-- ==================== Deepgram TTS ==================== + +-- Add Deepgram TTS Provider +DELETE FROM `ai_model_provider` WHERE id = 'TTS_Deepgram'; +INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES +('TTS_Deepgram', 'TTS', 'deepgram', 'Deepgram TTS', '[{"key":"api_key","label":"API Key","type":"string"},{"key":"model","label":"Model","type":"string"}]', 20, 1, NOW(), 1, NOW()); + +-- Add Deepgram TTS Model Configuration +DELETE FROM `ai_model_config` WHERE id = 'TTS_Deepgram'; +INSERT INTO `ai_model_config` ( + `id`, + `model_type`, + `model_code`, + `model_name`, + `is_default`, + `is_enabled`, + `config_json`, + `doc_link`, + `remark`, + `sort`, + `creator`, + `create_date`, + `updater`, + `update_date` +) VALUES ( + 'TTS_Deepgram', + 'TTS', + 'Deepgram', + 'Deepgram TTS', + 0, + 1, + '{"type": "deepgram", "api_key": "", "model": "aura-2-thalia-en"}', + 'https://developers.deepgram.com/docs/text-to-speech', + 'Deepgram TTS Configuration:\n1. Deepgram provides high-quality, low-latency AI text-to-speech service\n2. Uses official Deepgram Python SDK (deepgram-sdk)\n3. Supports multiple languages and Aura 2 voice models\n4. API Key: Register at https://console.deepgram.com/ to get your API key\n5. Model: Deepgram voice models directly specify the voice (e.g., aura-2-thalia-en, aura-2-stella-en, aura-2-orion-en)\n6. Available Models:\n - Female: aura-2-asteria-en, aura-2-luna-en, aura-2-stella-en, aura-2-athena-en\n - Male: aura-2-orion-en, aura-2-arcas-en, aura-2-perseus-en, aura-2-zeus-en\n7. Features: Natural voices, multi-language support, low latency\n8. Perfect for real-time voice applications and conversational AI', + 22, + NULL, + NULL, + NULL, + NULL +); + diff --git a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml index c135efdcb..3675c27e4 100755 --- a/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/main/manager-api/src/main/resources/db/changelog/db.changelog-master.yaml @@ -409,3 +409,10 @@ databaseChangeLog: - sqlFile: encoding: utf8 path: classpath:db/changelog/202511051120.sql + - changeSet: + id: 202511071245 + author: harold + changes: + - sqlFile: + encoding: utf8 + path: classpath:db/changelog/202511071245.sql diff --git a/main/xiaozhi-server/core/providers/tts/cartesia.py b/main/xiaozhi-server/core/providers/tts/cartesia.py index 38b1f1682..b4b69bca2 100644 --- a/main/xiaozhi-server/core/providers/tts/cartesia.py +++ b/main/xiaozhi-server/core/providers/tts/cartesia.py @@ -12,13 +12,7 @@ from typing import Optional, Callable, Dict, Any from config.logger import setup_logging from core.providers.tts.base import TTSProviderBase from core.providers.tts.dto.dto import InterfaceType - -try: - import cartesia -except ImportError: - raise ImportError( - "Cartesia SDK not installed. Install with: pip install cartesia" - ) +import cartesia TAG = __name__ logger = setup_logging() @@ -51,7 +45,7 @@ class TTSProvider(TTSProviderBase): # 标记为单流式接口 self.interface_type = InterfaceType.SINGLE_STREAM # 设置音频文件类型为 WAV - self.audio_file_type = "wav" + self.audio_file_type = "pcm" # 获取 API Key self.api_key = config.get("api_key") or os.environ.get("CARTESIA_API_KEY") @@ -81,7 +75,7 @@ class TTSProvider(TTSProviderBase): # 音频配置 self.encoding = config.get("encoding", "pcm_s16le") # 确保 sample_rate 是整数类型(配置文件可能返回字符串) - sample_rate_value = config.get("sample_rate", 24000) + sample_rate_value = config.get("sample_rate", 16000) self.sample_rate = int(sample_rate_value) if isinstance(sample_rate_value, str) else sample_rate_value # 验证至少有一个 voice 配置 @@ -102,7 +96,7 @@ class TTSProvider(TTSProviderBase): f"encoding={self.encoding}, sample_rate={self.sample_rate}" ) - async def _get_ws_client(self): + def _get_ws_client(self): """获取或创建 WebSocket 客户端(复用连接)""" if self._ws_client is None: self._ws_client = self.client.tts.websocket() @@ -133,12 +127,9 @@ class TTSProvider(TTSProviderBase): Returns: WAV 格式的完整音频字节数据 - """ - import io - import wave - + """ try: - ws = await self._get_ws_client() + ws = self._get_ws_client() pcm_chunks = [] voice = self._prepare_voice_param() @@ -162,19 +153,7 @@ class TTSProvider(TTSProviderBase): # 合并所有 PCM 音频块 pcm_data = b''.join(pcm_chunks) - - # 将 PCM 转换为 WAV 格式 - wav_buffer = io.BytesIO() - with wave.open(wav_buffer, 'wb') as wav_file: - wav_file.setnchannels(1) # 单声道 - wav_file.setsampwidth(2) # 16-bit = 2 bytes - wav_file.setframerate(self.sample_rate) # 使用配置的采样率 - wav_file.writeframes(pcm_data) - - wav_bytes = wav_buffer.getvalue() - - # 返回完整的 WAV 字节数据 - return wav_bytes + return pcm_data except Exception as e: logger.bind(tag=TAG).error(f"Cartesia TTS failed: {e}", exc_info=True) diff --git a/main/xiaozhi-server/core/providers/tts/deepgram.py b/main/xiaozhi-server/core/providers/tts/deepgram.py new file mode 100644 index 000000000..2f0c77769 --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/deepgram.py @@ -0,0 +1,66 @@ +import os +from typing import Optional +from deepgram import DeepgramClient +from config.logger import setup_logging +from core.providers.tts.base import TTSProviderBase +from core.providers.tts.dto.dto import InterfaceType + +TAG = __name__ +logger = setup_logging() + + +class TTSProvider(TTSProviderBase): + def __init__(self, config, delete_audio_file): + super().__init__(config, delete_audio_file) + self.interface_type = InterfaceType.SINGLE_STREAM + + # Deepgram configuration + self.api_key = config.get("api_key") or os.environ.get("DEEPGRAM_API_KEY") + if not self.api_key: + raise ValueError( + "Deepgram API key is required. " + "Provide via api_key in config or set DEEPGRAM_API_KEY environment variable" + ) + + self.model = config.get("model", "aura-2-thalia-en") or os.environ.get("DEEPGRAM_MODEL") # Default voice model + self.encoding = config.get("encoding", "linear16") # PCM format + self.sample_rate = config.get("sample_rate", 16000) # Match client sample rate + self.container = config.get("container", "none") # Raw audio + self.audio_file_type = "pcm" + + # Initialize Deepgram client + self.client = DeepgramClient(api_key=self.api_key) + + logger.bind(tag=TAG).info( + f"Deepgram TTS initialized: model={self.model}, " + f"sample_rate={self.sample_rate}, encoding={self.encoding}" + ) + + async def text_to_speech(self, text: str, output_file: Optional[str] = None) -> Optional[bytes]: + try: + audio_stream = self.client.speak.v1.audio.generate( + text=text, + model=self.model, + encoding = self.encoding, + sample_rate = self.sample_rate, + container = self.container, + ) + + if output_file: + with open(output_file, 'wb') as f: + for chunk in audio_stream: + f.write(chunk) + else: + audio_bytes = b"" + for chunk in audio_stream: + audio_bytes += chunk["data"] + return audio_bytes + + except Exception as e: + logger.bind(tag=TAG).error(f"Deepgram TTS failed: {e}", exc_info=True) + raise + + async def close(self): + """Resource cleanup""" + pass + diff --git a/main/xiaozhi-server/core/providers/tts/elevenlabs.py b/main/xiaozhi-server/core/providers/tts/elevenlabs.py index 43d7c6ddc..913f3ae98 100644 --- a/main/xiaozhi-server/core/providers/tts/elevenlabs.py +++ b/main/xiaozhi-server/core/providers/tts/elevenlabs.py @@ -53,7 +53,7 @@ class TTSProvider(TTSProviderBase): # 标记为单流式接口 self.interface_type = InterfaceType.SINGLE_STREAM # 设置音频文件类型为 MP3 - self.audio_file_type = "mp3" + self.audio_file_type = "pcm" # 获取 API Key self.api_key = config.get("api_key") or os.environ.get("ELEVEN_API_KEY") @@ -113,28 +113,24 @@ class TTSProvider(TTSProviderBase): # 使用 SDK 的 convert 方法生成完整音频(返回 generator) # 强制使用 mp3_44100 格式(忽略配置中的 output_format) # 因为 base.py 需要完整的音频文件格式(MP3/WAV),而不是原始 PCM - audio_result = self.client.text_to_speech.convert( + audio_stream = self.client.text_to_speech.convert( voice_id=self.voice_id, text=text, model_id=self.model, - output_format="mp3_44100", # 强制 MP3 格式,44.1kHz + output_format=self.output_format, voice_settings=self.voice_settings ) # 检查返回类型 - if isinstance(audio_result, bytes): - # 直接返回 bytes - return audio_result + if output_file: + with open(output_file, 'wb') as f: + for chunk in audio_stream: + f.write(chunk) else: - # 是 generator,需要收集所有音频块 - audio_chunks = [] - for chunk in audio_result: - if chunk: - audio_chunks.append(chunk) - - # 合并为完整的 MP3 数据 - mp3_data = b''.join(audio_chunks) - return mp3_data + audio_bytes = b"" + for chunk in audio_stream: + audio_bytes += chunk["data"] + return audio_bytes except Exception as e: logger.bind(tag=TAG).error(f"ElevenLabs TTS failed: {e}", exc_info=True) diff --git a/main/xiaozhi-server/core/providers/tts/minimax_httpstream.py b/main/xiaozhi-server/core/providers/tts/minimax_httpstream.py index 514d8912f..a2a8c529c 100644 --- a/main/xiaozhi-server/core/providers/tts/minimax_httpstream.py +++ b/main/xiaozhi-server/core/providers/tts/minimax_httpstream.py @@ -37,8 +37,7 @@ class TTSProvider(TTSProviderBase): } default_pronunciation_dict = {"tone": ["处理/(chu3)(li3)", "危险/dangerous"]} defult_audio_setting = { - "sample_rate": 24000, - "bitrate": 128000, + "sample_rate": 16000, "format": "pcm", "channel": 1, } @@ -56,8 +55,8 @@ class TTSProvider(TTSProviderBase): if self.voice: self.voice_setting["voice_id"] = self.voice - self.host = "api.minimaxi.com" # 备用地址:api-bj.minimaxi.com - self.api_url = f"https://{self.host}/v1/t2a_v2?GroupId={self.group_id}" + self.host = "api.minimax.io" + self.api_url = f"https://{self.host}/v1/t2a_v2" self.header = { "Content-Type": "application/json", "Authorization": f"Bearer {self.api_key}", diff --git a/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt b/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt new file mode 100644 index 000000000..152de0bee --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt @@ -0,0 +1,68 @@ +TTS Test Quick Start Guide +========================== + +1. Set API Keys (one-time setup) +--------------------------------- + +Add to ~/.zshrc for permanent access: + +echo 'export DEEPGRAM_API_KEY="sk-your-key"' >> ~/.zshrc +echo 'export ELEVENLABS_API_KEY="sk-your-key"' >> ~/.zshrc +echo 'export CARTESIA_API_KEY="your-key"' >> ~/.zshrc +echo 'export MINIMAX_API_KEY="your-key"' >> ~/.zshrc +echo 'export MINIMAX_GROUP_ID="your-group-id"' >> ~/.zshrc +source ~/.zshrc + + +2. Run Tests +------------ + +cd /Users/harold/Projects/live-agent/main/xiaozhi-server/ + +# Test Deepgram +python3 -m core.providers.tts.test.test_deepgram + +# Test ElevenLabs +python3 -m core.providers.tts.test.test_elevenlabs + +# Test Cartesia +python3 -m core.providers.tts.test.test_cartesia + +# Test Minimax +python3 -m core.providers.tts.test.test_minimax + +# Custom text +python3 -m core.providers.tts.test.test_deepgram "你好世界" +python3 -m core.providers.tts.test.test_minimax "你好世界" + + +3. Check Output +--------------- + +Generated audio files are in: +core/providers/tts/test/tmp/ + - deepgram_test.wav + - elevenlabs_test.wav + - cartesia_test.wav + - minimax_test.wav + + +4. Troubleshooting +------------------ + +If SDK not installed: + pip install deepgram-sdk elevenlabs cartesia aiohttp + +If API key error: + echo $DEEPGRAM_API_KEY # Check if set + echo $MINIMAX_API_KEY # Check Minimax key + echo $MINIMAX_GROUP_ID # Check Minimax group ID + source ~/.zshrc # Reload config + +If module not found: + cd /Users/harold/Projects/live-agent/main/xiaozhi-server/ + # Make sure you're in the right directory! + + +That's it! 🎉 + diff --git a/main/xiaozhi-server/core/providers/tts/test/__init__.py b/main/xiaozhi-server/core/providers/tts/test/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/main/xiaozhi-server/core/providers/tts/test/test_cartesia.py b/main/xiaozhi-server/core/providers/tts/test/test_cartesia.py new file mode 100644 index 000000000..9d0bc49f7 --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/test/test_cartesia.py @@ -0,0 +1,112 @@ +import sys +import asyncio +from io import BytesIO +import wave +import os +import cartesia + +if __name__ == "__main__": + """ + Test for Cartesia TTS + + Usage: + python3 -m core.providers.tts.test_cartesia + python3 -m core.providers.tts.test_cartesia "Custom text" + + Environment: + CARTESIA_API_KEY - Your API key (required) + CARTESIA_VOICE_ID - Voice ID (optional, default: a0e99841-438c-4a64-b679-ae501e7d6091) + CARTESIA_MODEL - Model (optional, default: sonic-english) + """ + + text = sys.argv[1] if len(sys.argv) > 1 else "Hello, this is a test of Cartesia text to speech." + + api_key = os.environ.get("CARTESIA_API_KEY") + if not api_key: + print("❌ Error: CARTESIA_API_KEY not set") + print(" export CARTESIA_API_KEY='your-key'") + sys.exit(1) + + # Get configuration from environment + voice_id = os.environ.get("CARTESIA_VOICE_ID", "f9a4b3a6-b44b-469f-90e3-c8e19bd30e99") + model = os.environ.get("CARTESIA_MODEL", "sonic-3") + + print(f"🎙️ Testing Cartesia TTS") + print(f" Model: {model}") + print(f" Voice ID: {voice_id[:16]}...") + print(f" Text: {text}\n") + + # Create Cartesia client + client = cartesia.Cartesia(api_key=api_key) + + try: + print("⏳ Generating audio...") + start = asyncio.get_event_loop().time() + + # Create WebSocket connection + ws = client.tts.websocket() + + # Collect audio chunks + pcm_chunks = [] + + # Send request and receive audio stream + for output in ws.send( + model_id=model, + transcript=text, + voice={ + "mode": "id", + "id": voice_id + }, + stream=True, + output_format={ + "container": "raw", + "encoding": "pcm_s16le", # 16-bit PCM + "sample_rate": 16000 + }, + language="zh" + ): + # Collect PCM audio data + if output and hasattr(output, 'audio') and output.audio: + pcm_chunks.append(output.audio) + + # Merge all PCM chunks + audio_bytes = b''.join(pcm_chunks) + duration = (asyncio.get_event_loop().time() - start) * 1000 + + print(f"✅ Audio generated") + print(f" Duration: {duration:.0f}ms") + print(f" Size: {len(audio_bytes):,} bytes\n") + + # Convert PCM to WAV format + wav_buffer = BytesIO() + + # Open wave file in write mode + with wave.open(wav_buffer, 'wb') as wf: + wf.setnchannels(1) # Mono + wf.setsampwidth(2) # 16-bit (2 bytes) per sample + wf.setframerate(16000) # Sample rate + wf.writeframes(audio_bytes) + + # Save to file + script_dir = os.path.dirname(os.path.abspath(__file__)) + output_file = os.path.join(script_dir, "tmp", "cartesia_test.wav") + with open(output_file, 'wb') as f: + f.write(wav_buffer.getvalue()) + + print(f"💾 Saved to: {output_file}") + print("🔊 Playing audio...") + + # Play audio file + os.system(f"afplay '{output_file}'") + + print("\n✅ Test completed successfully!") + + except Exception as e: + print(f"\n❌ Test failed: {e}") + import traceback + traceback.print_exc() + sys.exit(1) + except KeyboardInterrupt: + print("\n\n👋 Test interrupted") + sys.exit(1) + diff --git a/main/xiaozhi-server/core/providers/tts/test/test_deepgram.py b/main/xiaozhi-server/core/providers/tts/test/test_deepgram.py new file mode 100644 index 000000000..92c7ac5ef --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/test/test_deepgram.py @@ -0,0 +1,95 @@ +import sys +import asyncio +from io import BytesIO +import wave +import os +from deepgram import DeepgramClient + +if __name__ == "__main__": + """ + Test for Deepgram TTS + + Usage: + python3 -m core.providers.tts.test_deepgram + python3 -m core.providers.tts.test_deepgram "Custom text" + + Environment: + DEEPGRAM_API_KEY - Your API key (required) + DEEPGRAM_MODEL - Voice model (optional, default: aura-2-thalia-en) + """ + + text = sys.argv[1] if len(sys.argv) > 1 else "Hello, this is a test of Deepgram text to speech." + + api_key = os.environ.get("DEEPGRAM_API_KEY") + if not api_key: + print("❌ Error: DEEPGRAM_API_KEY not set") + print(" export DEEPGRAM_API_KEY='your-key'") + sys.exit(1) + + # Get configuration from environment + model = os.environ.get("DEEPGRAM_MODEL", "aura-2-thalia-en") + + print(f"🎙️ Testing Deepgram TTS") + print(f" Model: {model}") + print(f" Text: {text}\n") + + # Create Deepgram client + client = DeepgramClient(api_key=api_key) + + try: + print("⏳ Generating audio...") + start = asyncio.get_event_loop().time() + + # Generate audio using Deepgram SDK + audio_stream = client.speak.v1.audio.generate( + text=text, + model=model, + encoding="linear16", # PCM format + sample_rate=16000, + container="none" # Raw audio + ) + + # Collect audio chunks + audio_bytes = b"" + for chunk in audio_stream: + audio_bytes += chunk + + duration = (asyncio.get_event_loop().time() - start) * 1000 + + print(f"✅ Audio generated") + print(f" Duration: {duration:.0f}ms") + print(f" Size: {len(audio_bytes):,} bytes\n") + + # Convert PCM to WAV format + wav_buffer = BytesIO() + + # Open wave file in write mode + with wave.open(wav_buffer, 'wb') as wf: + wf.setnchannels(1) # Mono + wf.setsampwidth(2) # 16-bit (2 bytes) per sample + wf.setframerate(16000) # Sample rate + wf.writeframes(audio_bytes) + + # Save to file + script_dir = os.path.dirname(os.path.abspath(__file__)) + output_file = os.path.join(script_dir, "tmp", "deepgram_test.wav") + with open(output_file, 'wb') as f: + f.write(wav_buffer.getvalue()) + + print(f"💾 Saved to: {output_file}") + print("🔊 Playing audio...") + + # Play audio file + os.system(f"afplay '{output_file}'") + + print("\n✅ Test completed successfully!") + + except Exception as e: + print(f"\n❌ Test failed: {e}") + import traceback + traceback.print_exc() + sys.exit(1) + except KeyboardInterrupt: + print("\n\n👋 Test interrupted") + sys.exit(1) + diff --git a/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py b/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py new file mode 100644 index 000000000..ce7c52829 --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py @@ -0,0 +1,83 @@ +import sys +import asyncio +from io import BytesIO +import wave +import os +from elevenlabs.client import ElevenLabs +from elevenlabs import VoiceSettings + +if __name__ == "__main__": + """ + Test for ElevenLabs TTS + + Usage: + python3 -m core.providers.tts.elevenlabs + python3 -m core.providers.tts.elevenlabs "Custom text" + + Environment: + ELEVENLABS_API_KEY - Your API key (required) + ELEVENLABS_VOICE_ID - Voice ID (optional) + """ + + text = sys.argv[1] if len(sys.argv) > 1 else "Hello, this is a test of ElevenLabs text to speech." + + api_key = os.environ.get("ELEVENLABS_API_KEY") + if not api_key: + print("❌ Error: ELEVENLABS_API_KEY not set") + print(" export ELEVENLABS_API_KEY='your-key'") + sys.exit(1) + + # Create minimal provider instance + client = ElevenLabs(api_key=api_key) + voice_id = os.environ.get("ELEVENLABS_VOICE_ID", "EXAVITQu4vr4xnSDxMaL") + voice_settings = VoiceSettings( + stability=0.5, + similarity_boost=0.75, + style=0.0, + use_speaker_boost=True + ) + + try: + + print("⏳ Generating audio...") + start = asyncio.get_event_loop().time() + + # Generate audio + audio_stream = client.text_to_speech.convert( + voice_id=voice_id, + text=text, + model_id="eleven_multilingual_v2", + output_format="pcm_16000", + voice_settings=voice_settings + ) + + # Collect chunks + audio_bytes = b''.join(chunk for chunk in audio_stream if chunk) + duration = (asyncio.get_event_loop().time() - start) * 1000 + + print(f"✅ Audio generated") + print(f" Duration: {duration:.0f}ms") + print(f" Size: {len(audio_bytes):,} bytes\n") + + # Convert to WAV format + wav_buffer = BytesIO() + + # Open wave file in write mode + with wave.open(wav_buffer, 'wb') as wf: + wf.setnchannels(1) # Mono or stereo + wf.setsampwidth(2) # 16-bit (2 bytes) per sample + wf.setframerate(16000) # Sample rate (e.g., 16000 Hz) + wf.writeframes(audio_bytes) + wav_buffer.getvalue() + + script_dir = os.path.dirname(os.path.abspath(__file__)) + output_file = os.path.join(script_dir, "tmp", "elevenlabs_test.wav") + + with open(output_file, 'wb') as f: + f.write(wav_buffer.getvalue()) + # here,I want to get a .wav file to play the audio file + os.system(f"afplay '{output_file}'") + + except KeyboardInterrupt: + print("\n\n👋 Test interrupted") + sys.exit(1) \ No newline at end of file diff --git a/main/xiaozhi-server/core/providers/tts/test/test_minimax.py b/main/xiaozhi-server/core/providers/tts/test/test_minimax.py new file mode 100644 index 000000000..7e8fb4dba --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/test/test_minimax.py @@ -0,0 +1,208 @@ +import sys +import asyncio +import json +from io import BytesIO +import wave +import os +import platform +import aiohttp + +if __name__ == "__main__": + """ + Test for Minimax TTS + + Usage: + python3 -m core.providers.tts.test.test_minimax + python3 -m core.providers.tts.test.test_minimax "Custom text" + + Environment: + MINIMAX_API_KEY - Your API key (required) + MINIMAX_GROUP_ID - Your Group ID (required) + MINIMAX_MODEL - Model name (optional, default: speech-01-turbo) + MINIMAX_VOICE_ID - Voice ID (optional, default: female-shaonv) + """ + + text = sys.argv[1] if len(sys.argv) > 1 else "Hello, this is a test of Minimax text to speech." + + # Check required environment variables + api_key = os.environ.get("MINIMAX_API_KEY") + group_id = os.environ.get("MINIMAX_GROUP_ID") + + if not api_key: + print("❌ Error: MINIMAX_API_KEY not set") + print(" export MINIMAX_API_KEY='your-key'") + sys.exit(1) + + if not group_id: + print("❌ Error: MINIMAX_GROUP_ID not set") + print(" export MINIMAX_GROUP_ID='your-group-id'") + sys.exit(1) + + # Optional parameters + model = os.environ.get("MINIMAX_MODEL", "speech-2.6-hd") + voice_id = os.environ.get("MINIMAX_VOICE_ID", "English_Graceful_Lady") + + # Configuration + host = "api.minimax.io" + api_url = f"https://{host}/v1/t2a_v2" + + headers = { + "Content-Type": "application/json", + "Authorization": f"Bearer {api_key}", + } + + payload = { + "model": model, + "text": text, + "stream": True, + "voice_setting": { + "voice_id": voice_id, + "speed": 1.0, + "vol": 1.0, + "pitch": 0, + "emotion": "happy", + }, + "pronunciation_dict": { + "tone": [] + }, + "audio_setting": { + "sample_rate": 16000, + "format": "pcm", + "channel": 1, + } + } + + async def test(): + try: + print(f"⏳ Generating audio with Minimax TTS...") + print(f" Model: {model}") + print(f" Voice: {voice_id}") + print(f" Text: {text[:50]}{'...' if len(text) > 50 else ''}\n") + + start_time = asyncio.get_event_loop().time() + pcm_chunks = [] + + async with aiohttp.ClientSession() as session: + async with session.post( + api_url, + headers=headers, + data=json.dumps(payload), + timeout=aiohttp.ClientTimeout(total=30), + ) as resp: + + if resp.status != 200: + error_text = await resp.text() + print(f"❌ API Error: {resp.status}") + print(f" Response: {error_text}") + sys.exit(1) + + # Process streaming audio data + buffer = b"" + async for chunk in resp.content.iter_any(): + if not chunk: + continue + + buffer += chunk + + # Parse SSE (Server-Sent Events) format + while True: + # Find data chunk separator + header_pos = buffer.find(b"data: ") + if header_pos == -1: + break + + end_pos = buffer.find(b"\n\n", header_pos) + if end_pos == -1: + break + + # Extract single complete JSON block + json_str = buffer[header_pos + 6 : end_pos].decode("utf-8") + buffer = buffer[end_pos + 2 :] + + try: + data = json.loads(json_str) + status = data.get("data", {}).get("status", 1) + audio_hex = data.get("data", {}).get("audio") + + # Only process status=1 valid audio chunks + # Ignore status=2 end summary chunks + if status == 1 and audio_hex: + # Decode hex string to PCM bytes + audio_bytes = bytes.fromhex(audio_hex) + pcm_chunks.append(audio_bytes) + elif status == 2: + # End of stream + break + except json.JSONDecodeError as e: + print(f"⚠️ Warning: Failed to parse JSON: {e}") + continue + + duration = (asyncio.get_event_loop().time() - start_time) * 1000 + + # Combine all PCM chunks + pcm_data = b''.join(pcm_chunks) + + if not pcm_data: + print("❌ Error: No audio data received") + sys.exit(1) + + print(f"✅ Audio generated") + print(f" Duration: {duration:.0f}ms") + print(f" Size: {len(pcm_data):,} bytes") + print(f" Chunks: {len(pcm_chunks)}\n") + + # Convert PCM to WAV format + wav_buffer = BytesIO() + with wave.open(wav_buffer, 'wb') as wf: + wf.setnchannels(1) # Mono + wf.setsampwidth(2) # 16-bit (2 bytes) per sample + wf.setframerate(24000) # Sample rate: 24000 Hz + wf.writeframes(pcm_data) + + # Save to file + script_dir = os.path.dirname(os.path.abspath(__file__)) + output_file = os.path.join(script_dir, "tmp", "minimax_test.wav") + + # Create tmp directory if not exists + os.makedirs(os.path.dirname(output_file), exist_ok=True) + + with open(output_file, 'wb') as f: + f.write(wav_buffer.getvalue()) + + print(f"💾 Saved to: {output_file}\n") + print("🔊 Playing audio...") + + # Play audio (platform-specific) + system = platform.system() + if system == "Darwin": # macOS + os.system(f"afplay '{output_file}'") + elif system == "Linux": + # Try common Linux audio players + if os.system("which aplay > /dev/null 2>&1") == 0: + os.system(f"aplay '{output_file}'") + elif os.system("which ffplay > /dev/null 2>&1") == 0: + os.system(f"ffplay -nodisp -autoexit '{output_file}' 2>/dev/null") + else: + print("⚠️ No audio player found (aplay/ffplay)") + elif system == "Windows": + os.system(f'start {output_file}') + else: + print(f"⚠️ Unsupported platform: {system}") + + print("\n✅ Test completed successfully!") + + except aiohttp.ClientError as e: + print(f"❌ Network error: {e}") + sys.exit(1) + except KeyboardInterrupt: + print("\n\n👋 Test interrupted") + sys.exit(1) + except Exception as e: + print(f"❌ Unexpected error: {e}") + import traceback + traceback.print_exc() + sys.exit(1) + + # Run the async test + asyncio.run(test()) + diff --git a/main/xiaozhi-server/requirements.txt b/main/xiaozhi-server/requirements.txt index 7bd45b888..56d44091e 100644 --- a/main/xiaozhi-server/requirements.txt +++ b/main/xiaozhi-server/requirements.txt @@ -40,3 +40,4 @@ vosk==0.3.44 # TTS SDKs elevenlabs>=1.11.0 cartesia>=1.0.0 +deepgram-sdk>=3.0.0 From f472d8db591741eb2bdbf9ada910c654fd8ebff6 Mon Sep 17 00:00:00 2001 From: Harold Date: Fri, 7 Nov 2025 16:40:56 +0800 Subject: [PATCH 28/31] feat: fish --- .../core/providers/tts/test/QUICKSTART.txt | 21 +++- .../providers/tts/test/test_elevenlabs.py | 1 - .../providers/tts/test/test_fishspeech.py | 102 ++++++++++++++++++ 3 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 main/xiaozhi-server/core/providers/tts/test/test_fishspeech.py diff --git a/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt b/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt index 152de0bee..b6314d515 100644 --- a/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt +++ b/main/xiaozhi-server/core/providers/tts/test/QUICKSTART.txt @@ -11,6 +11,11 @@ echo 'export ELEVENLABS_API_KEY="sk-your-key"' >> ~/.zshrc echo 'export CARTESIA_API_KEY="your-key"' >> ~/.zshrc echo 'export MINIMAX_API_KEY="your-key"' >> ~/.zshrc echo 'export MINIMAX_GROUP_ID="your-group-id"' >> ~/.zshrc + +# FishSpeech +echo 'export FISH_API_KEY="your-key"' >> ~/.zshrc +echo 'export FISH_REFERENCE_ID="reference-id"' >> ~/.zshrc # optional + source ~/.zshrc @@ -31,9 +36,13 @@ python3 -m core.providers.tts.test.test_cartesia # Test Minimax python3 -m core.providers.tts.test.test_minimax +# Test FishSpeech +python3 -m core.providers.tts.test.test_fishspeech + # Custom text python3 -m core.providers.tts.test.test_deepgram "你好世界" python3 -m core.providers.tts.test.test_minimax "你好世界" +python3 -m core.providers.tts.test.test_fishspeech "你好世界" 3. Check Output @@ -45,19 +54,21 @@ core/providers/tts/test/tmp/ - elevenlabs_test.wav - cartesia_test.wav - minimax_test.wav + - fishspeech_test.wav 4. Troubleshooting ------------------ If SDK not installed: - pip install deepgram-sdk elevenlabs cartesia aiohttp + pip install deepgram-sdk elevenlabs cartesia aiohttp fish-audio-sdk If API key error: - echo $DEEPGRAM_API_KEY # Check if set - echo $MINIMAX_API_KEY # Check Minimax key - echo $MINIMAX_GROUP_ID # Check Minimax group ID - source ~/.zshrc # Reload config + echo $DEEPGRAM_API_KEY # Check if set + echo $MINIMAX_API_KEY # Check Minimax key + echo $MINIMAX_GROUP_ID # Check Minimax group ID + echo $FISH_API_KEY # Check FishSpeech key + source ~/.zshrc # Reload config If module not found: cd /Users/harold/Projects/live-agent/main/xiaozhi-server/ diff --git a/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py b/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py index ce7c52829..39edeab84 100644 --- a/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py +++ b/main/xiaozhi-server/core/providers/tts/test/test_elevenlabs.py @@ -68,7 +68,6 @@ if __name__ == "__main__": wf.setsampwidth(2) # 16-bit (2 bytes) per sample wf.setframerate(16000) # Sample rate (e.g., 16000 Hz) wf.writeframes(audio_bytes) - wav_buffer.getvalue() script_dir = os.path.dirname(os.path.abspath(__file__)) output_file = os.path.join(script_dir, "tmp", "elevenlabs_test.wav") diff --git a/main/xiaozhi-server/core/providers/tts/test/test_fishspeech.py b/main/xiaozhi-server/core/providers/tts/test/test_fishspeech.py new file mode 100644 index 000000000..a77c2615d --- /dev/null +++ b/main/xiaozhi-server/core/providers/tts/test/test_fishspeech.py @@ -0,0 +1,102 @@ +import sys +import os +from io import BytesIO +import wave +import platform +from fish_audio_sdk import Session, TTSRequest +import asyncio + +if __name__ == "__main__": + """ + Test for FishSpeech TTS + + Usage: + python3 -m core.providers.tts.test.test_fishspeech + python3 -m core.providers.tts.test.test_fishspeech "Custom text" + + Environment: + FISH_API_KEY - Your Fish.Audio API key (required) + FISH_REFERENCE_ID - Voice reference ID (optional) + + Examples: + export FISH_API_KEY="your-key" + python3 -m core.providers.tts.test.test_fishspeech "Hello world" + + # With custom voice + export FISH_REFERENCE_ID="7f92f8afb8ec43bf81429cc1c9199cb1" + python3 -m core.providers.tts.test.test_fishspeech "Hello world" + """ + + text = sys.argv[1] if len(sys.argv) > 1 else "Hello, this is a test of FishSpeech text to speech." + + api_key = os.environ.get("FISH_API_KEY") + if not api_key: + print("❌ Error: FISH_API_KEY not set") + print(" export FISH_API_KEY='your-key'") + print("\n💡 Get your API key from: https://fish.audio/") + sys.exit(1) + + # default reference id is Donald Trump + reference_id = os.environ.get("FISH_REFERENCE_ID", "5196af35f6ff4a0dbf541793fc9f2157") + + print(f"🐟 FishSpeech TTS Test") + print(f" API: https://api.fish.audio") + if reference_id: + print(f" Reference ID: {reference_id}") + print(f" Text: {text[:50]}{'...' if len(text) > 50 else ''}\n") + + try: + print("⏳ Generating audio...") + start = asyncio.get_event_loop().time() + + # Create session + session = Session(api_key) + + # Prepare TTS request + tts_request = TTSRequest( + text=text, + reference_id=reference_id, + format="pcm", + normalize=True, + sample_rate=16000, + ) + + # Generate audio + audio_stream = session.tts(tts_request, backend="s1") + duration = (asyncio.get_event_loop().time() - start) * 1000 + + audio_bytes = b''.join(chunk for chunk in audio_stream if chunk) + + print(f"✅ Audio generated") + print(f" Duration: {duration:.0f}ms") + + # Convert to WAV format + wav_buffer = BytesIO() + + # Open wave file in write mode + with wave.open(wav_buffer, 'wb') as wf: + wf.setnchannels(1) # Mono or stereo + wf.setsampwidth(2) # 16-bit (2 bytes) per sample + wf.setframerate(16000) # Sample rate (e.g., 16000 Hz) + wf.writeframes(audio_bytes) + + # Save to file + script_dir = os.path.dirname(os.path.abspath(__file__)) + output_file = os.path.join(script_dir, "tmp", "fish_test.wav") + + os.makedirs(os.path.dirname(output_file), exist_ok=True) + with open(output_file, 'wb') as f: + f.write(wav_buffer.getvalue()) + + os.system(f"afplay '{output_file}'") + + print("\n✅ Test completed successfully!") + + except Exception as e: + print(f"❌ Error: {e}") + import traceback + traceback.print_exc() + sys.exit(1) + except KeyboardInterrupt: + print("\n\n👋 Test interrupted") + sys.exit(1) From 30758d3ec0ec79609f4645963166ec9f41a435b0 Mon Sep 17 00:00:00 2001 From: Harold Date: Fri, 7 Nov 2025 17:46:19 +0800 Subject: [PATCH 29/31] feat: remove useless --- .../core/providers/tts/fishspeech.py | 4 +- .../core/providers/tts/stream_adapter.py | 263 ------------------ main/xiaozhi-server/core/tokenize/__init__.py | 28 -- .../core/tokenize/_basic_sent.py | 79 ------ main/xiaozhi-server/requirements.txt | 3 +- 5 files changed, 3 insertions(+), 374 deletions(-) delete mode 100644 main/xiaozhi-server/core/providers/tts/stream_adapter.py delete mode 100644 main/xiaozhi-server/core/tokenize/__init__.py delete mode 100644 main/xiaozhi-server/core/tokenize/_basic_sent.py diff --git a/main/xiaozhi-server/core/providers/tts/fishspeech.py b/main/xiaozhi-server/core/providers/tts/fishspeech.py index b023b40ba..14ff7bd98 100644 --- a/main/xiaozhi-server/core/providers/tts/fishspeech.py +++ b/main/xiaozhi-server/core/providers/tts/fishspeech.py @@ -1,11 +1,9 @@ import base64 -import requests -import ormsgpack from pathlib import Path from pydantic import BaseModel, Field, conint, model_validator from typing_extensions import Annotated from typing import Literal -from core.utils.util import check_model_key, parse_string_to_list +from core.utils.util import parse_string_to_list from core.providers.tts.base import TTSProviderBase from config.logger import setup_logging from fish_audio_sdk import Session, TTSRequest, ReferenceAudio diff --git a/main/xiaozhi-server/core/providers/tts/stream_adapter.py b/main/xiaozhi-server/core/providers/tts/stream_adapter.py deleted file mode 100644 index 60b151ab2..000000000 --- a/main/xiaozhi-server/core/providers/tts/stream_adapter.py +++ /dev/null @@ -1,263 +0,0 @@ -""" -Stream Adapter - Wrap non-streaming TTS to provide streaming interface - -This module provides StreamAdapter, which wraps a non-streaming TTS provider -(that only supports synthesize()) and provides a streaming interface (stream()). - -The adapter works by: -1. Accepting incremental text input via push_text() -2. Using a sentence tokenizer to segment text into sentences -3. Calling the wrapped TTS's synthesize() for each sentence -4. Streaming the audio output as it becomes available - -This allows any non-streaming TTS to be used in streaming contexts. -""" - -from __future__ import annotations - -import asyncio -from typing import TYPE_CHECKING - -from config.logger import setup_logging -from core.tokenize import SentenceTokenizer, blingfire -from core.tokenize import basic - -# 如果 blingfire 不可用,使用 basic 作为回退 -if blingfire is None: - _default_tokenizer_class = basic.SentenceTokenizer -else: - _default_tokenizer_class = blingfire.SentenceTokenizer -from core.utils.aio import Chan, cancel_and_wait -from core.utils.short_uuid import shortuuid - -from .base import SynthesizedAudio, TTS, SynthesizeStream, TTSCapabilities - -if TYPE_CHECKING: - from .emitter import AudioEmitter - from .pacer import SentenceStreamPacer - -logger = setup_logging() - - -class StreamAdapter(TTS): - """ - Wrap a non-streaming TTS to provide streaming interface. - - This adapter enables any TTS that supports synthesize() to be used - with the streaming API. It handles: - - Text tokenization into sentences - - Sequential synthesis of each sentence - - Optional pacing to optimize cost/quality - - Example: - # Wrap a non-streaming TTS - base_tts = SomeTTS(...) - streaming_tts = StreamAdapter( - tts=base_tts, - sentence_tokenizer=_default_tokenizer_class(), - text_pacing=True # Enable smart pacing - ) - - # Now use it as a streaming TTS - stream = streaming_tts.stream() - stream.push_text("Hello ") - stream.push_text("world!") - stream.end_input() - - async for audio in stream: - # Process audio frames - pass - """ - - def __init__( - self, - *, - tts: TTS, - sentence_tokenizer: SentenceTokenizer | None = None, - text_pacing: bool | SentenceStreamPacer = False, - ) -> None: - """ - Initialize StreamAdapter. - - Args: - tts: The non-streaming TTS to wrap - sentence_tokenizer: Tokenizer to segment text into sentences. - Defaults to basic.SentenceTokenizer() (or blingfire if available) - text_pacing: Smart pacing configuration: - - True: Use default SentenceStreamPacer - - SentenceStreamPacer instance: Use custom pacer - - False: No pacing (synthesize immediately) - """ - super().__init__( - capabilities=TTSCapabilities(streaming=True), - sample_rate=tts.sample_rate, - num_channels=tts.num_channels, - ) - self._wrapped_tts = tts - self._sentence_tokenizer = ( - sentence_tokenizer if sentence_tokenizer else _default_tokenizer_class() - ) - - self._stream_pacer: SentenceStreamPacer | None = None - if text_pacing is True: - from .pacer import SentenceStreamPacer - self._stream_pacer = SentenceStreamPacer() - elif text_pacing is not False: - # Assume it's a SentenceStreamPacer instance - self._stream_pacer = text_pacing - - @property - def model(self) -> str: - """Get the model from wrapped TTS""" - return self._wrapped_tts.model - - @property - def provider(self) -> str: - """Get the provider from wrapped TTS""" - return self._wrapped_tts.provider - - def synthesize(self, text: str) -> 'ChunkedStream': - """ - Synthesize using the wrapped TTS. - - Args: - text: Text to synthesize - - Returns: - ChunkedStream from the wrapped TTS - """ - return self._wrapped_tts.synthesize(text) - - def stream(self) -> StreamAdapterWrapper: - """ - Create a streaming synthesis session. - - Returns: - StreamAdapterWrapper: Streaming synthesis session - """ - return StreamAdapterWrapper(tts=self) - - def prewarm(self) -> None: - """Pre-warm the wrapped TTS""" - self._wrapped_tts.prewarm() - - async def aclose(self) -> None: - """Close the wrapped TTS""" - await self._wrapped_tts.aclose() - - -class StreamAdapterWrapper(SynthesizeStream): - """ - Streaming wrapper that synthesizes sentences sequentially. - - This class orchestrates: - 1. Reading incremental text from input channel - 2. Tokenizing text into sentences - 3. Optionally pacing sentence dispatch based on audio buffer - 4. Calling wrapped TTS for each sentence - 5. Streaming audio output - """ - - def __init__(self, *, tts: StreamAdapter) -> None: - """ - Initialize StreamAdapterWrapper. - - Args: - tts: The StreamAdapter instance - """ - super().__init__(tts=tts) - self._tts: StreamAdapter = tts - - async def _run(self, output_emitter: AudioEmitter) -> None: - """ - Main streaming synthesis logic. - - This method: - 1. Initializes the output emitter - 2. Creates sentence tokenizer stream (and optional pacer) - 3. Spawns two parallel tasks: - - _forward_input: Reads from input_ch → tokenizer - - _synthesize: Reads tokenized sentences → TTS → emitter - - Args: - output_emitter: AudioEmitter to push synthesized audio to - """ - # 1. Initialize output emitter - request_id = shortuuid() - output_emitter.initialize( - request_id=request_id, - sample_rate=self._tts.sample_rate, - num_channels=self._tts.num_channels, - stream=True, - ) - - # 2. Create sentence tokenizer stream - sent_stream = self._tts._sentence_tokenizer.stream() - - # 3. Optionally wrap with pacer - if self._tts._stream_pacer: - sent_stream = self._tts._stream_pacer.wrap( - sent_stream=sent_stream, - audio_emitter=output_emitter, - ) - - # 4. Start segment - segment_id = shortuuid() - output_emitter.start_segment(segment_id=segment_id) - - # 5. Define parallel tasks - async def _forward_input() -> None: - """Forward text from input channel to tokenizer""" - try: - async for data in self._input_ch: - if isinstance(data, self._FlushSentinel): - sent_stream.flush() - continue - - sent_stream.push_text(data) - finally: - sent_stream.end_input() - - async def _synthesize() -> None: - """ - Synthesize each sentence and push audio to emitter. - - For each tokenized sentence: - 1. Call wrapped_tts.synthesize(sentence) - 2. Stream audio frames from the synthesis - 3. Push each frame's audio data to output_emitter - 4. Flush after each sentence - """ - try: - async for sentence_ev in sent_stream: - # Skip empty sentences - text = sentence_ev.token.strip() - if not text: - continue - - # Synthesize this sentence using wrapped TTS - async with self._tts._wrapped_tts.synthesize(text) as tts_stream: - async for audio in tts_stream: - # Push audio data to emitter - # Note: audio.frame.data is memoryview, convert to bytes - audio_bytes = bytes(audio.frame.data) - output_emitter.push(audio_bytes) - - # Flush after each sentence - output_emitter.flush() - except Exception as e: - logger.bind(tag=__name__).error(f"Synthesis error: {e}") - raise - - # 6. Run both tasks in parallel - tasks = [ - asyncio.create_task(_forward_input(), name="forward_input"), - asyncio.create_task(_synthesize(), name="synthesize"), - ] - - try: - await asyncio.gather(*tasks) - finally: - await sent_stream.aclose() - await cancel_and_wait(*tasks) - diff --git a/main/xiaozhi-server/core/tokenize/__init__.py b/main/xiaozhi-server/core/tokenize/__init__.py deleted file mode 100644 index 241bd3a38..000000000 --- a/main/xiaozhi-server/core/tokenize/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from . import basic, utils -try: - from . import blingfire -except ImportError: - blingfire = None - -from .token_stream import BufferedSentenceStream, BufferedWordStream -from .tokenizer import ( - SentenceStream, - SentenceTokenizer, - TokenData, - WordStream, - WordTokenizer, -) - -__all__ = [ - "SentenceTokenizer", - "SentenceStream", - "WordTokenizer", - "WordStream", - "TokenData", - "BufferedSentenceStream", - "BufferedWordStream", - "basic", - "blingfire", - "utils", -] - diff --git a/main/xiaozhi-server/core/tokenize/_basic_sent.py b/main/xiaozhi-server/core/tokenize/_basic_sent.py deleted file mode 100644 index b3292d3b8..000000000 --- a/main/xiaozhi-server/core/tokenize/_basic_sent.py +++ /dev/null @@ -1,79 +0,0 @@ -import re - - -# Rule based segmentation based on https://stackoverflow.com/a/31505798, works surprisingly well -def split_sentences( - text: str, min_sentence_len: int = 20, retain_format: bool = False -) -> list[tuple[str, int, int]]: - """ - The text may not contain substrings "" or "" - """ - alphabets = r"([A-Za-z])" - prefixes = r"(Mr|St|Mrs|Ms|Dr)[.]" - suffixes = r"(Inc|Ltd|Jr|Sr|Co)" - starters = r"(Mr|Mrs|Ms|Dr|Prof|Capt|Cpt|Lt|He\s|She\s|It\s|They\s|Their\s|Our\s|We\s|But\s|However\s|That\s|This\s|Wherever)" # noqa: E501 - acronyms = r"([A-Z][.][A-Z][.](?:[A-Z][.])?)" - websites = r"[.](com|net|org|io|gov|edu|me)" - digits = r"([0-9])" - multiple_dots = r"\.{2,}" - - # fmt: off - if retain_format: - text = text.replace("\n","") - else: - text = text.replace("\n"," ") - - text = re.sub(prefixes,"\\1", text) - text = re.sub(websites,"\\1", text) - text = re.sub(digits + "[.]" + digits,"\\1\\2",text) - # text = re.sub(multiple_dots, lambda match: "" * len(match.group(0)) + "", text) - # TODO: need improvement for ""..." dots", check capital + next sentence should not be small # noqa: E501 - text = re.sub(multiple_dots, lambda match: "" * len(match.group(0)), text) - if "Ph.D" in text: - text = text.replace("Ph.D.","PhD") - text = re.sub(r"\s" + alphabets + "[.] "," \\1 ",text) - text = re.sub(acronyms+" "+starters,"\\1 \\2",text) - text = re.sub(alphabets + "[.]" + alphabets + "[.]" + alphabets + "[.]","\\1\\2\\3",text) # noqa: E501 - text = re.sub(alphabets + "[.]" + alphabets + "[.]","\\1\\2",text) - text = re.sub(r" "+suffixes+"[.] "+starters," \\1 \\2",text) - text = re.sub(r" "+suffixes+"[.]"," \\1",text) - text = re.sub(r" " + alphabets + "[.]"," \\1",text) - - # Mark end of sentence punctuations with - text = re.sub(r"([.!?。!?])([\"'])", "\\1\\2", text) - text = re.sub(r"([.!?。!?])(?![\"'])", "\\1", text) - - text = text.replace("",".") - # fmt: on - - if retain_format: - text = text.replace("", "\n") - splitted_sentences = text.split("") - text = text.replace("", "") - - sentences: list[tuple[str, int, int]] = [] - - buff = "" - start_pos = 0 - end_pos = 0 - pre_pad = "" if retain_format else " " - for match in splitted_sentences: - if retain_format: - sentence = match - else: - sentence = match.strip() - if not sentence: - continue - - buff += pre_pad + sentence - end_pos += len(match) - if len(buff) > min_sentence_len: - sentences.append((buff[len(pre_pad) :], start_pos, end_pos)) - start_pos = end_pos - buff = "" - - if buff: - sentences.append((buff[len(pre_pad) :], start_pos, len(text) - 1)) - - return sentences - diff --git a/main/xiaozhi-server/requirements.txt b/main/xiaozhi-server/requirements.txt index ea930ce41..b67be8248 100644 --- a/main/xiaozhi-server/requirements.txt +++ b/main/xiaozhi-server/requirements.txt @@ -41,4 +41,5 @@ redis>=4.0.0,<5.0.0 elevenlabs>=1.11.0 cartesia>=1.0.0 -deepgram-sdk>=3.0.0 \ No newline at end of file +deepgram-sdk>=3.0.0 +fish-audio-sdk==2025.6.3 \ No newline at end of file From 52d6b2e0bb4982f4a7f0ded0761f80eeb5411783 Mon Sep 17 00:00:00 2001 From: Harold Date: Fri, 7 Nov 2025 18:05:04 +0800 Subject: [PATCH 30/31] feat: rollback --- .dockerignore | 7 ------- main/xiaozhi-server/docker-compose_us_all.yml | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index bc155a7c5..000000000 --- a/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.git -__pycache__ -*.pyc -.env -Dockerfile -tmp/ -data/ \ No newline at end of file diff --git a/main/xiaozhi-server/docker-compose_us_all.yml b/main/xiaozhi-server/docker-compose_us_all.yml index 69352d9ea..06a7ec213 100644 --- a/main/xiaozhi-server/docker-compose_us_all.yml +++ b/main/xiaozhi-server/docker-compose_us_all.yml @@ -10,6 +10,7 @@ services: context: . dockerfile: Dockerfile image: xiaozhi-esp32-server:local + container_name: xiaozhi-esp32-server depends_on: xiaozhi-esp32-server-db: condition: service_healthy @@ -61,6 +62,7 @@ services: # image: ghcr.nju.edu.cn/xinnan-tech/xiaozhi-esp32-server:web_latest # platform: linux/amd64 # Uncomment to force x86 emulation on ARM64 + container_name: xiaozhi-esp32-server-web restart: unless-stopped networks: - xiaozhi-network @@ -97,6 +99,7 @@ services: # ============================================================================ xiaozhi-esp32-server-db: image: mysql:8.0 + container_name: xiaozhi-esp32-server-db restart: unless-stopped networks: - xiaozhi-network @@ -136,6 +139,7 @@ services: # ============================================================================ xiaozhi-esp32-server-redis: image: redis:7-alpine + container_name: xiaozhi-esp32-server-redis restart: unless-stopped networks: - xiaozhi-network @@ -166,6 +170,7 @@ services: networks: xiaozhi-network: driver: bridge + name: xiaozhi-local-network # ============================================================================ # Volumes (optional - for named volumes instead of bind mounts) From cd8356cf70e13afd448d7ee408ef977995ef2af8 Mon Sep 17 00:00:00 2001 From: Harold Date: Fri, 7 Nov 2025 18:17:15 +0800 Subject: [PATCH 31/31] feat: rollback --- .dockerignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..bc155a7c5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +__pycache__ +*.pyc +.env +Dockerfile +tmp/ +data/ \ No newline at end of file