Skip to content

Commit bcf459f

Browse files
fix(api/types): correct audio duration & role types (#1300)
1 parent 29a8627 commit bcf459f

File tree

7 files changed

+83
-10
lines changed

7 files changed

+83
-10
lines changed

Diff for: .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

Diff for: api.md

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ Types:
229229
- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemInputAudioTranscriptionFailedEvent</a></code>
230230
- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncateEvent</a></code>
231231
- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemTruncatedEvent</a></code>
232+
- <code><a href="./src/resources/beta/realtime/realtime.ts">ConversationItemWithReference</a></code>
232233
- <code><a href="./src/resources/beta/realtime/realtime.ts">ErrorEvent</a></code>
233234
- <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferAppendEvent</a></code>
234235
- <code><a href="./src/resources/beta/realtime/realtime.ts">InputAudioBufferClearEvent</a></code>

Diff for: src/lib/ChatCompletionStream.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
type ChatCompletionCreateParams,
1313
type ChatCompletionCreateParamsStreaming,
1414
type ChatCompletionCreateParamsBase,
15+
type ChatCompletionRole,
1516
} from '../resources/chat/completions';
1617
import {
1718
AbstractChatCompletionRunner,
@@ -797,7 +798,7 @@ export namespace ChatCompletionSnapshot {
797798
/**
798799
* The role of the author of this message.
799800
*/
800-
role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
801+
role?: ChatCompletionRole;
801802
}
802803

803804
export namespace Message {

Diff for: src/resources/audio/transcriptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export interface TranscriptionVerbose {
106106
/**
107107
* The duration of the input audio.
108108
*/
109-
duration: string;
109+
duration: number;
110110

111111
/**
112112
* The language of the input audio.

Diff for: src/resources/audio/translations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface TranslationVerbose {
4141
/**
4242
* The duration of the input audio.
4343
*/
44-
duration: string;
44+
duration: number;
4545

4646
/**
4747
* The language of the output translation (always `english`).

Diff for: src/resources/beta/realtime/realtime.ts

+75-4
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,76 @@ export interface ConversationItemTruncatedEvent {
439439
type: 'conversation.item.truncated';
440440
}
441441

442+
/**
443+
* The item to add to the conversation.
444+
*/
445+
export interface ConversationItemWithReference {
446+
/**
447+
* For an item of type (`message` | `function_call` | `function_call_output`) this
448+
* field allows the client to assign the unique ID of the item. It is not required
449+
* because the server will generate one if not provided.
450+
*
451+
* For an item of type `item_reference`, this field is required and is a reference
452+
* to any item that has previously existed in the conversation.
453+
*/
454+
id?: string;
455+
456+
/**
457+
* The arguments of the function call (for `function_call` items).
458+
*/
459+
arguments?: string;
460+
461+
/**
462+
* The ID of the function call (for `function_call` and `function_call_output`
463+
* items). If passed on a `function_call_output` item, the server will check that a
464+
* `function_call` item with the same ID exists in the conversation history.
465+
*/
466+
call_id?: string;
467+
468+
/**
469+
* The content of the message, applicable for `message` items.
470+
*
471+
* - Message items of role `system` support only `input_text` content
472+
* - Message items of role `user` support `input_text` and `input_audio` content
473+
* - Message items of role `assistant` support `text` content.
474+
*/
475+
content?: Array<ConversationItemContent>;
476+
477+
/**
478+
* The name of the function being called (for `function_call` items).
479+
*/
480+
name?: string;
481+
482+
/**
483+
* Identifier for the API object being returned - always `realtime.item`.
484+
*/
485+
object?: 'realtime.item';
486+
487+
/**
488+
* The output of the function call (for `function_call_output` items).
489+
*/
490+
output?: string;
491+
492+
/**
493+
* The role of the message sender (`user`, `assistant`, `system`), only applicable
494+
* for `message` items.
495+
*/
496+
role?: 'user' | 'assistant' | 'system';
497+
498+
/**
499+
* The status of the item (`completed`, `incomplete`). These have no effect on the
500+
* conversation, but are accepted for consistency with the
501+
* `conversation.item.created` event.
502+
*/
503+
status?: 'completed' | 'incomplete';
504+
505+
/**
506+
* The type of the item (`message`, `function_call`, `function_call_output`,
507+
* `item_reference`).
508+
*/
509+
type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
510+
}
511+
442512
/**
443513
* Returned when an error occurs, which could be a client problem or a server
444514
* problem. Most errors are recoverable and the session will stay open, we
@@ -1336,11 +1406,12 @@ export namespace ResponseCreateEvent {
13361406
conversation?: (string & {}) | 'auto' | 'none';
13371407

13381408
/**
1339-
* Input items to include in the prompt for the model. Creates a new context for
1340-
* this response, without including the default conversation. Can include
1341-
* references to items from the default conversation.
1409+
* Input items to include in the prompt for the model. Using this field creates a
1410+
* new context for this Response instead of using the default conversation. An
1411+
* empty array `[]` will clear the context for this Response. Note that this can
1412+
* include references to items from the default conversation.
13421413
*/
1343-
input?: Array<RealtimeAPI.ConversationItem>;
1414+
input?: Array<RealtimeAPI.ConversationItemWithReference>;
13441415

13451416
/**
13461417
* The default system instructions (i.e. system message) prepended to model calls.

Diff for: src/resources/chat/completions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ export namespace ChatCompletionChunk {
371371
/**
372372
* The role of the author of this message.
373373
*/
374-
role?: 'system' | 'user' | 'assistant' | 'tool';
374+
role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';
375375

376376
tool_calls?: Array<Delta.ToolCall>;
377377
}
@@ -756,7 +756,7 @@ export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
756756
/**
757757
* The role of the author of a message
758758
*/
759-
export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
759+
export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';
760760

761761
/**
762762
* Options for streaming response. Only set this when you set `stream: true`.

0 commit comments

Comments
 (0)