"""Request/response schemas for the specialist inference service.

Re-exports from models.py for discoverability, plus BatchConfig for
deployment configuration.
"""

from __future__ import annotations

from pydantic import BaseModel, Field

from services.specialist.models import (
    MODEL_VERSION,
    SCHEMA_VERSION,
    BatchResponse,
    ClassificationRequest,
    ClassificationResult,
    EntityResult,
    ExtractionRequest,
    RelationResult,
    StructuredResult,
)

__all__ = [
    "BatchConfig",
    "BatchResponse",
    "ClassificationRequest",
    "ClassificationResult",
    "EntityResult",
    "ExtractionRequest",
    "MODEL_VERSION",
    "RelationResult",
    "SCHEMA_VERSION",
    "SpanResult",
    "StructuredResult",
]


class SpanResult(BaseModel):
    """Generic span result used across extraction types."""

    text: str
    start_char: int
    end_char: int
    label: str
    score: float = Field(..., ge=0.0, le=1.0)
    model_version: str = MODEL_VERSION
    schema_version: str = SCHEMA_VERSION


class BatchConfig(BaseModel):
    """Configuration for dynamic batching behavior."""

    max_batch_size: int = Field(default=32, ge=1, le=512, description="Maximum items per batch")
    max_wait_ms: float = Field(default=50.0, ge=1.0, le=5000.0, description="Maximum wait time before flushing a partial batch (ms)")
    max_queue_size: int = Field(default=256, ge=1, le=10000, description="Maximum pending requests in queue before rejection")
    warm_up_on_start: bool = Field(default=True, description="Whether to run a warm-up inference on startup")
