mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-29 11:23:49 +08:00
updates
This commit is contained in:
@@ -21,7 +21,6 @@ if TYPE_CHECKING:
|
||||
BadRequestResponseErrorData,
|
||||
BadRequestResponseErrorDataTypedDict,
|
||||
)
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chaterror import ChatErrorError, ChatErrorErrorTypedDict, Code, CodeTypedDict
|
||||
from .chatgenerationparams import (
|
||||
ChatGenerationParams,
|
||||
@@ -36,8 +35,6 @@ if TYPE_CHECKING:
|
||||
ChatGenerationParamsStop,
|
||||
ChatGenerationParamsStopTypedDict,
|
||||
ChatGenerationParamsTypedDict,
|
||||
Debug,
|
||||
DebugTypedDict,
|
||||
Effort,
|
||||
Reasoning,
|
||||
ReasoningTypedDict,
|
||||
@@ -56,14 +53,16 @@ if TYPE_CHECKING:
|
||||
)
|
||||
from .chatmessagecontentitemaudio import (
|
||||
ChatMessageContentItemAudio,
|
||||
ChatMessageContentItemAudioFormat,
|
||||
ChatMessageContentItemAudioInputAudio,
|
||||
ChatMessageContentItemAudioInputAudioTypedDict,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemcachecontrol import (
|
||||
ChatMessageContentItemCacheControl,
|
||||
ChatMessageContentItemCacheControlTypedDict,
|
||||
TTL,
|
||||
from .chatmessagecontentitemfile import (
|
||||
ChatMessageContentItemFile,
|
||||
ChatMessageContentItemFileTypedDict,
|
||||
File,
|
||||
FileTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemimage import (
|
||||
ChatMessageContentItemImage,
|
||||
@@ -83,10 +82,8 @@ if TYPE_CHECKING:
|
||||
ChatMessageContentItemVideoTypedDict,
|
||||
ChatMessageContentItemVideoVideoURL,
|
||||
ChatMessageContentItemVideoVideoURLTypedDict,
|
||||
VideoURL1,
|
||||
VideoURL1TypedDict,
|
||||
VideoURL2,
|
||||
VideoURL2TypedDict,
|
||||
ChatMessageContentItemVideoVideoURLVideoURL,
|
||||
ChatMessageContentItemVideoVideoURLVideoURLTypedDict,
|
||||
)
|
||||
from .chatmessagetokenlogprob import (
|
||||
ChatMessageTokenLogprob,
|
||||
@@ -105,8 +102,13 @@ if TYPE_CHECKING:
|
||||
ChatMessageToolCallTypedDict,
|
||||
)
|
||||
from .chatresponse import ChatResponse, ChatResponseTypedDict
|
||||
from .chatresponsechoice import ChatResponseChoice, ChatResponseChoiceTypedDict
|
||||
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||
from .chatresponsechoice import (
|
||||
ChatCompletionFinishReason,
|
||||
ChatResponseChoice,
|
||||
ChatResponseChoiceTypedDict,
|
||||
ChatStreamingChoice,
|
||||
ChatStreamingChoiceTypedDict,
|
||||
)
|
||||
from .chatstreamingmessagechunk import (
|
||||
ChatStreamingMessageChunk,
|
||||
ChatStreamingMessageChunkRole,
|
||||
@@ -424,7 +426,6 @@ if TYPE_CHECKING:
|
||||
Engine,
|
||||
IDFileParser,
|
||||
IDModeration,
|
||||
IDResponseHealing,
|
||||
IDWeb,
|
||||
Ignore,
|
||||
IgnoreTypedDict,
|
||||
@@ -449,8 +450,6 @@ if TYPE_CHECKING:
|
||||
PluginFileParserTypedDict,
|
||||
PluginModeration,
|
||||
PluginModerationTypedDict,
|
||||
PluginResponseHealing,
|
||||
PluginResponseHealingTypedDict,
|
||||
PluginTypedDict,
|
||||
PluginWeb,
|
||||
PluginWebTypedDict,
|
||||
@@ -785,6 +784,7 @@ if TYPE_CHECKING:
|
||||
UserMessageContentTypedDict,
|
||||
UserMessageTypedDict,
|
||||
)
|
||||
from .videourl import VideoURL, VideoURLTypedDict
|
||||
from .websearchpreviewtooluserlocation import (
|
||||
WebSearchPreviewToolUserLocation,
|
||||
WebSearchPreviewToolUserLocationType,
|
||||
@@ -825,11 +825,12 @@ __all__ = [
|
||||
"ChatGenerationTokenUsageTypedDict",
|
||||
"ChatMessageContentItem",
|
||||
"ChatMessageContentItemAudio",
|
||||
"ChatMessageContentItemAudioFormat",
|
||||
"ChatMessageContentItemAudioInputAudio",
|
||||
"ChatMessageContentItemAudioInputAudioTypedDict",
|
||||
"ChatMessageContentItemAudioTypedDict",
|
||||
"ChatMessageContentItemCacheControl",
|
||||
"ChatMessageContentItemCacheControlTypedDict",
|
||||
"ChatMessageContentItemFile",
|
||||
"ChatMessageContentItemFileTypedDict",
|
||||
"ChatMessageContentItemImage",
|
||||
"ChatMessageContentItemImageDetail",
|
||||
"ChatMessageContentItemImageTypedDict",
|
||||
@@ -842,6 +843,8 @@ __all__ = [
|
||||
"ChatMessageContentItemVideoTypedDict",
|
||||
"ChatMessageContentItemVideoVideoURL",
|
||||
"ChatMessageContentItemVideoVideoURLTypedDict",
|
||||
"ChatMessageContentItemVideoVideoURLVideoURL",
|
||||
"ChatMessageContentItemVideoVideoURLVideoURLTypedDict",
|
||||
"ChatMessageTokenLogprob",
|
||||
"ChatMessageTokenLogprobTypedDict",
|
||||
"ChatMessageTokenLogprobs",
|
||||
@@ -902,8 +905,6 @@ __all__ = [
|
||||
"CreateChargeRequest",
|
||||
"CreateChargeRequestTypedDict",
|
||||
"DataCollection",
|
||||
"Debug",
|
||||
"DebugTypedDict",
|
||||
"DefaultParameters",
|
||||
"DefaultParametersTypedDict",
|
||||
"EdgeNetworkTimeoutResponseErrorData",
|
||||
@@ -911,17 +912,18 @@ __all__ = [
|
||||
"Effort",
|
||||
"EndpointStatus",
|
||||
"Engine",
|
||||
"File",
|
||||
"FileCitation",
|
||||
"FileCitationType",
|
||||
"FileCitationTypedDict",
|
||||
"FilePath",
|
||||
"FilePathType",
|
||||
"FilePathTypedDict",
|
||||
"FileTypedDict",
|
||||
"ForbiddenResponseErrorData",
|
||||
"ForbiddenResponseErrorDataTypedDict",
|
||||
"IDFileParser",
|
||||
"IDModeration",
|
||||
"IDResponseHealing",
|
||||
"IDWeb",
|
||||
"Ignore",
|
||||
"IgnoreTypedDict",
|
||||
@@ -1215,8 +1217,6 @@ __all__ = [
|
||||
"PluginFileParserTypedDict",
|
||||
"PluginModeration",
|
||||
"PluginModerationTypedDict",
|
||||
"PluginResponseHealing",
|
||||
"PluginResponseHealingTypedDict",
|
||||
"PluginTypedDict",
|
||||
"PluginWeb",
|
||||
"PluginWebTypedDict",
|
||||
@@ -1342,7 +1342,6 @@ __all__ = [
|
||||
"SystemMessageContent",
|
||||
"SystemMessageContentTypedDict",
|
||||
"SystemMessageTypedDict",
|
||||
"TTL",
|
||||
"Tokenizer",
|
||||
"TooManyRequestsResponseErrorData",
|
||||
"TooManyRequestsResponseErrorDataTypedDict",
|
||||
@@ -1392,10 +1391,8 @@ __all__ = [
|
||||
"UserMessageTypedDict",
|
||||
"Variables",
|
||||
"VariablesTypedDict",
|
||||
"VideoURL1",
|
||||
"VideoURL1TypedDict",
|
||||
"VideoURL2",
|
||||
"VideoURL2TypedDict",
|
||||
"VideoURL",
|
||||
"VideoURLTypedDict",
|
||||
"WebSearchPreviewToolUserLocation",
|
||||
"WebSearchPreviewToolUserLocationType",
|
||||
"WebSearchPreviewToolUserLocationTypedDict",
|
||||
@@ -1413,7 +1410,6 @@ _dynamic_imports: dict[str, str] = {
|
||||
"BadGatewayResponseErrorDataTypedDict": ".badgatewayresponseerrordata",
|
||||
"BadRequestResponseErrorData": ".badrequestresponseerrordata",
|
||||
"BadRequestResponseErrorDataTypedDict": ".badrequestresponseerrordata",
|
||||
"ChatCompletionFinishReason": ".chatcompletionfinishreason",
|
||||
"ChatErrorError": ".chaterror",
|
||||
"ChatErrorErrorTypedDict": ".chaterror",
|
||||
"Code": ".chaterror",
|
||||
@@ -1430,8 +1426,6 @@ _dynamic_imports: dict[str, str] = {
|
||||
"ChatGenerationParamsStop": ".chatgenerationparams",
|
||||
"ChatGenerationParamsStopTypedDict": ".chatgenerationparams",
|
||||
"ChatGenerationParamsTypedDict": ".chatgenerationparams",
|
||||
"Debug": ".chatgenerationparams",
|
||||
"DebugTypedDict": ".chatgenerationparams",
|
||||
"Effort": ".chatgenerationparams",
|
||||
"Reasoning": ".chatgenerationparams",
|
||||
"ReasoningTypedDict": ".chatgenerationparams",
|
||||
@@ -1444,12 +1438,14 @@ _dynamic_imports: dict[str, str] = {
|
||||
"ChatMessageContentItem": ".chatmessagecontentitem",
|
||||
"ChatMessageContentItemTypedDict": ".chatmessagecontentitem",
|
||||
"ChatMessageContentItemAudio": ".chatmessagecontentitemaudio",
|
||||
"ChatMessageContentItemAudioFormat": ".chatmessagecontentitemaudio",
|
||||
"ChatMessageContentItemAudioInputAudio": ".chatmessagecontentitemaudio",
|
||||
"ChatMessageContentItemAudioInputAudioTypedDict": ".chatmessagecontentitemaudio",
|
||||
"ChatMessageContentItemAudioTypedDict": ".chatmessagecontentitemaudio",
|
||||
"ChatMessageContentItemCacheControl": ".chatmessagecontentitemcachecontrol",
|
||||
"ChatMessageContentItemCacheControlTypedDict": ".chatmessagecontentitemcachecontrol",
|
||||
"TTL": ".chatmessagecontentitemcachecontrol",
|
||||
"ChatMessageContentItemFile": ".chatmessagecontentitemfile",
|
||||
"ChatMessageContentItemFileTypedDict": ".chatmessagecontentitemfile",
|
||||
"File": ".chatmessagecontentitemfile",
|
||||
"FileTypedDict": ".chatmessagecontentitemfile",
|
||||
"ChatMessageContentItemImage": ".chatmessagecontentitemimage",
|
||||
"ChatMessageContentItemImageDetail": ".chatmessagecontentitemimage",
|
||||
"ChatMessageContentItemImageTypedDict": ".chatmessagecontentitemimage",
|
||||
@@ -1463,10 +1459,8 @@ _dynamic_imports: dict[str, str] = {
|
||||
"ChatMessageContentItemVideoTypedDict": ".chatmessagecontentitemvideo",
|
||||
"ChatMessageContentItemVideoVideoURL": ".chatmessagecontentitemvideo",
|
||||
"ChatMessageContentItemVideoVideoURLTypedDict": ".chatmessagecontentitemvideo",
|
||||
"VideoURL1": ".chatmessagecontentitemvideo",
|
||||
"VideoURL1TypedDict": ".chatmessagecontentitemvideo",
|
||||
"VideoURL2": ".chatmessagecontentitemvideo",
|
||||
"VideoURL2TypedDict": ".chatmessagecontentitemvideo",
|
||||
"ChatMessageContentItemVideoVideoURLVideoURL": ".chatmessagecontentitemvideo",
|
||||
"ChatMessageContentItemVideoVideoURLVideoURLTypedDict": ".chatmessagecontentitemvideo",
|
||||
"ChatMessageTokenLogprob": ".chatmessagetokenlogprob",
|
||||
"ChatMessageTokenLogprobTypedDict": ".chatmessagetokenlogprob",
|
||||
"TopLogprob": ".chatmessagetokenlogprob",
|
||||
@@ -1479,10 +1473,11 @@ _dynamic_imports: dict[str, str] = {
|
||||
"ChatMessageToolCallTypedDict": ".chatmessagetoolcall",
|
||||
"ChatResponse": ".chatresponse",
|
||||
"ChatResponseTypedDict": ".chatresponse",
|
||||
"ChatCompletionFinishReason": ".chatresponsechoice",
|
||||
"ChatResponseChoice": ".chatresponsechoice",
|
||||
"ChatResponseChoiceTypedDict": ".chatresponsechoice",
|
||||
"ChatStreamingChoice": ".chatstreamingchoice",
|
||||
"ChatStreamingChoiceTypedDict": ".chatstreamingchoice",
|
||||
"ChatStreamingChoice": ".chatresponsechoice",
|
||||
"ChatStreamingChoiceTypedDict": ".chatresponsechoice",
|
||||
"ChatStreamingMessageChunk": ".chatstreamingmessagechunk",
|
||||
"ChatStreamingMessageChunkRole": ".chatstreamingmessagechunk",
|
||||
"ChatStreamingMessageChunkTypedDict": ".chatstreamingmessagechunk",
|
||||
@@ -1729,7 +1724,6 @@ _dynamic_imports: dict[str, str] = {
|
||||
"Engine": ".openresponsesrequest",
|
||||
"IDFileParser": ".openresponsesrequest",
|
||||
"IDModeration": ".openresponsesrequest",
|
||||
"IDResponseHealing": ".openresponsesrequest",
|
||||
"IDWeb": ".openresponsesrequest",
|
||||
"Ignore": ".openresponsesrequest",
|
||||
"IgnoreTypedDict": ".openresponsesrequest",
|
||||
@@ -1754,8 +1748,6 @@ _dynamic_imports: dict[str, str] = {
|
||||
"PluginFileParserTypedDict": ".openresponsesrequest",
|
||||
"PluginModeration": ".openresponsesrequest",
|
||||
"PluginModerationTypedDict": ".openresponsesrequest",
|
||||
"PluginResponseHealing": ".openresponsesrequest",
|
||||
"PluginResponseHealingTypedDict": ".openresponsesrequest",
|
||||
"PluginTypedDict": ".openresponsesrequest",
|
||||
"PluginWeb": ".openresponsesrequest",
|
||||
"PluginWebTypedDict": ".openresponsesrequest",
|
||||
@@ -2006,6 +1998,8 @@ _dynamic_imports: dict[str, str] = {
|
||||
"UserMessageContent": ".usermessage",
|
||||
"UserMessageContentTypedDict": ".usermessage",
|
||||
"UserMessageTypedDict": ".usermessage",
|
||||
"VideoURL": ".videourl",
|
||||
"VideoURLTypedDict": ".videourl",
|
||||
"WebSearchPreviewToolUserLocation": ".websearchpreviewtooluserlocation",
|
||||
"WebSearchPreviewToolUserLocationType": ".websearchpreviewtooluserlocation",
|
||||
"WebSearchPreviewToolUserLocationTypedDict": ".websearchpreviewtooluserlocation",
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import UnrecognizedStr
|
||||
from typing import Literal, Union
|
||||
|
||||
|
||||
ChatCompletionFinishReason = Union[
|
||||
Literal[
|
||||
"tool_calls",
|
||||
"stop",
|
||||
"length",
|
||||
"content_filter",
|
||||
"error",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
@@ -156,14 +156,6 @@ ChatGenerationParamsStop = TypeAliasType(
|
||||
)
|
||||
|
||||
|
||||
class DebugTypedDict(TypedDict):
|
||||
echo_upstream_body: NotRequired[bool]
|
||||
|
||||
|
||||
class Debug(BaseModel):
|
||||
echo_upstream_body: Optional[bool] = None
|
||||
|
||||
|
||||
class ChatGenerationParamsTypedDict(TypedDict):
|
||||
messages: List[MessageTypedDict]
|
||||
model: NotRequired[str]
|
||||
@@ -187,7 +179,6 @@ class ChatGenerationParamsTypedDict(TypedDict):
|
||||
tools: NotRequired[List[ToolDefinitionJSONTypedDict]]
|
||||
top_p: NotRequired[Nullable[float]]
|
||||
user: NotRequired[str]
|
||||
debug: NotRequired[DebugTypedDict]
|
||||
|
||||
|
||||
class ChatGenerationParams(BaseModel):
|
||||
@@ -235,8 +226,6 @@ class ChatGenerationParams(BaseModel):
|
||||
|
||||
user: Optional[str] = None
|
||||
|
||||
debug: Optional[Debug] = None
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = [
|
||||
@@ -261,7 +250,6 @@ class ChatGenerationParams(BaseModel):
|
||||
"tools",
|
||||
"top_p",
|
||||
"user",
|
||||
"debug",
|
||||
]
|
||||
nullable_fields = [
|
||||
"frequency_penalty",
|
||||
|
||||
@@ -5,6 +5,10 @@ from .chatmessagecontentitemaudio import (
|
||||
ChatMessageContentItemAudio,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemfile import (
|
||||
ChatMessageContentItemFile,
|
||||
ChatMessageContentItemFileTypedDict,
|
||||
)
|
||||
from .chatmessagecontentitemimage import (
|
||||
ChatMessageContentItemImage,
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
@@ -26,9 +30,10 @@ from typing_extensions import Annotated, TypeAliasType
|
||||
ChatMessageContentItemTypedDict = TypeAliasType(
|
||||
"ChatMessageContentItemTypedDict",
|
||||
Union[
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
ChatMessageContentItemImageTypedDict,
|
||||
ChatMessageContentItemAudioTypedDict,
|
||||
ChatMessageContentItemTextTypedDict,
|
||||
ChatMessageContentItemFileTypedDict,
|
||||
ChatMessageContentItemVideoTypedDict,
|
||||
],
|
||||
)
|
||||
@@ -41,6 +46,7 @@ ChatMessageContentItem = Annotated[
|
||||
Annotated[ChatMessageContentItemAudio, Tag("input_audio")],
|
||||
Annotated[ChatMessageContentItemVideo, Tag("input_video")],
|
||||
Annotated[ChatMessageContentItemVideo, Tag("video_url")],
|
||||
Annotated[ChatMessageContentItemFile, Tag("file")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "type", "type")),
|
||||
]
|
||||
|
||||
@@ -1,23 +1,42 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
ChatMessageContentItemAudioFormat = Union[
|
||||
Literal[
|
||||
"wav",
|
||||
"mp3",
|
||||
"flac",
|
||||
"m4a",
|
||||
"ogg",
|
||||
"pcm16",
|
||||
"pcm24",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioInputAudioTypedDict(TypedDict):
|
||||
data: str
|
||||
format_: str
|
||||
format_: ChatMessageContentItemAudioFormat
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioInputAudio(BaseModel):
|
||||
data: str
|
||||
|
||||
format_: Annotated[str, pydantic.Field(alias="format")]
|
||||
format_: Annotated[
|
||||
Annotated[
|
||||
ChatMessageContentItemAudioFormat, PlainValidator(validate_open_enum(False))
|
||||
],
|
||||
pydantic.Field(alias="format"),
|
||||
]
|
||||
|
||||
|
||||
class ChatMessageContentItemAudioTypedDict(TypedDict):
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel, UnrecognizedStr
|
||||
from openrouter.utils import validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
TTL = Union[
|
||||
Literal[
|
||||
"5m",
|
||||
"1h",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ChatMessageContentItemCacheControlTypedDict(TypedDict):
|
||||
type: Literal["ephemeral"]
|
||||
ttl: NotRequired[TTL]
|
||||
|
||||
|
||||
class ChatMessageContentItemCacheControl(BaseModel):
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["ephemeral"], AfterValidator(validate_const("ephemeral"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "ephemeral"
|
||||
|
||||
ttl: Annotated[Optional[TTL], PlainValidator(validate_open_enum(False))] = None
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class FileTypedDict(TypedDict):
|
||||
file_data: str
|
||||
file_id: NotRequired[str]
|
||||
filename: NotRequired[str]
|
||||
|
||||
|
||||
class File(BaseModel):
|
||||
file_data: str
|
||||
|
||||
file_id: Optional[str] = None
|
||||
|
||||
filename: Optional[str] = None
|
||||
|
||||
|
||||
class ChatMessageContentItemFileTypedDict(TypedDict):
|
||||
file: FileTypedDict
|
||||
type: Literal["file"]
|
||||
|
||||
|
||||
class ChatMessageContentItemFile(BaseModel):
|
||||
file: File
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["file"], AfterValidator(validate_const("file"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "file"
|
||||
@@ -1,22 +1,17 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatmessagecontentitemcachecontrol import (
|
||||
ChatMessageContentItemCacheControl,
|
||||
ChatMessageContentItemCacheControlTypedDict,
|
||||
)
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import validate_const
|
||||
import pydantic
|
||||
from pydantic.functional_validators import AfterValidator
|
||||
from typing import Literal, Optional
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing import Literal
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
class ChatMessageContentItemTextTypedDict(TypedDict):
|
||||
text: str
|
||||
type: Literal["text"]
|
||||
cache_control: NotRequired[ChatMessageContentItemCacheControlTypedDict]
|
||||
|
||||
|
||||
class ChatMessageContentItemText(BaseModel):
|
||||
@@ -26,5 +21,3 @@ class ChatMessageContentItemText(BaseModel):
|
||||
Annotated[Literal["text"], AfterValidator(validate_const("text"))],
|
||||
pydantic.Field(alias="type"),
|
||||
] = "text"
|
||||
|
||||
cache_control: Optional[ChatMessageContentItemCacheControl] = None
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .videourl import VideoURL, VideoURLTypedDict
|
||||
from openrouter.types import BaseModel
|
||||
from openrouter.utils import get_discriminator, validate_const
|
||||
import pydantic
|
||||
@@ -10,21 +11,21 @@ from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypeAliasType, TypedDict
|
||||
|
||||
|
||||
class VideoURL2TypedDict(TypedDict):
|
||||
class ChatMessageContentItemVideoVideoURLVideoURLTypedDict(TypedDict):
|
||||
url: str
|
||||
|
||||
|
||||
class VideoURL2(BaseModel):
|
||||
class ChatMessageContentItemVideoVideoURLVideoURL(BaseModel):
|
||||
url: str
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoVideoURLTypedDict(TypedDict):
|
||||
video_url: VideoURL2TypedDict
|
||||
video_url: ChatMessageContentItemVideoVideoURLVideoURLTypedDict
|
||||
type: Literal["video_url"]
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoVideoURL(BaseModel):
|
||||
video_url: VideoURL2
|
||||
video_url: ChatMessageContentItemVideoVideoURLVideoURL
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[Literal["video_url"], AfterValidator(validate_const("video_url"))],
|
||||
@@ -32,21 +33,13 @@ class ChatMessageContentItemVideoVideoURL(BaseModel):
|
||||
] = "video_url"
|
||||
|
||||
|
||||
class VideoURL1TypedDict(TypedDict):
|
||||
url: str
|
||||
|
||||
|
||||
class VideoURL1(BaseModel):
|
||||
url: str
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoInputVideoTypedDict(TypedDict):
|
||||
video_url: VideoURL1TypedDict
|
||||
video_url: VideoURLTypedDict
|
||||
type: Literal["input_video"]
|
||||
|
||||
|
||||
class ChatMessageContentItemVideoInputVideo(BaseModel):
|
||||
video_url: VideoURL1
|
||||
video_url: VideoURL
|
||||
|
||||
TYPE: Annotated[
|
||||
Annotated[
|
||||
|
||||
@@ -2,24 +2,41 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from .assistantmessage import AssistantMessage, AssistantMessageTypedDict
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
ChatMessageTokenLogprobs,
|
||||
ChatMessageTokenLogprobsTypedDict,
|
||||
)
|
||||
from .chatstreamingmessagechunk import (
|
||||
ChatStreamingMessageChunk,
|
||||
ChatStreamingMessageChunkTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
ChatCompletionFinishReason = Union[
|
||||
Literal[
|
||||
"tool_calls",
|
||||
"stop",
|
||||
"length",
|
||||
"content_filter",
|
||||
"error",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
class ChatResponseChoiceTypedDict(TypedDict):
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
index: float
|
||||
@@ -67,3 +84,52 @@ class ChatResponseChoice(BaseModel):
|
||||
m[k] = val
|
||||
|
||||
return m
|
||||
|
||||
|
||||
class ChatStreamingChoiceTypedDict(TypedDict):
|
||||
delta: ChatStreamingMessageChunkTypedDict
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
index: float
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
|
||||
|
||||
class ChatStreamingChoice(BaseModel):
|
||||
delta: ChatStreamingMessageChunk
|
||||
|
||||
finish_reason: Annotated[
|
||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
index: float
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["logprobs"]
|
||||
nullable_fields = ["finish_reason", "logprobs"]
|
||||
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
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from .chatcompletionfinishreason import ChatCompletionFinishReason
|
||||
from .chatmessagetokenlogprobs import (
|
||||
ChatMessageTokenLogprobs,
|
||||
ChatMessageTokenLogprobsTypedDict,
|
||||
)
|
||||
from .chatstreamingmessagechunk import (
|
||||
ChatStreamingMessageChunk,
|
||||
ChatStreamingMessageChunkTypedDict,
|
||||
)
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
)
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
|
||||
|
||||
class ChatStreamingChoiceTypedDict(TypedDict):
|
||||
delta: ChatStreamingMessageChunkTypedDict
|
||||
finish_reason: Nullable[ChatCompletionFinishReason]
|
||||
index: float
|
||||
logprobs: NotRequired[Nullable[ChatMessageTokenLogprobsTypedDict]]
|
||||
|
||||
|
||||
class ChatStreamingChoice(BaseModel):
|
||||
delta: ChatStreamingMessageChunk
|
||||
|
||||
finish_reason: Annotated[
|
||||
Nullable[ChatCompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
index: float
|
||||
|
||||
logprobs: OptionalNullable[ChatMessageTokenLogprobs] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["logprobs"]
|
||||
nullable_fields = ["finish_reason", "logprobs"]
|
||||
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
|
||||
@@ -5,7 +5,7 @@ from .chatgenerationtokenusage import (
|
||||
ChatGenerationTokenUsage,
|
||||
ChatGenerationTokenUsageTypedDict,
|
||||
)
|
||||
from .chatstreamingchoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||
from .chatresponsechoice import ChatStreamingChoice, ChatStreamingChoiceTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
|
||||
@@ -2,19 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
from .completionlogprobs import CompletionLogprobs, CompletionLogprobsTypedDict
|
||||
from openrouter.types import (
|
||||
BaseModel,
|
||||
Nullable,
|
||||
OptionalNullable,
|
||||
UNSET,
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
|
||||
from openrouter.utils import validate_open_enum
|
||||
from pydantic import model_serializer
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypedDict
|
||||
from typing import Literal, Union
|
||||
from typing_extensions import Annotated, TypedDict
|
||||
|
||||
|
||||
CompletionFinishReason = Union[
|
||||
@@ -32,8 +25,6 @@ class CompletionChoiceTypedDict(TypedDict):
|
||||
index: float
|
||||
logprobs: Nullable[CompletionLogprobsTypedDict]
|
||||
finish_reason: Nullable[CompletionFinishReason]
|
||||
native_finish_reason: NotRequired[str]
|
||||
reasoning: NotRequired[Nullable[str]]
|
||||
|
||||
|
||||
class CompletionChoice(BaseModel):
|
||||
@@ -47,14 +38,10 @@ class CompletionChoice(BaseModel):
|
||||
Nullable[CompletionFinishReason], PlainValidator(validate_open_enum(False))
|
||||
]
|
||||
|
||||
native_finish_reason: Optional[str] = None
|
||||
|
||||
reasoning: OptionalNullable[str] = UNSET
|
||||
|
||||
@model_serializer(mode="wrap")
|
||||
def serialize_model(self, handler):
|
||||
optional_fields = ["native_finish_reason", "reasoning"]
|
||||
nullable_fields = ["logprobs", "finish_reason", "reasoning"]
|
||||
optional_fields = []
|
||||
nullable_fields = ["logprobs", "finish_reason"]
|
||||
null_default_fields = []
|
||||
|
||||
serialized = handler(self)
|
||||
|
||||
@@ -17,7 +17,6 @@ class CompletionResponseTypedDict(TypedDict):
|
||||
model: str
|
||||
choices: List[CompletionChoiceTypedDict]
|
||||
object: Literal["text_completion"]
|
||||
provider: NotRequired[str]
|
||||
system_fingerprint: NotRequired[str]
|
||||
usage: NotRequired[CompletionUsageTypedDict]
|
||||
|
||||
@@ -39,8 +38,6 @@ class CompletionResponse(BaseModel):
|
||||
pydantic.Field(alias="object"),
|
||||
] = "text_completion"
|
||||
|
||||
provider: Optional[str] = None
|
||||
|
||||
system_fingerprint: Optional[str] = None
|
||||
|
||||
usage: Optional[CompletionUsage] = None
|
||||
|
||||
@@ -44,10 +44,9 @@ from openrouter.types import (
|
||||
UNSET_SENTINEL,
|
||||
UnrecognizedStr,
|
||||
)
|
||||
from openrouter.utils import get_discriminator, validate_const, validate_open_enum
|
||||
import pydantic
|
||||
from openrouter.utils import get_discriminator, validate_open_enum
|
||||
from pydantic import Discriminator, Tag, model_serializer
|
||||
from pydantic.functional_validators import AfterValidator, PlainValidator
|
||||
from pydantic.functional_validators import PlainValidator
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
|
||||
|
||||
@@ -136,7 +135,16 @@ OpenResponsesRequestToolUnion = Annotated[
|
||||
]
|
||||
|
||||
|
||||
ServiceTier = Literal["auto",]
|
||||
ServiceTier = Union[
|
||||
Literal[
|
||||
"auto",
|
||||
"default",
|
||||
"flex",
|
||||
"priority",
|
||||
"scale",
|
||||
],
|
||||
UnrecognizedStr,
|
||||
]
|
||||
|
||||
|
||||
Truncation = Union[
|
||||
@@ -348,17 +356,6 @@ class Provider(BaseModel):
|
||||
return m
|
||||
|
||||
|
||||
IDResponseHealing = Literal["response-healing",]
|
||||
|
||||
|
||||
class PluginResponseHealingTypedDict(TypedDict):
|
||||
id: IDResponseHealing
|
||||
|
||||
|
||||
class PluginResponseHealing(BaseModel):
|
||||
id: IDResponseHealing
|
||||
|
||||
|
||||
IDFileParser = Literal["file-parser",]
|
||||
|
||||
|
||||
@@ -440,12 +437,7 @@ class PluginModeration(BaseModel):
|
||||
|
||||
PluginTypedDict = TypeAliasType(
|
||||
"PluginTypedDict",
|
||||
Union[
|
||||
PluginModerationTypedDict,
|
||||
PluginResponseHealingTypedDict,
|
||||
PluginFileParserTypedDict,
|
||||
PluginWebTypedDict,
|
||||
],
|
||||
Union[PluginModerationTypedDict, PluginFileParserTypedDict, PluginWebTypedDict],
|
||||
)
|
||||
|
||||
|
||||
@@ -454,7 +446,6 @@ Plugin = Annotated[
|
||||
Annotated[PluginModeration, Tag("moderation")],
|
||||
Annotated[PluginWeb, Tag("web")],
|
||||
Annotated[PluginFileParser, Tag("file-parser")],
|
||||
Annotated[PluginResponseHealing, Tag("response-healing")],
|
||||
],
|
||||
Discriminator(lambda m: get_discriminator(m, "id", "id")),
|
||||
]
|
||||
@@ -487,8 +478,8 @@ class OpenResponsesRequestTypedDict(TypedDict):
|
||||
include: NotRequired[Nullable[List[OpenAIResponsesIncludable]]]
|
||||
background: NotRequired[Nullable[bool]]
|
||||
safety_identifier: NotRequired[Nullable[str]]
|
||||
store: Literal[False]
|
||||
service_tier: NotRequired[ServiceTier]
|
||||
store: NotRequired[Nullable[bool]]
|
||||
service_tier: NotRequired[Nullable[ServiceTier]]
|
||||
truncation: NotRequired[Nullable[Truncation]]
|
||||
stream: NotRequired[bool]
|
||||
provider: NotRequired[Nullable[ProviderTypedDict]]
|
||||
@@ -552,12 +543,11 @@ class OpenResponsesRequest(BaseModel):
|
||||
|
||||
safety_identifier: OptionalNullable[str] = UNSET
|
||||
|
||||
STORE: Annotated[
|
||||
Annotated[Optional[Literal[False]], AfterValidator(validate_const(False))],
|
||||
pydantic.Field(alias="store"),
|
||||
] = False
|
||||
store: OptionalNullable[bool] = UNSET
|
||||
|
||||
service_tier: Optional[ServiceTier] = "auto"
|
||||
service_tier: Annotated[
|
||||
OptionalNullable[ServiceTier], PlainValidator(validate_open_enum(False))
|
||||
] = UNSET
|
||||
|
||||
truncation: Annotated[
|
||||
OptionalNullable[Truncation], PlainValidator(validate_open_enum(False))
|
||||
@@ -619,6 +609,8 @@ class OpenResponsesRequest(BaseModel):
|
||||
"include",
|
||||
"background",
|
||||
"safety_identifier",
|
||||
"store",
|
||||
"service_tier",
|
||||
"truncation",
|
||||
"provider",
|
||||
]
|
||||
|
||||
@@ -11,14 +11,12 @@ ProviderName = Union[
|
||||
"AionLabs",
|
||||
"Alibaba",
|
||||
"Amazon Bedrock",
|
||||
"Amazon Nova",
|
||||
"Anthropic",
|
||||
"Arcee AI",
|
||||
"Arcee",
|
||||
"AtlasCloud",
|
||||
"Avian",
|
||||
"Azure",
|
||||
"BaseTen",
|
||||
"BytePlus",
|
||||
"Black Forest Labs",
|
||||
"Cerebras",
|
||||
"Chutes",
|
||||
@@ -33,7 +31,6 @@ ProviderName = Union[
|
||||
"Fireworks",
|
||||
"Friendli",
|
||||
"GMICloud",
|
||||
"GoPomelo",
|
||||
"Google",
|
||||
"Google AI Studio",
|
||||
"Groq",
|
||||
@@ -64,7 +61,6 @@ ProviderName = Union[
|
||||
"SambaNova",
|
||||
"SiliconFlow",
|
||||
"Stealth",
|
||||
"StreamLake",
|
||||
"Switchpoint",
|
||||
"Targon",
|
||||
"Together",
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
||||
|
||||
from __future__ import annotations
|
||||
from openrouter.types import BaseModel
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
|
||||
class VideoURLTypedDict(TypedDict):
|
||||
url: str
|
||||
|
||||
|
||||
class VideoURL(BaseModel):
|
||||
url: str
|
||||
Reference in New Issue
Block a user