New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

openai

Package Overview
Dependencies
Maintainers
5
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai - npm Package Compare versions

Comparing version 4.82.0 to 4.83.0

1

core.d.ts

@@ -206,2 +206,3 @@

idempotencyKey?: string;
__metadata?: Record<string, unknown>;
__binaryRequest?: boolean | undefined;

@@ -208,0 +209,0 @@ __binaryResponse?: boolean | undefined;

19

core.js

@@ -215,2 +215,3 @@ "use strict";

buildRequest(options, { retryCount = 0 } = {}) {
options = { ...options };
const { method, path, query, headers: headers = {} } = options;

@@ -226,5 +227,5 @@ const body = ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?

validatePositiveInteger('timeout', options.timeout);
const timeout = options.timeout ?? this.timeout;
options.timeout = options.timeout ?? this.timeout;
const httpAgent = options.httpAgent ?? this.httpAgent ?? (0, index_1.getDefaultAgent)(url);
const minAgentTimeout = timeout + 1000;
const minAgentTimeout = options.timeout + 1000;
if (typeof httpAgent?.options?.timeout === 'number' &&

@@ -253,3 +254,3 @@ minAgentTimeout > (httpAgent.options.timeout ?? 0)) {

};
return { req, url, timeout };
return { req, url, timeout: options.timeout };
}

@@ -268,5 +269,5 @@ buildHeaders({ options, headers, contentLength, retryCount, }) {

}
// Don't set the retry count header if it was already set or removed through default headers or by the
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
// account for the removal case.
// Don't set theses headers if they were already set or removed through default headers or by the caller.
// We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account
// for the removal case.
if ((0, exports.getHeader)(defaultHeaders, 'x-stainless-retry-count') === undefined &&

@@ -276,2 +277,7 @@ (0, exports.getHeader)(headers, 'x-stainless-retry-count') === undefined) {

}
if ((0, exports.getHeader)(defaultHeaders, 'x-stainless-timeout') === undefined &&
(0, exports.getHeader)(headers, 'x-stainless-timeout') === undefined &&
options.timeout) {
reqHeaders['x-stainless-timeout'] = String(options.timeout);
}
this.validateHeaders(reqHeaders, headers);

@@ -570,2 +576,3 @@ return reqHeaders;

idempotencyKey: true,
__metadata: true,
__binaryRequest: true,

@@ -572,0 +579,0 @@ __binaryResponse: true,

@@ -221,3 +221,3 @@ "use strict";

}
const model = this.deploymentName || options.body['model'];
const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
if (model !== undefined && !this.baseURL.includes('/deployments')) {

@@ -224,0 +224,0 @@ options.path = `/deployments/${model}${options.path}`;

import * as Core from "../core.js";
import { ChatCompletionTokenLogprob, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionCreateParamsBase } from "../resources/chat/completions.js";
import { ChatCompletionTokenLogprob, type ChatCompletion, type ChatCompletionChunk, type ChatCompletionCreateParams, type ChatCompletionCreateParamsBase, type ChatCompletionRole } from "../resources/chat/completions.js";
import { AbstractChatCompletionRunner, type AbstractChatCompletionRunnerEvents } from "./AbstractChatCompletionRunner.js";

@@ -158,3 +158,3 @@ import { type ReadableStream } from "../_shims/index.js";

*/
role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
role?: ChatCompletionRole;
}

