Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit afcea48

Browse files
stainless-app[bot]stainless-bot
authored andcommittedFeb 5, 2025·
fix(api/types): correct audio duration & role types (#2091)
1 parent b7a80b1 commit afcea48

11 files changed

+157
-13
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 69
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml

‎api.md

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ from openai.types.beta.realtime import (
255255
ConversationItemInputAudioTranscriptionFailedEvent,
256256
ConversationItemTruncateEvent,
257257
ConversationItemTruncatedEvent,
258+
ConversationItemWithReference,
258259
ErrorEvent,
259260
InputAudioBufferAppendEvent,
260261
InputAudioBufferClearEvent,

‎src/openai/types/audio/transcription_verbose.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class TranscriptionVerbose(BaseModel):
13-
duration: str
13+
duration: float
1414
"""The duration of the input audio."""
1515

1616
language: str

‎src/openai/types/audio/translation_verbose.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class TranslationVerbose(BaseModel):
12-
duration: str
12+
duration: float
1313
"""The duration of the input audio."""
1414

1515
language: str

‎src/openai/types/beta/realtime/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from .input_audio_buffer_commit_event import InputAudioBufferCommitEvent as InputAudioBufferCommitEvent
4343
from .response_output_item_done_event import ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent
4444
from .conversation_item_truncate_event import ConversationItemTruncateEvent as ConversationItemTruncateEvent
45+
from .conversation_item_with_reference import ConversationItemWithReference as ConversationItemWithReference
4546
from .input_audio_buffer_cleared_event import InputAudioBufferClearedEvent as InputAudioBufferClearedEvent
4647
from .response_content_part_done_event import ResponseContentPartDoneEvent as ResponseContentPartDoneEvent
4748
from .response_output_item_added_event import ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent
@@ -60,6 +61,9 @@
6061
from .conversation_item_truncate_event_param import (
6162
ConversationItemTruncateEventParam as ConversationItemTruncateEventParam,
6263
)
64+
from .conversation_item_with_reference_param import (
65+
ConversationItemWithReferenceParam as ConversationItemWithReferenceParam,
66+
)
6367
from .input_audio_buffer_speech_started_event import (
6468
InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent,
6569
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from typing_extensions import Literal
5+
6+
from ...._models import BaseModel
7+
from .conversation_item_content import ConversationItemContent
8+
9+
__all__ = ["ConversationItemWithReference"]
10+
11+
12+
class ConversationItemWithReference(BaseModel):
13+
id: Optional[str] = None
14+
"""
15+
For an item of type (`message` | `function_call` | `function_call_output`) this
16+
field allows the client to assign the unique ID of the item. It is not required
17+
because the server will generate one if not provided.
18+
19+
For an item of type `item_reference`, this field is required and is a reference
20+
to any item that has previously existed in the conversation.
21+
"""
22+
23+
arguments: Optional[str] = None
24+
"""The arguments of the function call (for `function_call` items)."""
25+
26+
call_id: Optional[str] = None
27+
"""
28+
The ID of the function call (for `function_call` and `function_call_output`
29+
items). If passed on a `function_call_output` item, the server will check that a
30+
`function_call` item with the same ID exists in the conversation history.
31+
"""
32+
33+
content: Optional[List[ConversationItemContent]] = None
34+
"""The content of the message, applicable for `message` items.
35+
36+
- Message items of role `system` support only `input_text` content
37+
- Message items of role `user` support `input_text` and `input_audio` content
38+
- Message items of role `assistant` support `text` content.
39+
"""
40+
41+
name: Optional[str] = None
42+
"""The name of the function being called (for `function_call` items)."""
43+
44+
object: Optional[Literal["realtime.item"]] = None
45+
"""Identifier for the API object being returned - always `realtime.item`."""
46+
47+
output: Optional[str] = None
48+
"""The output of the function call (for `function_call_output` items)."""
49+
50+
role: Optional[Literal["user", "assistant", "system"]] = None
51+
"""
52+
The role of the message sender (`user`, `assistant`, `system`), only applicable
53+
for `message` items.
54+
"""
55+
56+
status: Optional[Literal["completed", "incomplete"]] = None
57+
"""The status of the item (`completed`, `incomplete`).
58+
59+
These have no effect on the conversation, but are accepted for consistency with
60+
the `conversation.item.created` event.
61+
"""
62+
63+
type: Optional[Literal["message", "function_call", "function_call_output", "item_reference"]] = None
64+
"""
65+
The type of the item (`message`, `function_call`, `function_call_output`,
66+
`item_reference`).
67+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import Iterable
6+
from typing_extensions import Literal, TypedDict
7+
8+
from .conversation_item_content_param import ConversationItemContentParam
9+
10+
__all__ = ["ConversationItemWithReferenceParam"]
11+
12+
13+
class ConversationItemWithReferenceParam(TypedDict, total=False):
14+
id: str
15+
"""
16+
For an item of type (`message` | `function_call` | `function_call_output`) this
17+
field allows the client to assign the unique ID of the item. It is not required
18+
because the server will generate one if not provided.
19+
20+
For an item of type `item_reference`, this field is required and is a reference
21+
to any item that has previously existed in the conversation.
22+
"""
23+
24+
arguments: str
25+
"""The arguments of the function call (for `function_call` items)."""
26+
27+
call_id: str
28+
"""
29+
The ID of the function call (for `function_call` and `function_call_output`
30+
items). If passed on a `function_call_output` item, the server will check that a
31+
`function_call` item with the same ID exists in the conversation history.
32+
"""
33+
34+
content: Iterable[ConversationItemContentParam]
35+
"""The content of the message, applicable for `message` items.
36+
37+
- Message items of role `system` support only `input_text` content
38+
- Message items of role `user` support `input_text` and `input_audio` content
39+
- Message items of role `assistant` support `text` content.
40+
"""
41+
42+
name: str
43+
"""The name of the function being called (for `function_call` items)."""
44+
45+
object: Literal["realtime.item"]
46+
"""Identifier for the API object being returned - always `realtime.item`."""
47+
48+
output: str
49+
"""The output of the function call (for `function_call_output` items)."""
50+
51+
role: Literal["user", "assistant", "system"]
52+
"""
53+
The role of the message sender (`user`, `assistant`, `system`), only applicable
54+
for `message` items.
55+
"""
56+
57+
status: Literal["completed", "incomplete"]
58+
"""The status of the item (`completed`, `incomplete`).
59+
60+
These have no effect on the conversation, but are accepted for consistency with
61+
the `conversation.item.created` event.
62+
"""
63+
64+
type: Literal["message", "function_call", "function_call_output", "item_reference"]
65+
"""
66+
The type of the item (`message`, `function_call`, `function_call_output`,
67+
`item_reference`).
68+
"""

‎src/openai/types/beta/realtime/response_create_event.py

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

66
from ...._models import BaseModel
77
from ...shared.metadata import Metadata
8-
from .conversation_item import ConversationItem
8+
from .conversation_item_with_reference import ConversationItemWithReference
99

1010
__all__ = ["ResponseCreateEvent", "Response", "ResponseTool"]
1111

@@ -37,11 +37,13 @@ class Response(BaseModel):
3737
will not add items to default conversation.
3838
"""
3939

40-
input: Optional[List[ConversationItem]] = None
40+
input: Optional[List[ConversationItemWithReference]] = None
4141
"""Input items to include in the prompt for the model.
4242
43-
Creates a new context for this response, without including the default
44-
conversation. Can include references to items from the default conversation.
43+
Using this field creates a new context for this Response instead of using the
44+
default conversation. An empty array `[]` will clear the context for this
45+
Response. Note that this can include references to items from the default
46+
conversation.
4547
"""
4648

4749
instructions: Optional[str] = None

‎src/openai/types/beta/realtime/response_create_event_param.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from typing import List, Union, Iterable, Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8-
from .conversation_item_param import ConversationItemParam
98
from ...shared_params.metadata import Metadata
9+
from .conversation_item_with_reference_param import ConversationItemWithReferenceParam
1010

1111
__all__ = ["ResponseCreateEventParam", "Response", "ResponseTool"]
1212

@@ -38,11 +38,13 @@ class Response(TypedDict, total=False):
3838
will not add items to default conversation.
3939
"""
4040

41-
input: Iterable[ConversationItemParam]
41+
input: Iterable[ConversationItemWithReferenceParam]
4242
"""Input items to include in the prompt for the model.
4343
44-
Creates a new context for this response, without including the default
45-
conversation. Can include references to items from the default conversation.
44+
Using this field creates a new context for this Response instead of using the
45+
default conversation. An empty array `[]` will clear the context for this
46+
Response. Note that this can include references to items from the default
47+
conversation.
4648
"""
4749

4850
instructions: str

‎src/openai/types/chat/chat_completion_chunk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ChoiceDelta(BaseModel):
7070
refusal: Optional[str] = None
7171
"""The refusal message generated by the model."""
7272

73-
role: Optional[Literal["system", "user", "assistant", "tool"]] = None
73+
role: Optional[Literal["developer", "system", "user", "assistant", "tool"]] = None
7474
"""The role of the author of this message."""
7575

7676
tool_calls: Optional[List[ChoiceDeltaToolCall]] = None

‎src/openai/types/chat/chat_completion_role.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
__all__ = ["ChatCompletionRole"]
66

7-
ChatCompletionRole: TypeAlias = Literal["system", "user", "assistant", "tool", "function"]
7+
ChatCompletionRole: TypeAlias = Literal["developer", "system", "user", "assistant", "tool", "function"]

0 commit comments

Comments
 (0)
Please sign in to comment.