openai 6.46.0 → 6.47.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.
- package/CHANGELOG.md +27 -0
- package/README.md +9 -2
- package/client.d.mts +1 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +1 -0
- package/client.d.ts.map +1 -1
- package/client.js +11 -5
- package/client.js.map +1 -1
- package/client.mjs +11 -5
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts.map +1 -1
- package/core/streaming.d.ts.map +1 -1
- package/core/streaming.js +38 -6
- package/core/streaming.js.map +1 -1
- package/core/streaming.mjs +38 -6
- package/core/streaming.mjs.map +1 -1
- package/core/uploads.d.mts +1 -1
- package/core/uploads.d.mts.map +1 -1
- package/core/uploads.d.ts +1 -1
- package/core/uploads.d.ts.map +1 -1
- package/core/uploads.js +3 -1
- package/core/uploads.js.map +1 -1
- package/core/uploads.mjs +1 -0
- package/core/uploads.mjs.map +1 -1
- package/helpers/zod.d.mts +20 -7
- package/helpers/zod.d.mts.map +1 -1
- package/helpers/zod.d.ts +20 -7
- package/helpers/zod.d.ts.map +1 -1
- package/helpers/zod.js +24 -12
- package/helpers/zod.js.map +1 -1
- package/helpers/zod.mjs +24 -12
- package/helpers/zod.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/internal/uploads.d.mts +26 -1
- package/internal/uploads.d.mts.map +1 -1
- package/internal/uploads.d.ts +26 -1
- package/internal/uploads.d.ts.map +1 -1
- package/internal/uploads.js +169 -1
- package/internal/uploads.js.map +1 -1
- package/internal/uploads.mjs +169 -2
- package/internal/uploads.mjs.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.mts +3 -3
- package/lib/AbstractChatCompletionRunner.d.mts.map +1 -1
- package/lib/AbstractChatCompletionRunner.d.ts +3 -3
- package/lib/AbstractChatCompletionRunner.d.ts.map +1 -1
- package/lib/AbstractChatCompletionRunner.js +4 -3
- package/lib/AbstractChatCompletionRunner.js.map +1 -1
- package/lib/AbstractChatCompletionRunner.mjs +4 -3
- package/lib/AbstractChatCompletionRunner.mjs.map +1 -1
- package/lib/AssistantStream.d.mts.map +1 -1
- package/lib/AssistantStream.d.ts.map +1 -1
- package/lib/AssistantStream.js +3 -2
- package/lib/AssistantStream.js.map +1 -1
- package/lib/AssistantStream.mjs +3 -2
- package/lib/AssistantStream.mjs.map +1 -1
- package/lib/ChatCompletionRunner.d.mts +26 -2
- package/lib/ChatCompletionRunner.d.mts.map +1 -1
- package/lib/ChatCompletionRunner.d.ts +26 -2
- package/lib/ChatCompletionRunner.d.ts.map +1 -1
- package/lib/ChatCompletionRunner.js.map +1 -1
- package/lib/ChatCompletionRunner.mjs.map +1 -1
- package/lib/ChatCompletionStream.d.mts +14 -1
- package/lib/ChatCompletionStream.d.mts.map +1 -1
- package/lib/ChatCompletionStream.d.ts +14 -1
- package/lib/ChatCompletionStream.d.ts.map +1 -1
- package/lib/ChatCompletionStream.js +68 -12
- package/lib/ChatCompletionStream.js.map +1 -1
- package/lib/ChatCompletionStream.mjs +67 -12
- package/lib/ChatCompletionStream.mjs.map +1 -1
- package/lib/ChatCompletionStreamingRunner.d.mts +25 -2
- package/lib/ChatCompletionStreamingRunner.d.mts.map +1 -1
- package/lib/ChatCompletionStreamingRunner.d.ts +25 -2
- package/lib/ChatCompletionStreamingRunner.d.ts.map +1 -1
- package/lib/ChatCompletionStreamingRunner.js +77 -0
- package/lib/ChatCompletionStreamingRunner.js.map +1 -1
- package/lib/ChatCompletionStreamingRunner.mjs +78 -1
- package/lib/ChatCompletionStreamingRunner.mjs.map +1 -1
- package/lib/EventStream.d.mts +13 -0
- package/lib/EventStream.d.mts.map +1 -1
- package/lib/EventStream.d.ts +13 -0
- package/lib/EventStream.d.ts.map +1 -1
- package/lib/EventStream.js +107 -2
- package/lib/EventStream.js.map +1 -1
- package/lib/EventStream.mjs +107 -2
- package/lib/EventStream.mjs.map +1 -1
- package/lib/RunnableFunction.d.mts +38 -21
- package/lib/RunnableFunction.d.mts.map +1 -1
- package/lib/RunnableFunction.d.ts +38 -21
- package/lib/RunnableFunction.d.ts.map +1 -1
- package/lib/RunnableFunction.js.map +1 -1
- package/lib/RunnableFunction.mjs.map +1 -1
- package/lib/parser.d.mts +2 -2
- package/lib/parser.d.mts.map +1 -1
- package/lib/parser.d.ts +2 -2
- package/lib/parser.d.ts.map +1 -1
- package/lib/parser.js.map +1 -1
- package/lib/parser.mjs.map +1 -1
- package/lib/responses/ResponseStream.d.mts +6 -1
- package/lib/responses/ResponseStream.d.mts.map +1 -1
- package/lib/responses/ResponseStream.d.ts +6 -1
- package/lib/responses/ResponseStream.d.ts.map +1 -1
- package/lib/responses/ResponseStream.js +21 -0
- package/lib/responses/ResponseStream.js.map +1 -1
- package/lib/responses/ResponseStream.mjs +21 -0
- package/lib/responses/ResponseStream.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/admin/organization/projects/api-keys.d.mts +12 -0
- package/resources/admin/organization/projects/api-keys.d.mts.map +1 -1
- package/resources/admin/organization/projects/api-keys.d.ts +12 -0
- package/resources/admin/organization/projects/api-keys.d.ts.map +1 -1
- package/resources/beta/responses/responses.d.mts +3 -2
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +3 -2
- package/resources/beta/responses/responses.d.ts.map +1 -1
- package/resources/beta/responses/responses.js.map +1 -1
- package/resources/beta/responses/responses.mjs.map +1 -1
- package/resources/chat/completions/completions.d.mts +15 -6
- package/resources/chat/completions/completions.d.mts.map +1 -1
- package/resources/chat/completions/completions.d.ts +15 -6
- package/resources/chat/completions/completions.d.ts.map +1 -1
- package/resources/chat/completions/completions.js.map +1 -1
- package/resources/chat/completions/completions.mjs.map +1 -1
- package/resources/responses/responses.d.mts +3 -2
- package/resources/responses/responses.d.mts.map +1 -1
- package/resources/responses/responses.d.ts +3 -2
- package/resources/responses/responses.d.ts.map +1 -1
- package/resources/responses/responses.js.map +1 -1
- package/resources/responses/responses.mjs.map +1 -1
- package/resources/webhooks/webhooks.d.mts +2 -54
- package/resources/webhooks/webhooks.d.mts.map +1 -1
- package/resources/webhooks/webhooks.d.ts +2 -54
- package/resources/webhooks/webhooks.d.ts.map +1 -1
- package/src/client.ts +13 -5
- package/src/core/streaming.ts +36 -8
- package/src/core/uploads.ts +6 -1
- package/src/helpers/zod.ts +62 -23
- package/src/index.ts +1 -1
- package/src/internal/uploads.ts +214 -4
- package/src/lib/AbstractChatCompletionRunner.ts +17 -9
- package/src/lib/AssistantStream.ts +3 -2
- package/src/lib/ChatCompletionRunner.ts +46 -6
- package/src/lib/ChatCompletionStream.ts +108 -13
- package/src/lib/ChatCompletionStreamingRunner.ts +144 -7
- package/src/lib/EventStream.ts +114 -4
- package/src/lib/RunnableFunction.ts +60 -31
- package/src/lib/parser.ts +4 -0
- package/src/lib/responses/ResponseStream.ts +29 -1
- package/src/resources/admin/organization/projects/api-keys.ts +15 -1
- package/src/resources/beta/responses/responses.ts +3 -2
- package/src/resources/chat/completions/completions.ts +66 -9
- package/src/resources/responses/responses.ts +3 -2
- package/src/resources/webhooks/api.md +0 -1
- package/src/resources/webhooks/webhooks.ts +1 -65
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -4,15 +4,17 @@ import { JSONSchema } from './jsonschema';
|
|
|
4
4
|
|
|
5
5
|
type PromiseOrValue<T> = T | Promise<T>;
|
|
6
6
|
|
|
7
|
-
export type RunnableFunctionWithParse<Args extends object> = {
|
|
7
|
+
export type RunnableFunctionWithParse<Args extends object, ToolContext = unknown> = {
|
|
8
8
|
/**
|
|
9
9
|
* @param args the return value from `parse`.
|
|
10
10
|
* @param runner the runner evaluating this callback.
|
|
11
|
+
* @param toolContext the context passed to `.runTools()`.
|
|
11
12
|
* @returns a string to send back to OpenAI.
|
|
12
13
|
*/
|
|
13
14
|
function: (
|
|
14
15
|
args: Args,
|
|
15
16
|
runner: ChatCompletionRunner<unknown> | ChatCompletionStreamingRunner<unknown>,
|
|
17
|
+
toolContext: ToolContext,
|
|
16
18
|
) => PromiseOrValue<unknown>;
|
|
17
19
|
/**
|
|
18
20
|
* @param input the raw args from the OpenAI function call.
|
|
@@ -34,14 +36,17 @@ export type RunnableFunctionWithParse<Args extends object> = {
|
|
|
34
36
|
strict?: boolean | undefined;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
|
-
export type RunnableFunctionWithoutParse = {
|
|
39
|
+
export type RunnableFunctionWithoutParse<ToolContext = unknown> = {
|
|
38
40
|
/**
|
|
39
41
|
* @param args the raw args from the OpenAI function call.
|
|
42
|
+
* @param runner the runner evaluating this callback.
|
|
43
|
+
* @param toolContext the context passed to `.runTools()`.
|
|
40
44
|
* @returns a string to send back to OpenAI
|
|
41
45
|
*/
|
|
42
46
|
function: (
|
|
43
47
|
args: string,
|
|
44
48
|
runner: ChatCompletionRunner<unknown> | ChatCompletionStreamingRunner<unknown>,
|
|
49
|
+
toolContext: ToolContext,
|
|
45
50
|
) => PromiseOrValue<unknown>;
|
|
46
51
|
/**
|
|
47
52
|
* The parameters the function accepts, describes as a JSON Schema object.
|
|
@@ -58,56 +63,80 @@ export type RunnableFunctionWithoutParse = {
|
|
|
58
63
|
strict?: boolean | undefined;
|
|
59
64
|
};
|
|
60
65
|
|
|
61
|
-
export type RunnableFunction<Args extends object | string> =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
export type RunnableFunction<Args extends object | string, ToolContext = unknown> = Args extends string ?
|
|
67
|
+
RunnableFunctionWithoutParse<ToolContext>
|
|
68
|
+
: Args extends object ? RunnableFunctionWithParse<Args, ToolContext>
|
|
69
|
+
: never;
|
|
65
70
|
|
|
66
|
-
export type RunnableToolFunction<Args extends object | string> =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
export type RunnableToolFunction<Args extends object | string, ToolContext = unknown> = Args extends string ?
|
|
72
|
+
RunnableToolFunctionWithoutParse<ToolContext>
|
|
73
|
+
: Args extends object ? RunnableToolFunctionWithParse<Args, ToolContext>
|
|
74
|
+
: never;
|
|
70
75
|
|
|
71
|
-
export type RunnableToolFunctionWithoutParse = {
|
|
76
|
+
export type RunnableToolFunctionWithoutParse<ToolContext = unknown> = {
|
|
77
|
+
type: 'function';
|
|
78
|
+
function: RunnableFunctionWithoutParse<ToolContext>;
|
|
79
|
+
};
|
|
80
|
+
export type RunnableToolFunctionWithParse<Args extends object, ToolContext = unknown> = {
|
|
72
81
|
type: 'function';
|
|
73
|
-
function:
|
|
82
|
+
function: RunnableFunctionWithParse<Args, ToolContext>;
|
|
74
83
|
};
|
|
75
|
-
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A broad tool shape for contextually typing callbacks when the argument type is inferred.
|
|
87
|
+
*/
|
|
88
|
+
export type RunnableToolFunctionWithContext<ToolContext> = {
|
|
76
89
|
type: 'function';
|
|
77
|
-
function:
|
|
90
|
+
function: {
|
|
91
|
+
function: (
|
|
92
|
+
args: any,
|
|
93
|
+
runner: ChatCompletionRunner<unknown> | ChatCompletionStreamingRunner<unknown>,
|
|
94
|
+
toolContext: ToolContext,
|
|
95
|
+
) => PromiseOrValue<unknown>;
|
|
96
|
+
parse?: (input: string) => PromiseOrValue<any>;
|
|
97
|
+
parameters: JSONSchema;
|
|
98
|
+
description: string;
|
|
99
|
+
name?: string | undefined;
|
|
100
|
+
strict?: boolean | undefined;
|
|
101
|
+
};
|
|
78
102
|
};
|
|
79
103
|
|
|
80
|
-
export function isRunnableFunctionWithParse<Args extends object>(
|
|
104
|
+
export function isRunnableFunctionWithParse<Args extends object, ToolContext = unknown>(
|
|
81
105
|
fn: any,
|
|
82
|
-
): fn is RunnableFunctionWithParse<Args> {
|
|
106
|
+
): fn is RunnableFunctionWithParse<Args, ToolContext> {
|
|
83
107
|
return typeof (fn as any).parse === 'function';
|
|
84
108
|
}
|
|
85
109
|
|
|
86
110
|
export type BaseFunctionsArgs = readonly (object | string)[];
|
|
87
111
|
|
|
88
|
-
export type RunnableFunctions<FunctionsArgs extends BaseFunctionsArgs> =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
export type RunnableFunctions<FunctionsArgs extends BaseFunctionsArgs, ToolContext = unknown> = [
|
|
113
|
+
any[],
|
|
114
|
+
] extends [FunctionsArgs] ?
|
|
115
|
+
readonly RunnableFunction<any, ToolContext>[]
|
|
116
|
+
: {
|
|
117
|
+
[Index in keyof FunctionsArgs]: Index extends number ? RunnableFunction<FunctionsArgs[Index], ToolContext>
|
|
118
|
+
: FunctionsArgs[Index];
|
|
119
|
+
};
|
|
94
120
|
|
|
95
|
-
export type RunnableTools<FunctionsArgs extends BaseFunctionsArgs> =
|
|
96
|
-
[
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
121
|
+
export type RunnableTools<FunctionsArgs extends BaseFunctionsArgs, ToolContext = unknown> = [any[]] extends (
|
|
122
|
+
[FunctionsArgs]
|
|
123
|
+
) ?
|
|
124
|
+
readonly RunnableToolFunction<any, ToolContext>[]
|
|
125
|
+
: {
|
|
126
|
+
[Index in keyof FunctionsArgs]: Index extends number ?
|
|
127
|
+
RunnableToolFunction<FunctionsArgs[Index], ToolContext>
|
|
128
|
+
: FunctionsArgs[Index];
|
|
129
|
+
};
|
|
101
130
|
|
|
102
131
|
/**
|
|
103
132
|
* This is helper class for passing a `function` and `parse` where the `function`
|
|
104
133
|
* argument type matches the `parse` return type.
|
|
105
134
|
*/
|
|
106
|
-
export class ParsingToolFunction<Args extends object> {
|
|
135
|
+
export class ParsingToolFunction<Args extends object, ToolContext = unknown> {
|
|
107
136
|
type: 'function';
|
|
108
|
-
function: RunnableFunctionWithParse<Args>;
|
|
137
|
+
function: RunnableFunctionWithParse<Args, ToolContext>;
|
|
109
138
|
|
|
110
|
-
constructor(input: RunnableFunctionWithParse<Args>) {
|
|
139
|
+
constructor(input: RunnableFunctionWithParse<Args, ToolContext>) {
|
|
111
140
|
this.type = 'function';
|
|
112
141
|
this.function = input;
|
|
113
142
|
}
|
package/src/lib/parser.ts
CHANGED
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
ChatCompletionMessage,
|
|
8
8
|
ChatCompletionMessageFunctionToolCall,
|
|
9
9
|
ChatCompletionStreamingToolRunnerParams,
|
|
10
|
+
ChatCompletionStreamingToolRunnerParamsWithContext,
|
|
10
11
|
ChatCompletionStreamParams,
|
|
11
12
|
ChatCompletionToolRunnerParams,
|
|
13
|
+
ChatCompletionToolRunnerParamsWithContext,
|
|
12
14
|
ParsedChatCompletion,
|
|
13
15
|
ParsedChoice,
|
|
14
16
|
ParsedFunctionToolCall,
|
|
@@ -19,7 +21,9 @@ import { ResponseFormatJSONSchema } from '../resources/shared';
|
|
|
19
21
|
type AnyChatCompletionCreateParams =
|
|
20
22
|
| ChatCompletionCreateParams
|
|
21
23
|
| ChatCompletionToolRunnerParams<any>
|
|
24
|
+
| ChatCompletionToolRunnerParamsWithContext<any, any>
|
|
22
25
|
| ChatCompletionStreamingToolRunnerParams<any>
|
|
26
|
+
| ChatCompletionStreamingToolRunnerParamsWithContext<any, any>
|
|
23
27
|
| ChatCompletionStreamParams;
|
|
24
28
|
|
|
25
29
|
type Unpacked<T> = T extends (infer U)[] ? U : T;
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type ResponseStreamEvent,
|
|
8
8
|
} from '../../resources/responses/responses';
|
|
9
9
|
import { RequestOptions } from '../../internal/request-options';
|
|
10
|
+
import { type ReadableStream } from '../../internal/shim-types';
|
|
10
11
|
import { APIUserAbortError, OpenAIError } from '../../error';
|
|
11
12
|
import OpenAI from '../../index';
|
|
12
13
|
import { type BaseEvents, EventStream } from '../EventStream';
|
|
@@ -27,7 +28,9 @@ export type ResponseStreamByIdParams = {
|
|
|
27
28
|
*/
|
|
28
29
|
response_id: string;
|
|
29
30
|
/**
|
|
30
|
-
* If provided,
|
|
31
|
+
* If provided, events with a sequence number less than or equal to this value
|
|
32
|
+
* will not be emitted. The helper still replays them internally to build a
|
|
33
|
+
* complete snapshot for later events and `finalResponse()`.
|
|
31
34
|
*/
|
|
32
35
|
starting_after?: number;
|
|
33
36
|
/**
|
|
@@ -90,6 +93,12 @@ export class ResponseStream<ParsedT = null>
|
|
|
90
93
|
return runner;
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
static fromReadableStream(stream: ReadableStream): ResponseStream<null> {
|
|
97
|
+
const runner = new ResponseStream(null);
|
|
98
|
+
runner._run(() => runner._fromReadableStream(stream));
|
|
99
|
+
return runner;
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
#beginRequest() {
|
|
94
103
|
if (this.ended) return;
|
|
95
104
|
this.#currentResponseSnapshot = undefined;
|
|
@@ -175,6 +184,8 @@ export class ResponseStream<ParsedT = null>
|
|
|
175
184
|
let stream: Stream<ResponseStreamEvent> | undefined;
|
|
176
185
|
let starting_after: number | null = null;
|
|
177
186
|
if ('response_id' in params) {
|
|
187
|
+
// Keep the full replay so that `accumulateResponse()` sees `response.created` and can build
|
|
188
|
+
// complete snapshots before locally filtering events at `starting_after`.
|
|
178
189
|
stream = await client.responses.retrieve(
|
|
179
190
|
params.response_id,
|
|
180
191
|
{ stream: true },
|
|
@@ -198,6 +209,23 @@ export class ResponseStream<ParsedT = null>
|
|
|
198
209
|
return this.#endRequest();
|
|
199
210
|
}
|
|
200
211
|
|
|
212
|
+
protected async _fromReadableStream(
|
|
213
|
+
readableStream: ReadableStream,
|
|
214
|
+
options?: RequestOptions,
|
|
215
|
+
): Promise<ParsedResponse<ParsedT>> {
|
|
216
|
+
this._listenForAbort(options?.signal);
|
|
217
|
+
this.#beginRequest();
|
|
218
|
+
this._connected();
|
|
219
|
+
const stream = Stream.fromReadableStream<ResponseStreamEvent>(readableStream, this.controller);
|
|
220
|
+
for await (const event of stream) {
|
|
221
|
+
this.#addEvent(event, null);
|
|
222
|
+
}
|
|
223
|
+
if (stream.controller.signal?.aborted) {
|
|
224
|
+
throw new APIUserAbortError();
|
|
225
|
+
}
|
|
226
|
+
return this.#endRequest();
|
|
227
|
+
}
|
|
228
|
+
|
|
201
229
|
[Symbol.asyncIterator](this: ResponseStream<ParsedT>): AsyncIterator<ResponseStreamEvent> {
|
|
202
230
|
const pushQueue: ResponseStreamEvent[] = [];
|
|
203
231
|
const readQueue: {
|
|
@@ -121,6 +121,11 @@ export interface ProjectAPIKey {
|
|
|
121
121
|
|
|
122
122
|
owner: ProjectAPIKey.Owner;
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Whether the API key's owner currently has effective access to the project.
|
|
126
|
+
*/
|
|
127
|
+
owner_project_access: 'active' | 'inactive';
|
|
128
|
+
|
|
124
129
|
/**
|
|
125
130
|
* The redacted value of the API key
|
|
126
131
|
*/
|
|
@@ -218,7 +223,16 @@ export interface APIKeyRetrieveParams {
|
|
|
218
223
|
project_id: string;
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
export interface APIKeyListParams extends ConversationCursorPageParams {
|
|
226
|
+
export interface APIKeyListParams extends ConversationCursorPageParams {
|
|
227
|
+
/**
|
|
228
|
+
* Filter API keys by whether the owner currently has effective access to the
|
|
229
|
+
* project. Use `active` for owners with access, `inactive` for owners without
|
|
230
|
+
* access, or `any` for all enabled project API keys. If omitted, the endpoint
|
|
231
|
+
* applies its existing membership-based visibility rules, which may exclude some
|
|
232
|
+
* enabled keys.
|
|
233
|
+
*/
|
|
234
|
+
owner_project_access?: 'active' | 'inactive' | 'any';
|
|
235
|
+
}
|
|
222
236
|
|
|
223
237
|
export interface APIKeyDeleteParams {
|
|
224
238
|
/**
|
|
@@ -9006,8 +9006,9 @@ export interface BetaResponseReasoningItem {
|
|
|
9006
9006
|
content?: Array<BetaResponseReasoningItem.Content>;
|
|
9007
9007
|
|
|
9008
9008
|
/**
|
|
9009
|
-
* The encrypted content of the reasoning item
|
|
9010
|
-
*
|
|
9009
|
+
* The encrypted content of the reasoning item. This is populated by default for
|
|
9010
|
+
* reasoning items returned by `POST /v1/responses` and WebSocket `response.create`
|
|
9011
|
+
* requests.
|
|
9011
9012
|
*/
|
|
9012
9013
|
encrypted_content?: string | null;
|
|
9013
9014
|
|
|
@@ -15,8 +15,15 @@ import { path } from '../../../internal/utils/path';
|
|
|
15
15
|
import { ChatCompletionRunner } from '../../../lib/ChatCompletionRunner';
|
|
16
16
|
import { ChatCompletionStreamingRunner } from '../../../lib/ChatCompletionStreamingRunner';
|
|
17
17
|
import { RunnerOptions } from '../../../lib/AbstractChatCompletionRunner';
|
|
18
|
-
import {
|
|
19
|
-
|
|
18
|
+
import {
|
|
19
|
+
ChatCompletionToolRunnerParamsWithContext,
|
|
20
|
+
ChatCompletionToolRunnerParamsWithoutContext,
|
|
21
|
+
} from '../../../lib/ChatCompletionRunner';
|
|
22
|
+
import {
|
|
23
|
+
ChatCompletionStreamingToolRunnerParamsWithContext,
|
|
24
|
+
ChatCompletionStreamingToolRunnerParamsWithoutContext,
|
|
25
|
+
} from '../../../lib/ChatCompletionStreamingRunner';
|
|
26
|
+
import { type RunnableToolFunctionWithContext } from '../../../lib/RunnableFunction';
|
|
20
27
|
import { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream';
|
|
21
28
|
import { ExtractParsedContentFromParams, parseChatCompletion, validateInputTools } from '../../../lib/parser';
|
|
22
29
|
|
|
@@ -188,17 +195,55 @@ export class Completions extends APIResource {
|
|
|
188
195
|
* [the docs](https://github.com/openai/openai-node#automated-function-calls)
|
|
189
196
|
*/
|
|
190
197
|
runTools<
|
|
191
|
-
|
|
198
|
+
ToolContext,
|
|
199
|
+
Params extends Omit<
|
|
200
|
+
ChatCompletionToolRunnerParamsWithContext<any, ToolContext>,
|
|
201
|
+
'toolContext' | 'tools'
|
|
202
|
+
> = Omit<ChatCompletionToolRunnerParamsWithContext<any, ToolContext>, 'toolContext' | 'tools'>,
|
|
203
|
+
ParsedT = ExtractParsedContentFromParams<
|
|
204
|
+
Params & ChatCompletionToolRunnerParamsWithContext<any, ToolContext>
|
|
205
|
+
>,
|
|
206
|
+
>(
|
|
207
|
+
body: Params & {
|
|
208
|
+
toolContext: ToolContext;
|
|
209
|
+
tools: readonly RunnableToolFunctionWithContext<ToolContext>[];
|
|
210
|
+
},
|
|
211
|
+
options?: RunnerOptions,
|
|
212
|
+
): ChatCompletionRunner<ParsedT>;
|
|
213
|
+
|
|
214
|
+
runTools<
|
|
215
|
+
ToolContext,
|
|
216
|
+
Params extends Omit<
|
|
217
|
+
ChatCompletionStreamingToolRunnerParamsWithContext<any, ToolContext>,
|
|
218
|
+
'toolContext' | 'tools'
|
|
219
|
+
> = Omit<ChatCompletionStreamingToolRunnerParamsWithContext<any, ToolContext>, 'toolContext' | 'tools'>,
|
|
220
|
+
ParsedT = ExtractParsedContentFromParams<
|
|
221
|
+
Params & ChatCompletionStreamingToolRunnerParamsWithContext<any, ToolContext>
|
|
222
|
+
>,
|
|
223
|
+
>(
|
|
224
|
+
body: Params & {
|
|
225
|
+
toolContext: ToolContext;
|
|
226
|
+
tools: readonly RunnableToolFunctionWithContext<ToolContext>[];
|
|
227
|
+
},
|
|
228
|
+
options?: RunnerOptions,
|
|
229
|
+
): ChatCompletionStreamingRunner<ParsedT>;
|
|
230
|
+
|
|
231
|
+
runTools<
|
|
232
|
+
Params extends ChatCompletionToolRunnerParamsWithoutContext<any>,
|
|
192
233
|
ParsedT = ExtractParsedContentFromParams<Params>,
|
|
193
234
|
>(body: Params, options?: RunnerOptions): ChatCompletionRunner<ParsedT>;
|
|
194
235
|
|
|
195
236
|
runTools<
|
|
196
|
-
Params extends
|
|
237
|
+
Params extends ChatCompletionStreamingToolRunnerParamsWithoutContext<any>,
|
|
197
238
|
ParsedT = ExtractParsedContentFromParams<Params>,
|
|
198
239
|
>(body: Params, options?: RunnerOptions): ChatCompletionStreamingRunner<ParsedT>;
|
|
199
240
|
|
|
200
241
|
runTools<
|
|
201
|
-
Params extends
|
|
242
|
+
Params extends
|
|
243
|
+
| ChatCompletionToolRunnerParamsWithoutContext<any>
|
|
244
|
+
| ChatCompletionToolRunnerParamsWithContext<any, any>
|
|
245
|
+
| ChatCompletionStreamingToolRunnerParamsWithoutContext<any>
|
|
246
|
+
| ChatCompletionStreamingToolRunnerParamsWithContext<any, any>,
|
|
202
247
|
ParsedT = ExtractParsedContentFromParams<Params>,
|
|
203
248
|
>(
|
|
204
249
|
body: Params,
|
|
@@ -207,12 +252,16 @@ export class Completions extends APIResource {
|
|
|
207
252
|
if (body.stream) {
|
|
208
253
|
return ChatCompletionStreamingRunner.runTools(
|
|
209
254
|
this._client,
|
|
210
|
-
body as
|
|
255
|
+
body as ChatCompletionStreamingToolRunnerParamsWithContext<any, any>,
|
|
211
256
|
options,
|
|
212
257
|
);
|
|
213
258
|
}
|
|
214
259
|
|
|
215
|
-
return ChatCompletionRunner.runTools(
|
|
260
|
+
return ChatCompletionRunner.runTools(
|
|
261
|
+
this._client,
|
|
262
|
+
body as ChatCompletionToolRunnerParamsWithContext<any, any>,
|
|
263
|
+
options,
|
|
264
|
+
);
|
|
216
265
|
}
|
|
217
266
|
|
|
218
267
|
/**
|
|
@@ -255,8 +304,16 @@ export {
|
|
|
255
304
|
type RunnableFunctionWithoutParse,
|
|
256
305
|
ParsingToolFunction,
|
|
257
306
|
} from '../../../lib/RunnableFunction';
|
|
258
|
-
export {
|
|
259
|
-
|
|
307
|
+
export {
|
|
308
|
+
type ChatCompletionToolRunnerParams,
|
|
309
|
+
type ChatCompletionToolRunnerParamsWithContext,
|
|
310
|
+
type ChatCompletionToolRunnerParamsWithoutContext,
|
|
311
|
+
} from '../../../lib/ChatCompletionRunner';
|
|
312
|
+
export {
|
|
313
|
+
type ChatCompletionStreamingToolRunnerParams,
|
|
314
|
+
type ChatCompletionStreamingToolRunnerParamsWithContext,
|
|
315
|
+
type ChatCompletionStreamingToolRunnerParamsWithoutContext,
|
|
316
|
+
} from '../../../lib/ChatCompletionStreamingRunner';
|
|
260
317
|
export { ChatCompletionStream, type ChatCompletionStreamParams } from '../../../lib/ChatCompletionStream';
|
|
261
318
|
export { ChatCompletionRunner } from '../../../lib/ChatCompletionRunner';
|
|
262
319
|
|
|
@@ -6498,8 +6498,9 @@ export interface ResponseReasoningItem {
|
|
|
6498
6498
|
content?: Array<ResponseReasoningItem.Content>;
|
|
6499
6499
|
|
|
6500
6500
|
/**
|
|
6501
|
-
* The encrypted content of the reasoning item
|
|
6502
|
-
*
|
|
6501
|
+
* The encrypted content of the reasoning item. This is populated by default for
|
|
6502
|
+
* reasoning items returned by `POST /v1/responses` and WebSocket `response.create`
|
|
6503
|
+
* requests.
|
|
6503
6504
|
*/
|
|
6504
6505
|
encrypted_content?: string | null;
|
|
6505
6506
|
|
|
@@ -17,7 +17,6 @@ Types:
|
|
|
17
17
|
- <code><a href="./src/resources/webhooks.ts">ResponseCompletedWebhookEvent</a></code>
|
|
18
18
|
- <code><a href="./src/resources/webhooks.ts">ResponseFailedWebhookEvent</a></code>
|
|
19
19
|
- <code><a href="./src/resources/webhooks.ts">ResponseIncompleteWebhookEvent</a></code>
|
|
20
|
-
- <code><a href="./src/resources/webhooks.ts">SafetyIdentifierBlockedWebhookEvent</a></code>
|
|
21
20
|
- <code><a href="./src/resources/webhooks.ts">UnwrapWebhookEvent</a></code>
|
|
22
21
|
|
|
23
22
|
Methods:
|
|
@@ -791,68 +791,6 @@ export namespace ResponseIncompleteWebhookEvent {
|
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
793
|
|
|
794
|
-
/**
|
|
795
|
-
* Sent when a request associated with a safety identifier has been blocked.
|
|
796
|
-
*/
|
|
797
|
-
export interface SafetyIdentifierBlockedWebhookEvent {
|
|
798
|
-
/**
|
|
799
|
-
* The unique ID of the event.
|
|
800
|
-
*/
|
|
801
|
-
id: string;
|
|
802
|
-
|
|
803
|
-
/**
|
|
804
|
-
* The Unix timestamp (in seconds) of when the request was blocked.
|
|
805
|
-
*/
|
|
806
|
-
created_at: number;
|
|
807
|
-
|
|
808
|
-
/**
|
|
809
|
-
* Event data payload.
|
|
810
|
-
*/
|
|
811
|
-
data: SafetyIdentifierBlockedWebhookEvent.Data;
|
|
812
|
-
|
|
813
|
-
/**
|
|
814
|
-
* The type of the event. Always `safety_identifier.blocked`.
|
|
815
|
-
*/
|
|
816
|
-
type: 'safety_identifier.blocked';
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* The object of the event. Always `event`.
|
|
820
|
-
*/
|
|
821
|
-
object?: 'event';
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
export namespace SafetyIdentifierBlockedWebhookEvent {
|
|
825
|
-
/**
|
|
826
|
-
* Event data payload.
|
|
827
|
-
*/
|
|
828
|
-
export interface Data {
|
|
829
|
-
/**
|
|
830
|
-
* The safety category that triggered the block, such as `bio` or `cyber`.
|
|
831
|
-
*/
|
|
832
|
-
safety_category: string;
|
|
833
|
-
|
|
834
|
-
/**
|
|
835
|
-
* The stable safety identifier associated with the blocked request.
|
|
836
|
-
*/
|
|
837
|
-
safety_identifier: string;
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* The model used for the blocked request, if available.
|
|
841
|
-
*/
|
|
842
|
-
model?: string;
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* The project associated with the blocked request, if available.
|
|
846
|
-
*/
|
|
847
|
-
project_id?: string;
|
|
848
|
-
|
|
849
|
-
/**
|
|
850
|
-
* The OpenAI request ID for the blocked request, if available.
|
|
851
|
-
*/
|
|
852
|
-
request_id?: string;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
|
|
856
794
|
/**
|
|
857
795
|
* Sent when a batch API request has been cancelled.
|
|
858
796
|
*/
|
|
@@ -871,8 +809,7 @@ export type UnwrapWebhookEvent =
|
|
|
871
809
|
| ResponseCancelledWebhookEvent
|
|
872
810
|
| ResponseCompletedWebhookEvent
|
|
873
811
|
| ResponseFailedWebhookEvent
|
|
874
|
-
| ResponseIncompleteWebhookEvent
|
|
875
|
-
| SafetyIdentifierBlockedWebhookEvent;
|
|
812
|
+
| ResponseIncompleteWebhookEvent;
|
|
876
813
|
|
|
877
814
|
export declare namespace Webhooks {
|
|
878
815
|
export {
|
|
@@ -891,7 +828,6 @@ export declare namespace Webhooks {
|
|
|
891
828
|
type ResponseCompletedWebhookEvent as ResponseCompletedWebhookEvent,
|
|
892
829
|
type ResponseFailedWebhookEvent as ResponseFailedWebhookEvent,
|
|
893
830
|
type ResponseIncompleteWebhookEvent as ResponseIncompleteWebhookEvent,
|
|
894
|
-
type SafetyIdentifierBlockedWebhookEvent as SafetyIdentifierBlockedWebhookEvent,
|
|
895
831
|
type UnwrapWebhookEvent as UnwrapWebhookEvent,
|
|
896
832
|
};
|
|
897
833
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '6.
|
|
1
|
+
export const VERSION = '6.47.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "6.
|
|
1
|
+
export declare const VERSION = "6.47.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "6.
|
|
1
|
+
export declare const VERSION = "6.47.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '6.
|
|
1
|
+
export const VERSION = '6.47.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|