mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-31 12:30:30 +08:00
feat: regenerate SDK with updated OpenAPI spec
Speakeasy regeneration with latest schema changes including type renames and new server tool models.
This commit is contained in:
@@ -0,0 +1,350 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .easyinputmessage import EasyInputMessage, EasyInputMessageTypedDict
|
||||
from .functioncallitem import FunctionCallItem, FunctionCallItemTypedDict
|
||||
from .functioncalloutputitem import (
|
||||
FunctionCallOutputItem,
|
||||
FunctionCallOutputItemTypedDict,
|
||||
)
|
||||
from .inputmessageitem import InputMessageItem, InputMessageItemTypedDict
|
||||
from .openairesponsesrefusalcontent import (
|
||||
OpenAIResponsesRefusalContent,
|
||||
OpenAIResponsesRefusalContentTypedDict,
|
||||
)
|
||||
from .outputdatetimeitem import OutputDatetimeItem, OutputDatetimeItemTypedDict
|
||||
from .outputfilesearchcallitem import (
|
||||
OutputFileSearchCallItem,
|
||||
OutputFileSearchCallItemTypedDict,
|
||||
)
|
||||
from .outputfunctioncallitem import (
|
||||
OutputFunctionCallItem,
|
||||
OutputFunctionCallItemTypedDict,
|
||||
)
|
||||
from .outputimagegenerationcallitem import (
|
||||
OutputImageGenerationCallItem,
|
||||
OutputImageGenerationCallItemTypedDict,
|
||||
)
|
||||
from .outputservertoolitem import OutputServerToolItem, OutputServerToolItemTypedDict
|
||||
from .outputwebsearchcallitem import (
|
||||
OutputWebSearchCallItem,
|
||||
OutputWebSearchCallItemTypedDict,
|
||||
)
|
||||
from .reasoningitem import ReasoningItem, ReasoningItemTypedDict
|
||||
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
|
||||
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
||||
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
InputsTypeReasoning = Literal["reasoning",]
|
||||
|
||||
|
||||
InputsStatusInProgress2 = Literal["in_progress",]
|
||||
|
||||
|
||||
InputsStatusIncomplete2 = Literal["incomplete",]
|
||||
|
||||
|
||||
InputsStatusCompleted2 = Literal["completed",]
|
||||
|
||||
|
||||
InputsStatusUnion2TypedDict = TypeAliasType(
|
||||
"InputsStatusUnion2TypedDict",
|
||||
Union[InputsStatusCompleted2, InputsStatusIncomplete2, InputsStatusInProgress2],
|
||||
)
|
||||
|
||||
|
||||
InputsStatusUnion2 = TypeAliasType(
|
||||
"InputsStatusUnion2",
|
||||
Union[InputsStatusCompleted2, InputsStatusIncomplete2, InputsStatusInProgress2],
|
||||
)
|
||||
|
||||
|
||||
InputsFormat = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"azure-openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
r"""The format of the reasoning content"""
|
||||
|
||||
|
||||
class InputsReasoningTypedDict(TypedDict):
|
||||
r"""An output item containing reasoning"""
|
||||
|
||||
type: InputsTypeReasoning
|
||||
id: str
|
||||
summary: Nullable[List[ReasoningSummaryTextTypedDict]]
|
||||
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
|
||||
encrypted_content: NotRequired[Nullable[str]]
|
||||
status: NotRequired[InputsStatusUnion2TypedDict]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
r"""A signature for the reasoning content, used for verification"""
|
||||
format_: NotRequired[Nullable[InputsFormat]]
|
||||
r"""The format of the reasoning content"""
|
||||
|
||||
|
||||
class InputsReasoning(BaseModel):
|
||||
r"""An output item containing reasoning"""
|
||||
|
||||
type: InputsTypeReasoning
|
||||
|
||||
id: str
|
||||
|
||||
summary: Nullable[List[ReasoningSummaryText]]
|
||||
|
||||
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
|
||||
|
||||
encrypted_content: OptionalNullable[str] = UNSET
|
||||
|
||||
status: Optional[InputsStatusUnion2] = None
|
||||
|
||||
signature: OptionalNullable[str] = UNSET
|
||||
r"""A signature for the reasoning content, used for verification"""
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[InputsFormat], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
r"""The format of the reasoning content"""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
"content",
|
||||
"encrypted_content",
|
||||
"status",
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
nullable_fields = [
|
||||
"content",
|
||||
"summary",
|
||||
"encrypted_content",
|
||||
"signature",
|
||||
"format",
|
||||
]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
InputsRole = Literal["assistant",]
|
||||
|
||||
|
||||
InputsTypeMessage = Literal["message",]
|
||||
|
||||
|
||||
InputsStatusInProgress1 = Literal["in_progress",]
|
||||
|
||||
|
||||
InputsStatusIncomplete1 = Literal["incomplete",]
|
||||
|
||||
|
||||
InputsStatusCompleted1 = Literal["completed",]
|
||||
|
||||
|
||||
InputsStatusUnion1TypedDict = TypeAliasType(
|
||||
"InputsStatusUnion1TypedDict",
|
||||
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
|
||||
)
|
||||
|
||||
|
||||
InputsStatusUnion1 = TypeAliasType(
|
||||
"InputsStatusUnion1",
|
||||
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
|
||||
)
|
||||
|
||||
|
||||
InputsContent1TypedDict = TypeAliasType(
|
||||
"InputsContent1TypedDict",
|
||||
Union[OpenAIResponsesRefusalContentTypedDict, ResponseOutputTextTypedDict],
|
||||
)
|
||||
|
||||
|
||||
InputsContent1 = Annotated[
|
||||
Union[
|
||||
Annotated[ResponseOutputText, Tag("output_text")],
|
||||
Annotated[OpenAIResponsesRefusalContent, Tag("refusal")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
|
||||
InputsContent2TypedDict = TypeAliasType(
|
||||
"InputsContent2TypedDict", Union[List[InputsContent1TypedDict], str, Any]
|
||||
)
|
||||
|
||||
|
||||
InputsContent2 = TypeAliasType("InputsContent2", Union[List[InputsContent1], str, Any])
|
||||
|
||||
|
||||
InputsPhaseFinalAnswer = Literal["final_answer",]
|
||||
|
||||
|
||||
InputsPhaseCommentary = Literal["commentary",]
|
||||
|
||||
|
||||
InputsPhaseUnionTypedDict = TypeAliasType(
|
||||
"InputsPhaseUnionTypedDict",
|
||||
Union[InputsPhaseCommentary, InputsPhaseFinalAnswer, Any],
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
InputsPhaseUnion = TypeAliasType(
|
||||
"InputsPhaseUnion", Union[InputsPhaseCommentary, InputsPhaseFinalAnswer, Any]
|
||||
)
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
class InputsMessageTypedDict(TypedDict):
|
||||
r"""An output message item"""
|
||||
|
||||
id: str
|
||||
role: InputsRole
|
||||
type: InputsTypeMessage
|
||||
content: Nullable[InputsContent2TypedDict]
|
||||
status: NotRequired[InputsStatusUnion1TypedDict]
|
||||
phase: NotRequired[Nullable[InputsPhaseUnionTypedDict]]
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
|
||||
class InputsMessage(BaseModel):
|
||||
r"""An output message item"""
|
||||
|
||||
id: str
|
||||
|
||||
role: InputsRole
|
||||
|
||||
type: InputsTypeMessage
|
||||
|
||||
content: Nullable[InputsContent2]
|
||||
|
||||
status: Optional[InputsStatusUnion1] = None
|
||||
|
||||
phase: OptionalNullable[InputsPhaseUnion] = UNSET
|
||||
r"""The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."""
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["status", "phase"]
|
||||
nullable_fields = ["content", "phase"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
m = {}
|
||||
|
||||
for n, f in type(self).model_fields.items():
|
||||
k = f.alias or n
|
||||
val = serialized.get(k)
|
||||
serialized.pop(k, None)
|
||||
|
||||
optional_nullable = k in optional_fields and k in nullable_fields
|
||||
is_set = (
|
||||
self.__pydantic_fields_set__.intersection({n})
|
||||
or k in null_default_fields
|
||||
) # pylint: disable=no-member
|
||||
|
||||
if val is not None and val != UNSET_SENTINEL:
|
||||
m[k] = val
|
||||
elif val != UNSET_SENTINEL and (
|
||||
not k in optional_fields or (optional_nullable and is_set)
|
||||
):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
InputsUnion1TypedDict = TypeAliasType(
|
||||
"InputsUnion1TypedDict",
|
||||
Union[
|
||||
OutputWebSearchCallItemTypedDict,
|
||||
EasyInputMessageTypedDict,
|
||||
InputMessageItemTypedDict,
|
||||
OutputServerToolItemTypedDict,
|
||||
OutputImageGenerationCallItemTypedDict,
|
||||
OutputFileSearchCallItemTypedDict,
|
||||
FunctionCallOutputItemTypedDict,
|
||||
OutputDatetimeItemTypedDict,
|
||||
FunctionCallItemTypedDict,
|
||||
OutputFunctionCallItemTypedDict,
|
||||
InputsMessageTypedDict,
|
||||
InputsReasoningTypedDict,
|
||||
ReasoningItemTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
InputsUnion1 = TypeAliasType(
|
||||
"InputsUnion1",
|
||||
Union[
|
||||
OutputWebSearchCallItem,
|
||||
EasyInputMessage,
|
||||
InputMessageItem,
|
||||
OutputServerToolItem,
|
||||
OutputImageGenerationCallItem,
|
||||
OutputFileSearchCallItem,
|
||||
FunctionCallOutputItem,
|
||||
OutputDatetimeItem,
|
||||
FunctionCallItem,
|
||||
OutputFunctionCallItem,
|
||||
InputsMessage,
|
||||
InputsReasoning,
|
||||
ReasoningItem,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
InputsUnionTypedDict = TypeAliasType(
|
||||
"InputsUnionTypedDict", Union[str, List[InputsUnion1TypedDict]]
|
||||
)
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
|
||||
|
||||
InputsUnion = TypeAliasType("InputsUnion", Union[str, List[InputsUnion1]])
|
||||
r"""Input for a response request - can be a string or array of items"""
|
||||
Reference in New Issue
Block a user