Skip to content

Commit bb95fe3

Browse files
release: 1.21.1 (#1328)
* chore(api): docs and response_format response property (#1327) * release: 1.21.1
1 parent ba3beaf commit bb95fe3

13 files changed

+173
-53
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.21.0"
2+
".": "1.21.1"
33
}

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 1.21.1 (2024-04-17)
4+
5+
Full Changelog: [v1.21.0...v1.21.1](https://github.com/openai/openai-python/compare/v1.21.0...v1.21.1)
6+
7+
### Chores
8+
9+
* **api:** docs and response_format response property ([#1327](https://github.com/openai/openai-python/issues/1327)) ([7a6d142](https://github.com/openai/openai-python/commit/7a6d142f013994c4eb9a4f55888464c885f8baf0))
10+
311
## 1.21.0 (2024-04-17)
412

513
Full Changelog: [v1.20.0...v1.21.0](https://github.com/openai/openai-python/compare/v1.20.0...v1.21.0)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "openai"
3-
version = "1.21.0"
3+
version = "1.21.1"
44
description = "The official Python library for the openai API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/openai/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "openai"
4-
__version__ = "1.21.0" # x-release-please-version
4+
__version__ = "1.21.1" # x-release-please-version

src/openai/resources/beta/assistants.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def create(
109109
110110
response_format: Specifies the format that the model must output. Compatible with
111111
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
112-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
112+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
113113
114114
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
115115
message the model generates is valid JSON.
@@ -253,7 +253,7 @@ def update(
253253
254254
response_format: Specifies the format that the model must output. Compatible with
255255
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
256-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
256+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
257257
258258
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
259259
message the model generates is valid JSON.
@@ -494,7 +494,7 @@ async def create(
494494
495495
response_format: Specifies the format that the model must output. Compatible with
496496
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
497-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
497+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
498498
499499
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
500500
message the model generates is valid JSON.
@@ -638,7 +638,7 @@ async def update(
638638
639639
response_format: Specifies the format that the model must output. Compatible with
640640
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
641-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
641+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
642642
643643
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
644644
message the model generates is valid JSON.

src/openai/resources/beta/threads/runs/runs.py

+54-24
Large diffs are not rendered by default.

src/openai/resources/beta/threads/threads.py

+42-12
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def create_and_run(
340340
341341
response_format: Specifies the format that the model must output. Compatible with
342342
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
343-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
343+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
344344
345345
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
346346
message the model generates is valid JSON.
@@ -366,7 +366,7 @@ def create_and_run(
366366
tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
367367
not call any tools and instead generates a message. `auto` is the default value
368368
and means the model can pick between generating a message or calling a tool.
369-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
369+
Specifying a particular tool like `{"type": "file_search"}` or
370370
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
371371
call that tool.
372372
@@ -382,6 +382,11 @@ def create_and_run(
382382
model considers the results of the tokens with top_p probability mass. So 0.1
383383
means only the tokens comprising the top 10% probability mass are considered.
384384
385+
We generally recommend altering this or temperature but not both.
386+
387+
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
388+
control the intial context window of the run.
389+
385390
extra_headers: Send extra headers
386391
387392
extra_query: Add additional query parameters to the request
@@ -481,7 +486,7 @@ def create_and_run(
481486
482487
response_format: Specifies the format that the model must output. Compatible with
483488
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
484-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
489+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
485490
486491
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
487492
message the model generates is valid JSON.
@@ -503,7 +508,7 @@ def create_and_run(
503508
tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
504509
not call any tools and instead generates a message. `auto` is the default value
505510
and means the model can pick between generating a message or calling a tool.
506-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
511+
Specifying a particular tool like `{"type": "file_search"}` or
507512
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
508513
call that tool.
509514
@@ -519,6 +524,11 @@ def create_and_run(
519524
model considers the results of the tokens with top_p probability mass. So 0.1
520525
means only the tokens comprising the top 10% probability mass are considered.
521526
527+
We generally recommend altering this or temperature but not both.
528+
529+
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
530+
control the intial context window of the run.
531+
522532
extra_headers: Send extra headers
523533
524534
extra_query: Add additional query parameters to the request
@@ -618,7 +628,7 @@ def create_and_run(
618628
619629
response_format: Specifies the format that the model must output. Compatible with
620630
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
621-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
631+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
622632
623633
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
624634
message the model generates is valid JSON.
@@ -640,7 +650,7 @@ def create_and_run(
640650
tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
641651
not call any tools and instead generates a message. `auto` is the default value
642652
and means the model can pick between generating a message or calling a tool.
643-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
653+
Specifying a particular tool like `{"type": "file_search"}` or
644654
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
645655
call that tool.
646656
@@ -656,6 +666,11 @@ def create_and_run(
656666
model considers the results of the tokens with top_p probability mass. So 0.1
657667
means only the tokens comprising the top 10% probability mass are considered.
658668
669+
We generally recommend altering this or temperature but not both.
670+
671+
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
672+
control the intial context window of the run.
673+
659674
extra_headers: Send extra headers
660675
661676
extra_query: Add additional query parameters to the request
@@ -1296,7 +1311,7 @@ async def create_and_run(
12961311
12971312
response_format: Specifies the format that the model must output. Compatible with
12981313
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
1299-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
1314+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
13001315
13011316
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
13021317
message the model generates is valid JSON.
@@ -1322,7 +1337,7 @@ async def create_and_run(
13221337
tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
13231338
not call any tools and instead generates a message. `auto` is the default value
13241339
and means the model can pick between generating a message or calling a tool.
1325-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
1340+
Specifying a particular tool like `{"type": "file_search"}` or
13261341
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
13271342
call that tool.
13281343
@@ -1338,6 +1353,11 @@ async def create_and_run(
13381353
model considers the results of the tokens with top_p probability mass. So 0.1
13391354
means only the tokens comprising the top 10% probability mass are considered.
13401355
1356+
We generally recommend altering this or temperature but not both.
1357+
1358+
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
1359+
control the intial context window of the run.
1360+
13411361
extra_headers: Send extra headers
13421362
13431363
extra_query: Add additional query parameters to the request
@@ -1437,7 +1457,7 @@ async def create_and_run(
14371457
14381458
response_format: Specifies the format that the model must output. Compatible with
14391459
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
1440-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
1460+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
14411461
14421462
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
14431463
message the model generates is valid JSON.
@@ -1459,7 +1479,7 @@ async def create_and_run(
14591479
tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
14601480
not call any tools and instead generates a message. `auto` is the default value
14611481
and means the model can pick between generating a message or calling a tool.
1462-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
1482+
Specifying a particular tool like `{"type": "file_search"}` or
14631483
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
14641484
call that tool.
14651485
@@ -1475,6 +1495,11 @@ async def create_and_run(
14751495
model considers the results of the tokens with top_p probability mass. So 0.1
14761496
means only the tokens comprising the top 10% probability mass are considered.
14771497
1498+
We generally recommend altering this or temperature but not both.
1499+
1500+
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
1501+
control the intial context window of the run.
1502+
14781503
extra_headers: Send extra headers
14791504
14801505
extra_query: Add additional query parameters to the request
@@ -1574,7 +1599,7 @@ async def create_and_run(
15741599
15751600
response_format: Specifies the format that the model must output. Compatible with
15761601
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
1577-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
1602+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
15781603
15791604
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
15801605
message the model generates is valid JSON.
@@ -1596,7 +1621,7 @@ async def create_and_run(
15961621
tool_choice: Controls which (if any) tool is called by the model. `none` means the model will
15971622
not call any tools and instead generates a message. `auto` is the default value
15981623
and means the model can pick between generating a message or calling a tool.
1599-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
1624+
Specifying a particular tool like `{"type": "file_search"}` or
16001625
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
16011626
call that tool.
16021627
@@ -1612,6 +1637,11 @@ async def create_and_run(
16121637
model considers the results of the tokens with top_p probability mass. So 0.1
16131638
means only the tokens comprising the top 10% probability mass are considered.
16141639
1640+
We generally recommend altering this or temperature but not both.
1641+
1642+
truncation_strategy: Controls for how a thread will be truncated prior to the run. Use this to
1643+
control the intial context window of the run.
1644+
16151645
extra_headers: Send extra headers
16161646
16171647
extra_query: Add additional query parameters to the request

src/openai/types/beta/assistant.py

+36
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from ..._models import BaseModel
77
from .assistant_tool import AssistantTool
8+
from .assistant_response_format_option import AssistantResponseFormatOption
89

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

@@ -81,10 +82,45 @@ class Assistant(BaseModel):
8182
`code_interpreter`, `file_search`, or `function`.
8283
"""
8384

85+
response_format: Optional[AssistantResponseFormatOption] = None
86+
"""Specifies the format that the model must output.
87+
88+
Compatible with
89+
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
90+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
91+
92+
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
93+
message the model generates is valid JSON.
94+
95+
**Important:** when using JSON mode, you **must** also instruct the model to
96+
produce JSON yourself via a system or user message. Without this, the model may
97+
generate an unending stream of whitespace until the generation reaches the token
98+
limit, resulting in a long-running and seemingly "stuck" request. Also note that
99+
the message content may be partially cut off if `finish_reason="length"`, which
100+
indicates the generation exceeded `max_tokens` or the conversation exceeded the
101+
max context length.
102+
"""
103+
104+
temperature: Optional[float] = None
105+
"""What sampling temperature to use, between 0 and 2.
106+
107+
Higher values like 0.8 will make the output more random, while lower values like
108+
0.2 will make it more focused and deterministic.
109+
"""
110+
84111
tool_resources: Optional[ToolResources] = None
85112
"""A set of resources that are used by the assistant's tools.
86113
87114
The resources are specific to the type of tool. For example, the
88115
`code_interpreter` tool requires a list of file IDs, while the `file_search`
89116
tool requires a list of vector store IDs.
90117
"""
118+
119+
top_p: Optional[float] = None
120+
"""
121+
An alternative to sampling with temperature, called nucleus sampling, where the
122+
model considers the results of the tokens with top_p probability mass. So 0.1
123+
means only the tokens comprising the top 10% probability mass are considered.
124+
125+
We generally recommend altering this or temperature but not both.
126+
"""

src/openai/types/beta/assistant_create_params.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AssistantCreateParams(TypedDict, total=False):
7777
7878
Compatible with
7979
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
80-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
80+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
8181
8282
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
8383
message the model generates is valid JSON.

src/openai/types/beta/assistant_update_params.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class AssistantUpdateParams(TypedDict, total=False):
4747
4848
Compatible with
4949
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
50-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
50+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
5151
5252
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
5353
message the model generates is valid JSON.

src/openai/types/beta/thread_create_and_run_params.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
106106
107107
Compatible with
108108
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
109-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
109+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
110110
111111
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
112112
message the model generates is valid JSON.
@@ -135,7 +135,7 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
135135
Controls which (if any) tool is called by the model. `none` means the model will
136136
not call any tools and instead generates a message. `auto` is the default value
137137
and means the model can pick between generating a message or calling a tool.
138-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
138+
Specifying a particular tool like `{"type": "file_search"}` or
139139
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
140140
call that tool.
141141
"""
@@ -159,9 +159,15 @@ class ThreadCreateAndRunParamsBase(TypedDict, total=False):
159159
An alternative to sampling with temperature, called nucleus sampling, where the
160160
model considers the results of the tokens with top_p probability mass. So 0.1
161161
means only the tokens comprising the top 10% probability mass are considered.
162+
163+
We generally recommend altering this or temperature but not both.
162164
"""
163165

164166
truncation_strategy: Optional[TruncationStrategy]
167+
"""Controls for how a thread will be truncated prior to the run.
168+
169+
Use this to control the intial context window of the run.
170+
"""
165171

166172

167173
class ThreadMessageAttachment(TypedDict, total=False):

src/openai/types/beta/threads/run.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class Run(BaseModel):
162162
163163
Compatible with
164164
[GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
165-
all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.
165+
all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
166166
167167
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
168168
message the model generates is valid JSON.
@@ -197,7 +197,7 @@ class Run(BaseModel):
197197
Controls which (if any) tool is called by the model. `none` means the model will
198198
not call any tools and instead generates a message. `auto` is the default value
199199
and means the model can pick between generating a message or calling a tool.
200-
Specifying a particular tool like `{"type": "TOOL_TYPE"}` or
200+
Specifying a particular tool like `{"type": "file_search"}` or
201201
`{"type": "function", "function": {"name": "my_function"}}` forces the model to
202202
call that tool.
203203
"""
@@ -210,6 +210,10 @@ class Run(BaseModel):
210210
"""
211211

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

214218
usage: Optional[Usage] = None
215219
"""Usage statistics related to the run.

0 commit comments

Comments
 (0)