ai 3.1.0-canary.2 → 3.1.0-canary.3
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/ai-model-specification/dist/index.d.mts +76 -9
- package/ai-model-specification/dist/index.d.ts +76 -9
- package/ai-model-specification/dist/index.js +52 -16
- package/ai-model-specification/dist/index.js.map +1 -1
- package/ai-model-specification/dist/index.mjs +49 -15
- package/ai-model-specification/dist/index.mjs.map +1 -1
- package/core/dist/index.d.mts +79 -14
- package/core/dist/index.d.ts +79 -14
- package/core/dist/index.js +246 -338
- package/core/dist/index.js.map +1 -1
- package/core/dist/index.mjs +246 -337
- package/core/dist/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/provider/dist/index.d.mts +124 -45
- package/provider/dist/index.d.ts +124 -45
- package/provider/dist/index.js +131 -93
- package/provider/dist/index.js.map +1 -1
- package/provider/dist/index.mjs +129 -92
- package/provider/dist/index.mjs.map +1 -1
- package/react/dist/index.d.mts +4 -4
- package/react/dist/index.d.ts +4 -4
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs.map +1 -1
package/core/dist/index.d.ts
CHANGED
@@ -51,6 +51,10 @@ type LanguageModelV1CallSettings = {
|
|
51
51
|
* by the model, calls will generate deterministic results.
|
52
52
|
*/
|
53
53
|
seed?: number;
|
54
|
+
/**
|
55
|
+
* Abort signal for cancelling the operation.
|
56
|
+
*/
|
57
|
+
abortSignal?: AbortSignal;
|
54
58
|
};
|
55
59
|
|
56
60
|
/**
|
@@ -106,9 +110,9 @@ interface LanguageModelV1TextPart {
|
|
106
110
|
interface LanguageModelV1ImagePart {
|
107
111
|
type: 'image';
|
108
112
|
/**
|
109
|
-
* Image data as a Uint8Array.
|
113
|
+
* Image data as a Uint8Array (e.g. from a Blob or Buffer) or a URL.
|
110
114
|
*/
|
111
|
-
image: Uint8Array;
|
115
|
+
image: Uint8Array | URL;
|
112
116
|
/**
|
113
117
|
* Optional mime type of the image.
|
114
118
|
*/
|
@@ -234,6 +238,32 @@ type LanguageModelV1 = {
|
|
234
238
|
* model has only generated text.
|
235
239
|
*/
|
236
240
|
toolCalls?: Array<LanguageModelV1FunctionToolCall>;
|
241
|
+
/**
|
242
|
+
* Finish reason.
|
243
|
+
*/
|
244
|
+
finishReason: LanguageModelV1FinishReason;
|
245
|
+
/**
|
246
|
+
* Usage information.
|
247
|
+
*/
|
248
|
+
usage: {
|
249
|
+
promptTokens: number;
|
250
|
+
completionTokens: number;
|
251
|
+
};
|
252
|
+
/**
|
253
|
+
* Raw prompt and setting information for observability provider integration.
|
254
|
+
*/
|
255
|
+
rawCall: {
|
256
|
+
/**
|
257
|
+
* Raw prompt after expansion and conversion to the format that the
|
258
|
+
* provider uses to send the information to their API.
|
259
|
+
*/
|
260
|
+
rawPrompt: unknown;
|
261
|
+
/**
|
262
|
+
* Raw settings that are used for the API call. Includes provider-specific
|
263
|
+
* settings.
|
264
|
+
*/
|
265
|
+
rawSettings: Record<string, unknown>;
|
266
|
+
};
|
237
267
|
warnings?: LanguageModelV1CallWarning[];
|
238
268
|
}>;
|
239
269
|
/**
|
@@ -246,6 +276,21 @@ type LanguageModelV1 = {
|
|
246
276
|
*/
|
247
277
|
doStream(options: LanguageModelV1CallOptions): PromiseLike<{
|
248
278
|
stream: ReadableStream<LanguageModelV1StreamPart>;
|
279
|
+
/**
|
280
|
+
* Raw prompt and setting information for observability provider integration.
|
281
|
+
*/
|
282
|
+
rawCall: {
|
283
|
+
/**
|
284
|
+
* Raw prompt after expansion and conversion to the format that the
|
285
|
+
* provider uses to send the information to their API.
|
286
|
+
*/
|
287
|
+
rawPrompt: unknown;
|
288
|
+
/**
|
289
|
+
* Raw settings that are used for the API call. Includes provider-specific
|
290
|
+
* settings.
|
291
|
+
*/
|
292
|
+
rawSettings: Record<string, unknown>;
|
293
|
+
};
|
249
294
|
warnings?: LanguageModelV1CallWarning[];
|
250
295
|
}>;
|
251
296
|
};
|
@@ -271,6 +316,12 @@ type LanguageModelV1StreamPart = {
|
|
271
316
|
error: unknown;
|
272
317
|
};
|
273
318
|
|
319
|
+
type TokenUsage = {
|
320
|
+
promptTokens: number;
|
321
|
+
completionTokens: number;
|
322
|
+
totalTokens: number;
|
323
|
+
};
|
324
|
+
|
274
325
|
type CallSettings = {
|
275
326
|
/**
|
276
327
|
* Maximum number of tokens to generate.
|
@@ -313,6 +364,14 @@ type CallSettings = {
|
|
313
364
|
* by the model, calls will generate deterministic results.
|
314
365
|
*/
|
315
366
|
seed?: number;
|
367
|
+
/**
|
368
|
+
* Maximum number of retries. Set to 0 to disable retries. Default is 2.
|
369
|
+
*/
|
370
|
+
maxRetries?: number;
|
371
|
+
/**
|
372
|
+
* Abort signal.
|
373
|
+
*/
|
374
|
+
abortSignal?: AbortSignal;
|
316
375
|
};
|
317
376
|
|
318
377
|
/**
|
@@ -332,9 +391,12 @@ interface TextPart {
|
|
332
391
|
interface ImagePart {
|
333
392
|
type: 'image';
|
334
393
|
/**
|
335
|
-
* Image data. Can either be
|
394
|
+
* Image data. Can either be:
|
395
|
+
*
|
396
|
+
* - data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
|
397
|
+
* - URL: a URL that points to the image
|
336
398
|
*/
|
337
|
-
image: DataContent;
|
399
|
+
image: DataContent | URL;
|
338
400
|
/**
|
339
401
|
* Optional mime type of the image.
|
340
402
|
*/
|
@@ -379,22 +441,26 @@ type Prompt = {
|
|
379
441
|
/**
|
380
442
|
* Generate a structured, typed object using a language model.
|
381
443
|
*/
|
382
|
-
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, ...settings }: CallSettings & Prompt & {
|
444
|
+
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, ...settings }: CallSettings & Prompt & {
|
383
445
|
model: LanguageModelV1;
|
384
446
|
schema: z.Schema<T>;
|
385
447
|
mode?: 'auto' | 'json' | 'tool' | 'grammar';
|
386
448
|
}): Promise<GenerateObjectResult<T>>;
|
387
449
|
declare class GenerateObjectResult<T> {
|
388
450
|
readonly object: T;
|
451
|
+
readonly finishReason: LanguageModelV1FinishReason;
|
452
|
+
readonly usage: TokenUsage;
|
389
453
|
constructor(options: {
|
390
454
|
object: T;
|
455
|
+
finishReason: LanguageModelV1FinishReason;
|
456
|
+
usage: TokenUsage;
|
391
457
|
});
|
392
458
|
}
|
393
459
|
|
394
460
|
/**
|
395
461
|
* Stream an object as a partial object stream.
|
396
462
|
*/
|
397
|
-
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, ...settings }: CallSettings & Prompt & {
|
463
|
+
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, ...settings }: CallSettings & Prompt & {
|
398
464
|
model: LanguageModelV1;
|
399
465
|
schema: z.Schema<T>;
|
400
466
|
mode?: 'auto' | 'json' | 'tool' | 'grammar';
|
@@ -477,7 +543,7 @@ type ToToolResultArray<TOOLS extends Record<string, Tool>> = Array<ToToolResult<
|
|
477
543
|
/**
|
478
544
|
* Generate a text and call tools using a language model.
|
479
545
|
*/
|
480
|
-
declare function generateText<TOOLS extends Record<string, Tool>>({ model, tools, system, prompt, messages, ...settings }: CallSettings & Prompt & {
|
546
|
+
declare function generateText<TOOLS extends Record<string, Tool>>({ model, tools, system, prompt, messages, maxRetries, abortSignal, ...settings }: CallSettings & Prompt & {
|
481
547
|
model: LanguageModelV1;
|
482
548
|
tools?: TOOLS;
|
483
549
|
}): Promise<GenerateTextResult<TOOLS>>;
|
@@ -485,21 +551,21 @@ declare class GenerateTextResult<TOOLS extends Record<string, Tool>> {
|
|
485
551
|
readonly text: string;
|
486
552
|
readonly toolCalls: ToToolCallArray<TOOLS>;
|
487
553
|
readonly toolResults: ToToolResultArray<TOOLS>;
|
554
|
+
readonly finishReason: LanguageModelV1FinishReason;
|
555
|
+
readonly usage: TokenUsage;
|
488
556
|
constructor(options: {
|
489
557
|
text: string;
|
490
558
|
toolCalls: ToToolCallArray<TOOLS>;
|
491
559
|
toolResults: ToToolResultArray<TOOLS>;
|
560
|
+
finishReason: LanguageModelV1FinishReason;
|
561
|
+
usage: TokenUsage;
|
492
562
|
});
|
493
563
|
}
|
494
564
|
|
495
|
-
declare class StreamTextHttpResponse extends Response {
|
496
|
-
constructor(messageStream: ReadableStream<TextStreamPart<any>>);
|
497
|
-
}
|
498
|
-
|
499
565
|
/**
|
500
566
|
* Stream text generated by a language model.
|
501
567
|
*/
|
502
|
-
declare function streamText<TOOLS extends Record<string, Tool>>({ model, tools, system, prompt, messages, ...settings }: CallSettings & Prompt & {
|
568
|
+
declare function streamText<TOOLS extends Record<string, Tool>>({ model, tools, system, prompt, messages, maxRetries, abortSignal, ...settings }: CallSettings & Prompt & {
|
503
569
|
model: LanguageModelV1;
|
504
570
|
tools?: TOOLS;
|
505
571
|
}): Promise<StreamTextResult<TOOLS>>;
|
@@ -519,7 +585,6 @@ declare class StreamTextResult<TOOLS extends Record<string, Tool>> {
|
|
519
585
|
readonly textStream: AsyncIterable<string>;
|
520
586
|
readonly fullStream: AsyncIterable<TextStreamPart<TOOLS>>;
|
521
587
|
constructor(stream: ReadableStream<TextStreamPart<TOOLS>>);
|
522
|
-
toResponse(): StreamTextHttpResponse;
|
523
588
|
}
|
524
589
|
|
525
|
-
export { AssistantContent, AssistantMessage, DataContent, ErrorStreamPart, GenerateObjectResult, GenerateTextResult, ImagePart, Message, StreamObjectResult,
|
590
|
+
export { AssistantContent, AssistantMessage, DataContent, ErrorStreamPart, GenerateObjectResult, GenerateTextResult, ImagePart, Message, StreamObjectResult, StreamTextResult, TextPart, TextStreamPart, Tool, ToolCallPart, ToolContent, ToolMessage, ToolResultPart, UserContent, UserMessage, convertDataContentToBase64String, convertDataContentToUint8Array, generateObject, generateText, streamObject, streamText, tool };
|