mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
133 lines
3.9 KiB
Python
133 lines
3.9 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
|
|
from __future__ import annotations
|
|
from .inputfile import InputFile, InputFileTypedDict
|
|
from .inputimage import InputImage, InputImageTypedDict
|
|
from .inputtext import InputText, InputTextTypedDict
|
|
from functools import partial
|
|
from openrouter.types import (
|
|
BaseModel,
|
|
Nullable,
|
|
OptionalNullable,
|
|
UNSET,
|
|
UNSET_SENTINEL,
|
|
UnrecognizedStr,
|
|
)
|
|
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, Union
|
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
|
|
|
|
OpenAIResponseFunctionToolCallOutputOutput1TypedDict = TypeAliasType(
|
|
"OpenAIResponseFunctionToolCallOutputOutput1TypedDict",
|
|
Union[InputTextTypedDict, InputImageTypedDict, InputFileTypedDict],
|
|
)
|
|
|
|
|
|
class UnknownOpenAIResponseFunctionToolCallOutputOutput1(BaseModel):
|
|
r"""A OpenAIResponseFunctionToolCallOutputOutput1 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)
|
|
|
|
|
|
_OPEN_AI_RESPONSE_FUNCTION_TOOL_CALL_OUTPUT_OUTPUT_1_VARIANTS: dict[str, Any] = {
|
|
"input_file": InputFile,
|
|
"input_image": InputImage,
|
|
"input_text": InputText,
|
|
}
|
|
|
|
|
|
OpenAIResponseFunctionToolCallOutputOutput1 = Annotated[
|
|
Union[
|
|
InputFile,
|
|
InputImage,
|
|
InputText,
|
|
UnknownOpenAIResponseFunctionToolCallOutputOutput1,
|
|
],
|
|
BeforeValidator(
|
|
partial(
|
|
parse_open_union,
|
|
disc_key="type",
|
|
variants=_OPEN_AI_RESPONSE_FUNCTION_TOOL_CALL_OUTPUT_OUTPUT_1_VARIANTS,
|
|
unknown_cls=UnknownOpenAIResponseFunctionToolCallOutputOutput1,
|
|
union_name="OpenAIResponseFunctionToolCallOutputOutput1",
|
|
)
|
|
),
|
|
]
|
|
|
|
|
|
OpenAIResponseFunctionToolCallOutputOutput2TypedDict = TypeAliasType(
|
|
"OpenAIResponseFunctionToolCallOutputOutput2TypedDict",
|
|
Union[str, List[OpenAIResponseFunctionToolCallOutputOutput1TypedDict]],
|
|
)
|
|
|
|
|
|
OpenAIResponseFunctionToolCallOutputOutput2 = TypeAliasType(
|
|
"OpenAIResponseFunctionToolCallOutputOutput2",
|
|
Union[str, List[OpenAIResponseFunctionToolCallOutputOutput1]],
|
|
)
|
|
|
|
|
|
OpenAIResponseFunctionToolCallOutputStatus = Union[
|
|
Literal[
|
|
"in_progress",
|
|
"completed",
|
|
"incomplete",
|
|
],
|
|
UnrecognizedStr,
|
|
]
|
|
|
|
|
|
OpenAIResponseFunctionToolCallOutputType = Literal["function_call_output",]
|
|
|
|
|
|
class OpenAIResponseFunctionToolCallOutputTypedDict(TypedDict):
|
|
call_id: str
|
|
output: OpenAIResponseFunctionToolCallOutputOutput2TypedDict
|
|
type: OpenAIResponseFunctionToolCallOutputType
|
|
id: NotRequired[Nullable[str]]
|
|
status: NotRequired[Nullable[OpenAIResponseFunctionToolCallOutputStatus]]
|
|
|
|
|
|
class OpenAIResponseFunctionToolCallOutput(BaseModel):
|
|
call_id: str
|
|
|
|
output: OpenAIResponseFunctionToolCallOutputOutput2
|
|
|
|
type: OpenAIResponseFunctionToolCallOutputType
|
|
|
|
id: OptionalNullable[str] = UNSET
|
|
|
|
status: OptionalNullable[OpenAIResponseFunctionToolCallOutputStatus] = UNSET
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["id", "status"])
|
|
nullable_fields = set(["id", "status"])
|
|
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
|