"""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, Optional, 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."""

    class Anthropic(_WitVariantCase):
        """Anthropic API."""
        tag = 'anthropic'

    class Bedrock(_WitVariantCase):
        """AWS Bedrock."""
        tag = 'bedrock'

    class Openai(_WitVariantCase):
        """OpenAI API."""
        tag = 'openai'

    class Gemini(_WitVariantCase):
        """Google Gemini API."""
        tag = 'gemini'

    class Custom(_WitVariantCase):
        """Custom provider supplied by your application. Implement the
`model-provider` interface to serve it."""
        tag = 'custom'

    _CASES: dict[str, type] = {
        'anthropic': Anthropic,
        'bedrock': Bedrock,
        'openai': Openai,
        'gemini': Gemini,
        'custom': Custom,
    }

    @staticmethod
    def lift(raw: _WitVariant) -> ModelConfig:
        cls = ModelConfig._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown ModelConfig arm: {raw.tag!r}')
        return cls(raw.payload)

@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."""

    class UnknownProvider(_WitVariantCase):
        """No provider registered for the given `provider-id`."""
        tag = 'unknown-provider'

    class InvalidRequest(_WitVariantCase):
        """Provider refused the request due to malformed input."""
        tag = 'invalid-request'

    class Unauthorized(_WitVariantCase):
        """Caller lacks permission (missing or expired credentials)."""
        tag = 'unauthorized'

    class Throttled(_WitVariantCase):
        """Provider returned a rate-limit error. Retry after a backoff."""
        tag = 'throttled'

    class ServerError(_WitVariantCase):
        """Provider returned a server-side error. Retry may succeed."""
        tag = 'server-error'

    class ContextWindowExceeded(_WitVariantCase):
        """Request exceeded the model's context window."""
        tag = 'context-window-exceeded'

    class ContentFiltered(_WitVariantCase):
        """Content was rejected by provider safety policy."""
        tag = 'content-filtered'

    class Transient(_WitVariantCase):
        """Transient network or transport failure. Retry may succeed."""
        tag = 'transient'

    class Internal(_WitVariantCase):
        """Catch-all for internal failures."""
        tag = 'internal'

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

    @staticmethod
    def lift(raw: _WitVariant) -> ModelError:
        cls = ModelError._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown ModelError arm: {raw.tag!r}')
        return cls(raw.payload)
