mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
151 lines
5.6 KiB
Python
151 lines
5.6 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
|
|
from __future__ import annotations
|
|
from .fusionanalysisresult import FusionAnalysisResult, FusionAnalysisResultTypedDict
|
|
from .fusionsource import FusionSource, FusionSourceTypedDict
|
|
from .toolcallstatus import ToolCallStatus
|
|
from openrouter.types import BaseModel, UNSET_SENTINEL
|
|
from pydantic import model_serializer
|
|
from typing import List, Literal, Optional
|
|
from typing_extensions import NotRequired, TypedDict
|
|
|
|
|
|
class FailedModelTypedDict(TypedDict):
|
|
error: str
|
|
r"""Error message describing why the model failed."""
|
|
model: str
|
|
r"""Slug of the analysis model that failed."""
|
|
status_code: NotRequired[int]
|
|
r"""HTTP status code from the upstream response, when available (e.g. 402, 429)."""
|
|
|
|
|
|
class FailedModel(BaseModel):
|
|
error: str
|
|
r"""Error message describing why the model failed."""
|
|
|
|
model: str
|
|
r"""Slug of the analysis model that failed."""
|
|
|
|
status_code: Optional[int] = None
|
|
r"""HTTP status code from the upstream response, when available (e.g. 402, 429)."""
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["status_code"])
|
|
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))
|
|
|
|
if val != UNSET_SENTINEL:
|
|
if val is not None or k not in optional_fields:
|
|
m[k] = val
|
|
|
|
return m
|
|
|
|
|
|
class ResponseTypedDict(TypedDict):
|
|
model: str
|
|
content: NotRequired[str]
|
|
|
|
|
|
class Response(BaseModel):
|
|
model: str
|
|
|
|
content: Optional[str] = None
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["content"])
|
|
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))
|
|
|
|
if val != UNSET_SENTINEL:
|
|
if val is not None or k not in optional_fields:
|
|
m[k] = val
|
|
|
|
return m
|
|
|
|
|
|
OutputFusionServerToolItemType = Literal["openrouter:fusion",]
|
|
|
|
|
|
class OutputFusionServerToolItemTypedDict(TypedDict):
|
|
r"""An openrouter:fusion server tool output item"""
|
|
|
|
status: ToolCallStatus
|
|
type: OutputFusionServerToolItemType
|
|
analysis: NotRequired[FusionAnalysisResultTypedDict]
|
|
r"""Structured analysis produced by the fusion judge model."""
|
|
error: NotRequired[str]
|
|
r"""Error message when the fusion run did not produce an analysis result."""
|
|
failed_models: NotRequired[List[FailedModelTypedDict]]
|
|
r"""Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel."""
|
|
failure_reason: NotRequired[str]
|
|
r"""Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion."""
|
|
id: NotRequired[str]
|
|
responses: NotRequired[List[ResponseTypedDict]]
|
|
r"""Analysis models that produced a response in this fusion run, with each model's full panel content."""
|
|
sources: NotRequired[List[FusionSourceTypedDict]]
|
|
r"""Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source."""
|
|
|
|
|
|
class OutputFusionServerToolItem(BaseModel):
|
|
r"""An openrouter:fusion server tool output item"""
|
|
|
|
status: ToolCallStatus
|
|
|
|
type: OutputFusionServerToolItemType
|
|
|
|
analysis: Optional[FusionAnalysisResult] = None
|
|
r"""Structured analysis produced by the fusion judge model."""
|
|
|
|
error: Optional[str] = None
|
|
r"""Error message when the fusion run did not produce an analysis result."""
|
|
|
|
failed_models: Optional[List[FailedModel]] = None
|
|
r"""Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel."""
|
|
|
|
failure_reason: Optional[str] = None
|
|
r"""Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion."""
|
|
|
|
id: Optional[str] = None
|
|
|
|
responses: Optional[List[Response]] = None
|
|
r"""Analysis models that produced a response in this fusion run, with each model's full panel content."""
|
|
|
|
sources: Optional[List[FusionSource]] = None
|
|
r"""Web pages the analysis panels and judge retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source."""
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(
|
|
[
|
|
"analysis",
|
|
"error",
|
|
"failed_models",
|
|
"failure_reason",
|
|
"id",
|
|
"responses",
|
|
"sources",
|
|
]
|
|
)
|
|
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))
|
|
|
|
if val != UNSET_SENTINEL:
|
|
if val is not None or k not in optional_fields:
|
|
m[k] = val
|
|
|
|
return m
|