Files
openrouter-python-sdk-retry…/src/openrouter/components/streamevents.py
T

325 lines
12 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .annotationaddedevent import AnnotationAddedEvent, AnnotationAddedEventTypedDict
from .applypatchcalloperationdiffdeltaevent import (
ApplyPatchCallOperationDiffDeltaEvent,
ApplyPatchCallOperationDiffDeltaEventTypedDict,
)
from .applypatchcalloperationdiffdoneevent import (
ApplyPatchCallOperationDiffDoneEvent,
ApplyPatchCallOperationDiffDoneEventTypedDict,
)
from .contentpartaddedevent import ContentPartAddedEvent, ContentPartAddedEventTypedDict
from .contentpartdoneevent import ContentPartDoneEvent, ContentPartDoneEventTypedDict
from .customtoolcallinputdeltaevent import (
CustomToolCallInputDeltaEvent,
CustomToolCallInputDeltaEventTypedDict,
)
from .customtoolcallinputdoneevent import (
CustomToolCallInputDoneEvent,
CustomToolCallInputDoneEventTypedDict,
)
from .debugevent import DebugEvent, DebugEventTypedDict
from .errorevent import ErrorEvent, ErrorEventTypedDict
from .functioncallargsdeltaevent import (
FunctionCallArgsDeltaEvent,
FunctionCallArgsDeltaEventTypedDict,
)
from .functioncallargsdoneevent import (
FunctionCallArgsDoneEvent,
FunctionCallArgsDoneEventTypedDict,
)
from .fusioncallanalysiscompletedevent import (
FusionCallAnalysisCompletedEvent,
FusionCallAnalysisCompletedEventTypedDict,
)
from .fusioncallanalysisinprogressevent import (
FusionCallAnalysisInProgressEvent,
FusionCallAnalysisInProgressEventTypedDict,
)
from .fusioncallcompletedevent import (
FusionCallCompletedEvent,
FusionCallCompletedEventTypedDict,
)
from .fusioncallinprogressevent import (
FusionCallInProgressEvent,
FusionCallInProgressEventTypedDict,
)
from .fusioncallpaneladdedevent import (
FusionCallPanelAddedEvent,
FusionCallPanelAddedEventTypedDict,
)
from .fusioncallpanelcompletedevent import (
FusionCallPanelCompletedEvent,
FusionCallPanelCompletedEventTypedDict,
)
from .fusioncallpaneldeltaevent import (
FusionCallPanelDeltaEvent,
FusionCallPanelDeltaEventTypedDict,
)
from .fusioncallpanelfailedevent import (
FusionCallPanelFailedEvent,
FusionCallPanelFailedEventTypedDict,
)
from .fusioncallpanelreasoningdeltaevent import (
FusionCallPanelReasoningDeltaEvent,
FusionCallPanelReasoningDeltaEventTypedDict,
)
from .imagegencallcompletedevent import (
ImageGenCallCompletedEvent,
ImageGenCallCompletedEventTypedDict,
)
from .imagegencallgeneratingevent import (
ImageGenCallGeneratingEvent,
ImageGenCallGeneratingEventTypedDict,
)
from .imagegencallinprogressevent import (
ImageGenCallInProgressEvent,
ImageGenCallInProgressEventTypedDict,
)
from .imagegencallpartialimageevent import (
ImageGenCallPartialImageEvent,
ImageGenCallPartialImageEventTypedDict,
)
from .openresponsescreatedevent import (
OpenResponsesCreatedEvent,
OpenResponsesCreatedEventTypedDict,
)
from .openresponsesinprogressevent import (
OpenResponsesInProgressEvent,
OpenResponsesInProgressEventTypedDict,
)
from .reasoningdeltaevent import ReasoningDeltaEvent, ReasoningDeltaEventTypedDict
from .reasoningdoneevent import ReasoningDoneEvent, ReasoningDoneEventTypedDict
from .reasoningsummarypartaddedevent import (
ReasoningSummaryPartAddedEvent,
ReasoningSummaryPartAddedEventTypedDict,
)
from .reasoningsummarypartdoneevent import (
ReasoningSummaryPartDoneEvent,
ReasoningSummaryPartDoneEventTypedDict,
)
from .reasoningsummarytextdeltaevent import (
ReasoningSummaryTextDeltaEvent,
ReasoningSummaryTextDeltaEventTypedDict,
)
from .reasoningsummarytextdoneevent import (
ReasoningSummaryTextDoneEvent,
ReasoningSummaryTextDoneEventTypedDict,
)
from .refusaldeltaevent import RefusalDeltaEvent, RefusalDeltaEventTypedDict
from .refusaldoneevent import RefusalDoneEvent, RefusalDoneEventTypedDict
from .streameventsresponsecompleted import (
StreamEventsResponseCompleted,
StreamEventsResponseCompletedTypedDict,
)
from .streameventsresponsefailed import (
StreamEventsResponseFailed,
StreamEventsResponseFailedTypedDict,
)
from .streameventsresponseincomplete import (
StreamEventsResponseIncomplete,
StreamEventsResponseIncompleteTypedDict,
)
from .streameventsresponseoutputitemadded import (
StreamEventsResponseOutputItemAdded,
StreamEventsResponseOutputItemAddedTypedDict,
)
from .streameventsresponseoutputitemdone import (
StreamEventsResponseOutputItemDone,
StreamEventsResponseOutputItemDoneTypedDict,
)
from .textdeltaevent import TextDeltaEvent, TextDeltaEventTypedDict
from .textdoneevent import TextDoneEvent, TextDoneEventTypedDict
from .websearchcallcompletedevent import (
WebSearchCallCompletedEvent,
WebSearchCallCompletedEventTypedDict,
)
from .websearchcallinprogressevent import (
WebSearchCallInProgressEvent,
WebSearchCallInProgressEventTypedDict,
)
from .websearchcallsearchingevent import (
WebSearchCallSearchingEvent,
WebSearchCallSearchingEventTypedDict,
)
from functools import partial
from openrouter.types import BaseModel
from openrouter.utils.unions import parse_open_union
from pydantic import ConfigDict
from pydantic.functional_validators import BeforeValidator
from typing import Any, Literal, Union
from typing_extensions import Annotated, TypeAliasType
StreamEventsTypedDict = TypeAliasType(
"StreamEventsTypedDict",
Union[
DebugEventTypedDict,
OpenResponsesInProgressEventTypedDict,
StreamEventsResponseCompletedTypedDict,
StreamEventsResponseIncompleteTypedDict,
StreamEventsResponseFailedTypedDict,
OpenResponsesCreatedEventTypedDict,
FusionCallCompletedEventTypedDict,
StreamEventsResponseOutputItemAddedTypedDict,
WebSearchCallCompletedEventTypedDict,
StreamEventsResponseOutputItemDoneTypedDict,
ImageGenCallInProgressEventTypedDict,
ImageGenCallGeneratingEventTypedDict,
ImageGenCallCompletedEventTypedDict,
FusionCallInProgressEventTypedDict,
WebSearchCallInProgressEventTypedDict,
WebSearchCallSearchingEventTypedDict,
FusionCallPanelAddedEventTypedDict,
CustomToolCallInputDoneEventTypedDict,
CustomToolCallInputDeltaEventTypedDict,
ApplyPatchCallOperationDiffDeltaEventTypedDict,
FunctionCallArgsDeltaEventTypedDict,
ApplyPatchCallOperationDiffDoneEventTypedDict,
FusionCallAnalysisInProgressEventTypedDict,
FusionCallAnalysisCompletedEventTypedDict,
ErrorEventTypedDict,
ReasoningSummaryTextDoneEventTypedDict,
RefusalDoneEventTypedDict,
ReasoningSummaryTextDeltaEventTypedDict,
ReasoningSummaryPartDoneEventTypedDict,
ReasoningSummaryPartAddedEventTypedDict,
ReasoningDoneEventTypedDict,
ReasoningDeltaEventTypedDict,
FunctionCallArgsDoneEventTypedDict,
ContentPartAddedEventTypedDict,
ImageGenCallPartialImageEventTypedDict,
RefusalDeltaEventTypedDict,
FusionCallPanelDeltaEventTypedDict,
FusionCallPanelReasoningDeltaEventTypedDict,
FusionCallPanelCompletedEventTypedDict,
ContentPartDoneEventTypedDict,
TextDoneEventTypedDict,
TextDeltaEventTypedDict,
FusionCallPanelFailedEventTypedDict,
AnnotationAddedEventTypedDict,
],
)
r"""Union of all possible event types emitted during response streaming"""
class UnknownStreamEvents(BaseModel):
r"""A StreamEvents variant the SDK doesn't recognize. Preserves the raw payload."""
type: Literal["UNKNOWN"] = "UNKNOWN"
raw: Any
is_unknown: Literal[True] = True
model_config = ConfigDict(frozen=True)
_STREAM_EVENTS_VARIANTS: dict[str, Any] = {
"error": ErrorEvent,
"response.apply_patch_call_operation_diff.delta": ApplyPatchCallOperationDiffDeltaEvent,
"response.apply_patch_call_operation_diff.done": ApplyPatchCallOperationDiffDoneEvent,
"response.completed": StreamEventsResponseCompleted,
"response.content_part.added": ContentPartAddedEvent,
"response.content_part.done": ContentPartDoneEvent,
"response.created": OpenResponsesCreatedEvent,
"response.custom_tool_call_input.delta": CustomToolCallInputDeltaEvent,
"response.custom_tool_call_input.done": CustomToolCallInputDoneEvent,
"response.debug": DebugEvent,
"response.failed": StreamEventsResponseFailed,
"response.function_call_arguments.delta": FunctionCallArgsDeltaEvent,
"response.function_call_arguments.done": FunctionCallArgsDoneEvent,
"response.fusion_call.analysis.completed": FusionCallAnalysisCompletedEvent,
"response.fusion_call.analysis.in_progress": FusionCallAnalysisInProgressEvent,
"response.fusion_call.completed": FusionCallCompletedEvent,
"response.fusion_call.in_progress": FusionCallInProgressEvent,
"response.fusion_call.panel.added": FusionCallPanelAddedEvent,
"response.fusion_call.panel.completed": FusionCallPanelCompletedEvent,
"response.fusion_call.panel.delta": FusionCallPanelDeltaEvent,
"response.fusion_call.panel.failed": FusionCallPanelFailedEvent,
"response.fusion_call.panel.reasoning.delta": FusionCallPanelReasoningDeltaEvent,
"response.image_generation_call.completed": ImageGenCallCompletedEvent,
"response.image_generation_call.generating": ImageGenCallGeneratingEvent,
"response.image_generation_call.in_progress": ImageGenCallInProgressEvent,
"response.image_generation_call.partial_image": ImageGenCallPartialImageEvent,
"response.in_progress": OpenResponsesInProgressEvent,
"response.incomplete": StreamEventsResponseIncomplete,
"response.output_item.added": StreamEventsResponseOutputItemAdded,
"response.output_item.done": StreamEventsResponseOutputItemDone,
"response.output_text.annotation.added": AnnotationAddedEvent,
"response.output_text.delta": TextDeltaEvent,
"response.output_text.done": TextDoneEvent,
"response.reasoning_summary_part.added": ReasoningSummaryPartAddedEvent,
"response.reasoning_summary_part.done": ReasoningSummaryPartDoneEvent,
"response.reasoning_summary_text.delta": ReasoningSummaryTextDeltaEvent,
"response.reasoning_summary_text.done": ReasoningSummaryTextDoneEvent,
"response.reasoning_text.delta": ReasoningDeltaEvent,
"response.reasoning_text.done": ReasoningDoneEvent,
"response.refusal.delta": RefusalDeltaEvent,
"response.refusal.done": RefusalDoneEvent,
"response.web_search_call.completed": WebSearchCallCompletedEvent,
"response.web_search_call.in_progress": WebSearchCallInProgressEvent,
"response.web_search_call.searching": WebSearchCallSearchingEvent,
}
StreamEvents = Annotated[
Union[
ErrorEvent,
ApplyPatchCallOperationDiffDeltaEvent,
ApplyPatchCallOperationDiffDoneEvent,
StreamEventsResponseCompleted,
ContentPartAddedEvent,
ContentPartDoneEvent,
OpenResponsesCreatedEvent,
CustomToolCallInputDeltaEvent,
CustomToolCallInputDoneEvent,
DebugEvent,
StreamEventsResponseFailed,
FunctionCallArgsDeltaEvent,
FunctionCallArgsDoneEvent,
FusionCallAnalysisCompletedEvent,
FusionCallAnalysisInProgressEvent,
FusionCallCompletedEvent,
FusionCallInProgressEvent,
FusionCallPanelAddedEvent,
FusionCallPanelCompletedEvent,
FusionCallPanelDeltaEvent,
FusionCallPanelFailedEvent,
FusionCallPanelReasoningDeltaEvent,
ImageGenCallCompletedEvent,
ImageGenCallGeneratingEvent,
ImageGenCallInProgressEvent,
ImageGenCallPartialImageEvent,
OpenResponsesInProgressEvent,
StreamEventsResponseIncomplete,
StreamEventsResponseOutputItemAdded,
StreamEventsResponseOutputItemDone,
AnnotationAddedEvent,
TextDeltaEvent,
TextDoneEvent,
ReasoningSummaryPartAddedEvent,
ReasoningSummaryPartDoneEvent,
ReasoningSummaryTextDeltaEvent,
ReasoningSummaryTextDoneEvent,
ReasoningDeltaEvent,
ReasoningDoneEvent,
RefusalDeltaEvent,
RefusalDoneEvent,
WebSearchCallCompletedEvent,
WebSearchCallInProgressEvent,
WebSearchCallSearchingEvent,
UnknownStreamEvents,
],
BeforeValidator(
partial(
parse_open_union,
disc_key="type",
variants=_STREAM_EVENTS_VARIANTS,
unknown_cls=UnknownStreamEvents,
union_name="StreamEvents",
)
),
]
r"""Union of all possible event types emitted during response streaming"""