Commit a6695411

Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
2024-04-30 01:02:12
feat(api): add required tool_choice (#1382)
1 parent ffa8483
src/openai/resources/beta/threads/runs/runs.py
@@ -187,8 +187,9 @@ class Runs(SyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -330,8 +331,9 @@ class Runs(SyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -473,8 +475,9 @@ class Runs(SyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -1716,8 +1719,9 @@ class AsyncRuns(AsyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -1859,8 +1863,9 @@ class AsyncRuns(AsyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -2002,8 +2007,9 @@ class AsyncRuns(AsyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
src/openai/resources/beta/threads/threads.py
@@ -365,8 +365,9 @@ class Threads(SyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -507,8 +508,9 @@ class Threads(SyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -649,8 +651,9 @@ class Threads(SyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -1336,8 +1339,9 @@ class AsyncThreads(AsyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -1478,8 +1482,9 @@ class AsyncThreads(AsyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
@@ -1620,8 +1625,9 @@ class AsyncThreads(AsyncAPIResource):
 
           tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
               not call any tools and instead generates a message. `auto` is the default value
-              and means the model can pick between generating a message or calling a tool.
-              Specifying a particular tool like `{"type": "file_search"}` or
+              and means the model can pick between generating a message or calling one or more
+              tools. `required` means the model must call one or more tools before responding
+              to the user. Specifying a particular tool like `{"type": "file_search"}` or
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
               call that tool.
 
src/openai/resources/chat/completions.py
@@ -171,15 +171,15 @@ class Completions(SyncAPIResource):
 
               We generally recommend altering this or `top_p` but not both.
 
-          tool_choice: Controls which (if any) function is called by the model. `none` means the model
-              will not call a function and instead generates a message. `auto` means the model
-              can pick between generating a message or calling a function. Specifying a
-              particular function via
+          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
+              not call any tool and instead generates a message. `auto` means the model can
+              pick between generating a message or calling one or more tools. `required` means
+              the model must call one or more tools. Specifying a particular tool via
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-              call that function.
+              call that tool.
 
-              `none` is the default when no functions are present. `auto` is the default if
-              functions are present.
+              `none` is the default when no tools are present. `auto` is the default if tools
+              are present.
 
           tools: A list of tools the model may call. Currently, only functions are supported as a
               tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -339,15 +339,15 @@ class Completions(SyncAPIResource):
 
               We generally recommend altering this or `top_p` but not both.
 
-          tool_choice: Controls which (if any) function is called by the model. `none` means the model
-              will not call a function and instead generates a message. `auto` means the model
-              can pick between generating a message or calling a function. Specifying a
-              particular function via
+          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
+              not call any tool and instead generates a message. `auto` means the model can
+              pick between generating a message or calling one or more tools. `required` means
+              the model must call one or more tools. Specifying a particular tool via
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-              call that function.
+              call that tool.
 
-              `none` is the default when no functions are present. `auto` is the default if
-              functions are present.
+              `none` is the default when no tools are present. `auto` is the default if tools
+              are present.
 
           tools: A list of tools the model may call. Currently, only functions are supported as a
               tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -507,15 +507,15 @@ class Completions(SyncAPIResource):
 
               We generally recommend altering this or `top_p` but not both.
 
-          tool_choice: Controls which (if any) function is called by the model. `none` means the model
-              will not call a function and instead generates a message. `auto` means the model
-              can pick between generating a message or calling a function. Specifying a
-              particular function via
+          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
+              not call any tool and instead generates a message. `auto` means the model can
+              pick between generating a message or calling one or more tools. `required` means
+              the model must call one or more tools. Specifying a particular tool via
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-              call that function.
+              call that tool.
 
-              `none` is the default when no functions are present. `auto` is the default if
-              functions are present.
+              `none` is the default when no tools are present. `auto` is the default if tools
+              are present.
 
           tools: A list of tools the model may call. Currently, only functions are supported as a
               tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -751,15 +751,15 @@ class AsyncCompletions(AsyncAPIResource):
 
               We generally recommend altering this or `top_p` but not both.
 
-          tool_choice: Controls which (if any) function is called by the model. `none` means the model
-              will not call a function and instead generates a message. `auto` means the model
-              can pick between generating a message or calling a function. Specifying a
-              particular function via
+          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
+              not call any tool and instead generates a message. `auto` means the model can
+              pick between generating a message or calling one or more tools. `required` means
+              the model must call one or more tools. Specifying a particular tool via
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-              call that function.
+              call that tool.
 
-              `none` is the default when no functions are present. `auto` is the default if
-              functions are present.
+              `none` is the default when no tools are present. `auto` is the default if tools
+              are present.
 
           tools: A list of tools the model may call. Currently, only functions are supported as a
               tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -919,15 +919,15 @@ class AsyncCompletions(AsyncAPIResource):
 
               We generally recommend altering this or `top_p` but not both.
 
-          tool_choice: Controls which (if any) function is called by the model. `none` means the model
-              will not call a function and instead generates a message. `auto` means the model
-              can pick between generating a message or calling a function. Specifying a
-              particular function via
+          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
+              not call any tool and instead generates a message. `auto` means the model can
+              pick between generating a message or calling one or more tools. `required` means
+              the model must call one or more tools. Specifying a particular tool via
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-              call that function.
+              call that tool.
 
-              `none` is the default when no functions are present. `auto` is the default if
-              functions are present.
+              `none` is the default when no tools are present. `auto` is the default if tools
+              are present.
 
           tools: A list of tools the model may call. Currently, only functions are supported as a
               tool. Use this to provide a list of functions the model may generate JSON inputs
@@ -1087,15 +1087,15 @@ class AsyncCompletions(AsyncAPIResource):
 
               We generally recommend altering this or `top_p` but not both.
 
-          tool_choice: Controls which (if any) function is called by the model. `none` means the model
-              will not call a function and instead generates a message. `auto` means the model
-              can pick between generating a message or calling a function. Specifying a
-              particular function via
+          tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
+              not call any tool and instead generates a message. `auto` means the model can
+              pick between generating a message or calling one or more tools. `required` means
+              the model must call one or more tools. Specifying a particular tool via
               `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-              call that function.
+              call that tool.
 
-              `none` is the default when no functions are present. `auto` is the default if
-              functions are present.
+              `none` is the default when no tools are present. `auto` is the default if tools
+              are present.
 
           tools: A list of tools the model may call. Currently, only functions are supported as a
               tool. Use this to provide a list of functions the model may generate JSON inputs
src/openai/types/beta/threads/run.py
@@ -196,8 +196,9 @@ class Run(BaseModel):
     """
     Controls which (if any) tool is called by the model. `none` means the model will
     not call any tools and instead generates a message. `auto` is the default value
-    and means the model can pick between generating a message or calling a tool.
-    Specifying a particular tool like `{"type": "file_search"}` or
+    and means the model can pick between generating a message or calling one or more
+    tools. `required` means the model must call one or more tools before responding
+    to the user. Specifying a particular tool like `{"type": "file_search"}` or
     `{"type": "function", "function": {"name": "my_function"}}` forces the model to
     call that tool.
     """
src/openai/types/beta/threads/run_create_params.py
@@ -134,8 +134,9 @@ class RunCreateParamsBase(TypedDict, total=False):
     """
     Controls which (if any) tool is called by the model. `none` means the model will
     not call any tools and instead generates a message. `auto` is the default value
-    and means the model can pick between generating a message or calling a tool.
-    Specifying a particular tool like `{"type": "file_search"}` or
+    and means the model can pick between generating a message or calling one or more
+    tools. `required` means the model must call one or more tools before responding
+    to the user. Specifying a particular tool like `{"type": "file_search"}` or
     `{"type": "function", "function": {"name": "my_function"}}` forces the model to
     call that tool.
     """
src/openai/types/beta/assistant_tool_choice_option.py
@@ -7,4 +7,4 @@ from .assistant_tool_choice import AssistantToolChoice
 
 __all__ = ["AssistantToolChoiceOption"]
 
-AssistantToolChoiceOption = Union[Literal["none", "auto"], AssistantToolChoice]
+AssistantToolChoiceOption = Union[Literal["none", "auto", "required"], AssistantToolChoice]
src/openai/types/beta/assistant_tool_choice_option_param.py
@@ -9,4 +9,4 @@ from .assistant_tool_choice_param import AssistantToolChoiceParam
 
 __all__ = ["AssistantToolChoiceOptionParam"]
 
-AssistantToolChoiceOptionParam = Union[Literal["none", "auto"], AssistantToolChoiceParam]
+AssistantToolChoiceOptionParam = Union[Literal["none", "auto", "required"], AssistantToolChoiceParam]
src/openai/types/beta/thread_create_and_run_params.py
@@ -135,8 +135,9 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
     """
     Controls which (if any) tool is called by the model. `none` means the model will
     not call any tools and instead generates a message. `auto` is the default value
-    and means the model can pick between generating a message or calling a tool.
-    Specifying a particular tool like `{"type": "file_search"}` or
+    and means the model can pick between generating a message or calling one or more
+    tools. `required` means the model must call one or more tools before responding
+    to the user. Specifying a particular tool like `{"type": "file_search"}` or
     `{"type": "function", "function": {"name": "my_function"}}` forces the model to
     call that tool.
     """
src/openai/types/chat/chat_completion_tool_choice_option_param.py
@@ -9,4 +9,4 @@ from .chat_completion_named_tool_choice_param import ChatCompletionNamedToolChoi
 
 __all__ = ["ChatCompletionToolChoiceOptionParam"]
 
-ChatCompletionToolChoiceOptionParam = Union[Literal["none", "auto"], ChatCompletionNamedToolChoiceParam]
+ChatCompletionToolChoiceOptionParam = Union[Literal["none", "auto", "required"], ChatCompletionNamedToolChoiceParam]
src/openai/types/chat/completion_create_params.py
@@ -152,15 +152,15 @@ class CompletionCreateParamsBase(TypedDict, total=False):
 
     tool_choice: ChatCompletionToolChoiceOptionParam
     """
-    Controls which (if any) function is called by the model. `none` means the model
-    will not call a function and instead generates a message. `auto` means the model
-    can pick between generating a message or calling a function. Specifying a
-    particular function via
+    Controls which (if any) tool is called by the model. `none` means the model will
+    not call any tool and instead generates a message. `auto` means the model can
+    pick between generating a message or calling one or more tools. `required` means
+    the model must call one or more tools. Specifying a particular tool via
     `{"type": "function", "function": {"name": "my_function"}}` forces the model to
-    call that function.
+    call that tool.
 
-    `none` is the default when no functions are present. `auto` is the default if
-    functions are present.
+    `none` is the default when no tools are present. `auto` is the default if tools
+    are present.
     """
 
     tools: Iterable[ChatCompletionToolParam]