@@ -161,0 +161,0 @@ namespace Message {

{
"name": "openai",
"version": "4.82.0",
"version": "4.83.0",
"description": "The official TypeScript library for the OpenAI API",

@@ -5,0 +5,0 @@ "author": "OpenAI <support@openai.com>",

@@ -76,3 +76,3 @@ import { APIResource } from "../../resource.js";

*/
duration: string;
duration: number;
/**

@@ -79,0 +79,0 @@ * The language of the input audio.

@@ -32,3 +32,3 @@ "use strict";

create(body, options) {
return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }));
}

@@ -35,0 +35,0 @@ }

@@ -21,3 +21,3 @@ import { APIResource } from "../../resource.js";

*/
duration: string;
duration: number;
/**

@@ -24,0 +24,0 @@ * The language of the output translation (always `english`).

@@ -32,3 +32,3 @@ "use strict";

create(body, options) {
return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }));
}

@@ -35,0 +35,0 @@ }

@@ -376,2 +376,62 @@ import { APIResource } from "../../../resource.js";

/**
* The item to add to the conversation.
*/
export interface ConversationItemWithReference {
/**
* 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.
*/
id?: string;
/**
* The arguments of the function call (for `function_call` items).
*/
arguments?: string;
/**
* 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.
*/
call_id?: string;
/**
* 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.
*/
content?: Array<ConversationItemContent>;
/**
* The name of the function being called (for `function_call` items).
*/
name?: string;
/**
* Identifier for the API object being returned - always `realtime.item`.
*/
object?: 'realtime.item';
/**
* The output of the function call (for `function_call_output` items).
*/
output?: string;
/**
* The role of the message sender (`user`, `assistant`, `system`), only applicable
* for `message` items.
*/
role?: 'user' | 'assistant' | 'system';
/**
* 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.
*/
status?: 'completed' | 'incomplete';
/**
* The type of the item (`message`, `function_call`, `function_call_output`,
* `item_reference`).
*/
type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
}
/**
* Returned when an error occurs, which could be a client problem or a server

@@ -1114,7 +1174,8 @@ * problem. Most errors are recoverable and the session will stay open, we

/**
* 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.
* Input items to include in the prompt for the model. 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.
*/
input?: Array<RealtimeAPI.ConversationItem>;
input?: Array<RealtimeAPI.ConversationItemWithReference>;
/**

@@ -1121,0 +1182,0 @@ * The default system instructions (i.e. system message) prepended to model calls.

@@ -308,3 +308,3 @@ import { APIResource } from "../../resource.js";

*/
role?: 'system' | 'user' | 'assistant' | 'tool';
role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';
tool_calls?: Array<Delta.ToolCall>;

@@ -632,3 +632,3 @@ }

*/
export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';
/**

@@ -635,0 +635,0 @@ * Options for streaming response. Only set this when you set `stream: true`.

@@ -318,2 +318,3 @@ import { VERSION } from './version';

): { req: RequestInit; url: string; timeout: number } {
options = { ...options };
const { method, path, query, headers: headers = {} } = options;

@@ -331,5 +332,5 @@

if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
const timeout = options.timeout ?? this.timeout;
options.timeout = options.timeout ?? this.timeout;
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
const minAgentTimeout = timeout + 1000;
const minAgentTimeout = options.timeout + 1000;
if (

@@ -363,3 +364,3 @@ typeof (httpAgent as any)?.options?.timeout === 'number' &&

return { req, url, timeout };
return { req, url, timeout: options.timeout };
}

@@ -392,5 +393,5 @@

// Don't set the retry count header if it was already set or removed through default headers or by the
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
// account for the removal case.
// Don't set theses headers if they were already set or removed through default headers or by the caller.
// We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account
// for the removal case.
if (

@@ -402,2 +403,9 @@ getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&

}
if (
getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
getHeader(headers, 'x-stainless-timeout') === undefined &&
options.timeout
) {
reqHeaders['x-stainless-timeout'] = String(options.timeout);
}

@@ -822,2 +830,3 @@ this.validateHeaders(reqHeaders, headers);

__metadata?: Record<string, unknown>;
__binaryRequest?: boolean | undefined;

@@ -845,2 +854,3 @@ __binaryResponse?: boolean | undefined;

__metadata: true,
__binaryRequest: true,

@@ -847,0 +857,0 @@ __binaryResponse: true,

@@ -593,3 +593,3 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

}
const model = this.deploymentName || options.body['model'];
const model = this.deploymentName || options.body['model'] || options.__metadata?.['model'];
if (model !== undefined && !this.baseURL.includes('/deployments')) {

@@ -596,0 +596,0 @@ options.path = `/deployments/${model}${options.path}`;

@@ -15,2 +15,3 @@ import * as Core from '../core';

type ChatCompletionCreateParamsBase,
type ChatCompletionRole,
} from '../resources/chat/completions';

@@ -801,3 +802,3 @@ import {

*/
role?: 'system' | 'user' | 'assistant' | 'function' | 'tool';
role?: ChatCompletionRole;
}

