Commit 458a542a

stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
2025-08-08 19:24:58
fix(types): rename chat completion tool
1 parent 2ae42a3
Changed files (8)
src/openai/lib/_parsing/_completions.py
@@ -21,13 +21,13 @@ from ...types.chat import (
     ChatCompletionMessage,
     ParsedFunctionToolCall,
     ParsedChatCompletionMessage,
+    ChatCompletionToolUnionParam,
     ChatCompletionFunctionToolParam,
     completion_create_params,
 )
 from ..._exceptions import LengthFinishReasonError, ContentFilterFinishReasonError
 from ...types.shared_params import FunctionDefinition
 from ...types.chat.completion_create_params import ResponseFormat as ResponseFormatParam
-from ...types.chat.chat_completion_tool_param import ChatCompletionToolParam
 from ...types.chat.chat_completion_message_function_tool_call import Function
 
 ResponseFormatT = TypeVar(
@@ -41,7 +41,7 @@ log: logging.Logger = logging.getLogger("openai.lib.parsing")
 
 
 def is_strict_chat_completion_tool_param(
-    tool: ChatCompletionToolParam,
+    tool: ChatCompletionToolUnionParam,
 ) -> TypeGuard[ChatCompletionFunctionToolParam]:
     """Check if the given tool is a strict ChatCompletionFunctionToolParam."""
     if not tool["type"] == "function":
@@ -53,7 +53,7 @@ def is_strict_chat_completion_tool_param(
 
 
 def select_strict_chat_completion_tools(
-    tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+    tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
 ) -> Iterable[ChatCompletionFunctionToolParam] | NotGiven:
     """Select only the strict ChatCompletionFunctionToolParams from the given tools."""
     if not is_given(tools):
@@ -63,7 +63,7 @@ def select_strict_chat_completion_tools(
 
 
 def validate_input_tools(
-    tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+    tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
 ) -> Iterable[ChatCompletionFunctionToolParam] | NotGiven:
     if not is_given(tools):
         return NOT_GIVEN
@@ -86,7 +86,7 @@ def validate_input_tools(
 def parse_chat_completion(
     *,
     response_format: type[ResponseFormatT] | completion_create_params.ResponseFormat | NotGiven,
-    input_tools: Iterable[ChatCompletionToolParam] | NotGiven,
+    input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven,
     chat_completion: ChatCompletion | ParsedChatCompletion[object],
 ) -> ParsedChatCompletion[ResponseFormatT]:
     if is_given(input_tools):
@@ -166,13 +166,13 @@ def parse_chat_completion(
 
 
 def get_input_tool_by_name(
-    *, input_tools: list[ChatCompletionToolParam], name: str
+    *, input_tools: list[ChatCompletionToolUnionParam], name: str
 ) -> ChatCompletionFunctionToolParam | None:
     return next((t for t in input_tools if t["type"] == "function" and t.get("function", {}).get("name") == name), None)
 
 
 def parse_function_tool_arguments(
-    *, input_tools: list[ChatCompletionToolParam], function: Function | ParsedFunction
+    *, input_tools: list[ChatCompletionToolUnionParam], function: Function | ParsedFunction
 ) -> object | None:
     input_tool = get_input_tool_by_name(input_tools=input_tools, name=function.name)
     if not input_tool:
@@ -218,7 +218,7 @@ def solve_response_format_t(
 def has_parseable_input(
     *,
     response_format: type | ResponseFormatParam | NotGiven,
-    input_tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+    input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
 ) -> bool:
     if has_rich_response_format(response_format):
         return True
@@ -246,7 +246,7 @@ def is_response_format_param(response_format: object) -> TypeGuard[ResponseForma
     return is_dict(response_format)
 
 
-def is_parseable_tool(input_tool: ChatCompletionToolParam) -> bool:
+def is_parseable_tool(input_tool: ChatCompletionToolUnionParam) -> bool:
     if input_tool["type"] != "function":
         return False
 
src/openai/lib/streaming/chat/_completions.py
@@ -37,12 +37,11 @@ from ..._parsing import (
     parse_function_tool_arguments,
 )
 from ...._streaming import Stream, AsyncStream
-from ....types.chat import ChatCompletionChunk, ParsedChatCompletion
+from ....types.chat import ChatCompletionChunk, ParsedChatCompletion, ChatCompletionToolUnionParam
 from ...._exceptions import LengthFinishReasonError, ContentFilterFinishReasonError
 from ....types.chat.chat_completion import ChoiceLogprobs
 from ....types.chat.chat_completion_chunk import Choice as ChoiceChunk
 from ....types.chat.completion_create_params import ResponseFormat as ResponseFormatParam
-from ....types.chat.chat_completion_tool_param import ChatCompletionToolParam
 
 
 class ChatCompletionStream(Generic[ResponseFormatT]):
@@ -59,7 +58,7 @@ class ChatCompletionStream(Generic[ResponseFormatT]):
         *,
         raw_stream: Stream[ChatCompletionChunk],
         response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven,
-        input_tools: Iterable[ChatCompletionToolParam] | NotGiven,
+        input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven,
     ) -> None:
         self._raw_stream = raw_stream
         self._response = raw_stream.response
@@ -140,7 +139,7 @@ class ChatCompletionStreamManager(Generic[ResponseFormatT]):
         api_request: Callable[[], Stream[ChatCompletionChunk]],
         *,
         response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven,
-        input_tools: Iterable[ChatCompletionToolParam] | NotGiven,
+        input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven,
     ) -> None:
         self.__stream: ChatCompletionStream[ResponseFormatT] | None = None
         self.__api_request = api_request
@@ -182,7 +181,7 @@ class AsyncChatCompletionStream(Generic[ResponseFormatT]):
         *,
         raw_stream: AsyncStream[ChatCompletionChunk],
         response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven,
-        input_tools: Iterable[ChatCompletionToolParam] | NotGiven,
+        input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven,
     ) -> None:
         self._raw_stream = raw_stream
         self._response = raw_stream.response
@@ -263,7 +262,7 @@ class AsyncChatCompletionStreamManager(Generic[ResponseFormatT]):
         api_request: Awaitable[AsyncStream[ChatCompletionChunk]],
         *,
         response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven,
-        input_tools: Iterable[ChatCompletionToolParam] | NotGiven,
+        input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven,
     ) -> None:
         self.__stream: AsyncChatCompletionStream[ResponseFormatT] | None = None
         self.__api_request = api_request
@@ -315,7 +314,7 @@ class ChatCompletionStreamState(Generic[ResponseFormatT]):
     def __init__(
         self,
         *,
-        input_tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        input_tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         response_format: type[ResponseFormatT] | ResponseFormatParam | NotGiven = NOT_GIVEN,
     ) -> None:
         self.__current_completion_snapshot: ParsedChatCompletionSnapshot | None = None
@@ -585,7 +584,7 @@ class ChatCompletionStreamState(Generic[ResponseFormatT]):
 
 
 class ChoiceEventState:
-    def __init__(self, *, input_tools: list[ChatCompletionToolParam]) -> None:
+    def __init__(self, *, input_tools: list[ChatCompletionToolUnionParam]) -> None:
         self._input_tools = input_tools
 
         self._content_done = False
src/openai/resources/chat/completions/completions.py
@@ -47,9 +47,9 @@ from ....types.shared.reasoning_effort import ReasoningEffort
 from ....types.chat.chat_completion_chunk import ChatCompletionChunk
 from ....types.chat.parsed_chat_completion import ParsedChatCompletion
 from ....types.chat.chat_completion_deleted import ChatCompletionDeleted
-from ....types.chat.chat_completion_tool_param import ChatCompletionToolParam
 from ....types.chat.chat_completion_audio_param import ChatCompletionAudioParam
 from ....types.chat.chat_completion_message_param import ChatCompletionMessageParam
+from ....types.chat.chat_completion_tool_union_param import ChatCompletionToolUnionParam
 from ....types.chat.chat_completion_stream_options_param import ChatCompletionStreamOptionsParam
 from ....types.chat.chat_completion_prediction_content_param import ChatCompletionPredictionContentParam
 from ....types.chat.chat_completion_tool_choice_option_param import ChatCompletionToolChoiceOptionParam
@@ -111,7 +111,7 @@ class Completions(SyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -266,7 +266,7 @@ class Completions(SyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -555,7 +555,7 @@ class Completions(SyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -844,7 +844,7 @@ class Completions(SyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -1133,7 +1133,7 @@ class Completions(SyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -1408,7 +1408,7 @@ class Completions(SyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -1550,7 +1550,7 @@ class AsyncCompletions(AsyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -1705,7 +1705,7 @@ class AsyncCompletions(AsyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -1994,7 +1994,7 @@ class AsyncCompletions(AsyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -2283,7 +2283,7 @@ class AsyncCompletions(AsyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -2572,7 +2572,7 @@ class AsyncCompletions(AsyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
@@ -2847,7 +2847,7 @@ class AsyncCompletions(AsyncAPIResource):
         stream_options: Optional[ChatCompletionStreamOptionsParam] | NotGiven = NOT_GIVEN,
         temperature: Optional[float] | NotGiven = NOT_GIVEN,
         tool_choice: ChatCompletionToolChoiceOptionParam | NotGiven = NOT_GIVEN,
-        tools: Iterable[ChatCompletionToolParam] | NotGiven = NOT_GIVEN,
+        tools: Iterable[ChatCompletionToolUnionParam] | NotGiven = NOT_GIVEN,
         top_logprobs: Optional[int] | NotGiven = NOT_GIVEN,
         top_p: Optional[float] | NotGiven = NOT_GIVEN,
         user: str | NotGiven = NOT_GIVEN,
src/openai/types/chat/__init__.py
@@ -21,13 +21,13 @@ from .parsed_function_tool_call import (
     ParsedFunction as ParsedFunction,
     ParsedFunctionToolCall as ParsedFunctionToolCall,
 )
-from .chat_completion_tool_param import ChatCompletionToolParam as ChatCompletionToolParam
 from .chat_completion_audio_param import ChatCompletionAudioParam as ChatCompletionAudioParam
 from .chat_completion_function_tool import ChatCompletionFunctionTool as ChatCompletionFunctionTool
 from .chat_completion_message_param import ChatCompletionMessageParam as ChatCompletionMessageParam
 from .chat_completion_store_message import ChatCompletionStoreMessage as ChatCompletionStoreMessage
 from .chat_completion_token_logprob import ChatCompletionTokenLogprob as ChatCompletionTokenLogprob
 from .chat_completion_reasoning_effort import ChatCompletionReasoningEffort as ChatCompletionReasoningEffort
+from .chat_completion_tool_union_param import ChatCompletionToolUnionParam as ChatCompletionToolUnionParam
 from .chat_completion_content_part_text import ChatCompletionContentPartText as ChatCompletionContentPartText
 from .chat_completion_custom_tool_param import ChatCompletionCustomToolParam as ChatCompletionCustomToolParam
 from .chat_completion_message_tool_call import ChatCompletionMessageToolCall as ChatCompletionMessageToolCall
src/openai/types/chat/chat_completion_tool_param.py → src/openai/types/chat/chat_completion_tool_union_param.py
@@ -8,6 +8,6 @@ from typing_extensions import TypeAlias
 from .chat_completion_custom_tool_param import ChatCompletionCustomToolParam
 from .chat_completion_function_tool_param import ChatCompletionFunctionToolParam
 
-__all__ = ["ChatCompletionToolParam"]
+__all__ = ["ChatCompletionToolUnionParam"]
 
-ChatCompletionToolParam: TypeAlias = Union[ChatCompletionFunctionToolParam, ChatCompletionCustomToolParam]
+ChatCompletionToolUnionParam: TypeAlias = Union[ChatCompletionFunctionToolParam, ChatCompletionCustomToolParam]
src/openai/types/chat/completion_create_params.py
@@ -8,9 +8,9 @@ from typing_extensions import Literal, Required, TypeAlias, TypedDict
 from ..shared.chat_model import ChatModel
 from ..shared_params.metadata import Metadata
 from ..shared.reasoning_effort import ReasoningEffort
-from .chat_completion_tool_param import ChatCompletionToolParam
 from .chat_completion_audio_param import ChatCompletionAudioParam
 from .chat_completion_message_param import ChatCompletionMessageParam
+from .chat_completion_tool_union_param import ChatCompletionToolUnionParam
 from ..shared_params.function_parameters import FunctionParameters
 from ..shared_params.response_format_text import ResponseFormatText
 from .chat_completion_stream_options_param import ChatCompletionStreamOptionsParam
@@ -284,7 +284,7 @@ class CompletionCreateParamsBase(TypedDict, total=False):
     are present.
     """
 
-    tools: Iterable[ChatCompletionToolParam]
+    tools: Iterable[ChatCompletionToolUnionParam]
     """A list of tools the model may call.
 
     You can provide either
.stats.yml
@@ -1,4 +1,4 @@
 configured_endpoints: 111
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-d7e255da603b878e7e823135520211ce6a9e02890c9d549bbf3953a877ee5ef3.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-56d3a72a5caa187aebcf9de169a6a28a9dc3f70a79d7467a03a9e22595936066.yml
 openapi_spec_hash: 3eb8d86c06f0bb5e1190983e5acfc9ba
-config_hash: 2e7cf948f94e24f94c7d12ba2de2734a
+config_hash: 7e18239879286d68a48ac5487a649aa6
api.md
@@ -79,7 +79,7 @@ from openai.types.chat import (
     ChatCompletionStreamOptions,
     ChatCompletionSystemMessageParam,
     ChatCompletionTokenLogprob,
-    ChatCompletionTool,
+    ChatCompletionToolUnion,
     ChatCompletionToolChoiceOption,
     ChatCompletionToolMessageParam,
     ChatCompletionUserMessageParam,