|
21 | 21 | from typing import Any, ClassVar, Dict, List, Optional, Union |
22 | 22 | from typing_extensions import Annotated |
23 | 23 | from uuid import UUID |
| 24 | +from otari._client.models.chat_completion_request_tools_inner import ChatCompletionRequestToolsInner |
24 | 25 | from otari._client.models.chat_message_input import ChatMessageInput |
25 | 26 | from otari._client.models.guardrail_config import GuardrailConfig |
26 | 27 | from otari._client.models.mcp_server_config import McpServerConfig |
@@ -51,17 +52,18 @@ class ChatCompletionRequest(BaseModel): |
51 | 52 | reasoning_effort: Optional[StrictStr] = None |
52 | 53 | response_format: Optional[Dict[str, Any]] = None |
53 | 54 | seed: Optional[StrictInt] = None |
| 55 | + session_label: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(default=None, description="Optional caller-supplied label for cost attribution (per run, experiment, or conversation). In hybrid mode it is forwarded onto the platform usage report so spend can be sliced by session without standing up OpenTelemetry. Stripped before the request is forwarded upstream to the provider. Has no effect in standalone mode, where there is no platform to report it to.") |
54 | 56 | stop: Optional[Stop] = None |
55 | 57 | stream: Optional[StrictBool] = False |
56 | 58 | stream_options: Optional[Dict[str, Any]] = None |
57 | 59 | temperature: Optional[Union[StrictFloat, StrictInt]] = None |
58 | 60 | tool_choice: Optional[ToolChoice] = None |
59 | | - tools: Optional[List[Optional[Dict[str, Any]]]] = None |
| 61 | + tools: Optional[List[ChatCompletionRequestToolsInner]] = None |
60 | 62 | tools_header: Optional[Annotated[str, Field(strict=True, max_length=4000)]] = Field(default=None, description="Optional override for the lead-in that the gateway prepends before the per-tool hint block in the system message. Useful for expressing global tool-selection policy (e.g. 'prefer MCP tools over code_execution'). Falls back to OTARI_TOOLS_HEADER env, then to the built-in default.") |
61 | 63 | top_logprobs: Optional[StrictInt] = None |
62 | 64 | top_p: Optional[Union[StrictFloat, StrictInt]] = None |
63 | 65 | user: Optional[StrictStr] = None |
64 | | - __properties: ClassVar[List[str]] = ["frequency_penalty", "guardrails", "logit_bias", "logprobs", "max_completion_tokens", "max_tokens", "max_tool_iterations", "mcp_server_ids", "mcp_servers", "messages", "model", "n", "parallel_tool_calls", "presence_penalty", "reasoning_effort", "response_format", "seed", "stop", "stream", "stream_options", "temperature", "tool_choice", "tools", "tools_header", "top_logprobs", "top_p", "user"] |
| 66 | + __properties: ClassVar[List[str]] = ["frequency_penalty", "guardrails", "logit_bias", "logprobs", "max_completion_tokens", "max_tokens", "max_tool_iterations", "mcp_server_ids", "mcp_servers", "messages", "model", "n", "parallel_tool_calls", "presence_penalty", "reasoning_effort", "response_format", "seed", "session_label", "stop", "stream", "stream_options", "temperature", "tool_choice", "tools", "tools_header", "top_logprobs", "top_p", "user"] |
65 | 67 |
|
66 | 68 | @field_validator('reasoning_effort') |
67 | 69 | def reasoning_effort_validate_enum(cls, value): |
@@ -139,6 +141,13 @@ def to_dict(self) -> Dict[str, Any]: |
139 | 141 | # override the default output from pydantic by calling `to_dict()` of tool_choice |
140 | 142 | if self.tool_choice: |
141 | 143 | _dict['tool_choice'] = self.tool_choice.to_dict() |
| 144 | + # override the default output from pydantic by calling `to_dict()` of each item in tools (list) |
| 145 | + _items = [] |
| 146 | + if self.tools: |
| 147 | + for _item_tools in self.tools: |
| 148 | + if _item_tools: |
| 149 | + _items.append(_item_tools.to_dict()) |
| 150 | + _dict['tools'] = _items |
142 | 151 | # set to None if frequency_penalty (nullable) is None |
143 | 152 | # and model_fields_set contains the field |
144 | 153 | if self.frequency_penalty is None and "frequency_penalty" in self.model_fields_set: |
@@ -214,6 +223,11 @@ def to_dict(self) -> Dict[str, Any]: |
214 | 223 | if self.seed is None and "seed" in self.model_fields_set: |
215 | 224 | _dict['seed'] = None |
216 | 225 |
|
| 226 | + # set to None if session_label (nullable) is None |
| 227 | + # and model_fields_set contains the field |
| 228 | + if self.session_label is None and "session_label" in self.model_fields_set: |
| 229 | + _dict['session_label'] = None |
| 230 | + |
217 | 231 | # set to None if stop (nullable) is None |
218 | 232 | # and model_fields_set contains the field |
219 | 233 | if self.stop is None and "stop" in self.model_fields_set: |
@@ -288,12 +302,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
288 | 302 | "reasoning_effort": obj.get("reasoning_effort"), |
289 | 303 | "response_format": obj.get("response_format"), |
290 | 304 | "seed": obj.get("seed"), |
| 305 | + "session_label": obj.get("session_label"), |
291 | 306 | "stop": Stop.from_dict(obj["stop"]) if obj.get("stop") is not None else None, |
292 | 307 | "stream": obj.get("stream") if obj.get("stream") is not None else False, |
293 | 308 | "stream_options": obj.get("stream_options"), |
294 | 309 | "temperature": obj.get("temperature"), |
295 | 310 | "tool_choice": ToolChoice.from_dict(obj["tool_choice"]) if obj.get("tool_choice") is not None else None, |
296 | | - "tools": obj.get("tools"), |
| 311 | + "tools": [ChatCompletionRequestToolsInner.from_dict(_item) for _item in obj["tools"]] if obj.get("tools") is not None else None, |
297 | 312 | "tools_header": obj.get("tools_header"), |
298 | 313 | "top_logprobs": obj.get("top_logprobs"), |
299 | 314 | "top_p": obj.get("top_p"), |
|
0 commit comments