Files
openrouter-python-sdk-retry…/src/openrouter/components/agentmessageitem.py
T
github-actions[bot]GitHubspeakeasybotspeakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
8d8b3557fd chore: 🐝 Update SDK - Generate (spec change merged) 0.11.19 (#426)
Co-authored-by: speakeasybot <bot@speakeasyapi.dev>
Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
2026-07-10 15:45:53 +00:00

214 lines
5.8 KiB
Python

"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
from .inputtext import InputText, InputTextTypedDict
from openrouter.types import (
BaseModel,
Nullable,
OptionalNullable,
UNSET,
UNSET_SENTINEL,
UnrecognizedStr,
)
from openrouter.utils import get_discriminator
import pydantic
from pydantic import ConfigDict, Discriminator, Tag, model_serializer
from typing import Any, Dict, List, Literal, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
class AgentTypedDict(TypedDict):
agent_name: str
class Agent(BaseModel):
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
agent_name: str
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
TypeEncryptedContent = Literal["encrypted_content",]
class ContentEncryptedContentTypedDict(TypedDict):
encrypted_content: str
type: TypeEncryptedContent
class ContentEncryptedContent(BaseModel):
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
encrypted_content: str
type: TypeEncryptedContent
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
AgentMessageItemDetail = Union[
Literal[
"auto",
"high",
"low",
"original",
],
UnrecognizedStr,
]
AgentMessageItemTypeInputImage = Literal["input_image",]
class AgentMessageItemContentInputImageTypedDict(TypedDict):
r"""Image input content item"""
detail: AgentMessageItemDetail
type: AgentMessageItemTypeInputImage
image_url: NotRequired[Nullable[str]]
class AgentMessageItemContentInputImage(BaseModel):
r"""Image input content item"""
detail: AgentMessageItemDetail
type: AgentMessageItemTypeInputImage
image_url: OptionalNullable[str] = UNSET
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["image_url"])
nullable_fields = set(["image_url"])
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))
is_nullable_and_explicitly_set = (
k in nullable_fields
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
)
if val != UNSET_SENTINEL:
if (
val is not None
or k not in optional_fields
or is_nullable_and_explicitly_set
):
m[k] = val
return m
AgentMessageItemContentUnionTypedDict = TypeAliasType(
"AgentMessageItemContentUnionTypedDict",
Union[
InputTextTypedDict,
AgentMessageItemContentInputImageTypedDict,
ContentEncryptedContentTypedDict,
],
)
AgentMessageItemContentUnion = Annotated[
Union[
Annotated[InputText, Tag("input_text")],
Annotated[AgentMessageItemContentInputImage, Tag("input_image")],
Annotated[ContentEncryptedContent, Tag("encrypted_content")],
],
Discriminator(lambda m: get_discriminator(m, "type", "type")),
]
TypeAgentMessage = Literal["agent_message",]
class AgentMessageItemTypedDict(TypedDict):
r"""A message routed between agents in a multi-agent session"""
author: str
content: List[AgentMessageItemContentUnionTypedDict]
recipient: str
type: TypeAgentMessage
agent: NotRequired[Nullable[AgentTypedDict]]
id: NotRequired[Nullable[str]]
class AgentMessageItem(BaseModel):
r"""A message routed between agents in a multi-agent session"""
model_config = ConfigDict(
populate_by_name=True, arbitrary_types_allowed=True, extra="allow"
)
__pydantic_extra__: Dict[str, Nullable[Any]] = pydantic.Field(init=False)
author: str
content: List[AgentMessageItemContentUnion]
recipient: str
type: TypeAgentMessage
agent: OptionalNullable[Agent] = UNSET
id: OptionalNullable[str] = UNSET
@property
def additional_properties(self):
return self.__pydantic_extra__
@additional_properties.setter
def additional_properties(self, value):
self.__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
@model_serializer(mode="wrap")
def serialize_model(self, handler):
optional_fields = set(["agent", "id"])
nullable_fields = set(["agent", "id"])
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))
serialized.pop(k, serialized.pop(n, None))
is_nullable_and_explicitly_set = (
k in nullable_fields
and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
)
if val != UNSET_SENTINEL:
if (
val is not None
or k not in optional_fields
or is_nullable_and_explicitly_set
):
m[k] = val
for k, v in serialized.items():
m[k] = v
return m