mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
Co-authored-by: speakeasybot <bot@speakeasyapi.dev> Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
493 lines
16 KiB
Python
493 lines
16 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 .compactionitem import CompactionItem, CompactionItemTypedDict
|
|
from .customtoolcallitem import CustomToolCallItem, CustomToolCallItemTypedDict
|
|
from .customtoolcalloutputitem import (
|
|
CustomToolCallOutputItem,
|
|
CustomToolCallOutputItemTypedDict,
|
|
)
|
|
from .easyinputmessage import EasyInputMessage, EasyInputMessageTypedDict
|
|
from .functioncallitem import FunctionCallItem, FunctionCallItemTypedDict
|
|
from .functioncalloutputitem import (
|
|
FunctionCallOutputItem,
|
|
FunctionCallOutputItemTypedDict,
|
|
)
|
|
from .inputmessageitem import InputMessageItem, InputMessageItemTypedDict
|
|
from .itemreferenceitem import ItemReferenceItem, ItemReferenceItemTypedDict
|
|
from .localshellcallitem import LocalShellCallItem, LocalShellCallItemTypedDict
|
|
from .localshellcalloutputitem import (
|
|
LocalShellCallOutputItem,
|
|
LocalShellCallOutputItemTypedDict,
|
|
)
|
|
from .mcpapprovalrequestitem import (
|
|
McpApprovalRequestItem,
|
|
McpApprovalRequestItemTypedDict,
|
|
)
|
|
from .mcpapprovalresponseitem import (
|
|
McpApprovalResponseItem,
|
|
McpApprovalResponseItemTypedDict,
|
|
)
|
|
from .mcpcallitem import McpCallItem, McpCallItemTypedDict
|
|
from .mcplisttoolsitem import McpListToolsItem, McpListToolsItemTypedDict
|
|
from .openairesponsesrefusalcontent import (
|
|
OpenAIResponsesRefusalContent,
|
|
OpenAIResponsesRefusalContentTypedDict,
|
|
)
|
|
from .outputadvisorservertoolitem import (
|
|
OutputAdvisorServerToolItem,
|
|
OutputAdvisorServerToolItemTypedDict,
|
|
)
|
|
from .outputapplypatchservertoolitem import (
|
|
OutputApplyPatchServerToolItem,
|
|
OutputApplyPatchServerToolItemTypedDict,
|
|
)
|
|
from .outputbashservertoolitem import (
|
|
OutputBashServerToolItem,
|
|
OutputBashServerToolItemTypedDict,
|
|
)
|
|
from .outputbrowseruseservertoolitem import (
|
|
OutputBrowserUseServerToolItem,
|
|
OutputBrowserUseServerToolItemTypedDict,
|
|
)
|
|
from .outputcodeinterpretercallitem import (
|
|
OutputCodeInterpreterCallItem,
|
|
OutputCodeInterpreterCallItemTypedDict,
|
|
)
|
|
from .outputcodeinterpreterservertoolitem import (
|
|
OutputCodeInterpreterServerToolItem,
|
|
OutputCodeInterpreterServerToolItemTypedDict,
|
|
)
|
|
from .outputcomputercallitem import (
|
|
OutputComputerCallItem,
|
|
OutputComputerCallItemTypedDict,
|
|
)
|
|
from .outputcustomtoolcallitem import (
|
|
OutputCustomToolCallItem,
|
|
OutputCustomToolCallItemTypedDict,
|
|
)
|
|
from .outputdatetimeitem import OutputDatetimeItem, OutputDatetimeItemTypedDict
|
|
from .outputfilesearchcallitem import (
|
|
OutputFileSearchCallItem,
|
|
OutputFileSearchCallItemTypedDict,
|
|
)
|
|
from .outputfilesearchservertoolitem import (
|
|
OutputFileSearchServerToolItem,
|
|
OutputFileSearchServerToolItemTypedDict,
|
|
)
|
|
from .outputfilesservertoolitem import (
|
|
OutputFilesServerToolItem,
|
|
OutputFilesServerToolItemTypedDict,
|
|
)
|
|
from .outputfunctioncallitem import (
|
|
OutputFunctionCallItem,
|
|
OutputFunctionCallItemTypedDict,
|
|
)
|
|
from .outputfusionservertoolitem import (
|
|
OutputFusionServerToolItem,
|
|
OutputFusionServerToolItemTypedDict,
|
|
)
|
|
from .outputimagegenerationcallitem import (
|
|
OutputImageGenerationCallItem,
|
|
OutputImageGenerationCallItemTypedDict,
|
|
)
|
|
from .outputimagegenerationservertoolitem import (
|
|
OutputImageGenerationServerToolItem,
|
|
OutputImageGenerationServerToolItemTypedDict,
|
|
)
|
|
from .outputmcpservertoolitem import (
|
|
OutputMcpServerToolItem,
|
|
OutputMcpServerToolItemTypedDict,
|
|
)
|
|
from .outputmemoryservertoolitem import (
|
|
OutputMemoryServerToolItem,
|
|
OutputMemoryServerToolItemTypedDict,
|
|
)
|
|
from .outputsearchmodelsservertoolitem import (
|
|
OutputSearchModelsServerToolItem,
|
|
OutputSearchModelsServerToolItemTypedDict,
|
|
)
|
|
from .outputsubagentservertoolitem import (
|
|
OutputSubagentServerToolItem,
|
|
OutputSubagentServerToolItemTypedDict,
|
|
)
|
|
from .outputtexteditorservertoolitem import (
|
|
OutputTextEditorServerToolItem,
|
|
OutputTextEditorServerToolItemTypedDict,
|
|
)
|
|
from .outputtoolsearchservertoolitem import (
|
|
OutputToolSearchServerToolItem,
|
|
OutputToolSearchServerToolItemTypedDict,
|
|
)
|
|
from .outputwebfetchservertoolitem import (
|
|
OutputWebFetchServerToolItem,
|
|
OutputWebFetchServerToolItemTypedDict,
|
|
)
|
|
from .outputwebsearchcallitem import (
|
|
OutputWebSearchCallItem,
|
|
OutputWebSearchCallItemTypedDict,
|
|
)
|
|
from .outputwebsearchservertoolitem import (
|
|
OutputWebSearchServerToolItem,
|
|
OutputWebSearchServerToolItemTypedDict,
|
|
)
|
|
from .reasoningformat import ReasoningFormat
|
|
from .reasoningitem import ReasoningItem, ReasoningItemTypedDict
|
|
from .reasoningsummarytext import ReasoningSummaryText, ReasoningSummaryTextTypedDict
|
|
from .reasoningtextcontent import ReasoningTextContent, ReasoningTextContentTypedDict
|
|
from .responseoutputtext import ResponseOutputText, ResponseOutputTextTypedDict
|
|
from .shellcallitem import ShellCallItem, ShellCallItemTypedDict
|
|
from .shellcalloutputitem import ShellCallOutputItem, ShellCallOutputItemTypedDict
|
|
from openrouter.types import (
|
|
BaseModel,
|
|
Nullable,
|
|
OptionalNullable,
|
|
UNSET,
|
|
UNSET_SENTINEL,
|
|
)
|
|
from openrouter.utils import get_discriminator
|
|
import pydantic
|
|
from pydantic import Discriminator, Tag, model_serializer
|
|
from typing import Any, List, Literal, Optional, Union
|
|
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
|
|
|
|
|
InputsStatusInProgress2 = Literal["in_progress",]
|
|
|
|
|
|
InputsStatusIncomplete2 = Literal["incomplete",]
|
|
|
|
|
|
InputsStatusCompleted2 = Literal["completed",]
|
|
|
|
|
|
InputsStatusUnion2TypedDict = TypeAliasType(
|
|
"InputsStatusUnion2TypedDict",
|
|
Union[InputsStatusCompleted2, InputsStatusIncomplete2, InputsStatusInProgress2],
|
|
)
|
|
|
|
|
|
InputsStatusUnion2 = TypeAliasType(
|
|
"InputsStatusUnion2",
|
|
Union[InputsStatusCompleted2, InputsStatusIncomplete2, InputsStatusInProgress2],
|
|
)
|
|
|
|
|
|
InputsTypeReasoning = Literal["reasoning",]
|
|
|
|
|
|
class InputsReasoningTypedDict(TypedDict):
|
|
r"""An output item containing reasoning"""
|
|
|
|
id: str
|
|
summary: Nullable[List[ReasoningSummaryTextTypedDict]]
|
|
type: InputsTypeReasoning
|
|
content: NotRequired[Nullable[List[ReasoningTextContentTypedDict]]]
|
|
encrypted_content: NotRequired[Nullable[str]]
|
|
status: NotRequired[InputsStatusUnion2TypedDict]
|
|
format_: NotRequired[Nullable[ReasoningFormat]]
|
|
signature: NotRequired[Nullable[str]]
|
|
r"""A signature for the reasoning content, used for verification"""
|
|
|
|
|
|
class InputsReasoning(BaseModel):
|
|
r"""An output item containing reasoning"""
|
|
|
|
id: str
|
|
|
|
summary: Nullable[List[ReasoningSummaryText]]
|
|
|
|
type: InputsTypeReasoning
|
|
|
|
content: OptionalNullable[List[ReasoningTextContent]] = UNSET
|
|
|
|
encrypted_content: OptionalNullable[str] = UNSET
|
|
|
|
status: Optional[InputsStatusUnion2] = None
|
|
|
|
format_: Annotated[
|
|
OptionalNullable[ReasoningFormat], pydantic.Field(alias="format")
|
|
] = UNSET
|
|
|
|
signature: OptionalNullable[str] = UNSET
|
|
r"""A signature for the reasoning content, used for verification"""
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(
|
|
["content", "encrypted_content", "status", "format", "signature"]
|
|
)
|
|
nullable_fields = set(
|
|
["content", "encrypted_content", "summary", "format", "signature"]
|
|
)
|
|
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
|
|
|
|
|
|
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."""
|
|
|
|
|
|
InputsRole = Literal["assistant",]
|
|
|
|
|
|
InputsStatusInProgress1 = Literal["in_progress",]
|
|
|
|
|
|
InputsStatusIncomplete1 = Literal["incomplete",]
|
|
|
|
|
|
InputsStatusCompleted1 = Literal["completed",]
|
|
|
|
|
|
InputsStatusUnion1TypedDict = TypeAliasType(
|
|
"InputsStatusUnion1TypedDict",
|
|
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
|
|
)
|
|
|
|
|
|
InputsStatusUnion1 = TypeAliasType(
|
|
"InputsStatusUnion1",
|
|
Union[InputsStatusCompleted1, InputsStatusIncomplete1, InputsStatusInProgress1],
|
|
)
|
|
|
|
|
|
InputsTypeMessage = Literal["message",]
|
|
|
|
|
|
class InputsMessageTypedDict(TypedDict):
|
|
r"""An output message item"""
|
|
|
|
content: Nullable[InputsContent2TypedDict]
|
|
id: str
|
|
role: InputsRole
|
|
type: InputsTypeMessage
|
|
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."""
|
|
status: NotRequired[InputsStatusUnion1TypedDict]
|
|
|
|
|
|
class InputsMessage(BaseModel):
|
|
r"""An output message item"""
|
|
|
|
content: Nullable[InputsContent2]
|
|
|
|
id: str
|
|
|
|
role: InputsRole
|
|
|
|
type: InputsTypeMessage
|
|
|
|
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."""
|
|
|
|
status: Optional[InputsStatusUnion1] = None
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["phase", "status"])
|
|
nullable_fields = set(["content", "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
|
|
|
|
|
|
InputsUnion1TypedDict = TypeAliasType(
|
|
"InputsUnion1TypedDict",
|
|
Union[
|
|
ItemReferenceItemTypedDict,
|
|
CompactionItemTypedDict,
|
|
OutputFileSearchCallItemTypedDict,
|
|
EasyInputMessageTypedDict,
|
|
InputMessageItemTypedDict,
|
|
LocalShellCallOutputItemTypedDict,
|
|
OutputToolSearchServerToolItemTypedDict,
|
|
OutputFileSearchServerToolItemTypedDict,
|
|
OutputWebSearchServerToolItemTypedDict,
|
|
CustomToolCallOutputItemTypedDict,
|
|
OutputImageGenerationCallItemTypedDict,
|
|
OutputWebSearchCallItemTypedDict,
|
|
OutputDatetimeItemTypedDict,
|
|
OutputMcpServerToolItemTypedDict,
|
|
FunctionCallOutputItemTypedDict,
|
|
OutputSearchModelsServerToolItemTypedDict,
|
|
LocalShellCallItemTypedDict,
|
|
ApplyPatchCallItemTypedDict,
|
|
McpListToolsItemTypedDict,
|
|
ApplyPatchCallOutputItemTypedDict,
|
|
McpApprovalResponseItemTypedDict,
|
|
OutputBrowserUseServerToolItemTypedDict,
|
|
McpApprovalRequestItemTypedDict,
|
|
OutputTextEditorServerToolItemTypedDict,
|
|
OutputApplyPatchServerToolItemTypedDict,
|
|
CustomToolCallItemTypedDict,
|
|
InputsMessageTypedDict,
|
|
OutputMemoryServerToolItemTypedDict,
|
|
OutputCustomToolCallItemTypedDict,
|
|
OutputComputerCallItemTypedDict,
|
|
ShellCallOutputItemTypedDict,
|
|
ShellCallItemTypedDict,
|
|
OutputCodeInterpreterCallItemTypedDict,
|
|
OutputBashServerToolItemTypedDict,
|
|
OutputImageGenerationServerToolItemTypedDict,
|
|
McpCallItemTypedDict,
|
|
OutputFunctionCallItemTypedDict,
|
|
FunctionCallItemTypedDict,
|
|
OutputFilesServerToolItemTypedDict,
|
|
OutputSubagentServerToolItemTypedDict,
|
|
OutputAdvisorServerToolItemTypedDict,
|
|
OutputWebFetchServerToolItemTypedDict,
|
|
ReasoningItemTypedDict,
|
|
OutputCodeInterpreterServerToolItemTypedDict,
|
|
InputsReasoningTypedDict,
|
|
OutputFusionServerToolItemTypedDict,
|
|
],
|
|
)
|
|
|
|
|
|
InputsUnion1 = TypeAliasType(
|
|
"InputsUnion1",
|
|
Union[
|
|
ItemReferenceItem,
|
|
CompactionItem,
|
|
OutputFileSearchCallItem,
|
|
EasyInputMessage,
|
|
InputMessageItem,
|
|
LocalShellCallOutputItem,
|
|
OutputToolSearchServerToolItem,
|
|
OutputFileSearchServerToolItem,
|
|
OutputWebSearchServerToolItem,
|
|
CustomToolCallOutputItem,
|
|
OutputImageGenerationCallItem,
|
|
OutputWebSearchCallItem,
|
|
OutputDatetimeItem,
|
|
OutputMcpServerToolItem,
|
|
FunctionCallOutputItem,
|
|
OutputSearchModelsServerToolItem,
|
|
LocalShellCallItem,
|
|
ApplyPatchCallItem,
|
|
McpListToolsItem,
|
|
ApplyPatchCallOutputItem,
|
|
McpApprovalResponseItem,
|
|
OutputBrowserUseServerToolItem,
|
|
McpApprovalRequestItem,
|
|
OutputTextEditorServerToolItem,
|
|
OutputApplyPatchServerToolItem,
|
|
CustomToolCallItem,
|
|
InputsMessage,
|
|
OutputMemoryServerToolItem,
|
|
OutputCustomToolCallItem,
|
|
OutputComputerCallItem,
|
|
ShellCallOutputItem,
|
|
ShellCallItem,
|
|
OutputCodeInterpreterCallItem,
|
|
OutputBashServerToolItem,
|
|
OutputImageGenerationServerToolItem,
|
|
McpCallItem,
|
|
OutputFunctionCallItem,
|
|
FunctionCallItem,
|
|
OutputFilesServerToolItem,
|
|
OutputSubagentServerToolItem,
|
|
OutputAdvisorServerToolItem,
|
|
OutputWebFetchServerToolItem,
|
|
ReasoningItem,
|
|
OutputCodeInterpreterServerToolItem,
|
|
InputsReasoning,
|
|
OutputFusionServerToolItem,
|
|
],
|
|
)
|
|
|
|
|
|
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"""
|
|
|
|
|
|
try:
|
|
InputsReasoning.model_rebuild()
|
|
except NameError:
|
|
pass
|