|
5 | 5 | from collections.abc import Sequence |
6 | 6 | from typing import TYPE_CHECKING, Any, AsyncIterator, Generic, Iterator, Literal, cast |
7 | 7 |
|
| 8 | +from google.protobuf.wrappers_pb2 import BoolValue |
8 | 9 | from typing_extensions import Self, override |
9 | 10 | from yandex.cloud.ai.foundation_models.v1.text_common_pb2 import CompletionOptions, ReasoningOptions |
10 | 11 | from yandex.cloud.ai.foundation_models.v1.text_common_pb2 import Tool as ProtoCompletionsTool |
@@ -83,13 +84,15 @@ def configure( # type: ignore[override] |
83 | 84 | reasoning_mode: UndefinedOr[ReasoningModeType] = UNDEFINED, |
84 | 85 | response_format: UndefinedOr[ResponseType] = UNDEFINED, |
85 | 86 | tools: UndefinedOr[Sequence[CompletionTool] | CompletionTool] = UNDEFINED, |
| 87 | + parallel_tool_calls: UndefinedOr[bool] = UNDEFINED, |
86 | 88 | ) -> Self: |
87 | 89 | return super().configure( |
88 | 90 | temperature=temperature, |
89 | 91 | max_tokens=max_tokens, |
90 | 92 | reasoning_mode=reasoning_mode, |
91 | 93 | response_format=response_format, |
92 | 94 | tools=tools, |
| 95 | + parallel_tool_calls=parallel_tool_calls, |
93 | 96 | ) |
94 | 97 |
|
95 | 98 | def _make_completion_options(self, *, stream: bool | None) -> CompletionOptions: |
@@ -125,11 +128,16 @@ def _make_request( |
125 | 128 | if c.tools is not None: |
126 | 129 | tools = coerce_tuple(c.tools, BaseTool) # type: ignore[type-abstract] |
127 | 130 |
|
| 131 | + parallel_tool_calls: None | BoolValue = None |
| 132 | + if c.parallel_tool_calls is not None: |
| 133 | + parallel_tool_calls = BoolValue(value=c.parallel_tool_calls) |
| 134 | + |
128 | 135 | return CompletionRequest( |
129 | 136 | model_uri=self._uri, |
130 | 137 | completion_options=self._make_completion_options(stream=stream), |
131 | 138 | messages=messages_to_proto(messages), |
132 | 139 | tools=[tool._to_proto(ProtoCompletionsTool) for tool in tools], |
| 140 | + parallel_tool_calls=parallel_tool_calls, |
133 | 141 | **response_format_kwargs, |
134 | 142 | ) |
135 | 143 |
|
|
0 commit comments