Files
openrouter-python-sdk-retry…/src/openrouter/components/debugevent.py
T

81 lines
1.9 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from openrouter.types import BaseModel, Nullable, UNSET_SENTINEL, UnrecognizedStr
from pydantic import model_serializer
from typing import Any, Dict, Literal, Optional, Union
from typing_extensions import NotRequired, TypedDict
Event = Union[
Literal[
"adapter_request",
"upstream_headers_received",
"first_token_received",
"upstream_body_ended",
],
UnrecognizedStr,
]
class TimingsTypedDict(TypedDict):
epoch_ms: int
event: Event
start_ms: int
class Timings(BaseModel):
epoch_ms: int
event: Event
start_ms: int
class DebugTypedDict(TypedDict):
echo_upstream_body: NotRequired[Dict[str, Nullable[Any]]]
timings: NotRequired[TimingsTypedDict]
class Debug(BaseModel):
echo_upstream_body: Optional[Dict[str, Nullable[Any]]] = None
timings: Optional[Timings] = None
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["echo_upstream_body", "timings"])
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
DebugEventType = Literal["response.debug",]
class DebugEventTypedDict(TypedDict):
r"""Debug event emitted when debug.echo_upstream_body is true. Contains the transformed upstream request body or timing milestones."""
debug: DebugTypedDict
sequence_number: int
type: DebugEventType
class DebugEvent(BaseModel):
r"""Debug event emitted when debug.echo_upstream_body is true. Contains the transformed upstream request body or timing milestones."""
debug: Debug
sequence_number: int
type: DebugEventType