@effect/ai-openai-compat 4.0.0-beta.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/LICENSE +21 -0
- package/dist/OpenAiClient.d.ts +739 -0
- package/dist/OpenAiClient.d.ts.map +1 -0
- package/dist/OpenAiClient.js +170 -0
- package/dist/OpenAiClient.js.map +1 -0
- package/dist/OpenAiConfig.d.ts +47 -0
- package/dist/OpenAiConfig.d.ts.map +1 -0
- package/dist/OpenAiConfig.js +25 -0
- package/dist/OpenAiConfig.js.map +1 -0
- package/dist/OpenAiError.d.ts +93 -0
- package/dist/OpenAiError.d.ts.map +1 -0
- package/dist/OpenAiError.js +5 -0
- package/dist/OpenAiError.js.map +1 -0
- package/dist/OpenAiLanguageModel.d.ts +285 -0
- package/dist/OpenAiLanguageModel.d.ts.map +1 -0
- package/dist/OpenAiLanguageModel.js +1223 -0
- package/dist/OpenAiLanguageModel.js.map +1 -0
- package/dist/OpenAiTelemetry.d.ts +120 -0
- package/dist/OpenAiTelemetry.d.ts.map +1 -0
- package/dist/OpenAiTelemetry.js +35 -0
- package/dist/OpenAiTelemetry.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/errors.d.ts +2 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +286 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/utilities.d.ts +2 -0
- package/dist/internal/utilities.d.ts.map +1 -0
- package/dist/internal/utilities.js +25 -0
- package/dist/internal/utilities.js.map +1 -0
- package/package.json +62 -0
- package/src/OpenAiClient.ts +998 -0
- package/src/OpenAiConfig.ts +64 -0
- package/src/OpenAiError.ts +102 -0
- package/src/OpenAiLanguageModel.ts +1638 -0
- package/src/OpenAiTelemetry.ts +159 -0
- package/src/index.ts +41 -0
- package/src/internal/errors.ts +327 -0
- package/src/internal/utilities.ts +33 -0
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
import type * as Config from "effect/Config";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Redacted from "effect/Redacted";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as ServiceMap from "effect/ServiceMap";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
import type * as AiError from "effect/unstable/ai/AiError";
|
|
9
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
10
|
+
import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse";
|
|
11
|
+
/**
|
|
12
|
+
* @since 1.0.0
|
|
13
|
+
* @category models
|
|
14
|
+
*/
|
|
15
|
+
export interface Service {
|
|
16
|
+
readonly client: HttpClient.HttpClient;
|
|
17
|
+
readonly createResponse: (options: CreateResponseRequestJson) => Effect.Effect<[
|
|
18
|
+
body: CreateResponse200,
|
|
19
|
+
response: HttpClientResponse.HttpClientResponse
|
|
20
|
+
], AiError.AiError>;
|
|
21
|
+
readonly createResponseStream: (options: Omit<CreateResponseRequestJson, "stream" | "stream_options">) => Effect.Effect<[
|
|
22
|
+
response: HttpClientResponse.HttpClientResponse,
|
|
23
|
+
stream: Stream.Stream<CreateResponse200Sse, AiError.AiError>
|
|
24
|
+
], AiError.AiError>;
|
|
25
|
+
readonly createEmbedding: (options: CreateEmbeddingRequestJson) => Effect.Effect<CreateEmbedding200, AiError.AiError>;
|
|
26
|
+
}
|
|
27
|
+
declare const OpenAiClient_base: ServiceMap.ServiceClass<OpenAiClient, "@effect/ai-openai-compat/OpenAiClient", Service>;
|
|
28
|
+
/**
|
|
29
|
+
* @since 1.0.0
|
|
30
|
+
* @category service
|
|
31
|
+
*/
|
|
32
|
+
export declare class OpenAiClient extends OpenAiClient_base {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
* @category models
|
|
37
|
+
*/
|
|
38
|
+
export type Options = {
|
|
39
|
+
readonly apiKey?: Redacted.Redacted<string> | undefined;
|
|
40
|
+
readonly apiUrl?: string | undefined;
|
|
41
|
+
readonly organizationId?: Redacted.Redacted<string> | undefined;
|
|
42
|
+
readonly projectId?: Redacted.Redacted<string> | undefined;
|
|
43
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* @since 1.0.0
|
|
47
|
+
* @category constructors
|
|
48
|
+
*/
|
|
49
|
+
export declare const make: (options: Options) => Effect.Effect<Service, never, HttpClient.HttpClient>;
|
|
50
|
+
/**
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
* @category layers
|
|
53
|
+
*/
|
|
54
|
+
export declare const layer: (options: Options) => Layer.Layer<OpenAiClient, never, HttpClient.HttpClient>;
|
|
55
|
+
/**
|
|
56
|
+
* @since 1.0.0
|
|
57
|
+
* @category layers
|
|
58
|
+
*/
|
|
59
|
+
export declare const layerConfig: (options?: {
|
|
60
|
+
readonly apiKey?: Config.Config<Redacted.Redacted<string>> | undefined;
|
|
61
|
+
readonly apiUrl?: Config.Config<string> | undefined;
|
|
62
|
+
readonly organizationId?: Config.Config<Redacted.Redacted<string>> | undefined;
|
|
63
|
+
readonly projectId?: Config.Config<Redacted.Redacted<string>> | undefined;
|
|
64
|
+
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
|
|
65
|
+
}) => Layer.Layer<OpenAiClient, Config.ConfigError, HttpClient.HttpClient>;
|
|
66
|
+
type JsonObject = {
|
|
67
|
+
readonly [x: string]: Schema.Json;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
72
|
+
export type IncludeEnum = "message.input_image.image_url" | "reasoning.encrypted_content" | "message.output_text.logprobs";
|
|
73
|
+
/**
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
*/
|
|
76
|
+
export type MessageStatus = "in_progress" | "completed" | "incomplete";
|
|
77
|
+
type InputTextContent = {
|
|
78
|
+
readonly type: "input_text";
|
|
79
|
+
readonly text: string;
|
|
80
|
+
};
|
|
81
|
+
type InputImageContent = {
|
|
82
|
+
readonly type: "input_image";
|
|
83
|
+
readonly image_url?: string | null | undefined;
|
|
84
|
+
readonly file_id?: string | null | undefined;
|
|
85
|
+
readonly detail?: "low" | "high" | "auto" | null | undefined;
|
|
86
|
+
};
|
|
87
|
+
type InputFileContent = {
|
|
88
|
+
readonly type: "input_file";
|
|
89
|
+
readonly file_id?: string | null | undefined;
|
|
90
|
+
readonly filename?: string | undefined;
|
|
91
|
+
readonly file_url?: string | undefined;
|
|
92
|
+
readonly file_data?: string | undefined;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* @since 1.0.0
|
|
96
|
+
*/
|
|
97
|
+
export type InputContent = InputTextContent | InputImageContent | InputFileContent;
|
|
98
|
+
/**
|
|
99
|
+
* @since 1.0.0
|
|
100
|
+
*/
|
|
101
|
+
export type SummaryTextContent = {
|
|
102
|
+
readonly type: "summary_text";
|
|
103
|
+
readonly text: string;
|
|
104
|
+
};
|
|
105
|
+
type ReasoningTextContent = {
|
|
106
|
+
readonly type: "reasoning_text";
|
|
107
|
+
readonly text: string;
|
|
108
|
+
};
|
|
109
|
+
type RefusalContent = {
|
|
110
|
+
readonly type: "refusal";
|
|
111
|
+
readonly refusal: string;
|
|
112
|
+
};
|
|
113
|
+
type TextContent = {
|
|
114
|
+
readonly type: "text";
|
|
115
|
+
readonly text: string;
|
|
116
|
+
};
|
|
117
|
+
type ComputerScreenshotContent = {
|
|
118
|
+
readonly type: "computer_screenshot";
|
|
119
|
+
readonly image_url: string | null;
|
|
120
|
+
readonly file_id: string | null;
|
|
121
|
+
};
|
|
122
|
+
type FileCitationAnnotation = {
|
|
123
|
+
readonly type: "file_citation";
|
|
124
|
+
readonly file_id: string;
|
|
125
|
+
readonly index: number;
|
|
126
|
+
readonly filename: string;
|
|
127
|
+
};
|
|
128
|
+
type UrlCitationAnnotation = {
|
|
129
|
+
readonly type: "url_citation";
|
|
130
|
+
readonly url: string;
|
|
131
|
+
readonly start_index: number;
|
|
132
|
+
readonly end_index: number;
|
|
133
|
+
readonly title: string;
|
|
134
|
+
};
|
|
135
|
+
type ContainerFileCitationAnnotation = {
|
|
136
|
+
readonly type: "container_file_citation";
|
|
137
|
+
readonly container_id: string;
|
|
138
|
+
readonly file_id: string;
|
|
139
|
+
readonly start_index: number;
|
|
140
|
+
readonly end_index: number;
|
|
141
|
+
readonly filename: string;
|
|
142
|
+
};
|
|
143
|
+
type FilePathAnnotation = {
|
|
144
|
+
readonly type: "file_path";
|
|
145
|
+
readonly file_id: string;
|
|
146
|
+
readonly index: number;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* @since 1.0.0
|
|
150
|
+
*/
|
|
151
|
+
export type Annotation = FileCitationAnnotation | UrlCitationAnnotation | ContainerFileCitationAnnotation | FilePathAnnotation;
|
|
152
|
+
type OutputTextContent = {
|
|
153
|
+
readonly type: "output_text";
|
|
154
|
+
readonly text: string;
|
|
155
|
+
readonly annotations?: ReadonlyArray<Annotation> | undefined;
|
|
156
|
+
readonly logprobs?: ReadonlyArray<unknown> | undefined;
|
|
157
|
+
};
|
|
158
|
+
type OutputMessageContent = InputTextContent | OutputTextContent | TextContent | SummaryTextContent | ReasoningTextContent | RefusalContent | InputImageContent | ComputerScreenshotContent | InputFileContent;
|
|
159
|
+
type OutputMessage = {
|
|
160
|
+
readonly id: string;
|
|
161
|
+
readonly type: "message";
|
|
162
|
+
readonly role: "assistant";
|
|
163
|
+
readonly content: ReadonlyArray<OutputMessageContent>;
|
|
164
|
+
readonly status: MessageStatus;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* @since 1.0.0
|
|
168
|
+
*/
|
|
169
|
+
export type ReasoningItem = {
|
|
170
|
+
readonly type: "reasoning";
|
|
171
|
+
readonly id: string;
|
|
172
|
+
readonly encrypted_content?: string | null | undefined;
|
|
173
|
+
readonly summary: ReadonlyArray<SummaryTextContent>;
|
|
174
|
+
readonly content?: ReadonlyArray<ReasoningTextContent> | undefined;
|
|
175
|
+
readonly status?: MessageStatus | undefined;
|
|
176
|
+
};
|
|
177
|
+
type FunctionCall = {
|
|
178
|
+
readonly id?: string | undefined;
|
|
179
|
+
readonly type: "function_call";
|
|
180
|
+
readonly call_id: string;
|
|
181
|
+
readonly name: string;
|
|
182
|
+
readonly arguments: string;
|
|
183
|
+
readonly status?: MessageStatus | undefined;
|
|
184
|
+
};
|
|
185
|
+
type FunctionCallOutput = {
|
|
186
|
+
readonly id?: string | null | undefined;
|
|
187
|
+
readonly call_id: string;
|
|
188
|
+
readonly type: "function_call_output";
|
|
189
|
+
readonly output: string | ReadonlyArray<InputTextContent | InputImageContent | InputFileContent>;
|
|
190
|
+
readonly status?: MessageStatus | null | undefined;
|
|
191
|
+
};
|
|
192
|
+
type CustomToolCall = {
|
|
193
|
+
readonly type: "custom_tool_call";
|
|
194
|
+
readonly id?: string | undefined;
|
|
195
|
+
readonly call_id: string;
|
|
196
|
+
readonly name: string;
|
|
197
|
+
readonly input: string;
|
|
198
|
+
};
|
|
199
|
+
type CustomToolCallOutput = {
|
|
200
|
+
readonly type: "custom_tool_call_output";
|
|
201
|
+
readonly id?: string | undefined;
|
|
202
|
+
readonly call_id: string;
|
|
203
|
+
readonly output: string | ReadonlyArray<InputTextContent | InputImageContent | InputFileContent>;
|
|
204
|
+
};
|
|
205
|
+
type ItemReference = {
|
|
206
|
+
readonly type?: "item_reference" | null | undefined;
|
|
207
|
+
readonly id: string;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* @since 1.0.0
|
|
211
|
+
*/
|
|
212
|
+
export type InputItem = {
|
|
213
|
+
readonly role: "user" | "assistant" | "system" | "developer";
|
|
214
|
+
readonly content: string | ReadonlyArray<InputContent>;
|
|
215
|
+
readonly type?: "message" | undefined;
|
|
216
|
+
} | {
|
|
217
|
+
readonly type?: "message" | undefined;
|
|
218
|
+
readonly role: "user" | "system" | "developer";
|
|
219
|
+
readonly status?: MessageStatus | undefined;
|
|
220
|
+
readonly content: ReadonlyArray<InputContent>;
|
|
221
|
+
} | OutputMessage | FunctionCall | FunctionCallOutput | ReasoningItem | CustomToolCallOutput | CustomToolCall | ItemReference;
|
|
222
|
+
type FunctionTool = {
|
|
223
|
+
readonly type: "function";
|
|
224
|
+
readonly name: string;
|
|
225
|
+
readonly description?: string | null | undefined;
|
|
226
|
+
readonly parameters?: JsonObject | null | undefined;
|
|
227
|
+
readonly strict?: boolean | null | undefined;
|
|
228
|
+
};
|
|
229
|
+
type CustomToolParam = {
|
|
230
|
+
readonly type: "custom";
|
|
231
|
+
readonly name: string;
|
|
232
|
+
readonly description?: string | undefined;
|
|
233
|
+
readonly format?: unknown;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* @since 1.0.0
|
|
237
|
+
*/
|
|
238
|
+
export type Tool = FunctionTool | CustomToolParam;
|
|
239
|
+
type ToolChoice = "none" | "auto" | "required" | {
|
|
240
|
+
readonly type: "allowed_tools";
|
|
241
|
+
readonly mode: "auto" | "required";
|
|
242
|
+
readonly tools: ReadonlyArray<JsonObject>;
|
|
243
|
+
} | {
|
|
244
|
+
readonly type: "function";
|
|
245
|
+
readonly name: string;
|
|
246
|
+
} | {
|
|
247
|
+
readonly type: "custom";
|
|
248
|
+
readonly name: string;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* @since 1.0.0
|
|
252
|
+
*/
|
|
253
|
+
export type TextResponseFormatConfiguration = {
|
|
254
|
+
readonly type: "text";
|
|
255
|
+
} | {
|
|
256
|
+
readonly type: "json_schema";
|
|
257
|
+
readonly description?: string | undefined;
|
|
258
|
+
readonly name: string;
|
|
259
|
+
readonly schema: JsonObject;
|
|
260
|
+
readonly strict?: boolean | null | undefined;
|
|
261
|
+
} | {
|
|
262
|
+
readonly type: "json_object";
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* @since 1.0.0
|
|
266
|
+
*/
|
|
267
|
+
export type CreateResponse = {
|
|
268
|
+
readonly metadata?: Readonly<Record<string, string>> | null | undefined;
|
|
269
|
+
readonly top_logprobs?: number | undefined;
|
|
270
|
+
readonly temperature?: number | null | undefined;
|
|
271
|
+
readonly top_p?: number | null | undefined;
|
|
272
|
+
readonly user?: string | null | undefined;
|
|
273
|
+
readonly safety_identifier?: string | null | undefined;
|
|
274
|
+
readonly prompt_cache_key?: string | null | undefined;
|
|
275
|
+
readonly service_tier?: string | undefined;
|
|
276
|
+
readonly prompt_cache_retention?: "in-memory" | "24h" | null | undefined;
|
|
277
|
+
readonly previous_response_id?: string | null | undefined;
|
|
278
|
+
readonly model?: string | undefined;
|
|
279
|
+
readonly reasoning?: unknown;
|
|
280
|
+
readonly background?: boolean | null | undefined;
|
|
281
|
+
readonly max_output_tokens?: number | null | undefined;
|
|
282
|
+
readonly max_tool_calls?: number | null | undefined;
|
|
283
|
+
readonly text?: {
|
|
284
|
+
readonly format?: TextResponseFormatConfiguration | undefined;
|
|
285
|
+
readonly verbosity?: "low" | "medium" | "high" | null | undefined;
|
|
286
|
+
} | undefined;
|
|
287
|
+
readonly tools?: ReadonlyArray<Tool> | undefined;
|
|
288
|
+
readonly tool_choice?: ToolChoice | undefined;
|
|
289
|
+
readonly truncation?: "auto" | "disabled" | null | undefined;
|
|
290
|
+
readonly input?: string | ReadonlyArray<InputItem> | undefined;
|
|
291
|
+
readonly include?: ReadonlyArray<IncludeEnum> | null | undefined;
|
|
292
|
+
readonly parallel_tool_calls?: boolean | null | undefined;
|
|
293
|
+
readonly store?: boolean | null | undefined;
|
|
294
|
+
readonly instructions?: string | null | undefined;
|
|
295
|
+
readonly stream?: boolean | null | undefined;
|
|
296
|
+
readonly conversation?: string | null | undefined;
|
|
297
|
+
readonly modalities?: ReadonlyArray<"text" | "audio"> | undefined;
|
|
298
|
+
readonly seed?: number | undefined;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* @since 1.0.0
|
|
302
|
+
*/
|
|
303
|
+
export type ResponseUsage = {
|
|
304
|
+
readonly input_tokens: number;
|
|
305
|
+
readonly output_tokens: number;
|
|
306
|
+
readonly total_tokens: number;
|
|
307
|
+
readonly input_tokens_details?: unknown;
|
|
308
|
+
readonly output_tokens_details?: unknown;
|
|
309
|
+
};
|
|
310
|
+
type OutputItem = OutputMessage | FunctionCall | ReasoningItem | CustomToolCall;
|
|
311
|
+
/**
|
|
312
|
+
* @since 1.0.0
|
|
313
|
+
*/
|
|
314
|
+
export type Response = {
|
|
315
|
+
readonly id: string;
|
|
316
|
+
readonly object?: "response" | undefined;
|
|
317
|
+
readonly model: string;
|
|
318
|
+
readonly status?: "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete" | undefined;
|
|
319
|
+
readonly created_at: number;
|
|
320
|
+
readonly output: ReadonlyArray<OutputItem>;
|
|
321
|
+
readonly usage?: ResponseUsage | null | undefined;
|
|
322
|
+
readonly incomplete_details?: {
|
|
323
|
+
readonly reason?: "max_output_tokens" | "content_filter" | undefined;
|
|
324
|
+
} | null | undefined;
|
|
325
|
+
readonly service_tier?: string | undefined;
|
|
326
|
+
};
|
|
327
|
+
type ResponseCreatedEvent = {
|
|
328
|
+
readonly type: "response.created";
|
|
329
|
+
readonly response: Response;
|
|
330
|
+
readonly sequence_number: number;
|
|
331
|
+
};
|
|
332
|
+
type ResponseCompletedEvent = {
|
|
333
|
+
readonly type: "response.completed";
|
|
334
|
+
readonly response: Response;
|
|
335
|
+
readonly sequence_number: number;
|
|
336
|
+
};
|
|
337
|
+
type ResponseIncompleteEvent = {
|
|
338
|
+
readonly type: "response.incomplete";
|
|
339
|
+
readonly response: Response;
|
|
340
|
+
readonly sequence_number: number;
|
|
341
|
+
};
|
|
342
|
+
type ResponseFailedEvent = {
|
|
343
|
+
readonly type: "response.failed";
|
|
344
|
+
readonly response: Response;
|
|
345
|
+
readonly sequence_number: number;
|
|
346
|
+
};
|
|
347
|
+
type ResponseOutputItemAddedEvent = {
|
|
348
|
+
readonly type: "response.output_item.added";
|
|
349
|
+
readonly output_index: number;
|
|
350
|
+
readonly sequence_number: number;
|
|
351
|
+
readonly item: OutputItem;
|
|
352
|
+
};
|
|
353
|
+
type ResponseOutputItemDoneEvent = {
|
|
354
|
+
readonly type: "response.output_item.done";
|
|
355
|
+
readonly output_index: number;
|
|
356
|
+
readonly sequence_number: number;
|
|
357
|
+
readonly item: OutputItem;
|
|
358
|
+
};
|
|
359
|
+
type ResponseTextDeltaEvent = {
|
|
360
|
+
readonly type: "response.output_text.delta";
|
|
361
|
+
readonly item_id: string;
|
|
362
|
+
readonly output_index: number;
|
|
363
|
+
readonly content_index: number;
|
|
364
|
+
readonly delta: string;
|
|
365
|
+
readonly sequence_number: number;
|
|
366
|
+
readonly logprobs?: ReadonlyArray<unknown> | undefined;
|
|
367
|
+
};
|
|
368
|
+
type ResponseOutputTextAnnotationAddedEvent = {
|
|
369
|
+
readonly type: "response.output_text.annotation.added";
|
|
370
|
+
readonly item_id: string;
|
|
371
|
+
readonly output_index: number;
|
|
372
|
+
readonly content_index: number;
|
|
373
|
+
readonly annotation_index: number;
|
|
374
|
+
readonly sequence_number: number;
|
|
375
|
+
readonly annotation: Annotation;
|
|
376
|
+
};
|
|
377
|
+
type ResponseFunctionCallArgumentsDeltaEvent = {
|
|
378
|
+
readonly type: "response.function_call_arguments.delta";
|
|
379
|
+
readonly item_id: string;
|
|
380
|
+
readonly output_index: number;
|
|
381
|
+
readonly sequence_number: number;
|
|
382
|
+
readonly delta: string;
|
|
383
|
+
};
|
|
384
|
+
type ResponseReasoningSummaryPartAddedEvent = {
|
|
385
|
+
readonly type: "response.reasoning_summary_part.added";
|
|
386
|
+
readonly item_id: string;
|
|
387
|
+
readonly output_index: number;
|
|
388
|
+
readonly summary_index: number;
|
|
389
|
+
readonly sequence_number: number;
|
|
390
|
+
readonly part: SummaryTextContent;
|
|
391
|
+
};
|
|
392
|
+
type ResponseReasoningSummaryPartDoneEvent = {
|
|
393
|
+
readonly type: "response.reasoning_summary_part.done";
|
|
394
|
+
readonly item_id: string;
|
|
395
|
+
readonly output_index: number;
|
|
396
|
+
readonly summary_index: number;
|
|
397
|
+
readonly sequence_number: number;
|
|
398
|
+
readonly part: SummaryTextContent;
|
|
399
|
+
};
|
|
400
|
+
type ResponseReasoningSummaryTextDeltaEvent = {
|
|
401
|
+
readonly type: "response.reasoning_summary_text.delta";
|
|
402
|
+
readonly item_id: string;
|
|
403
|
+
readonly output_index: number;
|
|
404
|
+
readonly summary_index: number;
|
|
405
|
+
readonly delta: string;
|
|
406
|
+
readonly sequence_number: number;
|
|
407
|
+
};
|
|
408
|
+
type ResponseErrorEvent = {
|
|
409
|
+
readonly type: "error";
|
|
410
|
+
readonly code: string | null;
|
|
411
|
+
readonly message: string;
|
|
412
|
+
readonly param: string | null;
|
|
413
|
+
readonly sequence_number: number;
|
|
414
|
+
};
|
|
415
|
+
type UnknownResponseStreamEvent = {
|
|
416
|
+
readonly type: string;
|
|
417
|
+
readonly [key: string]: unknown;
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* @since 1.0.0
|
|
421
|
+
*/
|
|
422
|
+
export type ResponseStreamEvent = ResponseCreatedEvent | ResponseCompletedEvent | ResponseIncompleteEvent | ResponseFailedEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseTextDeltaEvent | ResponseOutputTextAnnotationAddedEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseReasoningSummaryPartAddedEvent | ResponseReasoningSummaryPartDoneEvent | ResponseReasoningSummaryTextDeltaEvent | ResponseErrorEvent | UnknownResponseStreamEvent;
|
|
423
|
+
/**
|
|
424
|
+
* @since 1.0.0
|
|
425
|
+
*/
|
|
426
|
+
export type Embedding = {
|
|
427
|
+
readonly embedding: ReadonlyArray<number> | string;
|
|
428
|
+
readonly index: number;
|
|
429
|
+
readonly object?: string | undefined;
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* @since 1.0.0
|
|
433
|
+
*/
|
|
434
|
+
export type CreateEmbeddingRequest = {
|
|
435
|
+
readonly input: string | ReadonlyArray<string> | ReadonlyArray<number> | ReadonlyArray<ReadonlyArray<number>>;
|
|
436
|
+
readonly model: string;
|
|
437
|
+
readonly encoding_format?: "float" | "base64" | undefined;
|
|
438
|
+
readonly dimensions?: number | undefined;
|
|
439
|
+
readonly user?: string | undefined;
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* @since 1.0.0
|
|
443
|
+
*/
|
|
444
|
+
export type CreateEmbeddingResponse = {
|
|
445
|
+
readonly data: ReadonlyArray<Embedding>;
|
|
446
|
+
readonly model: string;
|
|
447
|
+
readonly object?: "list" | undefined;
|
|
448
|
+
readonly usage?: {
|
|
449
|
+
readonly prompt_tokens: number;
|
|
450
|
+
readonly total_tokens: number;
|
|
451
|
+
} | undefined;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* @since 1.0.0
|
|
455
|
+
*/
|
|
456
|
+
export type CreateEmbeddingRequestJson = CreateEmbeddingRequest;
|
|
457
|
+
/**
|
|
458
|
+
* @since 1.0.0
|
|
459
|
+
*/
|
|
460
|
+
export type CreateEmbedding200 = CreateEmbeddingResponse;
|
|
461
|
+
/**
|
|
462
|
+
* @since 1.0.0
|
|
463
|
+
*/
|
|
464
|
+
export type ChatCompletionContentPart = {
|
|
465
|
+
readonly type: "text";
|
|
466
|
+
readonly text: string;
|
|
467
|
+
} | {
|
|
468
|
+
readonly type: "image_url";
|
|
469
|
+
readonly image_url: {
|
|
470
|
+
readonly url: string;
|
|
471
|
+
readonly detail?: "low" | "high" | "auto" | undefined;
|
|
472
|
+
};
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* @since 1.0.0
|
|
476
|
+
*/
|
|
477
|
+
export type ChatCompletionRequestToolCall = {
|
|
478
|
+
readonly id: string;
|
|
479
|
+
readonly type: "function";
|
|
480
|
+
readonly function: {
|
|
481
|
+
readonly name: string;
|
|
482
|
+
readonly arguments: string;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* @since 1.0.0
|
|
487
|
+
*/
|
|
488
|
+
export type ChatCompletionRequestMessage = {
|
|
489
|
+
readonly role: "system" | "developer" | "user" | "assistant";
|
|
490
|
+
readonly content: string | ReadonlyArray<ChatCompletionContentPart> | null;
|
|
491
|
+
readonly tool_calls?: ReadonlyArray<ChatCompletionRequestToolCall> | undefined;
|
|
492
|
+
} | {
|
|
493
|
+
readonly role: "tool";
|
|
494
|
+
readonly tool_call_id: string;
|
|
495
|
+
readonly content: string;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* @since 1.0.0
|
|
499
|
+
*/
|
|
500
|
+
export type ChatCompletionTool = {
|
|
501
|
+
readonly type: "function";
|
|
502
|
+
readonly function: {
|
|
503
|
+
readonly name: string;
|
|
504
|
+
readonly description?: string | null | undefined;
|
|
505
|
+
readonly parameters?: JsonObject | undefined;
|
|
506
|
+
readonly strict?: boolean | undefined;
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
/**
|
|
510
|
+
* @since 1.0.0
|
|
511
|
+
*/
|
|
512
|
+
export type ChatCompletionToolChoice = "none" | "auto" | "required" | {
|
|
513
|
+
readonly type: "function";
|
|
514
|
+
readonly function: {
|
|
515
|
+
readonly name: string;
|
|
516
|
+
};
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* @since 1.0.0
|
|
520
|
+
*/
|
|
521
|
+
export type ChatCompletionResponseFormat = {
|
|
522
|
+
readonly type: "json_object";
|
|
523
|
+
} | {
|
|
524
|
+
readonly type: "json_schema";
|
|
525
|
+
readonly json_schema: {
|
|
526
|
+
readonly name: string;
|
|
527
|
+
readonly schema: JsonObject;
|
|
528
|
+
readonly description?: string | undefined;
|
|
529
|
+
readonly strict?: boolean | undefined;
|
|
530
|
+
};
|
|
531
|
+
};
|
|
532
|
+
/**
|
|
533
|
+
* @since 1.0.0
|
|
534
|
+
*/
|
|
535
|
+
export type ChatCompletionRequest = {
|
|
536
|
+
readonly model: string;
|
|
537
|
+
readonly messages: ReadonlyArray<ChatCompletionRequestMessage>;
|
|
538
|
+
readonly temperature?: number | null | undefined;
|
|
539
|
+
readonly top_p?: number | null | undefined;
|
|
540
|
+
readonly max_tokens?: number | null | undefined;
|
|
541
|
+
readonly user?: string | null | undefined;
|
|
542
|
+
readonly seed?: number | undefined;
|
|
543
|
+
readonly parallel_tool_calls?: boolean | null | undefined;
|
|
544
|
+
readonly response_format?: ChatCompletionResponseFormat | undefined;
|
|
545
|
+
readonly tools?: ReadonlyArray<ChatCompletionTool> | undefined;
|
|
546
|
+
readonly tool_choice?: ChatCompletionToolChoice | undefined;
|
|
547
|
+
readonly service_tier?: string | undefined;
|
|
548
|
+
readonly stream?: boolean | undefined;
|
|
549
|
+
readonly stream_options?: {
|
|
550
|
+
readonly include_usage?: boolean | undefined;
|
|
551
|
+
} | undefined;
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* @since 1.0.0
|
|
555
|
+
*/
|
|
556
|
+
export type CreateResponseRequestJson = ChatCompletionRequest;
|
|
557
|
+
/**
|
|
558
|
+
* @since 1.0.0
|
|
559
|
+
*/
|
|
560
|
+
export type CreateResponse200 = ChatCompletionResponse;
|
|
561
|
+
/**
|
|
562
|
+
* @since 1.0.0
|
|
563
|
+
*/
|
|
564
|
+
export type CreateResponse200Sse = ChatCompletionStreamEvent;
|
|
565
|
+
declare const ChatCompletionToolCall: Schema.Struct<{
|
|
566
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
567
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
568
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
569
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
570
|
+
readonly name: Schema.String;
|
|
571
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
572
|
+
}>>;
|
|
573
|
+
}>;
|
|
574
|
+
declare const ChatCompletionMessage: Schema.Struct<{
|
|
575
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
576
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
577
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
578
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
579
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
580
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
581
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
582
|
+
readonly name: Schema.String;
|
|
583
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
584
|
+
}>>;
|
|
585
|
+
}>>>;
|
|
586
|
+
}>;
|
|
587
|
+
declare const ChatCompletionChoice: Schema.Struct<{
|
|
588
|
+
readonly index: Schema.Number;
|
|
589
|
+
readonly finish_reason: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
590
|
+
readonly message: Schema.optionalKey<Schema.Struct<{
|
|
591
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
592
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
593
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
594
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
595
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
596
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
597
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
598
|
+
readonly name: Schema.String;
|
|
599
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
600
|
+
}>>;
|
|
601
|
+
}>>>;
|
|
602
|
+
}>>;
|
|
603
|
+
readonly delta: Schema.optionalKey<Schema.Struct<{
|
|
604
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
605
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
606
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
607
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
608
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
609
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
610
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
611
|
+
readonly name: Schema.String;
|
|
612
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
613
|
+
}>>;
|
|
614
|
+
}>>>;
|
|
615
|
+
}>>;
|
|
616
|
+
}>;
|
|
617
|
+
declare const ChatCompletionUsage: Schema.Struct<{
|
|
618
|
+
readonly prompt_tokens: Schema.Number;
|
|
619
|
+
readonly completion_tokens: Schema.Number;
|
|
620
|
+
readonly total_tokens: Schema.Number;
|
|
621
|
+
readonly prompt_tokens_details: Schema.optionalKey<Schema.Any>;
|
|
622
|
+
readonly completion_tokens_details: Schema.optionalKey<Schema.Any>;
|
|
623
|
+
}>;
|
|
624
|
+
declare const ChatCompletionResponse: Schema.Struct<{
|
|
625
|
+
readonly id: Schema.String;
|
|
626
|
+
readonly model: Schema.String;
|
|
627
|
+
readonly created: Schema.Number;
|
|
628
|
+
readonly choices: Schema.Array$<Schema.Struct<{
|
|
629
|
+
readonly index: Schema.Number;
|
|
630
|
+
readonly finish_reason: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
631
|
+
readonly message: Schema.optionalKey<Schema.Struct<{
|
|
632
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
633
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
634
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
635
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
636
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
637
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
638
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
639
|
+
readonly name: Schema.String;
|
|
640
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
641
|
+
}>>;
|
|
642
|
+
}>>>;
|
|
643
|
+
}>>;
|
|
644
|
+
readonly delta: Schema.optionalKey<Schema.Struct<{
|
|
645
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
646
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
647
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
648
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
649
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
650
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
651
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
652
|
+
readonly name: Schema.String;
|
|
653
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
654
|
+
}>>;
|
|
655
|
+
}>>>;
|
|
656
|
+
}>>;
|
|
657
|
+
}>>;
|
|
658
|
+
readonly usage: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
|
|
659
|
+
readonly prompt_tokens: Schema.Number;
|
|
660
|
+
readonly completion_tokens: Schema.Number;
|
|
661
|
+
readonly total_tokens: Schema.Number;
|
|
662
|
+
readonly prompt_tokens_details: Schema.optionalKey<Schema.Any>;
|
|
663
|
+
readonly completion_tokens_details: Schema.optionalKey<Schema.Any>;
|
|
664
|
+
}>>>;
|
|
665
|
+
readonly service_tier: Schema.optionalKey<Schema.String>;
|
|
666
|
+
}>;
|
|
667
|
+
declare const ChatCompletionChunk: Schema.Struct<{
|
|
668
|
+
readonly id: Schema.String;
|
|
669
|
+
readonly model: Schema.String;
|
|
670
|
+
readonly created: Schema.Number;
|
|
671
|
+
readonly choices: Schema.Array$<Schema.Struct<{
|
|
672
|
+
readonly index: Schema.Number;
|
|
673
|
+
readonly finish_reason: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
674
|
+
readonly message: Schema.optionalKey<Schema.Struct<{
|
|
675
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
676
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
677
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
678
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
679
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
680
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
681
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
682
|
+
readonly name: Schema.String;
|
|
683
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
684
|
+
}>>;
|
|
685
|
+
}>>>;
|
|
686
|
+
}>>;
|
|
687
|
+
readonly delta: Schema.optionalKey<Schema.Struct<{
|
|
688
|
+
readonly role: Schema.optionalKey<Schema.String>;
|
|
689
|
+
readonly content: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
690
|
+
readonly tool_calls: Schema.optionalKey<Schema.Array$<Schema.Struct<{
|
|
691
|
+
readonly id: Schema.optionalKey<Schema.String>;
|
|
692
|
+
readonly index: Schema.optionalKey<Schema.Number>;
|
|
693
|
+
readonly type: Schema.optionalKey<Schema.String>;
|
|
694
|
+
readonly function: Schema.optionalKey<Schema.Struct<{
|
|
695
|
+
readonly name: Schema.String;
|
|
696
|
+
readonly arguments: Schema.optionalKey<Schema.String>;
|
|
697
|
+
}>>;
|
|
698
|
+
}>>>;
|
|
699
|
+
}>>;
|
|
700
|
+
}>>;
|
|
701
|
+
readonly usage: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
|
|
702
|
+
readonly prompt_tokens: Schema.Number;
|
|
703
|
+
readonly completion_tokens: Schema.Number;
|
|
704
|
+
readonly total_tokens: Schema.Number;
|
|
705
|
+
readonly prompt_tokens_details: Schema.optionalKey<Schema.Any>;
|
|
706
|
+
readonly completion_tokens_details: Schema.optionalKey<Schema.Any>;
|
|
707
|
+
}>>>;
|
|
708
|
+
readonly service_tier: Schema.optionalKey<Schema.String>;
|
|
709
|
+
}>;
|
|
710
|
+
/**
|
|
711
|
+
* @since 1.0.0
|
|
712
|
+
*/
|
|
713
|
+
export type ChatCompletionToolCall = typeof ChatCompletionToolCall.Type;
|
|
714
|
+
/**
|
|
715
|
+
* @since 1.0.0
|
|
716
|
+
*/
|
|
717
|
+
export type ChatCompletionMessage = typeof ChatCompletionMessage.Type;
|
|
718
|
+
/**
|
|
719
|
+
* @since 1.0.0
|
|
720
|
+
*/
|
|
721
|
+
export type ChatCompletionChoice = typeof ChatCompletionChoice.Type;
|
|
722
|
+
/**
|
|
723
|
+
* @since 1.0.0
|
|
724
|
+
*/
|
|
725
|
+
export type ChatCompletionUsage = typeof ChatCompletionUsage.Type;
|
|
726
|
+
/**
|
|
727
|
+
* @since 1.0.0
|
|
728
|
+
*/
|
|
729
|
+
export type ChatCompletionResponse = typeof ChatCompletionResponse.Type;
|
|
730
|
+
/**
|
|
731
|
+
* @since 1.0.0
|
|
732
|
+
*/
|
|
733
|
+
export type ChatCompletionChunk = typeof ChatCompletionChunk.Type;
|
|
734
|
+
/**
|
|
735
|
+
* @since 1.0.0
|
|
736
|
+
*/
|
|
737
|
+
export type ChatCompletionStreamEvent = ChatCompletionChunk | "[DONE]";
|
|
738
|
+
export {};
|
|
739
|
+
//# sourceMappingURL=OpenAiClient.d.ts.map
|