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

from .messages import Message, PromptInput
from .models import ModelError
from .streaming import StreamEvent
from .tools import ToolChoice, ToolSpec


class ModelEventStream:
    """Pull-based stream of model events from a custom provider; host produces, guest reads."""
    # Wraps a wasmtime-py ResourceAny / ResourceHost handle.
    # The runtime sets ._handle to the underlying resource and
    # ._invoke to a callable that dispatches a method by WIT name.

    def __init__(self, handle: Any, invoke: Any = None) -> None:
        self._handle = handle
        self._invoke = invoke

    def read(self) -> StreamEvent | None:
        return self._invoke('[method]model-event-stream.read', (self._handle,))


@dataclass(kw_only=True)
class ModelStreamOptions:
    """Options passed alongside the messages on each streaming call."""
    system_prompt: PromptInput | None
    tools: list[ToolSpec] | None
    tool_choice: ToolChoice | None


@dataclass(kw_only=True)
class StartStreamArgs:
    """Arguments for `start-stream`."""
    provider_id: str
    messages: list[Message]
    options: ModelStreamOptions


@dataclass(kw_only=True)
class CountTokensArgs:
    """Arguments for `count-tokens`."""
    provider_id: str
    messages: list[Message]
    system_prompt: PromptInput | None
    tools: list[ToolSpec] | None
