ai 3.1.0-canary.3 → 3.1.0-canary.4
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/README.md +1 -1
- package/ai-model-specification/dist/index.d.mts +77 -18
- package/ai-model-specification/dist/index.d.ts +77 -18
- package/ai-model-specification/dist/index.js +236 -137
- package/ai-model-specification/dist/index.js.map +1 -1
- package/ai-model-specification/dist/index.mjs +232 -136
- package/ai-model-specification/dist/index.mjs.map +1 -1
- package/core/dist/index.d.mts +42 -6
- package/core/dist/index.d.ts +42 -6
- package/core/dist/index.js +681 -291
- package/core/dist/index.js.map +1 -1
- package/core/dist/index.mjs +683 -291
- package/core/dist/index.mjs.map +1 -1
- package/{provider → openai}/dist/index.js +153 -116
- package/openai/dist/index.js.map +1 -0
- package/{provider → openai}/dist/index.mjs +149 -112
- package/openai/dist/index.mjs.map +1 -0
- package/package.json +12 -12
- package/react/dist/index.d.mts +4 -0
- package/react/dist/index.d.ts +4 -0
- package/react/dist/index.js +2 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +2 -1
- package/react/dist/index.mjs.map +1 -1
- package/provider/dist/index.js.map +0 -1
- package/provider/dist/index.mjs.map +0 -1
- /package/{provider → openai}/dist/index.d.mts +0 -0
- /package/{provider → openai}/dist/index.d.ts +0 -0
package/core/dist/index.d.mts
CHANGED
@@ -332,6 +332,8 @@ type CallSettings = {
|
|
332
332
|
* 1 (very random).
|
333
333
|
*
|
334
334
|
* It is recommended to set either `temperature` or `topP`, but not both.
|
335
|
+
*
|
336
|
+
* Default: 0
|
335
337
|
*/
|
336
338
|
temperature?: number;
|
337
339
|
/**
|
@@ -349,6 +351,8 @@ type CallSettings = {
|
|
349
351
|
*
|
350
352
|
* The presence penalty is a number between -1 (increase repetition)
|
351
353
|
* and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
354
|
+
*
|
355
|
+
* Default: 0
|
352
356
|
*/
|
353
357
|
presencePenalty?: number;
|
354
358
|
/**
|
@@ -357,6 +361,8 @@ type CallSettings = {
|
|
357
361
|
*
|
358
362
|
* The frequency penalty is a number between -1 (increase repetition)
|
359
363
|
* and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
364
|
+
*
|
365
|
+
* Default: 0
|
360
366
|
*/
|
361
367
|
frequencyPenalty?: number;
|
362
368
|
/**
|
@@ -365,7 +371,9 @@ type CallSettings = {
|
|
365
371
|
*/
|
366
372
|
seed?: number;
|
367
373
|
/**
|
368
|
-
* Maximum number of retries. Set to 0 to disable retries.
|
374
|
+
* Maximum number of retries. Set to 0 to disable retries.
|
375
|
+
*
|
376
|
+
* Default: 2.
|
369
377
|
*/
|
370
378
|
maxRetries?: number;
|
371
379
|
/**
|
@@ -457,6 +465,8 @@ declare class GenerateObjectResult<T> {
|
|
457
465
|
});
|
458
466
|
}
|
459
467
|
|
468
|
+
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
469
|
+
|
460
470
|
/**
|
461
471
|
* Stream an object as a partial object stream.
|
462
472
|
*/
|
@@ -466,10 +476,11 @@ declare function streamObject<T>({ model, schema, mode, system, prompt, messages
|
|
466
476
|
mode?: 'auto' | 'json' | 'tool' | 'grammar';
|
467
477
|
}): Promise<StreamObjectResult<T>>;
|
468
478
|
declare class StreamObjectResult<T> {
|
469
|
-
readonly
|
479
|
+
private readonly originalStream;
|
480
|
+
constructor(stream: ReadableStream<string | ErrorStreamPart>);
|
481
|
+
get objectStream(): AsyncIterableStream<PartialDeep<T, {
|
470
482
|
recurseIntoArrays: true;
|
471
483
|
}>>;
|
472
|
-
constructor(modelStream: ReadableStream<string | ErrorStreamPart>);
|
473
484
|
}
|
474
485
|
type ErrorStreamPart = {
|
475
486
|
type: 'error';
|
@@ -562,6 +573,30 @@ declare class GenerateTextResult<TOOLS extends Record<string, Tool>> {
|
|
562
573
|
});
|
563
574
|
}
|
564
575
|
|
576
|
+
/**
|
577
|
+
* Configuration options and helper callback methods for AIStream stream lifecycle events.
|
578
|
+
* @interface
|
579
|
+
*/
|
580
|
+
interface AIStreamCallbacksAndOptions {
|
581
|
+
/** `onStart`: Called once when the stream is initialized. */
|
582
|
+
onStart?: () => Promise<void> | void;
|
583
|
+
/** `onCompletion`: Called for each tokenized message. */
|
584
|
+
onCompletion?: (completion: string) => Promise<void> | void;
|
585
|
+
/** `onFinal`: Called once when the stream is closed with the final completion message. */
|
586
|
+
onFinal?: (completion: string) => Promise<void> | void;
|
587
|
+
/** `onToken`: Called for each tokenized message. */
|
588
|
+
onToken?: (token: string) => Promise<void> | void;
|
589
|
+
/** `onText`: Called for each text chunk. */
|
590
|
+
onText?: (text: string) => Promise<void> | void;
|
591
|
+
/**
|
592
|
+
* A flag for enabling the experimental_StreamData class and the new protocol.
|
593
|
+
* @see https://github.com/vercel-labs/ai/pull/425
|
594
|
+
*
|
595
|
+
* When StreamData is rolled out, this will be removed and the new protocol will be used by default.
|
596
|
+
*/
|
597
|
+
experimental_streamData?: boolean;
|
598
|
+
}
|
599
|
+
|
565
600
|
/**
|
566
601
|
* Stream text generated by a language model.
|
567
602
|
*/
|
@@ -581,10 +616,11 @@ type TextStreamPart<TOOLS extends Record<string, Tool>> = {
|
|
581
616
|
type: 'tool-result';
|
582
617
|
} & ToToolResult<TOOLS>);
|
583
618
|
declare class StreamTextResult<TOOLS extends Record<string, Tool>> {
|
584
|
-
private readonly
|
585
|
-
readonly textStream: AsyncIterable<string>;
|
586
|
-
readonly fullStream: AsyncIterable<TextStreamPart<TOOLS>>;
|
619
|
+
private readonly originalStream;
|
587
620
|
constructor(stream: ReadableStream<TextStreamPart<TOOLS>>);
|
621
|
+
get textStream(): AsyncIterableStream<string>;
|
622
|
+
get fullStream(): AsyncIterableStream<TextStreamPart<TOOLS>>;
|
623
|
+
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
|
588
624
|
}
|
589
625
|
|
590
626
|
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 };
|
package/core/dist/index.d.ts
CHANGED
@@ -332,6 +332,8 @@ type CallSettings = {
|
|
332
332
|
* 1 (very random).
|
333
333
|
*
|
334
334
|
* It is recommended to set either `temperature` or `topP`, but not both.
|
335
|
+
*
|
336
|
+
* Default: 0
|
335
337
|
*/
|
336
338
|
temperature?: number;
|
337
339
|
/**
|
@@ -349,6 +351,8 @@ type CallSettings = {
|
|
349
351
|
*
|
350
352
|
* The presence penalty is a number between -1 (increase repetition)
|
351
353
|
* and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
354
|
+
*
|
355
|
+
* Default: 0
|
352
356
|
*/
|
353
357
|
presencePenalty?: number;
|
354
358
|
/**
|
@@ -357,6 +361,8 @@ type CallSettings = {
|
|
357
361
|
*
|
358
362
|
* The frequency penalty is a number between -1 (increase repetition)
|
359
363
|
* and 1 (maximum penalty, decrease repetition). 0 means no penalty.
|
364
|
+
*
|
365
|
+
* Default: 0
|
360
366
|
*/
|
361
367
|
frequencyPenalty?: number;
|
362
368
|
/**
|
@@ -365,7 +371,9 @@ type CallSettings = {
|
|
365
371
|
*/
|
366
372
|
seed?: number;
|
367
373
|
/**
|
368
|
-
* Maximum number of retries. Set to 0 to disable retries.
|
374
|
+
* Maximum number of retries. Set to 0 to disable retries.
|
375
|
+
*
|
376
|
+
* Default: 2.
|
369
377
|
*/
|
370
378
|
maxRetries?: number;
|
371
379
|
/**
|
@@ -457,6 +465,8 @@ declare class GenerateObjectResult<T> {
|
|
457
465
|
});
|
458
466
|
}
|
459
467
|
|
468
|
+
type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
|
469
|
+
|
460
470
|
/**
|
461
471
|
* Stream an object as a partial object stream.
|
462
472
|
*/
|
@@ -466,10 +476,11 @@ declare function streamObject<T>({ model, schema, mode, system, prompt, messages
|
|
466
476
|
mode?: 'auto' | 'json' | 'tool' | 'grammar';
|
467
477
|
}): Promise<StreamObjectResult<T>>;
|
468
478
|
declare class StreamObjectResult<T> {
|
469
|
-
readonly
|
479
|
+
private readonly originalStream;
|
480
|
+
constructor(stream: ReadableStream<string | ErrorStreamPart>);
|
481
|
+
get objectStream(): AsyncIterableStream<PartialDeep<T, {
|
470
482
|
recurseIntoArrays: true;
|
471
483
|
}>>;
|
472
|
-
constructor(modelStream: ReadableStream<string | ErrorStreamPart>);
|
473
484
|
}
|
474
485
|
type ErrorStreamPart = {
|
475
486
|
type: 'error';
|
@@ -562,6 +573,30 @@ declare class GenerateTextResult<TOOLS extends Record<string, Tool>> {
|
|
562
573
|
});
|
563
574
|
}
|
564
575
|
|
576
|
+
/**
|
577
|
+
* Configuration options and helper callback methods for AIStream stream lifecycle events.
|
578
|
+
* @interface
|
579
|
+
*/
|
580
|
+
interface AIStreamCallbacksAndOptions {
|
581
|
+
/** `onStart`: Called once when the stream is initialized. */
|
582
|
+
onStart?: () => Promise<void> | void;
|
583
|
+
/** `onCompletion`: Called for each tokenized message. */
|
584
|
+
onCompletion?: (completion: string) => Promise<void> | void;
|
585
|
+
/** `onFinal`: Called once when the stream is closed with the final completion message. */
|
586
|
+
onFinal?: (completion: string) => Promise<void> | void;
|
587
|
+
/** `onToken`: Called for each tokenized message. */
|
588
|
+
onToken?: (token: string) => Promise<void> | void;
|
589
|
+
/** `onText`: Called for each text chunk. */
|
590
|
+
onText?: (text: string) => Promise<void> | void;
|
591
|
+
/**
|
592
|
+
* A flag for enabling the experimental_StreamData class and the new protocol.
|
593
|
+
* @see https://github.com/vercel-labs/ai/pull/425
|
594
|
+
*
|
595
|
+
* When StreamData is rolled out, this will be removed and the new protocol will be used by default.
|
596
|
+
*/
|
597
|
+
experimental_streamData?: boolean;
|
598
|
+
}
|
599
|
+
|
565
600
|
/**
|
566
601
|
* Stream text generated by a language model.
|
567
602
|
*/
|
@@ -581,10 +616,11 @@ type TextStreamPart<TOOLS extends Record<string, Tool>> = {
|
|
581
616
|
type: 'tool-result';
|
582
617
|
} & ToToolResult<TOOLS>);
|
583
618
|
declare class StreamTextResult<TOOLS extends Record<string, Tool>> {
|
584
|
-
private readonly
|
585
|
-
readonly textStream: AsyncIterable<string>;
|
586
|
-
readonly fullStream: AsyncIterable<TextStreamPart<TOOLS>>;
|
619
|
+
private readonly originalStream;
|
587
620
|
constructor(stream: ReadableStream<TextStreamPart<TOOLS>>);
|
621
|
+
get textStream(): AsyncIterableStream<string>;
|
622
|
+
get fullStream(): AsyncIterableStream<TextStreamPart<TOOLS>>;
|
623
|
+
toAIStream(callbacks?: AIStreamCallbacksAndOptions): ReadableStream<any>;
|
588
624
|
}
|
589
625
|
|
590
626
|
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 };
|