ai 6.0.0-beta.85 → 6.0.0-beta.87
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 +12 -0
- package/dist/index.d.mts +137 -127
- package/dist/index.d.ts +137 -127
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createGateway, gateway } from '@ai-sdk/gateway';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { Tool, InferToolInput, InferToolOutput,
|
|
3
|
+
import { Tool, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, AssistantModelMessage, ToolModelMessage, ReasoningPart, ModelMessage, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
|
|
4
4
|
export { AssistantContent, AssistantModelMessage, DataContent, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
|
|
5
5
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
6
6
|
import { EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV3Embedding, ImageModelV3, ImageModelV3CallWarning, ImageModelV3ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV3, LanguageModelV2, LanguageModelV3FinishReason, LanguageModelV3CallWarning, LanguageModelV3Source, LanguageModelV3Middleware, EmbeddingModelV3Middleware, RerankingModelV3, SharedV3ProviderMetadata, SpeechModelV3, SpeechModelV2, SpeechModelV3CallWarning, TranscriptionModelV3, TranscriptionModelV2, TranscriptionModelV3CallWarning, LanguageModelV3Usage, LanguageModelV3CallOptions, AISDKError, LanguageModelV3ToolCall, JSONSchema7, JSONParseError, TypeValidationError, JSONObject, SharedV3Warning, EmbeddingModelCallOptions, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
|
|
@@ -452,6 +452,119 @@ type ContentPart<TOOLS extends ToolSet> = {
|
|
|
452
452
|
providerMetadata?: ProviderMetadata;
|
|
453
453
|
}) | ToolApprovalRequestOutput<TOOLS>;
|
|
454
454
|
|
|
455
|
+
/**
|
|
456
|
+
Create a type from an object with all keys and nested keys set to optional.
|
|
457
|
+
The helper supports normal objects and schemas (which are resolved automatically).
|
|
458
|
+
It always recurses into arrays.
|
|
459
|
+
|
|
460
|
+
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
|
461
|
+
*/
|
|
462
|
+
type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
|
|
463
|
+
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
|
464
|
+
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
465
|
+
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
|
466
|
+
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
467
|
+
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
|
468
|
+
type PartialObject<ObjectType extends object> = {
|
|
469
|
+
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
interface Output<OUTPUT = any, PARTIAL = any> {
|
|
473
|
+
/**
|
|
474
|
+
* The response format to use for the model.
|
|
475
|
+
*/
|
|
476
|
+
responseFormat: PromiseLike<LanguageModelV3CallOptions['responseFormat']>;
|
|
477
|
+
/**
|
|
478
|
+
* Parses the complete output of the model.
|
|
479
|
+
*/
|
|
480
|
+
parseCompleteOutput(options: {
|
|
481
|
+
text: string;
|
|
482
|
+
}, context: {
|
|
483
|
+
response: LanguageModelResponseMetadata;
|
|
484
|
+
usage: LanguageModelUsage;
|
|
485
|
+
finishReason: FinishReason;
|
|
486
|
+
}): Promise<OUTPUT>;
|
|
487
|
+
/**
|
|
488
|
+
* Parses the partial output of the model.
|
|
489
|
+
*/
|
|
490
|
+
parsePartialOutput(options: {
|
|
491
|
+
text: string;
|
|
492
|
+
}): Promise<{
|
|
493
|
+
partial: PARTIAL;
|
|
494
|
+
} | undefined>;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Output specification for text generation.
|
|
498
|
+
* This is the default output mode that generates plain text.
|
|
499
|
+
*
|
|
500
|
+
* @returns An output specification for generating text.
|
|
501
|
+
*/
|
|
502
|
+
declare const text: () => Output<string, string>;
|
|
503
|
+
/**
|
|
504
|
+
* Output specification for typed object generation using schemas.
|
|
505
|
+
* When the model generates a text response, it will return an object that matches the schema.
|
|
506
|
+
*
|
|
507
|
+
* @param schema - The schema of the object to generate.
|
|
508
|
+
*
|
|
509
|
+
* @returns An output specification for generating objects with the specified schema.
|
|
510
|
+
*/
|
|
511
|
+
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
|
512
|
+
schema: FlexibleSchema<OUTPUT>;
|
|
513
|
+
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
|
514
|
+
/**
|
|
515
|
+
* Array output specification for text generation.
|
|
516
|
+
* When the model generates a text response, it will return an array of elements.
|
|
517
|
+
*
|
|
518
|
+
* @param element - The schema of the element to generate.
|
|
519
|
+
* @returns An output specification for generating an array of elements.
|
|
520
|
+
*/
|
|
521
|
+
declare const array: <ELEMENT>({ element: inputElementSchema, }: {
|
|
522
|
+
element: FlexibleSchema<ELEMENT>;
|
|
523
|
+
}) => Output<Array<ELEMENT>, Array<ELEMENT>>;
|
|
524
|
+
/**
|
|
525
|
+
* Choice output specification for text generation.
|
|
526
|
+
* When the model generates a text response, it will return a one of the choice options.
|
|
527
|
+
*
|
|
528
|
+
* @param options - The options to choose from.
|
|
529
|
+
* @returns An output specification for generating a choice.
|
|
530
|
+
*/
|
|
531
|
+
declare const choice: <ELEMENT extends string>({ options: choiceOptions, }: {
|
|
532
|
+
options: Array<ELEMENT>;
|
|
533
|
+
}) => Output<ELEMENT, ELEMENT>;
|
|
534
|
+
/**
|
|
535
|
+
* Output specification for unstructured JSON generation.
|
|
536
|
+
* When the model generates a text response, it will return a JSON object.
|
|
537
|
+
*
|
|
538
|
+
* @returns An output specification for generating JSON.
|
|
539
|
+
*/
|
|
540
|
+
declare const json: () => Output<JSONValue$1, JSONValue$1>;
|
|
541
|
+
|
|
542
|
+
type output_Output<OUTPUT = any, PARTIAL = any> = Output<OUTPUT, PARTIAL>;
|
|
543
|
+
declare const output_array: typeof array;
|
|
544
|
+
declare const output_choice: typeof choice;
|
|
545
|
+
declare const output_json: typeof json;
|
|
546
|
+
declare const output_object: typeof object;
|
|
547
|
+
declare const output_text: typeof text;
|
|
548
|
+
declare namespace output {
|
|
549
|
+
export {
|
|
550
|
+
output_Output as Output,
|
|
551
|
+
output_array as array,
|
|
552
|
+
output_choice as choice,
|
|
553
|
+
output_json as json,
|
|
554
|
+
output_object as object,
|
|
555
|
+
output_text as text,
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Infers the complete output type from the output specification.
|
|
561
|
+
*/
|
|
562
|
+
type InferCompleteOutput<OUTPUT extends Output> = OUTPUT extends Output<infer COMPLETE_OUTPUT, any> ? COMPLETE_OUTPUT : never;
|
|
563
|
+
/**
|
|
564
|
+
* Infers the partial output type from the output specification.
|
|
565
|
+
*/
|
|
566
|
+
type InferPartialOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer PARTIAL_OUTPUT> ? PARTIAL_OUTPUT : never;
|
|
567
|
+
|
|
455
568
|
/**
|
|
456
569
|
A message that was generated during the generation process.
|
|
457
570
|
It can be either an assistant message or a tool message.
|
|
@@ -553,7 +666,7 @@ type StepResult<TOOLS extends ToolSet> = {
|
|
|
553
666
|
The result of a `generateText` call.
|
|
554
667
|
It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
|
|
555
668
|
*/
|
|
556
|
-
interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
669
|
+
interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
557
670
|
/**
|
|
558
671
|
The content that was generated in the last step.
|
|
559
672
|
*/
|
|
@@ -660,121 +773,14 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
|
|
|
660
773
|
|
|
661
774
|
@deprecated Use `output` instead.
|
|
662
775
|
*/
|
|
663
|
-
readonly experimental_output: OUTPUT
|
|
776
|
+
readonly experimental_output: InferCompleteOutput<OUTPUT>;
|
|
664
777
|
/**
|
|
665
778
|
The generated structured output. It uses the `output` specification.
|
|
666
779
|
|
|
667
780
|
*/
|
|
668
|
-
readonly output: OUTPUT
|
|
781
|
+
readonly output: InferCompleteOutput<OUTPUT>;
|
|
669
782
|
}
|
|
670
783
|
|
|
671
|
-
/**
|
|
672
|
-
Create a type from an object with all keys and nested keys set to optional.
|
|
673
|
-
The helper supports normal objects and schemas (which are resolved automatically).
|
|
674
|
-
It always recurses into arrays.
|
|
675
|
-
|
|
676
|
-
Adopted from [type-fest](https://github.com/sindresorhus/type-fest/tree/main) PartialDeep.
|
|
677
|
-
*/
|
|
678
|
-
type DeepPartial<T> = T extends FlexibleSchema ? DeepPartialInternal<InferSchema<T>> : DeepPartialInternal<T>;
|
|
679
|
-
type DeepPartialInternal<T> = T extends null | undefined | string | number | boolean | symbol | bigint | void | Date | RegExp | ((...arguments_: any[]) => unknown) | (new (...arguments_: any[]) => unknown) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMap<KeyType, ValueType> : T extends Set<infer ItemType> ? PartialSet<ItemType> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMap<KeyType, ValueType> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySet<ItemType> : T extends object ? T extends ReadonlyArray<infer ItemType> ? ItemType[] extends T ? readonly ItemType[] extends T ? ReadonlyArray<DeepPartialInternal<ItemType | undefined>> : Array<DeepPartialInternal<ItemType | undefined>> : PartialObject<T> : PartialObject<T> : unknown;
|
|
680
|
-
type PartialMap<KeyType, ValueType> = {} & Map<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
681
|
-
type PartialSet<T> = {} & Set<DeepPartialInternal<T>>;
|
|
682
|
-
type PartialReadonlyMap<KeyType, ValueType> = {} & ReadonlyMap<DeepPartialInternal<KeyType>, DeepPartialInternal<ValueType>>;
|
|
683
|
-
type PartialReadonlySet<T> = {} & ReadonlySet<DeepPartialInternal<T>>;
|
|
684
|
-
type PartialObject<ObjectType extends object> = {
|
|
685
|
-
[KeyType in keyof ObjectType]?: DeepPartialInternal<ObjectType[KeyType]>;
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
interface Output<OUTPUT = any, PARTIAL = any> {
|
|
689
|
-
/**
|
|
690
|
-
* The response format to use for the model.
|
|
691
|
-
*/
|
|
692
|
-
responseFormat: PromiseLike<LanguageModelV3CallOptions['responseFormat']>;
|
|
693
|
-
/**
|
|
694
|
-
* Parses the complete output of the model.
|
|
695
|
-
*/
|
|
696
|
-
parseCompleteOutput(options: {
|
|
697
|
-
text: string;
|
|
698
|
-
}, context: {
|
|
699
|
-
response: LanguageModelResponseMetadata;
|
|
700
|
-
usage: LanguageModelUsage;
|
|
701
|
-
finishReason: FinishReason;
|
|
702
|
-
}): Promise<OUTPUT>;
|
|
703
|
-
/**
|
|
704
|
-
* Parses the partial output of the model.
|
|
705
|
-
*/
|
|
706
|
-
parsePartialOutput(options: {
|
|
707
|
-
text: string;
|
|
708
|
-
}): Promise<{
|
|
709
|
-
partial: PARTIAL;
|
|
710
|
-
} | undefined>;
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Output specification for text generation.
|
|
714
|
-
* This is the default output mode that generates plain text.
|
|
715
|
-
*
|
|
716
|
-
* @returns An output specification for generating text.
|
|
717
|
-
*/
|
|
718
|
-
declare const text: () => Output<string, string>;
|
|
719
|
-
/**
|
|
720
|
-
* Output specification for typed object generation using schemas.
|
|
721
|
-
* When the model generates a text response, it will return an object that matches the schema.
|
|
722
|
-
*
|
|
723
|
-
* @param schema - The schema of the object to generate.
|
|
724
|
-
*
|
|
725
|
-
* @returns An output specification for generating objects with the specified schema.
|
|
726
|
-
*/
|
|
727
|
-
declare const object: <OUTPUT>({ schema: inputSchema, }: {
|
|
728
|
-
schema: FlexibleSchema<OUTPUT>;
|
|
729
|
-
}) => Output<OUTPUT, DeepPartial<OUTPUT>>;
|
|
730
|
-
/**
|
|
731
|
-
* Array output specification for text generation.
|
|
732
|
-
* When the model generates a text response, it will return an array of elements.
|
|
733
|
-
*
|
|
734
|
-
* @param element - The schema of the element to generate.
|
|
735
|
-
* @returns An output specification for generating an array of elements.
|
|
736
|
-
*/
|
|
737
|
-
declare const array: <ELEMENT>({ element: inputElementSchema, }: {
|
|
738
|
-
element: FlexibleSchema<ELEMENT>;
|
|
739
|
-
}) => Output<Array<ELEMENT>, Array<ELEMENT>>;
|
|
740
|
-
/**
|
|
741
|
-
* Choice output specification for text generation.
|
|
742
|
-
* When the model generates a text response, it will return a one of the choice options.
|
|
743
|
-
*
|
|
744
|
-
* @param options - The options to choose from.
|
|
745
|
-
* @returns An output specification for generating a choice.
|
|
746
|
-
*/
|
|
747
|
-
declare const choice: <ELEMENT extends string>({ options: choiceOptions, }: {
|
|
748
|
-
options: Array<ELEMENT>;
|
|
749
|
-
}) => Output<ELEMENT, ELEMENT>;
|
|
750
|
-
/**
|
|
751
|
-
* Output specification for unstructured JSON generation.
|
|
752
|
-
* When the model generates a text response, it will return a JSON object.
|
|
753
|
-
*
|
|
754
|
-
* @returns An output specification for generating JSON.
|
|
755
|
-
*/
|
|
756
|
-
declare const json: () => Output<JSONValue$1, JSONValue$1>;
|
|
757
|
-
|
|
758
|
-
type output_Output<OUTPUT = any, PARTIAL = any> = Output<OUTPUT, PARTIAL>;
|
|
759
|
-
declare const output_array: typeof array;
|
|
760
|
-
declare const output_choice: typeof choice;
|
|
761
|
-
declare const output_json: typeof json;
|
|
762
|
-
declare const output_object: typeof object;
|
|
763
|
-
declare const output_text: typeof text;
|
|
764
|
-
declare namespace output {
|
|
765
|
-
export {
|
|
766
|
-
output_Output as Output,
|
|
767
|
-
output_array as array,
|
|
768
|
-
output_choice as choice,
|
|
769
|
-
output_json as json,
|
|
770
|
-
output_object as object,
|
|
771
|
-
output_text as text,
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
type InferGenerateOutput<OUTPUT extends Output> = OUTPUT extends Output<infer T, any> ? T : never;
|
|
776
|
-
type InferStreamOutput<OUTPUT extends Output> = OUTPUT extends Output<any, infer P> ? P : never;
|
|
777
|
-
|
|
778
784
|
type CallSettings = {
|
|
779
785
|
/**
|
|
780
786
|
Maximum number of tokens to generate.
|
|
@@ -1140,7 +1146,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
1140
1146
|
@returns
|
|
1141
1147
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
|
1142
1148
|
*/
|
|
1143
|
-
declare function generateText<TOOLS extends ToolSet, OUTPUT
|
|
1149
|
+
declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output = never>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, _internal: { generateId, currentDate, }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
|
|
1144
1150
|
/**
|
|
1145
1151
|
The language model to use.
|
|
1146
1152
|
*/
|
|
@@ -1182,13 +1188,13 @@ changing the tool call and result types in the result.
|
|
|
1182
1188
|
/**
|
|
1183
1189
|
Optional specification for parsing structured outputs from the LLM response.
|
|
1184
1190
|
*/
|
|
1185
|
-
output?:
|
|
1191
|
+
output?: OUTPUT;
|
|
1186
1192
|
/**
|
|
1187
1193
|
Optional specification for parsing structured outputs from the LLM response.
|
|
1188
1194
|
|
|
1189
1195
|
@deprecated Use `output` instead.
|
|
1190
1196
|
*/
|
|
1191
|
-
experimental_output?:
|
|
1197
|
+
experimental_output?: OUTPUT;
|
|
1192
1198
|
/**
|
|
1193
1199
|
Custom download function to use for URLs.
|
|
1194
1200
|
|
|
@@ -1386,7 +1392,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
|
1386
1392
|
@return
|
|
1387
1393
|
A result object for accessing different stream types and additional information.
|
|
1388
1394
|
*/
|
|
1389
|
-
declare function streamText<TOOLS extends ToolSet, OUTPUT
|
|
1395
|
+
declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output = never>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, _internal: { now, generateId, currentDate, }, ...settings }: CallSettings & Prompt & {
|
|
1390
1396
|
/**
|
|
1391
1397
|
The language model to use.
|
|
1392
1398
|
*/
|
|
@@ -1428,13 +1434,13 @@ functionality that can be fully encapsulated in the provider.
|
|
|
1428
1434
|
/**
|
|
1429
1435
|
Optional specification for parsing structured outputs from the LLM response.
|
|
1430
1436
|
*/
|
|
1431
|
-
output?:
|
|
1437
|
+
output?: OUTPUT;
|
|
1432
1438
|
/**
|
|
1433
1439
|
Optional specification for parsing structured outputs from the LLM response.
|
|
1434
1440
|
|
|
1435
1441
|
@deprecated Use `output` instead.
|
|
1436
1442
|
*/
|
|
1437
|
-
experimental_output?:
|
|
1443
|
+
experimental_output?: OUTPUT;
|
|
1438
1444
|
/**
|
|
1439
1445
|
Optional function that you can use to provide different settings for a step.
|
|
1440
1446
|
|
|
@@ -1509,7 +1515,7 @@ Internal. For test use only. May change without notice.
|
|
|
1509
1515
|
generateId?: IdGenerator;
|
|
1510
1516
|
currentDate?: () => Date;
|
|
1511
1517
|
};
|
|
1512
|
-
}): StreamTextResult<TOOLS,
|
|
1518
|
+
}): StreamTextResult<TOOLS, OUTPUT>;
|
|
1513
1519
|
|
|
1514
1520
|
/**
|
|
1515
1521
|
* Tool output when the tool execution has been denied (for static tools).
|
|
@@ -2221,7 +2227,7 @@ type ConsumeStreamOptions = {
|
|
|
2221
2227
|
/**
|
|
2222
2228
|
A result object for accessing different stream types and additional information.
|
|
2223
2229
|
*/
|
|
2224
|
-
interface StreamTextResult<TOOLS extends ToolSet,
|
|
2230
|
+
interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
|
|
2225
2231
|
/**
|
|
2226
2232
|
The content that was generated in the last step.
|
|
2227
2233
|
|
|
@@ -2373,11 +2379,15 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
|
|
|
2373
2379
|
*
|
|
2374
2380
|
* @deprecated Use `partialOutputStream` instead.
|
|
2375
2381
|
*/
|
|
2376
|
-
readonly experimental_partialOutputStream: AsyncIterableStream<
|
|
2382
|
+
readonly experimental_partialOutputStream: AsyncIterableStream<InferPartialOutput<OUTPUT>>;
|
|
2377
2383
|
/**
|
|
2378
|
-
* A stream of partial outputs. It uses the `output` specification.
|
|
2384
|
+
* A stream of partial parsed outputs. It uses the `output` specification.
|
|
2385
|
+
*/
|
|
2386
|
+
readonly partialOutputStream: AsyncIterableStream<InferPartialOutput<OUTPUT>>;
|
|
2387
|
+
/**
|
|
2388
|
+
* The complete parsed output. It uses the `output` specification.
|
|
2379
2389
|
*/
|
|
2380
|
-
readonly
|
|
2390
|
+
readonly output: Promise<InferCompleteOutput<OUTPUT>>;
|
|
2381
2391
|
/**
|
|
2382
2392
|
Consumes the stream without processing the parts.
|
|
2383
2393
|
This is useful to force the stream to finish.
|
|
@@ -2557,11 +2567,11 @@ interface Agent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OUTPUT extends
|
|
|
2557
2567
|
/**
|
|
2558
2568
|
* Generates an output from the agent (non-streaming).
|
|
2559
2569
|
*/
|
|
2560
|
-
generate(options: AgentCallParameters<CALL_OPTIONS>): PromiseLike<GenerateTextResult<TOOLS,
|
|
2570
|
+
generate(options: AgentCallParameters<CALL_OPTIONS>): PromiseLike<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2561
2571
|
/**
|
|
2562
2572
|
* Streams an output from the agent (streaming).
|
|
2563
2573
|
*/
|
|
2564
|
-
stream(options: AgentCallParameters<CALL_OPTIONS>): PromiseLike<StreamTextResult<TOOLS,
|
|
2574
|
+
stream(options: AgentCallParameters<CALL_OPTIONS>): PromiseLike<StreamTextResult<TOOLS, OUTPUT>>;
|
|
2565
2575
|
}
|
|
2566
2576
|
|
|
2567
2577
|
/**
|
|
@@ -2700,11 +2710,11 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
|
|
|
2700
2710
|
/**
|
|
2701
2711
|
* Generates an output from the agent (non-streaming).
|
|
2702
2712
|
*/
|
|
2703
|
-
generate(options: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS,
|
|
2713
|
+
generate(options: AgentCallParameters<CALL_OPTIONS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
|
|
2704
2714
|
/**
|
|
2705
2715
|
* Streams an output from the agent (streaming).
|
|
2706
2716
|
*/
|
|
2707
|
-
stream(options: AgentCallParameters<CALL_OPTIONS>): Promise<StreamTextResult<TOOLS,
|
|
2717
|
+
stream(options: AgentCallParameters<CALL_OPTIONS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
|
|
2708
2718
|
}
|
|
2709
2719
|
|
|
2710
2720
|
/**
|
|
@@ -5090,4 +5100,4 @@ declare global {
|
|
|
5090
5100
|
var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
|
|
5091
5101
|
}
|
|
5092
5102
|
|
|
5093
|
-
export { AbstractChat, Agent, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferGenerateOutput, InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapLanguageModel, wrapProvider };
|
|
5103
|
+
export { AbstractChat, Agent, AsyncIterableStream, CallSettings, CallWarning, ChatAddToolApproveResponseFunction, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelMiddleware, EmbeddingModelUsage, ErrorHandler, ToolLoopAgent as Experimental_Agent, ToolLoopAgentSettings as Experimental_AgentSettings, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnFinishCallback, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferAgentUIMessage, InferCompleteOutput as InferGenerateOutput, InferPartialOutput as InferStreamOutput, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RerankResult, RerankingModel, RetryError, SafeValidateUIMessagesResult, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolOutputDenied, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolApprovalRequestOutput, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolLoopAgent, ToolLoopAgentOnFinishCallback, ToolLoopAgentOnStepFinishCallback, ToolLoopAgentSettings, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolOutputDenied, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createAgentUIStream, createAgentUIStreamResponse, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultEmbeddingSettingsMiddleware, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithApprovalResponses, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeAgentUIStreamToResponse, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, rerank, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapEmbeddingModel, wrapLanguageModel, wrapProvider };
|
package/dist/index.js
CHANGED
|
@@ -877,7 +877,7 @@ function detectMediaType({
|
|
|
877
877
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
878
878
|
|
|
879
879
|
// src/version.ts
|
|
880
|
-
var VERSION = true ? "6.0.0-beta.
|
|
880
|
+
var VERSION = true ? "6.0.0-beta.87" : "0.0.0-test";
|
|
881
881
|
|
|
882
882
|
// src/util/download/download.ts
|
|
883
883
|
var download = async ({ url }) => {
|
|
@@ -5131,7 +5131,7 @@ var DefaultStreamTextResult = class {
|
|
|
5131
5131
|
this._totalUsage = new DelayedPromise();
|
|
5132
5132
|
this._finishReason = new DelayedPromise();
|
|
5133
5133
|
this._steps = new DelayedPromise();
|
|
5134
|
-
this.
|
|
5134
|
+
this.outputSpecification = output;
|
|
5135
5135
|
this.includeRawChunks = includeRawChunks;
|
|
5136
5136
|
this.tools = tools;
|
|
5137
5137
|
let stepFinish;
|
|
@@ -6033,7 +6033,7 @@ var DefaultStreamTextResult = class {
|
|
|
6033
6033
|
return this.partialOutputStream;
|
|
6034
6034
|
}
|
|
6035
6035
|
get partialOutputStream() {
|
|
6036
|
-
if (this.
|
|
6036
|
+
if (this.outputSpecification == null) {
|
|
6037
6037
|
throw new NoOutputSpecifiedError();
|
|
6038
6038
|
}
|
|
6039
6039
|
return createAsyncIterableStream(
|
|
@@ -6048,6 +6048,21 @@ var DefaultStreamTextResult = class {
|
|
|
6048
6048
|
)
|
|
6049
6049
|
);
|
|
6050
6050
|
}
|
|
6051
|
+
get output() {
|
|
6052
|
+
return this.finalStep.then((step) => {
|
|
6053
|
+
if (this.outputSpecification == null) {
|
|
6054
|
+
throw new NoOutputSpecifiedError();
|
|
6055
|
+
}
|
|
6056
|
+
return this.outputSpecification.parseCompleteOutput(
|
|
6057
|
+
{ text: step.text },
|
|
6058
|
+
{
|
|
6059
|
+
response: step.response,
|
|
6060
|
+
usage: step.usage,
|
|
6061
|
+
finishReason: step.finishReason
|
|
6062
|
+
}
|
|
6063
|
+
);
|
|
6064
|
+
});
|
|
6065
|
+
}
|
|
6051
6066
|
toUIMessageStream({
|
|
6052
6067
|
originalMessages,
|
|
6053
6068
|
generateMessageId,
|