Skip to content

Commit d161688

Browse files
committed
feat(api): add optional name argument + improve docs (openai#972)
1 parent 9e6e1a2 commit d161688

21 files changed

+205
-151
lines changed

src/openai/resources/audio/speech.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def create(
5353
`tts-1` or `tts-1-hd`
5454
5555
voice: The voice to use when generating the audio. Supported voices are `alloy`,
56-
`echo`, `fable`, `onyx`, `nova`, and `shimmer`.
56+
`echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are
57+
available in the
58+
[Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).
5759
5860
response_format: The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`.
5961
@@ -120,7 +122,9 @@ async def create(
120122
`tts-1` or `tts-1-hd`
121123
122124
voice: The voice to use when generating the audio. Supported voices are `alloy`,
123-
`echo`, `fable`, `onyx`, `nova`, and `shimmer`.
125+
`echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are
126+
available in the
127+
[Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).
124128
125129
response_format: The format to audio in. Supported formats are `mp3`, `opus`, `aac`, and `flac`.
126130

src/openai/resources/chat/completions.py

+62-50
Large diffs are not rendered by default.

src/openai/resources/completions.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def create(
103103
existing frequency in the text so far, decreasing the model's likelihood to
104104
repeat the same line verbatim.
105105
106-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
106+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
107107
108108
logit_bias: Modify the likelihood of specified tokens appearing in the completion.
109109
@@ -143,7 +143,7 @@ def create(
143143
whether they appear in the text so far, increasing the model's likelihood to
144144
talk about new topics.
145145
146-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
146+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
147147
148148
seed: If specified, our system will make a best effort to sample deterministically,
149149
such that repeated requests with the same `seed` and parameters should return
@@ -272,7 +272,7 @@ def create(
272272
existing frequency in the text so far, decreasing the model's likelihood to
273273
repeat the same line verbatim.
274274
275-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
275+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
276276
277277
logit_bias: Modify the likelihood of specified tokens appearing in the completion.
278278
@@ -312,7 +312,7 @@ def create(
312312
whether they appear in the text so far, increasing the model's likelihood to
313313
talk about new topics.
314314
315-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
315+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
316316
317317
seed: If specified, our system will make a best effort to sample deterministically,
318318
such that repeated requests with the same `seed` and parameters should return
@@ -434,7 +434,7 @@ def create(
434434
existing frequency in the text so far, decreasing the model's likelihood to
435435
repeat the same line verbatim.
436436
437-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
437+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
438438
439439
logit_bias: Modify the likelihood of specified tokens appearing in the completion.
440440
@@ -474,7 +474,7 @@ def create(
474474
whether they appear in the text so far, increasing the model's likelihood to
475475
talk about new topics.
476476
477-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
477+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
478478
479479
seed: If specified, our system will make a best effort to sample deterministically,
480480
such that repeated requests with the same `seed` and parameters should return
@@ -671,7 +671,7 @@ async def create(
671671
existing frequency in the text so far, decreasing the model's likelihood to
672672
repeat the same line verbatim.
673673
674-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
674+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
675675
676676
logit_bias: Modify the likelihood of specified tokens appearing in the completion.
677677
@@ -711,7 +711,7 @@ async def create(
711711
whether they appear in the text so far, increasing the model's likelihood to
712712
talk about new topics.
713713
714-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
714+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
715715
716716
seed: If specified, our system will make a best effort to sample deterministically,
717717
such that repeated requests with the same `seed` and parameters should return
@@ -840,7 +840,7 @@ async def create(
840840
existing frequency in the text so far, decreasing the model's likelihood to
841841
repeat the same line verbatim.
842842
843-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
843+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
844844
845845
logit_bias: Modify the likelihood of specified tokens appearing in the completion.
846846
@@ -880,7 +880,7 @@ async def create(
880880
whether they appear in the text so far, increasing the model's likelihood to
881881
talk about new topics.
882882
883-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
883+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
884884
885885
seed: If specified, our system will make a best effort to sample deterministically,
886886
such that repeated requests with the same `seed` and parameters should return
@@ -1002,7 +1002,7 @@ async def create(
10021002
existing frequency in the text so far, decreasing the model's likelihood to
10031003
repeat the same line verbatim.
10041004
1005-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
1005+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
10061006
10071007
logit_bias: Modify the likelihood of specified tokens appearing in the completion.
10081008
@@ -1042,7 +1042,7 @@ async def create(
10421042
whether they appear in the text so far, increasing the model's likelihood to
10431043
talk about new topics.
10441044
1045-
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/gpt/parameter-details)
1045+
[See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation/parameter-details)
10461046
10471047
seed: If specified, our system will make a best effort to sample deterministically,
10481048
such that repeated requests with the same `seed` and parameters should return

src/openai/resources/embeddings.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def create(
5151
input: Input text to embed, encoded as a string or array of tokens. To embed multiple
5252
inputs in a single request, pass an array of strings or array of token arrays.
5353
The input must not exceed the max input tokens for the model (8192 tokens for
54-
`text-embedding-ada-002`) and cannot be an empty string.
54+
`text-embedding-ada-002`), cannot be an empty string, and any array must be 2048
55+
dimensions or less.
5556
[Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
5657
for counting tokens.
5758
@@ -144,7 +145,8 @@ async def create(
144145
input: Input text to embed, encoded as a string or array of tokens. To embed multiple
145146
inputs in a single request, pass an array of strings or array of token arrays.
146147
The input must not exceed the max input tokens for the model (8192 tokens for
147-
`text-embedding-ada-002`) and cannot be an empty string.
148+
`text-embedding-ada-002`), cannot be an empty string, and any array must be 2048
149+
dimensions or less.
148150
[Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
149151
for counting tokens.
150152

src/openai/resources/files.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def create(
4646
extra_body: Body | None = None,
4747
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
4848
) -> FileObject:
49-
"""Upload a file that can be used across various endpoints/features.
49+
"""Upload a file that can be used across various endpoints.
5050
51-
The size of
52-
all the files uploaded by one organization can be up to 100 GB.
51+
The size of all the
52+
files uploaded by one organization can be up to 100 GB.
5353
54-
The size of individual files for can be a maximum of 512MB. See the
54+
The size of individual files can be a maximum of 512 MB. See the
5555
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) to
5656
learn more about the types of files supported. The Fine-tuning API only supports
5757
`.jsonl` files.
@@ -309,12 +309,12 @@ async def create(
309309
extra_body: Body | None = None,
310310
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
311311
) -> FileObject:
312-
"""Upload a file that can be used across various endpoints/features.
312+
"""Upload a file that can be used across various endpoints.
313313
314-
The size of
315-
all the files uploaded by one organization can be up to 100 GB.
314+
The size of all the
315+
files uploaded by one organization can be up to 100 GB.
316316
317-
The size of individual files for can be a maximum of 512MB. See the
317+
The size of individual files can be a maximum of 512 MB. See the
318318
[Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) to
319319
learn more about the types of files supported. The Fine-tuning API only supports
320320
`.jsonl` files.

src/openai/types/audio/speech_create_params.py

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class SpeechCreateParams(TypedDict, total=False):
2222
"""The voice to use when generating the audio.
2323
2424
Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`.
25+
Previews of the voices are available in the
26+
[Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech/voice-options).
2527
"""
2628

2729
response_format: Literal["mp3", "opus", "aac", "flac"]

src/openai/types/chat/chat_completion_assistant_message_param.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,28 @@ class FunctionCall(TypedDict, total=False):
2424

2525

2626
class ChatCompletionAssistantMessageParam(TypedDict, total=False):
27-
content: Required[Optional[str]]
28-
"""The contents of the assistant message."""
29-
3027
role: Required[Literal["assistant"]]
3128
"""The role of the messages author, in this case `assistant`."""
3229

30+
content: Optional[str]
31+
"""The contents of the assistant message.
32+
33+
Required unless `tool_calls` or `function_call` is specified.
34+
"""
35+
3336
function_call: FunctionCall
3437
"""Deprecated and replaced by `tool_calls`.
3538
3639
The name and arguments of a function that should be called, as generated by the
3740
model.
3841
"""
3942

43+
name: str
44+
"""An optional name for the participant.
45+
46+
Provides the model information to differentiate between participants of the same
47+
role.
48+
"""
49+
4050
tool_calls: List[ChatCompletionMessageToolCallParam]
4151
"""The tool calls generated by the model, such as function calls."""

src/openai/types/chat/chat_completion_content_part_image_param.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ class ImageURL(TypedDict, total=False):
1212
"""Either a URL of the image or the base64 encoded image data."""
1313

1414
detail: Literal["auto", "low", "high"]
15-
"""Specifies the detail level of the image."""
15+
"""Specifies the detail level of the image.
16+
17+
Learn more in the
18+
[Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
19+
"""
1620

1721

1822
class ChatCompletionContentPartImageParam(TypedDict, total=False):

src/openai/types/chat/chat_completion_function_message_param.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
65
from typing_extensions import Literal, Required, TypedDict
76

87
__all__ = ["ChatCompletionFunctionMessageParam"]
98

109

1110
class ChatCompletionFunctionMessageParam(TypedDict, total=False):
12-
content: Required[Optional[str]]
13-
"""The return value from the function call, to return to the model."""
11+
content: Required[str]
12+
"""The contents of the function message."""
1413

1514
name: Required[str]
1615
"""The name of the function to call."""

src/openai/types/chat/chat_completion_named_tool_choice_param.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Function(TypedDict, total=False):
1313

1414

1515
class ChatCompletionNamedToolChoiceParam(TypedDict, total=False):
16-
function: Function
16+
function: Required[Function]
1717

18-
type: Literal["function"]
18+
type: Required[Literal["function"]]
1919
"""The type of the tool. Currently, only `function` is supported."""

src/openai/types/chat/chat_completion_system_message_param.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
65
from typing_extensions import Literal, Required, TypedDict
76

87
__all__ = ["ChatCompletionSystemMessageParam"]
98

109

1110
class ChatCompletionSystemMessageParam(TypedDict, total=False):
12-
content: Required[Optional[str]]
11+
content: Required[str]
1312
"""The contents of the system message."""
1413

1514
role: Required[Literal["system"]]
1615
"""The role of the messages author, in this case `system`."""
16+
17+
name: str
18+
"""An optional name for the participant.
19+
20+
Provides the model information to differentiate between participants of the same
21+
role.
22+
"""

src/openai/types/chat/chat_completion_tool_message_param.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
from __future__ import annotations
44

5-
from typing import Optional
65
from typing_extensions import Literal, Required, TypedDict
76

87
__all__ = ["ChatCompletionToolMessageParam"]
98

109

1110
class ChatCompletionToolMessageParam(TypedDict, total=False):
12-
content: Required[Optional[str]]
11+
content: Required[str]
1312
"""The contents of the tool message."""
1413

1514
role: Required[Literal["tool"]]

src/openai/types/chat/chat_completion_user_message_param.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@
1111

1212

1313
class ChatCompletionUserMessageParam(TypedDict, total=False):
14-
content: Required[Union[str, List[ChatCompletionContentPartParam], None]]
14+
content: Required[Union[str, List[ChatCompletionContentPartParam]]]
1515
"""The contents of the user message."""
1616

1717
role: Required[Literal["user"]]
1818
"""The role of the messages author, in this case `user`."""
19+
20+
name: str
21+
"""An optional name for the participant.
22+
23+
Provides the model information to differentiate between participants of the same
24+
role.
25+
"""

0 commit comments

Comments
 (0)