mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
Co-authored-by: speakeasybot <bot@speakeasyapi.dev> Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
242 lines
6.5 KiB
Python
242 lines
6.5 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
|
|
from __future__ import annotations
|
|
from .applypatchcallitem import ApplyPatchCallItem, ApplyPatchCallItemTypedDict
|
|
from .applypatchcalloutputitem import (
|
|
ApplyPatchCallOutputItem,
|
|
ApplyPatchCallOutputItemTypedDict,
|
|
)
|
|
from .inputaudio import InputAudio, InputAudioTypedDict
|
|
from .inputfile import InputFile, InputFileTypedDict
|
|
from .inputimage import InputImage, InputImageTypedDict
|
|
from .inputtext import InputText, InputTextTypedDict
|
|
from .openairesponsecustomtoolcall import (
|
|
OpenAIResponseCustomToolCall,
|
|
OpenAIResponseCustomToolCallTypedDict,
|
|
)
|
|
from .openairesponsecustomtoolcalloutput import (
|
|
OpenAIResponseCustomToolCallOutput,
|
|
OpenAIResponseCustomToolCallOutputTypedDict,
|
|
)
|
|
from .openairesponsefunctiontoolcall import (
|
|
OpenAIResponseFunctionToolCall,
|
|
OpenAIResponseFunctionToolCallTypedDict,
|
|
)
|
|
from .openairesponsefunctiontoolcalloutput import (
|
|
OpenAIResponseFunctionToolCallOutput,
|
|
OpenAIResponseFunctionToolCallOutputTypedDict,
|
|
)
|
|
from .openairesponseinputmessageitem import (
|
|
OpenAIResponseInputMessageItem,
|
|
OpenAIResponseInputMessageItemTypedDict,
|
|
)
|
|
from .outputitemimagegenerationcall import (
|
|
OutputItemImageGenerationCall,
|
|
OutputItemImageGenerationCallTypedDict,
|
|
)
|
|
from .outputmessage import OutputMessage, OutputMessageTypedDict
|
|
from functools import partial
|
|
from openrouter.types import (
|
|
BaseModel,
|
|
Nullable,
|
|
OptionalNullable,
|
|
UNSET,
|
|
UNSET_SENTINEL,
|
|
)
|
|
from openrouter.utils.unions import parse_open_union
|
|
from pydantic import ConfigDict, model_serializer
|
|
from pydantic.functional_validators import BeforeValidator
|
|
from typing import Any, List, Literal, Optional, Union
|
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
|
|
|
|
BaseInputsContent1TypedDict = TypeAliasType(
|
|
"BaseInputsContent1TypedDict",
|
|
Union[
|
|
InputAudioTypedDict, InputTextTypedDict, InputImageTypedDict, InputFileTypedDict
|
|
],
|
|
)
|
|
|
|
|
|
class UnknownBaseInputsContent1(BaseModel):
|
|
r"""A BaseInputsContent1 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)
|
|
|
|
|
|
_BASE_INPUTS_CONTENT_1_VARIANTS: dict[str, Any] = {
|
|
"input_audio": InputAudio,
|
|
"input_file": InputFile,
|
|
"input_image": InputImage,
|
|
"input_text": InputText,
|
|
}
|
|
|
|
|
|
BaseInputsContent1 = Annotated[
|
|
Union[InputAudio, InputFile, InputImage, InputText, UnknownBaseInputsContent1],
|
|
BeforeValidator(
|
|
partial(
|
|
parse_open_union,
|
|
disc_key="type",
|
|
variants=_BASE_INPUTS_CONTENT_1_VARIANTS,
|
|
unknown_cls=UnknownBaseInputsContent1,
|
|
union_name="BaseInputsContent1",
|
|
)
|
|
),
|
|
]
|
|
|
|
|
|
BaseInputsContent2TypedDict = TypeAliasType(
|
|
"BaseInputsContent2TypedDict", Union[List[BaseInputsContent1TypedDict], str]
|
|
)
|
|
|
|
|
|
BaseInputsContent2 = TypeAliasType(
|
|
"BaseInputsContent2", Union[List[BaseInputsContent1], str]
|
|
)
|
|
|
|
|
|
BaseInputsPhaseFinalAnswer = Literal["final_answer",]
|
|
|
|
|
|
BaseInputsPhaseCommentary = Literal["commentary",]
|
|
|
|
|
|
BaseInputsPhaseUnionTypedDict = TypeAliasType(
|
|
"BaseInputsPhaseUnionTypedDict",
|
|
Union[BaseInputsPhaseCommentary, BaseInputsPhaseFinalAnswer, Any],
|
|
)
|
|
|
|
|
|
BaseInputsPhaseUnion = TypeAliasType(
|
|
"BaseInputsPhaseUnion",
|
|
Union[BaseInputsPhaseCommentary, BaseInputsPhaseFinalAnswer, Any],
|
|
)
|
|
|
|
|
|
BaseInputsRoleDeveloper = Literal["developer",]
|
|
|
|
|
|
BaseInputsRoleAssistant = Literal["assistant",]
|
|
|
|
|
|
BaseInputsRoleSystem = Literal["system",]
|
|
|
|
|
|
BaseInputsRoleUser = Literal["user",]
|
|
|
|
|
|
BaseInputsRoleUnionTypedDict = TypeAliasType(
|
|
"BaseInputsRoleUnionTypedDict",
|
|
Union[
|
|
BaseInputsRoleUser,
|
|
BaseInputsRoleSystem,
|
|
BaseInputsRoleAssistant,
|
|
BaseInputsRoleDeveloper,
|
|
],
|
|
)
|
|
|
|
|
|
BaseInputsRoleUnion = TypeAliasType(
|
|
"BaseInputsRoleUnion",
|
|
Union[
|
|
BaseInputsRoleUser,
|
|
BaseInputsRoleSystem,
|
|
BaseInputsRoleAssistant,
|
|
BaseInputsRoleDeveloper,
|
|
],
|
|
)
|
|
|
|
|
|
BaseInputsType = Literal["message",]
|
|
|
|
|
|
class BaseInputsMessageTypedDict(TypedDict):
|
|
content: BaseInputsContent2TypedDict
|
|
role: BaseInputsRoleUnionTypedDict
|
|
phase: NotRequired[Nullable[BaseInputsPhaseUnionTypedDict]]
|
|
type: NotRequired[BaseInputsType]
|
|
|
|
|
|
class BaseInputsMessage(BaseModel):
|
|
content: BaseInputsContent2
|
|
|
|
role: BaseInputsRoleUnion
|
|
|
|
phase: OptionalNullable[BaseInputsPhaseUnion] = UNSET
|
|
|
|
type: Optional[BaseInputsType] = None
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["phase", "type"])
|
|
nullable_fields = set(["phase"])
|
|
serialized = handler(self)
|
|
m = {}
|
|
|
|
for n, f in type(self).model_fields.items():
|
|
k = f.alias or n
|
|
val = serialized.get(k, serialized.get(n))
|
|
is_nullable_and_explicitly_set = (
|
|
k in nullable_fields
|
|
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
|
|
)
|
|
|
|
if val != UNSET_SENTINEL:
|
|
if (
|
|
val is not None
|
|
or k not in optional_fields
|
|
or is_nullable_and_explicitly_set
|
|
):
|
|
m[k] = val
|
|
|
|
return m
|
|
|
|
|
|
BaseInputsUnion1TypedDict = TypeAliasType(
|
|
"BaseInputsUnion1TypedDict",
|
|
Union[
|
|
BaseInputsMessageTypedDict,
|
|
OpenAIResponseInputMessageItemTypedDict,
|
|
OutputItemImageGenerationCallTypedDict,
|
|
OpenAIResponseCustomToolCallOutputTypedDict,
|
|
OpenAIResponseFunctionToolCallOutputTypedDict,
|
|
ApplyPatchCallItemTypedDict,
|
|
ApplyPatchCallOutputItemTypedDict,
|
|
OutputMessageTypedDict,
|
|
OpenAIResponseCustomToolCallTypedDict,
|
|
OpenAIResponseFunctionToolCallTypedDict,
|
|
],
|
|
)
|
|
|
|
|
|
BaseInputsUnion1 = TypeAliasType(
|
|
"BaseInputsUnion1",
|
|
Union[
|
|
BaseInputsMessage,
|
|
OpenAIResponseInputMessageItem,
|
|
OutputItemImageGenerationCall,
|
|
OpenAIResponseCustomToolCallOutput,
|
|
OpenAIResponseFunctionToolCallOutput,
|
|
ApplyPatchCallItem,
|
|
ApplyPatchCallOutputItem,
|
|
OutputMessage,
|
|
OpenAIResponseCustomToolCall,
|
|
OpenAIResponseFunctionToolCall,
|
|
],
|
|
)
|
|
|
|
|
|
BaseInputsUnionTypedDict = TypeAliasType(
|
|
"BaseInputsUnionTypedDict", Union[str, List[BaseInputsUnion1TypedDict], Any]
|
|
)
|
|
|
|
|
|
BaseInputsUnion = TypeAliasType(
|
|
"BaseInputsUnion", Union[str, List[BaseInputsUnion1], Any]
|
|
)
|