"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from opperai.types import BaseModel
from opperai.utils import eventstreaming
from pydantic import SkipValidation
from typing import Dict, List, Optional, Union
from typing_extensions import NotRequired, TypedDict


class FunctionStreamCallStreamPostDataTypedDict(TypedDict):
    r"""The streaming chunk data payload. Content depends on streaming mode: both modes use 'delta', structured mode adds 'json_path' for field tracking"""

    delta: NotRequired[str]
    r"""Incremental content for both unstructured and structured streaming. For structured streaming, contains actual field values being streamed to the json_path location"""
    json_path: NotRequired[str]
    r"""Dot-notation path showing which output_schema field is being populated. Enables precise UI updates by routing content to specific components."""
    span_id: NotRequired[str]
    r"""Unique identifier for the execution span, included in first streaming chunk"""
    chunk_type: NotRequired[str]
    r"""Streaming mode: 'text' for unstructured, 'json' for structured with output_schema"""


class FunctionStreamCallStreamPostData(BaseModel):
    r"""The streaming chunk data payload. Content depends on streaming mode: both modes use 'delta', structured mode adds 'json_path' for field tracking"""

    delta: Optional[str] = None
    r"""Incremental content for both unstructured and structured streaming. For structured streaming, contains actual field values being streamed to the json_path location"""

    json_path: Optional[str] = None
    r"""Dot-notation path showing which output_schema field is being populated. Enables precise UI updates by routing content to specific components."""

    span_id: Optional[str] = None
    r"""Unique identifier for the execution span, included in first streaming chunk"""

    chunk_type: Optional[str] = None
    r"""Streaming mode: 'text' for unstructured, 'json' for structured with output_schema"""


class FunctionStreamCallStreamPostResponseBodyTypedDict(TypedDict):
    r"""Server-Sent Event following the SSE specification"""

    data: FunctionStreamCallStreamPostDataTypedDict
    r"""The streaming chunk data payload. Content depends on streaming mode: both modes use 'delta', structured mode adds 'json_path' for field tracking"""
    id: NotRequired[str]
    r"""Event ID for the SSE event"""
    event: NotRequired[str]
    r"""Event type for the SSE event"""
    retry: NotRequired[int]
    r"""Retry interval in milliseconds for the SSE connection"""


class FunctionStreamCallStreamPostResponseBody(BaseModel):
    r"""Server-Sent Event following the SSE specification"""

    data: FunctionStreamCallStreamPostData
    r"""The streaming chunk data payload. Content depends on streaming mode: both modes use 'delta', structured mode adds 'json_path' for field tracking"""

    id: Optional[str] = None
    r"""Event ID for the SSE event"""

    event: Optional[str] = None
    r"""Event type for the SSE event"""

    retry: Optional[int] = None
    r"""Retry interval in milliseconds for the SSE connection"""


class FunctionStreamCallStreamPostResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: Union[
        eventstreaming.EventStream[FunctionStreamCallStreamPostResponseBodyTypedDict],
        eventstreaming.EventStreamAsync[
            FunctionStreamCallStreamPostResponseBodyTypedDict
        ],
    ]


class FunctionStreamCallStreamPostResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: SkipValidation[
        Union[
            eventstreaming.EventStream[FunctionStreamCallStreamPostResponseBody],
            eventstreaming.EventStreamAsync[FunctionStreamCallStreamPostResponseBody],
        ]
    ]
