openai 6.46.0 → 6.48.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 +47 -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/headers.d.mts.map +1 -1
- package/internal/headers.d.ts.map +1 -1
- package/internal/headers.js +7 -3
- package/internal/headers.js.map +1 -1
- package/internal/headers.mjs +7 -3
- package/internal/headers.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/audit-logs.d.mts +2 -2
- package/resources/admin/organization/audit-logs.d.mts.map +1 -1
- package/resources/admin/organization/audit-logs.d.ts +2 -2
- package/resources/admin/organization/audit-logs.d.ts.map +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/admin/organization/projects/index.d.mts +1 -1
- package/resources/admin/organization/projects/index.d.mts.map +1 -1
- package/resources/admin/organization/projects/index.d.ts +1 -1
- package/resources/admin/organization/projects/index.d.ts.map +1 -1
- package/resources/admin/organization/projects/index.js +4 -4
- package/resources/admin/organization/projects/index.js.map +1 -1
- package/resources/admin/organization/projects/index.mjs +1 -1
- package/resources/admin/organization/projects/index.mjs.map +1 -1
- package/resources/admin/organization/projects/projects.d.mts +2 -2
- package/resources/admin/organization/projects/projects.d.mts.map +1 -1
- package/resources/admin/organization/projects/projects.d.ts +2 -2
- package/resources/admin/organization/projects/projects.d.ts.map +1 -1
- package/resources/admin/organization/projects/projects.js +2 -2
- package/resources/admin/organization/projects/projects.js.map +1 -1
- package/resources/admin/organization/projects/projects.mjs +2 -2
- package/resources/admin/organization/projects/projects.mjs.map +1 -1
- package/resources/admin/organization/projects/service-accounts/api-keys.d.mts +58 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.d.mts.map +1 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.d.ts +58 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.d.ts.map +1 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.js +26 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.js.map +1 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.mjs +22 -0
- package/resources/admin/organization/projects/service-accounts/api-keys.mjs.map +1 -0
- package/resources/admin/organization/projects/service-accounts/index.d.mts +3 -0
- package/resources/admin/organization/projects/service-accounts/index.d.mts.map +1 -0
- package/resources/admin/organization/projects/service-accounts/index.d.ts +3 -0
- package/resources/admin/organization/projects/service-accounts/index.d.ts.map +1 -0
- package/resources/admin/organization/projects/service-accounts/index.js +9 -0
- package/resources/admin/organization/projects/service-accounts/index.js.map +1 -0
- package/resources/admin/organization/projects/service-accounts/index.mjs +4 -0
- package/resources/admin/organization/projects/service-accounts/index.mjs.map +1 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.d.mts +177 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.d.mts.map +1 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.d.ts +177 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.d.ts.map +1 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.js +109 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.js.map +1 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.mjs +104 -0
- package/resources/admin/organization/projects/service-accounts/service-accounts.mjs.map +1 -0
- package/resources/admin/organization/projects/service-accounts.d.mts +1 -167
- package/resources/admin/organization/projects/service-accounts.d.mts.map +1 -1
- package/resources/admin/organization/projects/service-accounts.d.ts +1 -167
- package/resources/admin/organization/projects/service-accounts.d.ts.map +1 -1
- package/resources/admin/organization/projects/service-accounts.js +2 -97
- package/resources/admin/organization/projects/service-accounts.js.map +1 -1
- package/resources/admin/organization/projects/service-accounts.mjs +1 -95
- package/resources/admin/organization/projects/service-accounts.mjs.map +1 -1
- package/resources/admin/organization/usage.d.mts +517 -88
- package/resources/admin/organization/usage.d.mts.map +1 -1
- package/resources/admin/organization/usage.d.ts +517 -88
- package/resources/admin/organization/usage.d.ts.map +1 -1
- package/resources/beta/responses/responses.d.mts +7 -6
- package/resources/beta/responses/responses.d.mts.map +1 -1
- package/resources/beta/responses/responses.d.ts +7 -6
- 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/headers.ts +7 -3
- 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/audit-logs.ts +169 -1
- package/src/resources/admin/organization/projects/api-keys.ts +15 -1
- package/src/resources/admin/organization/projects/index.ts +1 -1
- package/src/resources/admin/organization/projects/projects.ts +13 -13
- package/src/resources/admin/organization/projects/service-accounts/api-keys.ts +80 -0
- package/src/resources/admin/organization/projects/service-accounts/index.ts +15 -0
- package/src/resources/admin/organization/projects/service-accounts/service-accounts.ts +284 -0
- package/src/resources/admin/organization/projects/service-accounts.ts +1 -264
- package/src/resources/admin/organization/usage.ts +616 -88
- package/src/resources/beta/responses/responses.ts +7 -6
- 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: {
|
|
@@ -113,7 +113,91 @@ export interface AuditLogListResponse {
|
|
|
113
113
|
| 'service_account.deleted'
|
|
114
114
|
| 'user.added'
|
|
115
115
|
| 'user.updated'
|
|
116
|
-
| 'user.deleted'
|
|
116
|
+
| 'user.deleted'
|
|
117
|
+
| 'tenant.metadata.updated'
|
|
118
|
+
| 'tenant.microsoft_entra_mapping.upserted'
|
|
119
|
+
| 'tenant.microsoft_entra_mapping.deleted'
|
|
120
|
+
| 'tenant.workload_identity.provider.created'
|
|
121
|
+
| 'tenant.workload_identity.provider.updated'
|
|
122
|
+
| 'tenant.workload_identity.provider.archived'
|
|
123
|
+
| 'tenant.workload_identity.mapping.created'
|
|
124
|
+
| 'tenant.workload_identity.mapping.updated'
|
|
125
|
+
| 'tenant.workload_identity.mapping.archived'
|
|
126
|
+
| 'tenant.workload_identity.binding.created'
|
|
127
|
+
| 'tenant.workload_identity.principal.provisioned'
|
|
128
|
+
| 'tenant.admin_api_key.created'
|
|
129
|
+
| 'tenant.admin_api_key.updated'
|
|
130
|
+
| 'tenant.admin_api_key.deleted'
|
|
131
|
+
| 'tenant.project_api_key.created'
|
|
132
|
+
| 'tenant.chatgpt_access_token.revoked'
|
|
133
|
+
| 'tenant.migration.completed'
|
|
134
|
+
| 'tenant.sso.migrated'
|
|
135
|
+
| 'tenant.domains.migrated'
|
|
136
|
+
| 'tenant.sso_connection.created'
|
|
137
|
+
| 'tenant.sso_connection.updated'
|
|
138
|
+
| 'tenant.sso_connection.deleted'
|
|
139
|
+
| 'tenant.sso_connection.setup.started'
|
|
140
|
+
| 'tenant.policy.created'
|
|
141
|
+
| 'tenant.policy.updated'
|
|
142
|
+
| 'tenant.policy.deleted'
|
|
143
|
+
| 'tenant.policy.attached'
|
|
144
|
+
| 'tenant.policy.detached'
|
|
145
|
+
| 'tenant.principal_authentication_policy.resolved'
|
|
146
|
+
| 'tenant.scim.setup.started'
|
|
147
|
+
| 'tenant.scim.deletion.requested'
|
|
148
|
+
| 'tenant.scim.directory.created'
|
|
149
|
+
| 'tenant.product_access_policy.updated'
|
|
150
|
+
| 'tenant.resource_share_grant.created'
|
|
151
|
+
| 'tenant.resource_share_grant.updated'
|
|
152
|
+
| 'tenant.resource_share_grant.accepted'
|
|
153
|
+
| 'tenant.resource_share_grant.declined'
|
|
154
|
+
| 'tenant.resource_share_grant.revoked'
|
|
155
|
+
| 'tenant.resource_share_grant.deleted'
|
|
156
|
+
| 'tenant.service_account.updated'
|
|
157
|
+
| 'tenant.service_account.deleted'
|
|
158
|
+
| 'tenant.service_account.token.revoked'
|
|
159
|
+
| 'tenant.billing.overage_limit.updated'
|
|
160
|
+
| 'tenant.billing.alerts.updated'
|
|
161
|
+
| 'tenant.billing.info.updated'
|
|
162
|
+
| 'tenant.usage_limit.workspace.updated'
|
|
163
|
+
| 'tenant.usage_limit.group.updated'
|
|
164
|
+
| 'tenant.usage_limit.user.updated'
|
|
165
|
+
| 'tenant.usage_limit.increase_request.updated'
|
|
166
|
+
| 'tenant.usage_limit.increase_request.resolved'
|
|
167
|
+
| 'tenant.group.created'
|
|
168
|
+
| 'tenant.group.updated'
|
|
169
|
+
| 'tenant.group.deleted'
|
|
170
|
+
| 'tenant.group.member.added'
|
|
171
|
+
| 'tenant.group.member.removed'
|
|
172
|
+
| 'tenant.migration_rollout.status.updated'
|
|
173
|
+
| 'tenant.migration_rollout.tier.updated'
|
|
174
|
+
| 'tenant.role.metadata.updated'
|
|
175
|
+
| 'tenant.custom_role.created'
|
|
176
|
+
| 'tenant.custom_role.updated'
|
|
177
|
+
| 'tenant.custom_role.deleted'
|
|
178
|
+
| 'tenant.role_assignment.created'
|
|
179
|
+
| 'tenant.role_assignment.deleted'
|
|
180
|
+
| 'tenant.resource_role_assignment.created'
|
|
181
|
+
| 'tenant.resource_role_assignment.deleted'
|
|
182
|
+
| 'tenant.resource_access.updated'
|
|
183
|
+
| 'tenant.resource_access.deleted'
|
|
184
|
+
| 'tenant.session_policy.created'
|
|
185
|
+
| 'tenant.session_policy.updated'
|
|
186
|
+
| 'tenant.session_policy.deleted'
|
|
187
|
+
| 'tenant.session_revocation.started'
|
|
188
|
+
| 'tenant.third_party_app_policy.updated'
|
|
189
|
+
| 'tenant.user.added'
|
|
190
|
+
| 'tenant.user.updated'
|
|
191
|
+
| 'tenant.user.removed'
|
|
192
|
+
| 'tenant.user.looked_up'
|
|
193
|
+
| 'tenant.user.invited'
|
|
194
|
+
| 'tenant.membership.revoked'
|
|
195
|
+
| 'tenant.api_organization_invite.upserted'
|
|
196
|
+
| 'tenant.api_organization_invite.deleted'
|
|
197
|
+
| 'tenant.chatgpt_workspace_invite.upserted'
|
|
198
|
+
| 'tenant.membership.accepted'
|
|
199
|
+
| 'tenant.membership.declined'
|
|
200
|
+
| 'tenant.workspace_invite_email_settings.updated';
|
|
117
201
|
|
|
118
202
|
/**
|
|
119
203
|
* The actor who performed the audit logged action.
|
|
@@ -1834,6 +1918,90 @@ export interface AuditLogListParams extends ConversationCursorPageParams {
|
|
|
1834
1918
|
| 'user.added'
|
|
1835
1919
|
| 'user.updated'
|
|
1836
1920
|
| 'user.deleted'
|
|
1921
|
+
| 'tenant.metadata.updated'
|
|
1922
|
+
| 'tenant.microsoft_entra_mapping.upserted'
|
|
1923
|
+
| 'tenant.microsoft_entra_mapping.deleted'
|
|
1924
|
+
| 'tenant.workload_identity.provider.created'
|
|
1925
|
+
| 'tenant.workload_identity.provider.updated'
|
|
1926
|
+
| 'tenant.workload_identity.provider.archived'
|
|
1927
|
+
| 'tenant.workload_identity.mapping.created'
|
|
1928
|
+
| 'tenant.workload_identity.mapping.updated'
|
|
1929
|
+
| 'tenant.workload_identity.mapping.archived'
|
|
1930
|
+
| 'tenant.workload_identity.binding.created'
|
|
1931
|
+
| 'tenant.workload_identity.principal.provisioned'
|
|
1932
|
+
| 'tenant.admin_api_key.created'
|
|
1933
|
+
| 'tenant.admin_api_key.updated'
|
|
1934
|
+
| 'tenant.admin_api_key.deleted'
|
|
1935
|
+
| 'tenant.project_api_key.created'
|
|
1936
|
+
| 'tenant.chatgpt_access_token.revoked'
|
|
1937
|
+
| 'tenant.migration.completed'
|
|
1938
|
+
| 'tenant.sso.migrated'
|
|
1939
|
+
| 'tenant.domains.migrated'
|
|
1940
|
+
| 'tenant.sso_connection.created'
|
|
1941
|
+
| 'tenant.sso_connection.updated'
|
|
1942
|
+
| 'tenant.sso_connection.deleted'
|
|
1943
|
+
| 'tenant.sso_connection.setup.started'
|
|
1944
|
+
| 'tenant.policy.created'
|
|
1945
|
+
| 'tenant.policy.updated'
|
|
1946
|
+
| 'tenant.policy.deleted'
|
|
1947
|
+
| 'tenant.policy.attached'
|
|
1948
|
+
| 'tenant.policy.detached'
|
|
1949
|
+
| 'tenant.principal_authentication_policy.resolved'
|
|
1950
|
+
| 'tenant.scim.setup.started'
|
|
1951
|
+
| 'tenant.scim.deletion.requested'
|
|
1952
|
+
| 'tenant.scim.directory.created'
|
|
1953
|
+
| 'tenant.product_access_policy.updated'
|
|
1954
|
+
| 'tenant.resource_share_grant.created'
|
|
1955
|
+
| 'tenant.resource_share_grant.updated'
|
|
1956
|
+
| 'tenant.resource_share_grant.accepted'
|
|
1957
|
+
| 'tenant.resource_share_grant.declined'
|
|
1958
|
+
| 'tenant.resource_share_grant.revoked'
|
|
1959
|
+
| 'tenant.resource_share_grant.deleted'
|
|
1960
|
+
| 'tenant.service_account.updated'
|
|
1961
|
+
| 'tenant.service_account.deleted'
|
|
1962
|
+
| 'tenant.service_account.token.revoked'
|
|
1963
|
+
| 'tenant.billing.overage_limit.updated'
|
|
1964
|
+
| 'tenant.billing.alerts.updated'
|
|
1965
|
+
| 'tenant.billing.info.updated'
|
|
1966
|
+
| 'tenant.usage_limit.workspace.updated'
|
|
1967
|
+
| 'tenant.usage_limit.group.updated'
|
|
1968
|
+
| 'tenant.usage_limit.user.updated'
|
|
1969
|
+
| 'tenant.usage_limit.increase_request.updated'
|
|
1970
|
+
| 'tenant.usage_limit.increase_request.resolved'
|
|
1971
|
+
| 'tenant.group.created'
|
|
1972
|
+
| 'tenant.group.updated'
|
|
1973
|
+
| 'tenant.group.deleted'
|
|
1974
|
+
| 'tenant.group.member.added'
|
|
1975
|
+
| 'tenant.group.member.removed'
|
|
1976
|
+
| 'tenant.migration_rollout.status.updated'
|
|
1977
|
+
| 'tenant.migration_rollout.tier.updated'
|
|
1978
|
+
| 'tenant.role.metadata.updated'
|
|
1979
|
+
| 'tenant.custom_role.created'
|
|
1980
|
+
| 'tenant.custom_role.updated'
|
|
1981
|
+
| 'tenant.custom_role.deleted'
|
|
1982
|
+
| 'tenant.role_assignment.created'
|
|
1983
|
+
| 'tenant.role_assignment.deleted'
|
|
1984
|
+
| 'tenant.resource_role_assignment.created'
|
|
1985
|
+
| 'tenant.resource_role_assignment.deleted'
|
|
1986
|
+
| 'tenant.resource_access.updated'
|
|
1987
|
+
| 'tenant.resource_access.deleted'
|
|
1988
|
+
| 'tenant.session_policy.created'
|
|
1989
|
+
| 'tenant.session_policy.updated'
|
|
1990
|
+
| 'tenant.session_policy.deleted'
|
|
1991
|
+
| 'tenant.session_revocation.started'
|
|
1992
|
+
| 'tenant.third_party_app_policy.updated'
|
|
1993
|
+
| 'tenant.user.added'
|
|
1994
|
+
| 'tenant.user.updated'
|
|
1995
|
+
| 'tenant.user.removed'
|
|
1996
|
+
| 'tenant.user.looked_up'
|
|
1997
|
+
| 'tenant.user.invited'
|
|
1998
|
+
| 'tenant.membership.revoked'
|
|
1999
|
+
| 'tenant.api_organization_invite.upserted'
|
|
2000
|
+
| 'tenant.api_organization_invite.deleted'
|
|
2001
|
+
| 'tenant.chatgpt_workspace_invite.upserted'
|
|
2002
|
+
| 'tenant.membership.accepted'
|
|
2003
|
+
| 'tenant.membership.declined'
|
|
2004
|
+
| 'tenant.workspace_invite_email_settings.updated'
|
|
1837
2005
|
>;
|
|
1838
2006
|
|
|
1839
2007
|
/**
|
|
@@ -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
|
/**
|
|
@@ -57,19 +57,6 @@ import {
|
|
|
57
57
|
RoleUpdateParams,
|
|
58
58
|
Roles,
|
|
59
59
|
} from './roles';
|
|
60
|
-
import * as ServiceAccountsAPI from './service-accounts';
|
|
61
|
-
import {
|
|
62
|
-
ProjectServiceAccount,
|
|
63
|
-
ProjectServiceAccountsPage,
|
|
64
|
-
ServiceAccountCreateParams,
|
|
65
|
-
ServiceAccountCreateResponse,
|
|
66
|
-
ServiceAccountDeleteParams,
|
|
67
|
-
ServiceAccountDeleteResponse,
|
|
68
|
-
ServiceAccountListParams,
|
|
69
|
-
ServiceAccountRetrieveParams,
|
|
70
|
-
ServiceAccountUpdateParams,
|
|
71
|
-
ServiceAccounts,
|
|
72
|
-
} from './service-accounts';
|
|
73
60
|
import * as SpendAlertsAPI from './spend-alerts';
|
|
74
61
|
import {
|
|
75
62
|
ProjectSpendAlert,
|
|
@@ -93,6 +80,19 @@ import {
|
|
|
93
80
|
ProjectGroup,
|
|
94
81
|
ProjectGroupsPage,
|
|
95
82
|
} from './groups/groups';
|
|
83
|
+
import * as ServiceAccountsAPI from './service-accounts/service-accounts';
|
|
84
|
+
import {
|
|
85
|
+
ProjectServiceAccount,
|
|
86
|
+
ProjectServiceAccountsPage,
|
|
87
|
+
ServiceAccountCreateParams,
|
|
88
|
+
ServiceAccountCreateResponse,
|
|
89
|
+
ServiceAccountDeleteParams,
|
|
90
|
+
ServiceAccountDeleteResponse,
|
|
91
|
+
ServiceAccountListParams,
|
|
92
|
+
ServiceAccountRetrieveParams,
|
|
93
|
+
ServiceAccountUpdateParams,
|
|
94
|
+
ServiceAccounts,
|
|
95
|
+
} from './service-accounts/service-accounts';
|
|
96
96
|
import * as UsersAPI from './users/users';
|
|
97
97
|
import {
|
|
98
98
|
ProjectUser,
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../../../../core/resource';
|
|
4
|
+
import { APIPromise } from '../../../../../core/api-promise';
|
|
5
|
+
import { RequestOptions } from '../../../../../internal/request-options';
|
|
6
|
+
import { path } from '../../../../../internal/utils/path';
|
|
7
|
+
|
|
8
|
+
export class APIKeys extends APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* Creates an API key for a service account in the project.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const apiKey =
|
|
15
|
+
* await client.admin.organization.projects.serviceAccounts.apiKeys.create(
|
|
16
|
+
* 'service_account_id',
|
|
17
|
+
* { project_id: 'project_id' },
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
create(
|
|
22
|
+
serviceAccountID: string,
|
|
23
|
+
params: APIKeyCreateParams,
|
|
24
|
+
options?: RequestOptions,
|
|
25
|
+
): APIPromise<APIKeyCreateResponse> {
|
|
26
|
+
const { project_id, ...body } = params;
|
|
27
|
+
return this._client.post(
|
|
28
|
+
path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}/api_keys`,
|
|
29
|
+
{ body, ...options, __security: { adminAPIKeyAuth: true } },
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface APIKeyCreateResponse {
|
|
35
|
+
/**
|
|
36
|
+
* The identifier of the API key.
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The Unix timestamp (in seconds) when the API key was created.
|
|
42
|
+
*/
|
|
43
|
+
created_at: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The name of the API key.
|
|
47
|
+
*/
|
|
48
|
+
name: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The object type, which is always `organization.project.service_account.api_key`
|
|
52
|
+
*/
|
|
53
|
+
object: 'organization.project.service_account.api_key';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The unredacted API key value.
|
|
57
|
+
*/
|
|
58
|
+
value: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface APIKeyCreateParams {
|
|
62
|
+
/**
|
|
63
|
+
* Path param: The ID of the project.
|
|
64
|
+
*/
|
|
65
|
+
project_id: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Body param: API key name.
|
|
69
|
+
*/
|
|
70
|
+
name?: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Body param: API key scopes.
|
|
74
|
+
*/
|
|
75
|
+
scopes?: Array<string>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export declare namespace APIKeys {
|
|
79
|
+
export { type APIKeyCreateResponse as APIKeyCreateResponse, type APIKeyCreateParams as APIKeyCreateParams };
|
|
80
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export { APIKeys, type APIKeyCreateResponse, type APIKeyCreateParams } from './api-keys';
|
|
4
|
+
export {
|
|
5
|
+
ServiceAccounts,
|
|
6
|
+
type ProjectServiceAccount,
|
|
7
|
+
type ServiceAccountCreateResponse,
|
|
8
|
+
type ServiceAccountDeleteResponse,
|
|
9
|
+
type ServiceAccountCreateParams,
|
|
10
|
+
type ServiceAccountRetrieveParams,
|
|
11
|
+
type ServiceAccountUpdateParams,
|
|
12
|
+
type ServiceAccountListParams,
|
|
13
|
+
type ServiceAccountDeleteParams,
|
|
14
|
+
type ProjectServiceAccountsPage,
|
|
15
|
+
} from './service-accounts';
|