Commit f344db25

stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
2025-02-05 19:26:48
fix(api/types): correct audio duration & role types (#2091)
1 parent 6afde0d
src/openai/types/audio/transcription_verbose.py
@@ -10,7 +10,7 @@ __all__ = ["TranscriptionVerbose"]
 
 
 class TranscriptionVerbose(BaseModel):
-    duration: str
+    duration: float
     """The duration of the input audio."""
 
     language: str
src/openai/types/audio/translation_verbose.py
@@ -9,7 +9,7 @@ __all__ = ["TranslationVerbose"]
 
 
 class TranslationVerbose(BaseModel):
-    duration: str
+    duration: float
     """The duration of the input audio."""
 
     language: str
src/openai/types/beta/realtime/__init__.py
@@ -42,6 +42,7 @@ from .input_audio_buffer_append_event import InputAudioBufferAppendEvent as Inpu
 from .input_audio_buffer_commit_event import InputAudioBufferCommitEvent as InputAudioBufferCommitEvent
 from .response_output_item_done_event import ResponseOutputItemDoneEvent as ResponseOutputItemDoneEvent
 from .conversation_item_truncate_event import ConversationItemTruncateEvent as ConversationItemTruncateEvent
+from .conversation_item_with_reference import ConversationItemWithReference as ConversationItemWithReference
 from .input_audio_buffer_cleared_event import InputAudioBufferClearedEvent as InputAudioBufferClearedEvent
 from .response_content_part_done_event import ResponseContentPartDoneEvent as ResponseContentPartDoneEvent
 from .response_output_item_added_event import ResponseOutputItemAddedEvent as ResponseOutputItemAddedEvent
@@ -60,6 +61,9 @@ from .response_audio_transcript_delta_event import (
 from .conversation_item_truncate_event_param import (
     ConversationItemTruncateEventParam as ConversationItemTruncateEventParam,
 )
+from .conversation_item_with_reference_param import (
+    ConversationItemWithReferenceParam as ConversationItemWithReferenceParam,
+)
 from .input_audio_buffer_speech_started_event import (
     InputAudioBufferSpeechStartedEvent as InputAudioBufferSpeechStartedEvent,
 )
src/openai/types/beta/realtime/conversation_item_with_reference.py
@@ -0,0 +1,67 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from typing import List, Optional
+from typing_extensions import Literal
+
+from ...._models import BaseModel
+from .conversation_item_content import ConversationItemContent
+
+__all__ = ["ConversationItemWithReference"]
+
+
+class ConversationItemWithReference(BaseModel):
+    id: Optional[str] = None
+    """
+    For an item of type (`message` | `function_call` | `function_call_output`) this
+    field allows the client to assign the unique ID of the item. It is not required
+    because the server will generate one if not provided.
+
+    For an item of type `item_reference`, this field is required and is a reference
+    to any item that has previously existed in the conversation.
+    """
+
+    arguments: Optional[str] = None
+    """The arguments of the function call (for `function_call` items)."""
+
+    call_id: Optional[str] = None
+    """
+    The ID of the function call (for `function_call` and `function_call_output`
+    items). If passed on a `function_call_output` item, the server will check that a
+    `function_call` item with the same ID exists in the conversation history.
+    """
+
+    content: Optional[List[ConversationItemContent]] = None
+    """The content of the message, applicable for `message` items.
+
+    - Message items of role `system` support only `input_text` content
+    - Message items of role `user` support `input_text` and `input_audio` content
+    - Message items of role `assistant` support `text` content.
+    """
+
+    name: Optional[str] = None
+    """The name of the function being called (for `function_call` items)."""
+
+    object: Optional[Literal["realtime.item"]] = None
+    """Identifier for the API object being returned - always `realtime.item`."""
+
+    output: Optional[str] = None
+    """The output of the function call (for `function_call_output` items)."""
+
+    role: Optional[Literal["user", "assistant", "system"]] = None
+    """
+    The role of the message sender (`user`, `assistant`, `system`), only applicable
+    for `message` items.
+    """
+
+    status: Optional[Literal["completed", "incomplete"]] = None
+    """The status of the item (`completed`, `incomplete`).
+
+    These have no effect on the conversation, but are accepted for consistency with
+    the `conversation.item.created` event.
+    """
+
+    type: Optional[Literal["message", "function_call", "function_call_output", "item_reference"]] = None
+    """
+    The type of the item (`message`, `function_call`, `function_call_output`,
+    `item_reference`).
+    """
src/openai/types/beta/realtime/conversation_item_with_reference_param.py
@@ -0,0 +1,68 @@
+# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+from __future__ import annotations
+
+from typing import Iterable
+from typing_extensions import Literal, TypedDict
+
+from .conversation_item_content_param import ConversationItemContentParam
+
+__all__ = ["ConversationItemWithReferenceParam"]
+
+
+class ConversationItemWithReferenceParam(TypedDict, total=False):
+    id: str
+    """
+    For an item of type (`message` | `function_call` | `function_call_output`) this
+    field allows the client to assign the unique ID of the item. It is not required
+    because the server will generate one if not provided.
+
+    For an item of type `item_reference`, this field is required and is a reference
+    to any item that has previously existed in the conversation.
+    """
+
+    arguments: str
+    """The arguments of the function call (for `function_call` items)."""
+
+    call_id: str
+    """
+    The ID of the function call (for `function_call` and `function_call_output`
+    items). If passed on a `function_call_output` item, the server will check that a
+    `function_call` item with the same ID exists in the conversation history.
+    """
+
+    content: Iterable[ConversationItemContentParam]
+    """The content of the message, applicable for `message` items.
+
+    - Message items of role `system` support only `input_text` content
+    - Message items of role `user` support `input_text` and `input_audio` content
+    - Message items of role `assistant` support `text` content.
+    """
+
+    name: str
+    """The name of the function being called (for `function_call` items)."""
+
+    object: Literal["realtime.item"]
+    """Identifier for the API object being returned - always `realtime.item`."""
+
+    output: str
+    """The output of the function call (for `function_call_output` items)."""
+
+    role: Literal["user", "assistant", "system"]
+    """
+    The role of the message sender (`user`, `assistant`, `system`), only applicable
+    for `message` items.
+    """
+
+    status: Literal["completed", "incomplete"]
+    """The status of the item (`completed`, `incomplete`).
+
+    These have no effect on the conversation, but are accepted for consistency with
+    the `conversation.item.created` event.
+    """
+
+    type: Literal["message", "function_call", "function_call_output", "item_reference"]
+    """
+    The type of the item (`message`, `function_call`, `function_call_output`,
+    `item_reference`).
+    """
src/openai/types/beta/realtime/response_create_event.py
@@ -5,7 +5,7 @@ from typing_extensions import Literal
 
 from ...._models import BaseModel
 from ...shared.metadata import Metadata
-from .conversation_item import ConversationItem
+from .conversation_item_with_reference import ConversationItemWithReference
 
 __all__ = ["ResponseCreateEvent", "Response", "ResponseTool"]
 
@@ -37,11 +37,13 @@ class Response(BaseModel):
     will not add items to default conversation.
     """
 
-    input: Optional[List[ConversationItem]] = None
+    input: Optional[List[ConversationItemWithReference]] = None
     """Input items to include in the prompt for the model.
 
-    Creates a new context for this response, without including the default
-    conversation. Can include references to items from the default conversation.
+    Using this field creates a new context for this Response instead of using the
+    default conversation. An empty array `[]` will clear the context for this
+    Response. Note that this can include references to items from the default
+    conversation.
     """
 
     instructions: Optional[str] = None
src/openai/types/beta/realtime/response_create_event_param.py
@@ -5,8 +5,8 @@ from __future__ import annotations
 from typing import List, Union, Iterable, Optional
 from typing_extensions import Literal, Required, TypedDict
 
-from .conversation_item_param import ConversationItemParam
 from ...shared_params.metadata import Metadata
+from .conversation_item_with_reference_param import ConversationItemWithReferenceParam
 
 __all__ = ["ResponseCreateEventParam", "Response", "ResponseTool"]
 
@@ -38,11 +38,13 @@ class Response(TypedDict, total=False):
     will not add items to default conversation.
     """
 
-    input: Iterable[ConversationItemParam]
+    input: Iterable[ConversationItemWithReferenceParam]
     """Input items to include in the prompt for the model.
 
-    Creates a new context for this response, without including the default
-    conversation. Can include references to items from the default conversation.
+    Using this field creates a new context for this Response instead of using the
+    default conversation. An empty array `[]` will clear the context for this
+    Response. Note that this can include references to items from the default
+    conversation.
     """
 
     instructions: str
src/openai/types/chat/chat_completion_chunk.py
@@ -70,7 +70,7 @@ class ChoiceDelta(BaseModel):
     refusal: Optional[str] = None
     """The refusal message generated by the model."""
 
-    role: Optional[Literal["system", "user", "assistant", "tool"]] = None
+    role: Optional[Literal["developer", "system", "user", "assistant", "tool"]] = None
     """The role of the author of this message."""
 
     tool_calls: Optional[List[ChoiceDeltaToolCall]] = None
src/openai/types/chat/chat_completion_role.py
@@ -4,4 +4,4 @@ from typing_extensions import Literal, TypeAlias
 
 __all__ = ["ChatCompletionRole"]
 
-ChatCompletionRole: TypeAlias = Literal["system", "user", "assistant", "tool", "function"]
+ChatCompletionRole: TypeAlias = Literal["developer", "system", "user", "assistant", "tool", "function"]
.stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 69
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-6204952a29973265b9c0d66fc67ffaf53c6a90ae4d75cdacf9d147676f5274c9.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-fc5dbc19505b0035f9e7f88868619f4fb519b048bde011f6154f3132d4be71fb.yml
api.md
@@ -255,6 +255,7 @@ from openai.types.beta.realtime import (
     ConversationItemInputAudioTranscriptionFailedEvent,
     ConversationItemTruncateEvent,
     ConversationItemTruncatedEvent,
+    ConversationItemWithReference,
     ErrorEvent,
     InputAudioBufferAppendEvent,
     InputAudioBufferClearEvent,