@@ -804,0 +805,0 @@

@@ -28,3 +28,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

): Core.APIPromise<TranscriptionCreateResponse | string> {
return this._client.post('/audio/transcriptions', Core.multipartFormRequestOptions({ body, ...options }));
return this._client.post(
'/audio/transcriptions',
Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
);
}

@@ -107,3 +110,3 @@ }

*/
duration: string;
duration: number;

@@ -110,0 +113,0 @@ /**

@@ -29,3 +29,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

): Core.APIPromise<TranslationCreateResponse | string> {
return this._client.post('/audio/translations', Core.multipartFormRequestOptions({ body, ...options }));
return this._client.post(
'/audio/translations',
Core.multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }),
);
}

@@ -42,3 +45,3 @@ }

*/
duration: string;
duration: number;

@@ -45,0 +48,0 @@ /**

@@ -443,2 +443,72 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

/**
* The item to add to the conversation.
*/
export interface ConversationItemWithReference {
/**
* 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.
*/
id?: string;
/**
* The arguments of the function call (for `function_call` items).
*/
arguments?: string;
/**
* 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.
*/
call_id?: string;
/**
* 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.
*/
content?: Array<ConversationItemContent>;
/**
* The name of the function being called (for `function_call` items).
*/
name?: string;
/**
* Identifier for the API object being returned - always `realtime.item`.
*/
object?: 'realtime.item';
/**
* The output of the function call (for `function_call_output` items).
*/
output?: string;
/**
* The role of the message sender (`user`, `assistant`, `system`), only applicable
* for `message` items.
*/
role?: 'user' | 'assistant' | 'system';
/**
* 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.
*/
status?: 'completed' | 'incomplete';
/**
* The type of the item (`message`, `function_call`, `function_call_output`,
* `item_reference`).
*/
type?: 'message' | 'function_call' | 'function_call_output' | 'item_reference';
}
/**
* Returned when an error occurs, which could be a client problem or a server

@@ -1340,7 +1410,8 @@ * problem. Most errors are recoverable and the session will stay open, we

/**
* 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.
* Input items to include in the prompt for the model. 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.
*/
input?: Array<RealtimeAPI.ConversationItem>;
input?: Array<RealtimeAPI.ConversationItemWithReference>;

@@ -1347,0 +1418,0 @@ /**

@@ -374,3 +374,3 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

*/
role?: 'system' | 'user' | 'assistant' | 'tool';
role?: 'developer' | 'system' | 'user' | 'assistant' | 'tool';

@@ -760,3 +760,3 @@ tool_calls?: Array<Delta.ToolCall>;

*/
export type ChatCompletionRole = 'system' | 'user' | 'assistant' | 'tool' | 'function';
export type ChatCompletionRole = 'developer' | 'system' | 'user' | 'assistant' | 'tool' | 'function';

@@ -763,0 +763,0 @@ /**

@@ -1,1 +0,1 @@

export const VERSION = '4.82.0'; // x-release-please-version
export const VERSION = '4.83.0'; // x-release-please-version

@@ -1,2 +0,2 @@

export declare const VERSION = "4.82.0";
export declare const VERSION = "4.83.0";
//# sourceMappingURL=version.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = '4.82.0'; // x-release-please-version
exports.VERSION = '4.83.0'; // x-release-please-version
//# sourceMappingURL=version.js.map

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc