fleet-memory/memora-clients/python/models/think_request.py
2025-11-13 13:51:42 +01:00

97 lines
2.7 KiB
Python

from __future__ import annotations
from collections.abc import Mapping
from typing import Any, TypeVar, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
T = TypeVar("T", bound="ThinkRequest")
@_attrs_define
class ThinkRequest:
"""Request model for think endpoint.
Example:
{'context': 'This is for a research paper on AI ethics', 'query': 'What do you think about artificial
intelligence?', 'thinking_budget': 50}
Attributes:
query (str):
thinking_budget (int | Unset): Default: 50.
context (None | str | Unset):
"""
query: str
thinking_budget: int | Unset = 50
context: None | str | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
query = self.query
thinking_budget = self.thinking_budget
context: None | str | Unset
if isinstance(self.context, Unset):
context = UNSET
else:
context = self.context
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"query": query,
}
)
if thinking_budget is not UNSET:
field_dict["thinking_budget"] = thinking_budget
if context is not UNSET:
field_dict["context"] = context
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
query = d.pop("query")
thinking_budget = d.pop("thinking_budget", UNSET)
def _parse_context(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)
context = _parse_context(d.pop("context", UNSET))
think_request = cls(
query=query,
thinking_budget=thinking_budget,
context=context,
)
think_request.additional_properties = d
return think_request
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties