mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
Commits included in this export:
- 6ddaaa6989d725bbe966e45f7aed0c1bd72f9153 - 4779741b6ba710b1299612b82e8544516bd9dd6a - 22083fcc8f58884d8212d6f3314b231c4ddd21cd - a925a620f97196d509e073a163caac053bd82316 - 5c05d8829784601ffd151acef1a6978c266f913d - 6f4fff535fbf4274255c255ae23620b8e00e614f - ef358e96cb01e469b77d44683603a602b0813116 - e6299b4ebfe5c2eed6c598771f0fd99f84555401 - 24d3f0ee1c2aa19a62f7902836034080b9246813 - 68922847c2969b773887310eb7aa9a814e199c5a - 729ee2338c39df22461526153e7f4ba868fd498e - e1074ff86fccf5e48406b7595298873106d3cc5a - 123bbdaf841d299162a82ee2573adfbb70a45b8f - ac457b8a8dad98fdf5ddcae8dd4711361cea3084 - ea825199f4c59dd68fec01cf8d18a582963c9f25 - 4d48e4f6bb936e785787314a965298da6b78fea0 - 718729a573ee98893a4408d5a52ab4686661fe54 - b867adcde6b64f3f2a11c4626254b39098e4b0b4 - 21912c097b4066d109766c6b4492826595cd57c5 - bc1ed85adc976a4634ca8a41b82e4fc2c39a864f - d145c89c941937a312ed1357590d2bfda9a3603d - 12f05b5dee397ead47cfcd545a7a2e3c7ff57524 - dd28f75a19a015809797c7abf3f8758f7c37262e - c96e569781e07ab44172d9c69940ec17bafd81f4 - c9d5a90e3c2b5077a2bdd49773f1a46d1a5a79c7 - 58b08f87116ceab9076de2fdc0a4c74c919b44c4 GitOrigin-RevId: 6ddaaa6989d725bbe966e45f7aed0c1bd72f9153
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
Schema21 = Union[
|
||||
Literal[
|
||||
"unknown",
|
||||
"openai-responses-v1",
|
||||
"azure-openai-responses-v1",
|
||||
"xai-responses-v1",
|
||||
"anthropic-claude-v1",
|
||||
"google-gemini-v1",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class Schema19ReasoningTextTypedDict(TypedDict):
|
||||
type: Literal["reasoning.text"]
|
||||
text: NotRequired[Nullable[str]]
|
||||
signature: NotRequired[Nullable[str]]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema21]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema19ReasoningText(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["reasoning.text"], AfterValidator(validate_const("reasoning.text"))
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "reasoning.text"
|
||||
|
||||
text: OptionalNullable[str] = UNSET
|
||||
|
||||
signature: OptionalNullable[str] = UNSET
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[Schema21], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["text", "signature", "id", "format", "index"]
|
||||
nullable_fields = ["text", "signature", "id", "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
|
||||
|
||||
|
||||
class Schema19ReasoningEncryptedTypedDict(TypedDict):
|
||||
data: str
|
||||
type: Literal["reasoning.encrypted"]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema21]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema19ReasoningEncrypted(BaseModel):
|
||||
data: str
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["reasoning.encrypted"],
|
||||
AfterValidator(validate_const("reasoning.encrypted")),
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "reasoning.encrypted"
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[Schema21], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "format", "index"]
|
||||
nullable_fields = ["id", "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
|
||||
|
||||
|
||||
class Schema19ReasoningSummaryTypedDict(TypedDict):
|
||||
summary: str
|
||||
type: Literal["reasoning.summary"]
|
||||
id: NotRequired[Nullable[str]]
|
||||
format_: NotRequired[Nullable[Schema21]]
|
||||
index: NotRequired[float]
|
||||
|
||||
|
||||
class Schema19ReasoningSummary(BaseModel):
|
||||
summary: str
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
Literal["reasoning.summary"],
|
||||
AfterValidator(validate_const("reasoning.summary")),
|
||||
],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "reasoning.summary"
|
||||
|
||||
id: OptionalNullable[str] = UNSET
|
||||
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
OptionalNullable[Schema21], PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
] = UNSET
|
||||
|
||||
index: Optional[float] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["id", "format", "index"]
|
||||
nullable_fields = ["id", "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
|
||||
|
||||
|
||||
Schema19TypedDict = TypeAliasType(
|
||||
"Schema19TypedDict",
|
||||
Union[
|
||||
Schema19ReasoningSummaryTypedDict,
|
||||
Schema19ReasoningEncryptedTypedDict,
|
||||
Schema19ReasoningTextTypedDict,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Schema19 = Annotated[
|
||||
Union[
|
||||
Annotated[Schema19ReasoningSummary, Tag("reasoning.summary")],
|
||||
Annotated[Schema19ReasoningEncrypted, Tag("reasoning.encrypted")],
|
||||
Annotated[Schema19ReasoningText, Tag("reasoning.text")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
Reference in New Issue
Block a user