ai 3.2.34 → 3.2.35
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/dist/index.d.mts +68 -26
- package/dist/index.d.ts +68 -26
- package/dist/index.js +275 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -178
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -8
- package/rsc/dist/rsc-server.mjs +33 -4
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.d.mts
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
import { DeepPartial, Attachment, JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
2
2
|
export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
|
3
|
+
import { AttributeValue, Span } from '@opentelemetry/api';
|
3
4
|
import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1StreamPart } from '@ai-sdk/provider';
|
4
5
|
export { APICallError, EmptyResponseBodyError, InvalidArgumentError, InvalidDataContentError, InvalidPromptError, InvalidResponseDataError, InvalidToolArgumentsError, JSONParseError, LoadAPIKeyError, NoObjectGeneratedError, NoSuchToolError, RetryError, ToolCallParseError, TypeValidationError, UnsupportedFunctionalityError, UnsupportedJSONSchemaError } from '@ai-sdk/provider';
|
5
6
|
import { z } from 'zod';
|
6
|
-
import {
|
7
|
+
import { Validator } from '@ai-sdk/provider-utils';
|
8
|
+
import { JSONSchema7 } from 'json-schema';
|
7
9
|
import { ServerResponse } from 'http';
|
8
10
|
import { ServerResponse as ServerResponse$1 } from 'node:http';
|
9
11
|
import { AssistantStream } from 'openai/lib/AssistantStream';
|
10
12
|
import { Run } from 'openai/resources/beta/threads/runs/runs';
|
11
13
|
|
14
|
+
/**
|
15
|
+
* Telemetry configuration.
|
16
|
+
*/
|
17
|
+
type TelemetrySettings = {
|
18
|
+
/**
|
19
|
+
* Enable or disable telemetry. Disabled by default while experimental.
|
20
|
+
*/
|
21
|
+
isEnabled?: boolean;
|
22
|
+
/**
|
23
|
+
* Identifier for this function. Used to group telemetry data by function.
|
24
|
+
*/
|
25
|
+
functionId?: string;
|
26
|
+
/**
|
27
|
+
* Additional information to include in the telemetry data.
|
28
|
+
*/
|
29
|
+
metadata?: Record<string, AttributeValue>;
|
30
|
+
};
|
31
|
+
|
12
32
|
/**
|
13
33
|
Represents the number of tokens used in a prompt and completion.
|
14
34
|
*/
|
@@ -129,7 +149,7 @@ Embed a value using an embedding model. The type of the value is defined by the
|
|
129
149
|
|
130
150
|
@returns A result object that contains the embedding, the value, and additional information.
|
131
151
|
*/
|
132
|
-
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers, }: {
|
152
|
+
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, }: {
|
133
153
|
/**
|
134
154
|
The embedding model to use.
|
135
155
|
*/
|
@@ -153,6 +173,10 @@ declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers,
|
|
153
173
|
Only applicable for HTTP-based providers.
|
154
174
|
*/
|
155
175
|
headers?: Record<string, string>;
|
176
|
+
/**
|
177
|
+
* Optional telemetry configuration (experimental).
|
178
|
+
*/
|
179
|
+
experimental_telemetry?: TelemetrySettings;
|
156
180
|
}): Promise<EmbedResult<VALUE>>;
|
157
181
|
|
158
182
|
/**
|
@@ -473,22 +497,38 @@ type Prompt = {
|
|
473
497
|
};
|
474
498
|
|
475
499
|
/**
|
476
|
-
*
|
500
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
477
501
|
*/
|
478
|
-
|
502
|
+
declare const schemaSymbol: unique symbol;
|
503
|
+
type Schema<OBJECT = unknown> = Validator<OBJECT> & {
|
479
504
|
/**
|
480
|
-
*
|
505
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
481
506
|
*/
|
482
|
-
|
507
|
+
[schemaSymbol]: true;
|
483
508
|
/**
|
484
|
-
*
|
509
|
+
* Schema type for inference.
|
485
510
|
*/
|
486
|
-
|
511
|
+
_type: OBJECT;
|
487
512
|
/**
|
488
|
-
*
|
513
|
+
* The JSON Schema for the schema. It is passed to the providers.
|
489
514
|
*/
|
490
|
-
|
515
|
+
readonly jsonSchema: JSONSchema7;
|
491
516
|
};
|
517
|
+
/**
|
518
|
+
* Create a schema using a JSON Schema.
|
519
|
+
*
|
520
|
+
* @param jsonSchema The JSON Schema for the schema.
|
521
|
+
* @param options.validate Optional. A validation function for the schema.
|
522
|
+
*/
|
523
|
+
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validate, }?: {
|
524
|
+
validate?: (value: unknown) => {
|
525
|
+
success: true;
|
526
|
+
value: OBJECT;
|
527
|
+
} | {
|
528
|
+
success: false;
|
529
|
+
error: Error;
|
530
|
+
};
|
531
|
+
}): Schema<OBJECT>;
|
492
532
|
|
493
533
|
/**
|
494
534
|
The result of a `generateObject` call.
|
@@ -571,7 +611,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
571
611
|
@returns
|
572
612
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
573
613
|
*/
|
574
|
-
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
614
|
+
declare function generateObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
575
615
|
/**
|
576
616
|
The language model to use.
|
577
617
|
*/
|
@@ -579,11 +619,11 @@ The language model to use.
|
|
579
619
|
/**
|
580
620
|
The schema of the object that the model should generate.
|
581
621
|
*/
|
582
|
-
schema: z.Schema<T>;
|
622
|
+
schema: z.Schema<T> | Schema<T>;
|
583
623
|
/**
|
584
624
|
The mode to use for object generation.
|
585
625
|
|
586
|
-
The
|
626
|
+
The schema is converted in a JSON schema and used in one of the following ways
|
587
627
|
|
588
628
|
- 'auto': The provider will choose the best mode for the model.
|
589
629
|
- 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
|
@@ -748,7 +788,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
748
788
|
@return
|
749
789
|
A result object for accessing the partial object stream and additional information.
|
750
790
|
*/
|
751
|
-
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
791
|
+
declare function streamObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
752
792
|
/**
|
753
793
|
The language model to use.
|
754
794
|
*/
|
@@ -756,11 +796,11 @@ The language model to use.
|
|
756
796
|
/**
|
757
797
|
The schema of the object that the model should generate.
|
758
798
|
*/
|
759
|
-
schema: z.Schema<T>;
|
799
|
+
schema: z.Schema<T> | Schema<T>;
|
760
800
|
/**
|
761
801
|
The mode to use for object generation.
|
762
802
|
|
763
|
-
The
|
803
|
+
The schema is converted in a JSON schema and used in one of the following ways
|
764
804
|
|
765
805
|
- 'auto': The provider will choose the best mode for the model.
|
766
806
|
- 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
|
@@ -812,7 +852,7 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
812
852
|
stream: ReadableStream<string | Omit<LanguageModelV1StreamPart, 'text-delta'>>;
|
813
853
|
warnings: StreamObjectResult<T>['warnings'];
|
814
854
|
rawResponse?: StreamObjectResult<T>['rawResponse'];
|
815
|
-
schema: z.Schema<T>;
|
855
|
+
schema: z.Schema<T> | Schema<T>;
|
816
856
|
onFinish: Parameters<typeof streamObject<T>>[0]['onFinish'];
|
817
857
|
});
|
818
858
|
get object(): Promise<T>;
|
@@ -830,13 +870,15 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
830
870
|
*/
|
831
871
|
declare const experimental_streamObject: typeof streamObject;
|
832
872
|
|
873
|
+
type Parameters$1 = z.ZodTypeAny | Schema<any>;
|
874
|
+
type inferParameters<PARAMETERS extends Parameters$1> = PARAMETERS extends Schema<any> ? PARAMETERS['_type'] : PARAMETERS extends z.ZodTypeAny ? z.infer<PARAMETERS> : never;
|
833
875
|
/**
|
834
876
|
A tool contains the description and the schema of the input that the tool expects.
|
835
877
|
This enables the language model to generate the input.
|
836
878
|
|
837
879
|
The tool can also contain an optional execute function for the actual execution function of the tool.
|
838
880
|
*/
|
839
|
-
interface CoreTool<PARAMETERS extends
|
881
|
+
interface CoreTool<PARAMETERS extends Parameters$1 = any, RESULT = any> {
|
840
882
|
/**
|
841
883
|
An optional description of what the tool does. Will be used by the language model to decide whether to use the tool.
|
842
884
|
*/
|
@@ -851,17 +893,17 @@ interface CoreTool<PARAMETERS extends z.ZodTypeAny = any, RESULT = any> {
|
|
851
893
|
An async function that is called with the arguments from the tool call and produces a result.
|
852
894
|
If not provided, the tool will not be executed automatically.
|
853
895
|
*/
|
854
|
-
execute?: (args:
|
896
|
+
execute?: (args: inferParameters<PARAMETERS>) => PromiseLike<RESULT>;
|
855
897
|
}
|
856
898
|
/**
|
857
899
|
Helper function for inferring the execute args of a tool.
|
858
900
|
*/
|
859
|
-
declare function tool<PARAMETERS extends
|
860
|
-
execute: (args:
|
901
|
+
declare function tool<PARAMETERS extends Parameters$1, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
902
|
+
execute: (args: inferParameters<PARAMETERS>) => PromiseLike<RESULT>;
|
861
903
|
}): CoreTool<PARAMETERS, RESULT> & {
|
862
|
-
execute: (args:
|
904
|
+
execute: (args: inferParameters<PARAMETERS>) => PromiseLike<RESULT>;
|
863
905
|
};
|
864
|
-
declare function tool<PARAMETERS extends
|
906
|
+
declare function tool<PARAMETERS extends Parameters$1, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
865
907
|
execute?: undefined;
|
866
908
|
}): CoreTool<PARAMETERS, RESULT> & {
|
867
909
|
execute: undefined;
|
@@ -948,7 +990,7 @@ type ToToolResultObject<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
948
990
|
type: 'tool-result';
|
949
991
|
toolCallId: string;
|
950
992
|
toolName: NAME & string;
|
951
|
-
args:
|
993
|
+
args: inferParameters<TOOLS[NAME]['parameters']>;
|
952
994
|
result: Awaited<ReturnType<Exclude<TOOLS[NAME]['execute'], undefined>>>;
|
953
995
|
};
|
954
996
|
}>;
|
@@ -986,7 +1028,7 @@ type ToToolCall<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
986
1028
|
type: 'tool-call';
|
987
1029
|
toolCallId: string;
|
988
1030
|
toolName: NAME & string;
|
989
|
-
args:
|
1031
|
+
args: inferParameters<TOOLS[NAME]['parameters']>;
|
990
1032
|
};
|
991
1033
|
}>;
|
992
1034
|
type ToToolCallArray<TOOLS extends Record<string, CoreTool>> = Array<ToToolCall<TOOLS>>;
|
@@ -2312,4 +2354,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2312
2354
|
*/
|
2313
2355
|
declare const nanoid: (size?: number | undefined) => string;
|
2314
2356
|
|
2315
|
-
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidMessageRoleError, InvalidModelIdError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoSuchModelError, NoSuchProviderError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, convertUint8ArrayToText, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
2357
|
+
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidMessageRoleError, InvalidModelIdError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoSuchModelError, NoSuchProviderError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, convertUint8ArrayToText, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, jsonSchema, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
package/dist/index.d.ts
CHANGED
@@ -1,14 +1,34 @@
|
|
1
1
|
import { DeepPartial, Attachment, JSONValue, CreateMessage, FunctionCall as FunctionCall$1, AssistantMessage, DataMessage } from '@ai-sdk/ui-utils';
|
2
2
|
export { AssistantMessage, AssistantStatus, ChatRequest, ChatRequestOptions, CreateMessage, DataMessage, DeepPartial, Function, FunctionCall, FunctionCallHandler, IdGenerator, JSONValue, Message, RequestOptions, StreamPart, Tool, ToolCall, ToolCallHandler, ToolChoice, ToolInvocation, UseAssistantOptions, formatStreamPart, parseComplexResponse, parseStreamPart, readDataStream } from '@ai-sdk/ui-utils';
|
3
|
+
import { AttributeValue, Span } from '@opentelemetry/api';
|
3
4
|
import { EmbeddingModelV1, EmbeddingModelV1Embedding, LanguageModelV1, LanguageModelV1FinishReason, LanguageModelV1LogProbs, LanguageModelV1CallWarning, LanguageModelV1StreamPart } from '@ai-sdk/provider';
|
4
5
|
export { APICallError, EmptyResponseBodyError, InvalidArgumentError, InvalidDataContentError, InvalidPromptError, InvalidResponseDataError, InvalidToolArgumentsError, JSONParseError, LoadAPIKeyError, NoObjectGeneratedError, NoSuchToolError, RetryError, ToolCallParseError, TypeValidationError, UnsupportedFunctionalityError, UnsupportedJSONSchemaError } from '@ai-sdk/provider';
|
5
6
|
import { z } from 'zod';
|
6
|
-
import {
|
7
|
+
import { Validator } from '@ai-sdk/provider-utils';
|
8
|
+
import { JSONSchema7 } from 'json-schema';
|
7
9
|
import { ServerResponse } from 'http';
|
8
10
|
import { ServerResponse as ServerResponse$1 } from 'node:http';
|
9
11
|
import { AssistantStream } from 'openai/lib/AssistantStream';
|
10
12
|
import { Run } from 'openai/resources/beta/threads/runs/runs';
|
11
13
|
|
14
|
+
/**
|
15
|
+
* Telemetry configuration.
|
16
|
+
*/
|
17
|
+
type TelemetrySettings = {
|
18
|
+
/**
|
19
|
+
* Enable or disable telemetry. Disabled by default while experimental.
|
20
|
+
*/
|
21
|
+
isEnabled?: boolean;
|
22
|
+
/**
|
23
|
+
* Identifier for this function. Used to group telemetry data by function.
|
24
|
+
*/
|
25
|
+
functionId?: string;
|
26
|
+
/**
|
27
|
+
* Additional information to include in the telemetry data.
|
28
|
+
*/
|
29
|
+
metadata?: Record<string, AttributeValue>;
|
30
|
+
};
|
31
|
+
|
12
32
|
/**
|
13
33
|
Represents the number of tokens used in a prompt and completion.
|
14
34
|
*/
|
@@ -129,7 +149,7 @@ Embed a value using an embedding model. The type of the value is defined by the
|
|
129
149
|
|
130
150
|
@returns A result object that contains the embedding, the value, and additional information.
|
131
151
|
*/
|
132
|
-
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers, }: {
|
152
|
+
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, }: {
|
133
153
|
/**
|
134
154
|
The embedding model to use.
|
135
155
|
*/
|
@@ -153,6 +173,10 @@ declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers,
|
|
153
173
|
Only applicable for HTTP-based providers.
|
154
174
|
*/
|
155
175
|
headers?: Record<string, string>;
|
176
|
+
/**
|
177
|
+
* Optional telemetry configuration (experimental).
|
178
|
+
*/
|
179
|
+
experimental_telemetry?: TelemetrySettings;
|
156
180
|
}): Promise<EmbedResult<VALUE>>;
|
157
181
|
|
158
182
|
/**
|
@@ -473,22 +497,38 @@ type Prompt = {
|
|
473
497
|
};
|
474
498
|
|
475
499
|
/**
|
476
|
-
*
|
500
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
477
501
|
*/
|
478
|
-
|
502
|
+
declare const schemaSymbol: unique symbol;
|
503
|
+
type Schema<OBJECT = unknown> = Validator<OBJECT> & {
|
479
504
|
/**
|
480
|
-
*
|
505
|
+
* Used to mark schemas so we can support both Zod and custom schemas.
|
481
506
|
*/
|
482
|
-
|
507
|
+
[schemaSymbol]: true;
|
483
508
|
/**
|
484
|
-
*
|
509
|
+
* Schema type for inference.
|
485
510
|
*/
|
486
|
-
|
511
|
+
_type: OBJECT;
|
487
512
|
/**
|
488
|
-
*
|
513
|
+
* The JSON Schema for the schema. It is passed to the providers.
|
489
514
|
*/
|
490
|
-
|
515
|
+
readonly jsonSchema: JSONSchema7;
|
491
516
|
};
|
517
|
+
/**
|
518
|
+
* Create a schema using a JSON Schema.
|
519
|
+
*
|
520
|
+
* @param jsonSchema The JSON Schema for the schema.
|
521
|
+
* @param options.validate Optional. A validation function for the schema.
|
522
|
+
*/
|
523
|
+
declare function jsonSchema<OBJECT = unknown>(jsonSchema: JSONSchema7, { validate, }?: {
|
524
|
+
validate?: (value: unknown) => {
|
525
|
+
success: true;
|
526
|
+
value: OBJECT;
|
527
|
+
} | {
|
528
|
+
success: false;
|
529
|
+
error: Error;
|
530
|
+
};
|
531
|
+
}): Schema<OBJECT>;
|
492
532
|
|
493
533
|
/**
|
494
534
|
The result of a `generateObject` call.
|
@@ -571,7 +611,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
571
611
|
@returns
|
572
612
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
573
613
|
*/
|
574
|
-
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
614
|
+
declare function generateObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, experimental_telemetry: telemetry, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
575
615
|
/**
|
576
616
|
The language model to use.
|
577
617
|
*/
|
@@ -579,11 +619,11 @@ The language model to use.
|
|
579
619
|
/**
|
580
620
|
The schema of the object that the model should generate.
|
581
621
|
*/
|
582
|
-
schema: z.Schema<T>;
|
622
|
+
schema: z.Schema<T> | Schema<T>;
|
583
623
|
/**
|
584
624
|
The mode to use for object generation.
|
585
625
|
|
586
|
-
The
|
626
|
+
The schema is converted in a JSON schema and used in one of the following ways
|
587
627
|
|
588
628
|
- 'auto': The provider will choose the best mode for the model.
|
589
629
|
- 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
|
@@ -748,7 +788,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
748
788
|
@return
|
749
789
|
A result object for accessing the partial object stream and additional information.
|
750
790
|
*/
|
751
|
-
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
791
|
+
declare function streamObject<T>({ model, schema: inputSchema, mode, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: Omit<CallSettings, 'stopSequences'> & Prompt & {
|
752
792
|
/**
|
753
793
|
The language model to use.
|
754
794
|
*/
|
@@ -756,11 +796,11 @@ The language model to use.
|
|
756
796
|
/**
|
757
797
|
The schema of the object that the model should generate.
|
758
798
|
*/
|
759
|
-
schema: z.Schema<T>;
|
799
|
+
schema: z.Schema<T> | Schema<T>;
|
760
800
|
/**
|
761
801
|
The mode to use for object generation.
|
762
802
|
|
763
|
-
The
|
803
|
+
The schema is converted in a JSON schema and used in one of the following ways
|
764
804
|
|
765
805
|
- 'auto': The provider will choose the best mode for the model.
|
766
806
|
- 'tool': A tool with the JSON schema as parameters is is provided and the provider is instructed to use it.
|
@@ -812,7 +852,7 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
812
852
|
stream: ReadableStream<string | Omit<LanguageModelV1StreamPart, 'text-delta'>>;
|
813
853
|
warnings: StreamObjectResult<T>['warnings'];
|
814
854
|
rawResponse?: StreamObjectResult<T>['rawResponse'];
|
815
|
-
schema: z.Schema<T>;
|
855
|
+
schema: z.Schema<T> | Schema<T>;
|
816
856
|
onFinish: Parameters<typeof streamObject<T>>[0]['onFinish'];
|
817
857
|
});
|
818
858
|
get object(): Promise<T>;
|
@@ -830,13 +870,15 @@ declare class DefaultStreamObjectResult<T> implements StreamObjectResult<T> {
|
|
830
870
|
*/
|
831
871
|
declare const experimental_streamObject: typeof streamObject;
|
832
872
|
|
873
|
+
type Parameters$1 = z.ZodTypeAny | Schema<any>;
|
874
|
+
type inferParameters<PARAMETERS extends Parameters$1> = PARAMETERS extends Schema<any> ? PARAMETERS['_type'] : PARAMETERS extends z.ZodTypeAny ? z.infer<PARAMETERS> : never;
|
833
875
|
/**
|
834
876
|
A tool contains the description and the schema of the input that the tool expects.
|
835
877
|
This enables the language model to generate the input.
|
836
878
|
|
837
879
|
The tool can also contain an optional execute function for the actual execution function of the tool.
|
838
880
|
*/
|
839
|
-
interface CoreTool<PARAMETERS extends
|
881
|
+
interface CoreTool<PARAMETERS extends Parameters$1 = any, RESULT = any> {
|
840
882
|
/**
|
841
883
|
An optional description of what the tool does. Will be used by the language model to decide whether to use the tool.
|
842
884
|
*/
|
@@ -851,17 +893,17 @@ interface CoreTool<PARAMETERS extends z.ZodTypeAny = any, RESULT = any> {
|
|
851
893
|
An async function that is called with the arguments from the tool call and produces a result.
|
852
894
|
If not provided, the tool will not be executed automatically.
|
853
895
|
*/
|
854
|
-
execute?: (args:
|
896
|
+
execute?: (args: inferParameters<PARAMETERS>) => PromiseLike<RESULT>;
|
855
897
|
}
|
856
898
|
/**
|
857
899
|
Helper function for inferring the execute args of a tool.
|
858
900
|
*/
|
859
|
-
declare function tool<PARAMETERS extends
|
860
|
-
execute: (args:
|
901
|
+
declare function tool<PARAMETERS extends Parameters$1, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
902
|
+
execute: (args: inferParameters<PARAMETERS>) => PromiseLike<RESULT>;
|
861
903
|
}): CoreTool<PARAMETERS, RESULT> & {
|
862
|
-
execute: (args:
|
904
|
+
execute: (args: inferParameters<PARAMETERS>) => PromiseLike<RESULT>;
|
863
905
|
};
|
864
|
-
declare function tool<PARAMETERS extends
|
906
|
+
declare function tool<PARAMETERS extends Parameters$1, RESULT>(tool: CoreTool<PARAMETERS, RESULT> & {
|
865
907
|
execute?: undefined;
|
866
908
|
}): CoreTool<PARAMETERS, RESULT> & {
|
867
909
|
execute: undefined;
|
@@ -948,7 +990,7 @@ type ToToolResultObject<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
948
990
|
type: 'tool-result';
|
949
991
|
toolCallId: string;
|
950
992
|
toolName: NAME & string;
|
951
|
-
args:
|
993
|
+
args: inferParameters<TOOLS[NAME]['parameters']>;
|
952
994
|
result: Awaited<ReturnType<Exclude<TOOLS[NAME]['execute'], undefined>>>;
|
953
995
|
};
|
954
996
|
}>;
|
@@ -986,7 +1028,7 @@ type ToToolCall<TOOLS extends Record<string, CoreTool>> = ValueOf<{
|
|
986
1028
|
type: 'tool-call';
|
987
1029
|
toolCallId: string;
|
988
1030
|
toolName: NAME & string;
|
989
|
-
args:
|
1031
|
+
args: inferParameters<TOOLS[NAME]['parameters']>;
|
990
1032
|
};
|
991
1033
|
}>;
|
992
1034
|
type ToToolCallArray<TOOLS extends Record<string, CoreTool>> = Array<ToToolCall<TOOLS>>;
|
@@ -2312,4 +2354,4 @@ declare const generateId: (size?: number | undefined) => string;
|
|
2312
2354
|
*/
|
2313
2355
|
declare const nanoid: (size?: number | undefined) => string;
|
2314
2356
|
|
2315
|
-
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidMessageRoleError, InvalidModelIdError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoSuchModelError, NoSuchProviderError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, convertUint8ArrayToText, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|
2357
|
+
export { AIStream, AIStreamCallbacksAndOptions, AIStreamParser, AIStreamParserOptions, AWSBedrockAnthropicMessagesStream, AWSBedrockAnthropicStream, AWSBedrockCohereStream, AWSBedrockLlama2Stream, AWSBedrockStream, AnthropicStream, AssistantContent, AssistantResponse, CallWarning, CohereStream, CompletionTokenUsage, CompletionUsage, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreTool, CoreToolChoice, CoreToolMessage, CoreUserMessage, DataContent, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingTokenUsage, ExperimentalAssistantMessage, ExperimentalMessage, ExperimentalTool, ExperimentalToolMessage, ExperimentalUserMessage, FinishReason, FunctionCallPayload, GenerateObjectResult, GenerateTextResult, GoogleGenerativeAIStream, HuggingFaceStream, ImagePart, InkeepAIStreamCallbacksAndOptions, InkeepChatResultCallbacks, InkeepOnFinalMetadata, InkeepStream, InvalidMessageRoleError, InvalidModelIdError, langchainAdapter as LangChainAdapter, LangChainStream, LanguageModel, LogProbs, MistralStream, NoSuchModelError, NoSuchProviderError, ObjectStreamInputPart, ObjectStreamPart, OpenAIStream, OpenAIStreamCallbacks, ReplicateStream, StreamData, StreamObjectResult, StreamTextResult, StreamingTextResponse, TextPart$1 as TextPart, TextStreamPart, TokenUsage, ToolCallPart, ToolCallPayload, ToolContent, ToolResultPart, UserContent, convertDataContentToBase64String, convertDataContentToUint8Array, convertToCoreMessages, convertUint8ArrayToText, cosineSimilarity, createCallbacksTransformer, createEventStreamTransformer, createStreamDataTransformer, embed, embedMany, experimental_AssistantResponse, experimental_ModelRegistry, experimental_ProviderRegistry, experimental_StreamData, experimental_createModelRegistry, experimental_createProviderRegistry, experimental_generateObject, experimental_generateText, experimental_streamObject, experimental_streamText, generateId, generateObject, generateText, jsonSchema, nanoid, readableFromAsyncIterable, streamObject, streamText, streamToResponse, tool, trimStartOfStreamHelper };
|