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

from __future__ import annotations
from .app_api_public_v2_functions_callfunctionrequest import (
    AppAPIPublicV2FunctionsCallFunctionRequest,
    AppAPIPublicV2FunctionsCallFunctionRequestTypedDict,
)
from opperai.types import BaseModel
from opperai.utils import (
    FieldMetadata,
    PathParamMetadata,
    RequestMetadata,
    eventstreaming,
)
from pydantic import SkipValidation
from typing import Dict, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


class StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostRequestTypedDict(
    TypedDict
):
    function_id: str
    r"""The id of the function to call"""
    revision_id: str
    r"""The id of the revision to call"""
    app_api_public_v2_functions_call_function_request: (
        AppAPIPublicV2FunctionsCallFunctionRequestTypedDict
    )


class StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostRequest(
    BaseModel
):
    function_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The id of the function to call"""

    revision_id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The id of the revision to call"""

    app_api_public_v2_functions_call_function_request: Annotated[
        AppAPIPublicV2FunctionsCallFunctionRequest,
        FieldMetadata(request=RequestMetadata(media_type="application/json")),
    ]


class StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostDataTypedDict(
    TypedDict
):
    r"""The actual data payload containing streaming chunk information"""

    delta: NotRequired[str]
    r"""Incremental text content generated by the model"""
    span_id: NotRequired[str]
    r"""Unique identifier for the execution span"""


class StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostData(BaseModel):
    r"""The actual data payload containing streaming chunk information"""

    delta: Optional[str] = None
    r"""Incremental text content generated by the model"""

    span_id: Optional[str] = None
    r"""Unique identifier for the execution span"""


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

    data: StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostDataTypedDict
    r"""The actual data payload containing streaming chunk information"""
    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 StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostResponseBody(
    BaseModel
):
    r"""Server-Sent Event following the SSE specification"""

    data: StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostData
    r"""The actual data payload containing streaming chunk information"""

    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 StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostResponseTypedDict(
    TypedDict
):
    headers: Dict[str, List[str]]
    result: Union[
        eventstreaming.EventStream[
            StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostResponseBodyTypedDict
        ],
        eventstreaming.EventStreamAsync[
            StreamFunctionRevisionFunctionsFunctionIDCallStreamRevisionIDPostResponseBodyTypedDict
        ],
    ]


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

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