mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
|
|
from __future__ import annotations
|
|
from .formatjsonobjectconfig import (
|
|
FormatJSONObjectConfig,
|
|
FormatJSONObjectConfigTypedDict,
|
|
)
|
|
from .formatjsonschemaconfig import (
|
|
FormatJSONSchemaConfig,
|
|
FormatJSONSchemaConfigTypedDict,
|
|
)
|
|
from .formattextconfig import FormatTextConfig, FormatTextConfigTypedDict
|
|
from functools import partial
|
|
from openrouter.types import BaseModel
|
|
from openrouter.utils.unions import parse_open_union
|
|
from pydantic import ConfigDict
|
|
from pydantic.functional_validators import BeforeValidator
|
|
from typing import Any, Literal, Union
|
|
from typing_extensions import Annotated, TypeAliasType
|
|
|
|
|
|
FormatsTypedDict = TypeAliasType(
|
|
"FormatsTypedDict",
|
|
Union[
|
|
FormatTextConfigTypedDict,
|
|
FormatJSONObjectConfigTypedDict,
|
|
FormatJSONSchemaConfigTypedDict,
|
|
],
|
|
)
|
|
r"""Text response format configuration"""
|
|
|
|
|
|
class UnknownFormats(BaseModel):
|
|
r"""A Formats 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)
|
|
|
|
|
|
_FORMATS_VARIANTS: dict[str, Any] = {
|
|
"text": FormatTextConfig,
|
|
"json_object": FormatJSONObjectConfig,
|
|
"json_schema": FormatJSONSchemaConfig,
|
|
}
|
|
|
|
|
|
Formats = Annotated[
|
|
Union[
|
|
FormatTextConfig, FormatJSONObjectConfig, FormatJSONSchemaConfig, UnknownFormats
|
|
],
|
|
BeforeValidator(
|
|
partial(
|
|
parse_open_union,
|
|
disc_key="type",
|
|
variants=_FORMATS_VARIANTS,
|
|
unknown_cls=UnknownFormats,
|
|
union_name="Formats",
|
|
)
|
|
),
|
|
]
|
|
r"""Text response format configuration"""
|