openai 4.82.0 → 4.83.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/core.d.ts +1 -0
  3. package/core.d.ts.map +1 -1
  4. package/core.js +13 -6
  5. package/core.js.map +1 -1
  6. package/core.mjs +13 -6
  7. package/core.mjs.map +1 -1
  8. package/index.js +1 -1
  9. package/index.js.map +1 -1
  10. package/index.mjs +1 -1
  11. package/index.mjs.map +1 -1
  12. package/lib/ChatCompletionStream.d.ts +2 -2
  13. package/lib/ChatCompletionStream.d.ts.map +1 -1
  14. package/lib/ChatCompletionStream.js.map +1 -1
  15. package/lib/ChatCompletionStream.mjs.map +1 -1
  16. package/package.json +1 -1
  17. package/resources/audio/transcriptions.d.ts +1 -1
  18. package/resources/audio/transcriptions.d.ts.map +1 -1
  19. package/resources/audio/transcriptions.js +1 -1
  20. package/resources/audio/transcriptions.js.map +1 -1
  21. package/resources/audio/transcriptions.mjs +1 -1
  22. package/resources/audio/transcriptions.mjs.map +1 -1
  23. package/resources/audio/translations.d.ts +1 -1
  24. package/resources/audio/translations.d.ts.map +1 -1
  25. package/resources/audio/translations.js +1 -1
  26. package/resources/audio/translations.js.map +1 -1
  27. package/resources/audio/translations.mjs +1 -1
  28. package/resources/audio/translations.mjs.map +1 -1
  29. package/resources/beta/realtime/realtime.d.ts +65 -4
  30. package/resources/beta/realtime/realtime.d.ts.map +1 -1
  31. package/resources/beta/realtime/realtime.js.map +1 -1
  32. package/resources/beta/realtime/realtime.mjs.map +1 -1
  33. package/resources/chat/completions.d.ts +2 -2
  34. package/resources/chat/completions.d.ts.map +1 -1
  35. package/src/core.ts +16 -6
  36. package/src/index.ts +1 -1
  37. package/src/lib/ChatCompletionStream.ts +2 -1
  38. package/src/resources/audio/transcriptions.ts +5 -2
  39. package/src/resources/audio/translations.ts +5 -2
  40. package/src/resources/beta/realtime/realtime.ts +75 -4
  41. package/src/resources/chat/completions.ts +2 -2
  42. package/src/version.ts +1 -1
  43. package/version.d.ts +1 -1
  44. package/version.js +1 -1
  45. package/version.mjs +1 -1
package/src/index.ts CHANGED
@@ -590,7 +590,7 @@ export class AzureOpenAI extends OpenAI {
590
590
  if (!Core.isObj(options.body)) {
591
591
  throw new Error('Expected request body to be an object');
592
592
  }
593
- const model = this.deploymentName || options.body['model'];
593
+ const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
594
594
  if (model !== undefined && !this.baseURL.includes('/deployments')) {
595
595
  options.path = `/deployments/${model}${options.path}`;
596
596
  }
@@ -12,6 +12,7 @@ import {
12
12
  type ChatCompletionCreateParams,
13
13
  type ChatCompletionCreateParamsStreaming,
14
14
  type ChatCompletionCreateParamsBase,
15
+ type ChatCompletionRole,
15
16
  } from '../resources/chat/completions';
16
17
  import {
17
18
  AbstractChatCompletionRunner,
@@ -797,7 +798,7 @@ export namespace ChatCompletionSnapshot {
797
798
  /**
798
799
  * The role of the author of this message.
799
800
  */
800
- role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
801
+ role?: ChatCompletionRole;
801
802
  }
802
803
 
803
804
  export namespace Message {
@@ -25,7 +25,10 @@ export class Transcriptions extends APIResource {
25
25
  body: TranscriptionCreateParams,
26
26
  options?: Core.RequestOptions,
27
27
  ): Core.APIPromise<TranscriptionCreateResponse | string> {
28
- return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
28
+ return this._client.post(
29
+ '/audio/transcriptions',
30
+ Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
31
+ );
29
32
  }
30
33
  }
31
34
 
@@ -103,7 +106,7 @@ export interface TranscriptionVerbose {
103
106
  /**
104
107
  * The duration of the input audio.
105
108
  */
106
- duration: string;
109
+ duration: number;
107
110
 
108
111
  /**
109
112
  * The language of the input audio.
@@ -26,7 +26,10 @@ export class Translations extends APIResource {
26
26
  body: TranslationCreateParams,
27
27
  options?: Core.RequestOptions,
28
28
  ): Core.APIPromise<TranslationCreateResponse | string> {
29
- return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
29
+ return this._client.post(
30
+ '/audio/translations',
31
+ Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
32
+ );
30
33
  }
31
34
  }
32
35
 
@@ -38,7 +41,7 @@ export interface TranslationVerbose {
38
41
  /**
39
42
  * The duration of the input audio.
40
43
  */
41
- duration: string;
44
+ duration: number;
42
45
 
43
46
  /**
44
47
  * The language of the output translation (always `english`).
@@ -439,6 +439,76 @@ export interface ConversationItemTruncatedEvent {
439
439
  type: 'conversation.item.truncated';
440
440
  }
441
441
 
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
+
442
512
  /**
443
513
  * Returned when an error occurs, which could be a client problem or a server
444
514
  * problem. Most errors are recoverable and the session will stay open, we
@@ -1336,11 +1406,12 @@ export namespace ResponseCreateEvent {
1336
1406
  conversation?: (string & {}) | 'auto' | 'none';
1337
1407
 
1338
1408
  /**
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.
1342
1413
  */
1343
- input?: Array<RealtimeAPI.ConversationItem>;
1414
+ input?: Array<RealtimeAPI.ConversationItemWithReference>;
1344
1415
 
1345
1416
  /**
1346
1417
  * The default system instructions (i.e. system message) prepended to model calls.
@@ -371,7 +371,7 @@ export namespace ChatCompletionChunk {
371
371
  /**
372
372
  * The role of the author of this message.
373
373
  */
374
- role?: 'system' | 'user' | 'assistant' | 'tool';
374
+ role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';
375
375
 
376
376
  tool_calls?: Array<Delta.ToolCall>;
377
377
  }
@@ -756,7 +756,7 @@ export type ChatCompletionReasoningEffort = 'low' | 'medium' | 'high';
756
756
  /**
757
757
  * The role of the author of a message
758
758
  */
759
- export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
759
+ export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';
760
760
 
761
761
  /**
762
762
  * Options for streaming response. Only set this when you set `stream: true`.
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '4.82.0'; // x-release-please-version
1
+ export const VERSION = '4.83.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.82.0";
1
+ export declare const VERSION = "4.83.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '4.82.0'; // x-release-please-version
4
+ exports.VERSION = '4.83.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '4.82.0'; // x-release-please-version
1
+ export const VERSION = '4.83.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map