Skip to content

Commit

Permalink
fix(api/types): correct audio duration & role types (#2091)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Feb 5, 2025
1 parent 6afde0d commit f344db2
Show file tree
Hide file tree
Showing 11 changed files with 157 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ from openai.types.beta.realtime import (
ConversationItemInputAudioTranscriptionFailedEvent,
ConversationItemTruncateEvent,
ConversationItemTruncatedEvent,
ConversationItemWithReference,
ErrorEvent,
InputAudioBufferAppendEvent,
InputAudioBufferClearEvent,
Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/audio/transcription_verbose.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class TranscriptionVerbose(BaseModel):
duration: str
duration: float
"""The duration of the input audio."""

language: str
Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/audio/translation_verbose.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class TranslationVerbose(BaseModel):
duration: str
duration: float
"""The duration of the input audio."""

language: str
Expand Down
4 changes: 4 additions & 0 deletions src/openai/types/beta/realtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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
Expand All @@ -60,6 +61,9 @@
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,
)
Expand Down
67 changes: 67 additions & 0 deletions src/openai/types/beta/realtime/conversation_item_with_reference.py
Original file line number Diff line number Diff line change
@@ -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`).
"""
Original file line number Diff line number Diff line change
@@ -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`).
"""
10 changes: 6 additions & 4 deletions src/openai/types/beta/realtime/response_create_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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"]

Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/openai/types/beta/realtime/response_create_event_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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"]

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/chat/chat_completion_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/openai/types/chat/chat_completion_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__all__ = ["ChatCompletionRole"]

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

0 comments on commit f344db2

Please sign in to comment.