Skip to content

Commit

Permalink
chore(api): docs and response_format response property (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Apr 17, 2024
1 parent ba3beaf commit 7a6d142
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 50 deletions.
8 changes: 4 additions & 4 deletions src/openai/resources/beta/assistants.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def create(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -253,7 +253,7 @@ def update(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -494,7 +494,7 @@ async def create(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -638,7 +638,7 @@ async def update(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down
78 changes: 54 additions & 24 deletions src/openai/resources/beta/threads/runs/runs.py

Large diffs are not rendered by default.

54 changes: 42 additions & 12 deletions src/openai/resources/beta/threads/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def create_and_run(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand All @@ -366,7 +366,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
Expand All @@ -382,6 +382,11 @@ def create_and_run(
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
control the intial context window of the run.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -481,7 +486,7 @@ def create_and_run(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand All @@ -503,7 +508,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
Expand All @@ -519,6 +524,11 @@ def create_and_run(
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
control the intial context window of the run.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -618,7 +628,7 @@ def create_and_run(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand All @@ -640,7 +650,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
Expand All @@ -656,6 +666,11 @@ def create_and_run(
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
control the intial context window of the run.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -1296,7 +1311,7 @@ async def create_and_run(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand All @@ -1322,7 +1337,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
Expand All @@ -1338,6 +1353,11 @@ async def create_and_run(
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
control the intial context window of the run.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -1437,7 +1457,7 @@ async def create_and_run(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand All @@ -1459,7 +1479,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
Expand All @@ -1475,6 +1495,11 @@ async def create_and_run(
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
control the intial context window of the run.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down Expand Up @@ -1574,7 +1599,7 @@ async def create_and_run(
response_format: Specifies the format that the model must output. Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand All @@ -1596,7 +1621,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
Expand All @@ -1612,6 +1637,11 @@ async def create_and_run(
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
control the intial context window of the run.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand Down
36 changes: 36 additions & 0 deletions src/openai/types/beta/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from ..._models import BaseModel
from .assistant_tool import AssistantTool
from .assistant_response_format_option import AssistantResponseFormatOption

__all__ = ["Assistant", "ToolResources", "ToolResourcesCodeInterpreter", "ToolResourcesFileSearch"]

Expand Down Expand Up @@ -81,10 +82,45 @@ class Assistant(BaseModel):
`code_interpreter`, `file_search`, or `function`.
"""

response_format: Optional[AssistantResponseFormatOption] = None
"""Specifies the format that the model must output.
Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
**Important:** when using JSON mode, you **must** also instruct the model to
produce JSON yourself via a system or user message. Without this, the model may
generate an unending stream of whitespace until the generation reaches the token
limit, resulting in a long-running and seemingly "stuck" request. Also note that
the message content may be partially cut off if `finish_reason="length"`, which
indicates the generation exceeded `max_tokens` or the conversation exceeded the
max context length.
"""

temperature: Optional[float] = None
"""What sampling temperature to use, between 0 and 2.
Higher values like 0.8 will make the output more random, while lower values like
0.2 will make it more focused and deterministic.
"""

tool_resources: Optional[ToolResources] = None
"""A set of resources that are used by the assistant's tools.
The resources are specific to the type of tool. For example, the
`code_interpreter` tool requires a list of file IDs, while the `file_search`
tool requires a list of vector store IDs.
"""

top_p: Optional[float] = None
"""
An alternative to sampling with temperature, called nucleus sampling, where the
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
"""
2 changes: 1 addition & 1 deletion src/openai/types/beta/assistant_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AssistantCreateParams(TypedDict, total=False):
Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/beta/assistant_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class AssistantUpdateParams(TypedDict, total=False):
Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down
10 changes: 8 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 @@ -106,7 +106,7 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -135,7 +135,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
"""
Expand All @@ -159,9 +159,15 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
An alternative to sampling with temperature, called nucleus sampling, where the
model considers the results of the tokens with top_p probability mass. So 0.1
means only the tokens comprising the top 10% probability mass are considered.
We generally recommend altering this or temperature but not both.
"""

truncation_strategy: Optional[TruncationStrategy]
"""Controls for how a thread will be truncated prior to the run.
Use this to control the intial context window of the run.
"""


class ThreadMessageAttachment(TypedDict, total=False):
Expand Down
8 changes: 6 additions & 2 deletions src/openai/types/beta/threads/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Run(BaseModel):
Compatible with
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
message the model generates is valid JSON.
Expand Down Expand Up @@ -197,7 +197,7 @@ 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": "TOOL_TYPE"}` or
Specifying a particular tool like `{"type": "file_search"}` or
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
call that tool.
"""
Expand All @@ -210,6 +210,10 @@ class Run(BaseModel):
"""

truncation_strategy: Optional[TruncationStrategy] = None
"""Controls for how a thread will be truncated prior to the run.
Use this to control the intial context window of the run.
"""

usage: Optional[Usage] = None
"""Usage statistics related to the run.
Expand Down

0 comments on commit 7a6d142

Please sign in to comment.