Skip to content

Commit

Permalink
feat(api): add required tool_choice (#1382)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Apr 29, 2024
1 parent 7003dbb commit c558f65
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 82 deletions.
30 changes: 18 additions & 12 deletions src/openai/resources/beta/threads/runs/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ def create(
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.
Expand Down Expand Up @@ -330,8 +331,9 @@ def create(
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.
Expand Down Expand Up @@ -473,8 +475,9 @@ def create(
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.
Expand Down Expand Up @@ -1716,8 +1719,9 @@ async def create(
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.
Expand Down Expand Up @@ -1859,8 +1863,9 @@ async def create(
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.
Expand Down Expand Up @@ -2002,8 +2007,9 @@ async def create(
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.
Expand Down
30 changes: 18 additions & 12 deletions src/openai/resources/beta/threads/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,9 @@ def create_and_run(
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.
Expand Down Expand Up @@ -507,8 +508,9 @@ def create_and_run(
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.
Expand Down Expand Up @@ -649,8 +651,9 @@ def create_and_run(
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.
Expand Down Expand Up @@ -1336,8 +1339,9 @@ async def create_and_run(
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.
Expand Down Expand Up @@ -1478,8 +1482,9 @@ async def create_and_run(
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.
Expand Down Expand Up @@ -1620,8 +1625,9 @@ async def create_and_run(
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.
Expand Down
84 changes: 42 additions & 42 deletions src/openai/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,15 @@ def create(
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
Expand Down Expand Up @@ -339,15 +339,15 @@ def create(
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
Expand Down Expand Up @@ -507,15 +507,15 @@ def create(
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
Expand Down Expand Up @@ -751,15 +751,15 @@ async def create(
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
Expand Down Expand Up @@ -919,15 +919,15 @@ async def create(
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
Expand Down Expand Up @@ -1087,15 +1087,15 @@ async def create(
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
Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/beta/assistant_tool_choice_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

__all__ = ["AssistantToolChoiceOption"]

AssistantToolChoiceOption = Union[Literal["none", "auto"], AssistantToolChoice]
AssistantToolChoiceOption = Union[Literal["none", "auto", "required"], AssistantToolChoice]
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

__all__ = ["AssistantToolChoiceOptionParam"]

AssistantToolChoiceOptionParam = Union[Literal["none", "auto"], AssistantToolChoiceParam]
AssistantToolChoiceOptionParam = Union[Literal["none", "auto", "required"], AssistantToolChoiceParam]
5 changes: 3 additions & 2 deletions src/openai/types/beta/thread_create_and_run_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down

0 comments on commit c558f65

Please sign in to comment.