"""Auto-generated by bindgen. Do not edit."""
# ruff: noqa: E501, F401, I001
# fmt: off

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, ClassVar, Optional, TYPE_CHECKING, Union

from wasmtime.component import Variant as _WitVariant
from wasmtime.component import VariantCase as _WitVariantCase


@dataclass(kw_only=True)
class AnthropicModel:
    """Anthropic API model configuration."""
    model_id: str | None
    api_key: str | None
    additional_config: str | None


@dataclass(kw_only=True)
class BedrockModel:
    """AWS Bedrock model configuration."""
    model_id: str
    region: str | None
    access_key_id: str | None
    secret_access_key: str | None
    session_token: str | None
    additional_config: str | None


@dataclass(kw_only=True)
class OpenaiModel:
    """OpenAI API model configuration."""
    model_id: str | None
    api_key: str | None
    additional_config: str | None


@dataclass(kw_only=True)
class GoogleModel:
    """Google Gemini API model configuration."""
    model_id: str | None
    api_key: str | None
    additional_config: str | None


@dataclass(kw_only=True)
class CustomModel:
    """Custom model provider supplied by your application."""
    provider_id: str
    model_id: str | None
    additional_config: str | None
    stateful: bool


class ModelConfig:
    """Which model provider the agent should use."""
    if TYPE_CHECKING:
        Anthropic: ClassVar[type["_ModelConfig_Anthropic"]]
        Bedrock: ClassVar[type["_ModelConfig_Bedrock"]]
        Openai: ClassVar[type["_ModelConfig_Openai"]]
        Gemini: ClassVar[type["_ModelConfig_Gemini"]]
        Custom: ClassVar[type["_ModelConfig_Custom"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "ModelConfig": ...

class _ModelConfig_Anthropic(_WitVariantCase, ModelConfig):
    """Anthropic API."""
    tag = 'anthropic'
ModelConfig.Anthropic = _ModelConfig_Anthropic  # type: ignore[attr-defined]

class _ModelConfig_Bedrock(_WitVariantCase, ModelConfig):
    """AWS Bedrock."""
    tag = 'bedrock'
ModelConfig.Bedrock = _ModelConfig_Bedrock  # type: ignore[attr-defined]

class _ModelConfig_Openai(_WitVariantCase, ModelConfig):
    """OpenAI API."""
    tag = 'openai'
ModelConfig.Openai = _ModelConfig_Openai  # type: ignore[attr-defined]

class _ModelConfig_Gemini(_WitVariantCase, ModelConfig):
    """Google Gemini API."""
    tag = 'gemini'
ModelConfig.Gemini = _ModelConfig_Gemini  # type: ignore[attr-defined]

class _ModelConfig_Custom(_WitVariantCase, ModelConfig):
    """Custom provider supplied by your application. Implement the
`model-provider` interface to serve it."""
    tag = 'custom'
ModelConfig.Custom = _ModelConfig_Custom  # type: ignore[attr-defined]

ModelConfig._CASES = {  # type: ignore[attr-defined]
    'anthropic': ModelConfig.Anthropic,
    'bedrock': ModelConfig.Bedrock,
    'openai': ModelConfig.Openai,
    'gemini': ModelConfig.Gemini,
    'custom': ModelConfig.Custom,
}


def _ModelConfig_lift(raw: _WitVariant) -> ModelConfig:
    cls = ModelConfig._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown ModelConfig arm: {raw.tag!r}')
    return cls(raw.payload)
ModelConfig.lift = staticmethod(_ModelConfig_lift)  # type: ignore[attr-defined]

@dataclass(kw_only=True)
class ModelParams:
    """Sampling parameters applied to every call on the chosen provider."""
    max_tokens: int | None
    temperature: float | None
    top_p: float | None


class ModelError:
    """Why a model call failed. Retry logic keys off of which arm fires, so
implementations should pick the narrowest one that fits."""
    if TYPE_CHECKING:
        UnknownProvider: ClassVar[type["_ModelError_UnknownProvider"]]
        InvalidRequest: ClassVar[type["_ModelError_InvalidRequest"]]
        Unauthorized: ClassVar[type["_ModelError_Unauthorized"]]
        Throttled: ClassVar[type["_ModelError_Throttled"]]
        ServerError: ClassVar[type["_ModelError_ServerError"]]
        ContextWindowExceeded: ClassVar[type["_ModelError_ContextWindowExceeded"]]
        ContentFiltered: ClassVar[type["_ModelError_ContentFiltered"]]
        Transient: ClassVar[type["_ModelError_Transient"]]
        Internal: ClassVar[type["_ModelError_Internal"]]
        _CASES: ClassVar[dict[str, type]]
        @staticmethod
        def lift(raw: _WitVariant) -> "ModelError": ...

class _ModelError_UnknownProvider(_WitVariantCase, ModelError):
    """No provider registered for the given `provider-id`."""
    tag = 'unknown-provider'
ModelError.UnknownProvider = _ModelError_UnknownProvider  # type: ignore[attr-defined]

class _ModelError_InvalidRequest(_WitVariantCase, ModelError):
    """Provider refused the request due to malformed input."""
    tag = 'invalid-request'
ModelError.InvalidRequest = _ModelError_InvalidRequest  # type: ignore[attr-defined]

class _ModelError_Unauthorized(_WitVariantCase, ModelError):
    """Caller lacks permission (missing or expired credentials)."""
    tag = 'unauthorized'
ModelError.Unauthorized = _ModelError_Unauthorized  # type: ignore[attr-defined]

class _ModelError_Throttled(_WitVariantCase, ModelError):
    """Provider returned a rate-limit error. Retry after a backoff."""
    tag = 'throttled'
ModelError.Throttled = _ModelError_Throttled  # type: ignore[attr-defined]

class _ModelError_ServerError(_WitVariantCase, ModelError):
    """Provider returned a server-side error. Retry may succeed."""
    tag = 'server-error'
ModelError.ServerError = _ModelError_ServerError  # type: ignore[attr-defined]

class _ModelError_ContextWindowExceeded(_WitVariantCase, ModelError):
    """Request exceeded the model's context window."""
    tag = 'context-window-exceeded'
ModelError.ContextWindowExceeded = _ModelError_ContextWindowExceeded  # type: ignore[attr-defined]

class _ModelError_ContentFiltered(_WitVariantCase, ModelError):
    """Content was rejected by provider safety policy."""
    tag = 'content-filtered'
ModelError.ContentFiltered = _ModelError_ContentFiltered  # type: ignore[attr-defined]

class _ModelError_Transient(_WitVariantCase, ModelError):
    """Transient network or transport failure. Retry may succeed."""
    tag = 'transient'
ModelError.Transient = _ModelError_Transient  # type: ignore[attr-defined]

class _ModelError_Internal(_WitVariantCase, ModelError):
    """Catch-all for internal failures."""
    tag = 'internal'
ModelError.Internal = _ModelError_Internal  # type: ignore[attr-defined]

ModelError._CASES = {  # type: ignore[attr-defined]
    'unknown-provider': ModelError.UnknownProvider,
    'invalid-request': ModelError.InvalidRequest,
    'unauthorized': ModelError.Unauthorized,
    'throttled': ModelError.Throttled,
    'server-error': ModelError.ServerError,
    'context-window-exceeded': ModelError.ContextWindowExceeded,
    'content-filtered': ModelError.ContentFiltered,
    'transient': ModelError.Transient,
    'internal': ModelError.Internal,
}


def _ModelError_lift(raw: _WitVariant) -> ModelError:
    cls = ModelError._CASES.get(raw.tag)  # type: ignore[attr-defined]
    if cls is None:
        raise ValueError(f'unknown ModelError arm: {raw.tag!r}')
    return cls(raw.payload)
ModelError.lift = staticmethod(_ModelError_lift)  # type: ignore[attr-defined]
