@ai-sdk/provider 0.0.23 → 0.0.26
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 +22 -0
- package/README.md +1 -1
- package/dist/index.d.mts +129 -16
- package/dist/index.d.ts +129 -16
- package/dist/index.js +117 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# @ai-sdk/provider
|
2
2
|
|
3
|
+
## 0.0.26
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- aa98cdb: chore: more flexible dependency versioning
|
8
|
+
- 1486128: feat: add supportsUrl to language model specification
|
9
|
+
- 7b937c5: feat (provider-utils): improve id generator robustness
|
10
|
+
- 3b1b69a: feat: provider-defined tools
|
11
|
+
- 811a317: feat (ai/core): multi-part tool results (incl. images)
|
12
|
+
|
13
|
+
## 0.0.25
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- b9b0d7b: feat (ai): access raw request body
|
18
|
+
|
19
|
+
## 0.0.24
|
20
|
+
|
21
|
+
### Patch Changes
|
22
|
+
|
23
|
+
- d595d0d: feat (ai/core): file content parts
|
24
|
+
|
3
25
|
## 0.0.23
|
4
26
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
#
|
1
|
+
# AI SDK - Provider Language Model Specification
|
package/dist/index.d.mts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
2
|
+
export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
2
3
|
|
3
4
|
/**
|
4
5
|
An embedding is a vector, i.e. an array of numbers.
|
@@ -82,13 +83,13 @@ type EmbeddingModelV1<VALUE> = {
|
|
82
83
|
}>;
|
83
84
|
};
|
84
85
|
|
85
|
-
declare const symbol$
|
86
|
+
declare const symbol$d: unique symbol;
|
86
87
|
/**
|
87
88
|
* Custom error class for AI SDK related errors.
|
88
89
|
* @extends Error
|
89
90
|
*/
|
90
91
|
declare class AISDKError extends Error {
|
91
|
-
private readonly [symbol$
|
92
|
+
private readonly [symbol$d];
|
92
93
|
/**
|
93
94
|
* The underlying cause of the error, if any.
|
94
95
|
*/
|
@@ -125,9 +126,9 @@ declare class AISDKError extends Error {
|
|
125
126
|
};
|
126
127
|
}
|
127
128
|
|
128
|
-
declare const symbol$
|
129
|
+
declare const symbol$c: unique symbol;
|
129
130
|
declare class APICallError extends AISDKError {
|
130
|
-
private readonly [symbol$
|
131
|
+
private readonly [symbol$c];
|
131
132
|
readonly url: string;
|
132
133
|
readonly requestBodyValues: unknown;
|
133
134
|
readonly statusCode?: number;
|
@@ -169,9 +170,9 @@ declare class APICallError extends AISDKError {
|
|
169
170
|
};
|
170
171
|
}
|
171
172
|
|
172
|
-
declare const symbol$
|
173
|
+
declare const symbol$b: unique symbol;
|
173
174
|
declare class EmptyResponseBodyError extends AISDKError {
|
174
|
-
private readonly [symbol$
|
175
|
+
private readonly [symbol$b];
|
175
176
|
constructor({ message }?: {
|
176
177
|
message?: string;
|
177
178
|
});
|
@@ -184,6 +185,21 @@ declare class EmptyResponseBodyError extends AISDKError {
|
|
184
185
|
|
185
186
|
declare function getErrorMessage(error: unknown | undefined): string;
|
186
187
|
|
188
|
+
declare const symbol$a: unique symbol;
|
189
|
+
/**
|
190
|
+
* A function argument is invalid.
|
191
|
+
*/
|
192
|
+
declare class InvalidArgumentError extends AISDKError {
|
193
|
+
private readonly [symbol$a];
|
194
|
+
readonly argument: string;
|
195
|
+
constructor({ message, cause, argument, }: {
|
196
|
+
argument: string;
|
197
|
+
message: string;
|
198
|
+
cause?: unknown;
|
199
|
+
});
|
200
|
+
static isInstance(error: unknown): error is InvalidArgumentError;
|
201
|
+
}
|
202
|
+
|
187
203
|
declare const symbol$9: unique symbol;
|
188
204
|
/**
|
189
205
|
* A prompt is invalid. This error should be thrown by providers when they cannot
|
@@ -535,8 +551,7 @@ map the user-facing tool definitions to this format.
|
|
535
551
|
*/
|
536
552
|
type LanguageModelV1FunctionTool = {
|
537
553
|
/**
|
538
|
-
The type of the tool
|
539
|
-
add more specific tool types in the future and use a discriminated union.
|
554
|
+
The type of the tool (always 'function').
|
540
555
|
*/
|
541
556
|
type: 'function';
|
542
557
|
/**
|
@@ -591,7 +606,7 @@ type LanguageModelV1Message = ({
|
|
591
606
|
content: string;
|
592
607
|
} | {
|
593
608
|
role: 'user';
|
594
|
-
content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart>;
|
609
|
+
content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
|
595
610
|
} | {
|
596
611
|
role: 'assistant';
|
597
612
|
content: Array<LanguageModelV1TextPart | LanguageModelV1ToolCallPart>;
|
@@ -643,6 +658,26 @@ interface LanguageModelV1ImagePart {
|
|
643
658
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
644
659
|
}
|
645
660
|
/**
|
661
|
+
File content part of a prompt. It contains a file.
|
662
|
+
*/
|
663
|
+
interface LanguageModelV1FilePart {
|
664
|
+
type: 'file';
|
665
|
+
/**
|
666
|
+
File data as base64 encoded string or as a URL.
|
667
|
+
*/
|
668
|
+
data: string | URL;
|
669
|
+
/**
|
670
|
+
Mime type of the file.
|
671
|
+
*/
|
672
|
+
mimeType: string;
|
673
|
+
/**
|
674
|
+
* Additional provider-specific metadata. They are passed through
|
675
|
+
* to the provider from the AI SDK and enable provider-specific
|
676
|
+
* functionality that can be fully encapsulated in the provider.
|
677
|
+
*/
|
678
|
+
providerMetadata?: LanguageModelV1ProviderMetadata;
|
679
|
+
}
|
680
|
+
/**
|
646
681
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
647
682
|
*/
|
648
683
|
interface LanguageModelV1ToolCallPart {
|
@@ -688,6 +723,27 @@ interface LanguageModelV1ToolResultPart {
|
|
688
723
|
*/
|
689
724
|
isError?: boolean;
|
690
725
|
/**
|
726
|
+
Tool results as an array of parts. This enables advanced tool results including images.
|
727
|
+
When this is used, the `result` field should be ignored (if the provider supports content).
|
728
|
+
*/
|
729
|
+
content?: Array<{
|
730
|
+
type: 'text';
|
731
|
+
/**
|
732
|
+
Text content.
|
733
|
+
*/
|
734
|
+
text: string;
|
735
|
+
} | {
|
736
|
+
type: 'image';
|
737
|
+
/**
|
738
|
+
base-64 encoded image data
|
739
|
+
*/
|
740
|
+
data: string;
|
741
|
+
/**
|
742
|
+
Mime type of the image.
|
743
|
+
*/
|
744
|
+
mimeType?: string;
|
745
|
+
}>;
|
746
|
+
/**
|
691
747
|
* Additional provider-specific metadata. They are passed through
|
692
748
|
* to the provider from the AI SDK and enable provider-specific
|
693
749
|
* functionality that can be fully encapsulated in the provider.
|
@@ -695,6 +751,28 @@ interface LanguageModelV1ToolResultPart {
|
|
695
751
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
696
752
|
}
|
697
753
|
|
754
|
+
/**
|
755
|
+
The configuration of a tool that is defined by the provider.
|
756
|
+
*/
|
757
|
+
type LanguageModelV1ProviderDefinedTool = {
|
758
|
+
/**
|
759
|
+
The type of the tool (always 'provider-defined').
|
760
|
+
*/
|
761
|
+
type: 'provider-defined';
|
762
|
+
/**
|
763
|
+
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
|
764
|
+
*/
|
765
|
+
id: `${string}.${string}`;
|
766
|
+
/**
|
767
|
+
The name of the tool. Unique within this model call.
|
768
|
+
*/
|
769
|
+
name: string;
|
770
|
+
/**
|
771
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
772
|
+
*/
|
773
|
+
args: Record<string, unknown>;
|
774
|
+
};
|
775
|
+
|
698
776
|
type LanguageModelV1ToolChoice = {
|
699
777
|
type: 'auto';
|
700
778
|
} | {
|
@@ -731,7 +809,7 @@ type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
|
|
731
809
|
/**
|
732
810
|
The tools that are available for the model.
|
733
811
|
*/
|
734
|
-
tools?: Array<LanguageModelV1FunctionTool>;
|
812
|
+
tools?: Array<LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool>;
|
735
813
|
/**
|
736
814
|
Specifies how the tool should be selected. Defaults to 'auto'.
|
737
815
|
*/
|
@@ -764,9 +842,9 @@ Specifies how the tool should be selected. Defaults to 'auto'.
|
|
764
842
|
*/
|
765
843
|
prompt: LanguageModelV1Prompt;
|
766
844
|
/**
|
767
|
-
|
768
|
-
|
769
|
-
|
845
|
+
Additional provider-specific metadata.
|
846
|
+
The metadata is passed through to the provider from the AI SDK and enables
|
847
|
+
provider-specific functionality that can be fully encapsulated in the provider.
|
770
848
|
*/
|
771
849
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
772
850
|
};
|
@@ -779,6 +857,10 @@ type LanguageModelV1CallWarning = {
|
|
779
857
|
type: 'unsupported-setting';
|
780
858
|
setting: keyof LanguageModelV1CallSettings;
|
781
859
|
details?: string;
|
860
|
+
} | {
|
861
|
+
type: 'unsupported-tool';
|
862
|
+
tool: LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool;
|
863
|
+
details?: string;
|
782
864
|
} | {
|
783
865
|
type: 'other';
|
784
866
|
message: string;
|
@@ -875,6 +957,14 @@ type LanguageModelV1 = {
|
|
875
957
|
*/
|
876
958
|
readonly supportsStructuredOutputs?: boolean;
|
877
959
|
/**
|
960
|
+
Checks if the model supports the given URL for file parts natively.
|
961
|
+
If the model does not support the URL,
|
962
|
+
the AI SDK will download the file and pass the file data to the model.
|
963
|
+
|
964
|
+
When undefined, the AI SDK will download the file.
|
965
|
+
*/
|
966
|
+
supportsUrl?(url: URL): boolean;
|
967
|
+
/**
|
878
968
|
Generates a language model output (non-streaming).
|
879
969
|
|
880
970
|
Naming: "do" prefix to prevent accidental direct usage of the method
|
@@ -926,6 +1016,19 @@ type LanguageModelV1 = {
|
|
926
1016
|
*/
|
927
1017
|
headers?: Record<string, string>;
|
928
1018
|
};
|
1019
|
+
/**
|
1020
|
+
Optional request information for telemetry and debugging purposes.
|
1021
|
+
*/
|
1022
|
+
request?: {
|
1023
|
+
/**
|
1024
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
1025
|
+
Non-HTTP(s) providers should not set this.
|
1026
|
+
*/
|
1027
|
+
body?: string;
|
1028
|
+
};
|
1029
|
+
/**
|
1030
|
+
Optional response information for telemetry and debugging purposes.
|
1031
|
+
*/
|
929
1032
|
response?: {
|
930
1033
|
/**
|
931
1034
|
ID for the generated response, if the provider sends one.
|
@@ -989,6 +1092,16 @@ type LanguageModelV1 = {
|
|
989
1092
|
*/
|
990
1093
|
headers?: Record<string, string>;
|
991
1094
|
};
|
1095
|
+
/**
|
1096
|
+
Optional request information for telemetry and debugging purposes.
|
1097
|
+
*/
|
1098
|
+
request?: {
|
1099
|
+
/**
|
1100
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
1101
|
+
Non-HTTP(s) providers should not set this.
|
1102
|
+
*/
|
1103
|
+
body?: string;
|
1104
|
+
};
|
992
1105
|
warnings?: LanguageModelV1CallWarning[];
|
993
1106
|
}>;
|
994
1107
|
};
|
@@ -1030,7 +1143,7 @@ interface ProviderV1 {
|
|
1030
1143
|
Returns the language model with the given id.
|
1031
1144
|
The model id is then passed to the provider function to get the model.
|
1032
1145
|
|
1033
|
-
@param {string}
|
1146
|
+
@param {string} modelId - The id of the model to return.
|
1034
1147
|
|
1035
1148
|
@returns {LanguageModel} The language model associated with the id
|
1036
1149
|
|
@@ -1041,7 +1154,7 @@ interface ProviderV1 {
|
|
1041
1154
|
Returns the text embedding model with the given id.
|
1042
1155
|
The model id is then passed to the provider function to get the model.
|
1043
1156
|
|
1044
|
-
@param {string}
|
1157
|
+
@param {string} modelId - The id of the model to return.
|
1045
1158
|
|
1046
1159
|
@returns {LanguageModel} The language model associated with the id
|
1047
1160
|
|
@@ -1050,4 +1163,4 @@ interface ProviderV1 {
|
|
1050
1163
|
textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
|
1051
1164
|
}
|
1052
1165
|
|
1053
|
-
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
1166
|
+
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
2
|
+
export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
2
3
|
|
3
4
|
/**
|
4
5
|
An embedding is a vector, i.e. an array of numbers.
|
@@ -82,13 +83,13 @@ type EmbeddingModelV1<VALUE> = {
|
|
82
83
|
}>;
|
83
84
|
};
|
84
85
|
|
85
|
-
declare const symbol$
|
86
|
+
declare const symbol$d: unique symbol;
|
86
87
|
/**
|
87
88
|
* Custom error class for AI SDK related errors.
|
88
89
|
* @extends Error
|
89
90
|
*/
|
90
91
|
declare class AISDKError extends Error {
|
91
|
-
private readonly [symbol$
|
92
|
+
private readonly [symbol$d];
|
92
93
|
/**
|
93
94
|
* The underlying cause of the error, if any.
|
94
95
|
*/
|
@@ -125,9 +126,9 @@ declare class AISDKError extends Error {
|
|
125
126
|
};
|
126
127
|
}
|
127
128
|
|
128
|
-
declare const symbol$
|
129
|
+
declare const symbol$c: unique symbol;
|
129
130
|
declare class APICallError extends AISDKError {
|
130
|
-
private readonly [symbol$
|
131
|
+
private readonly [symbol$c];
|
131
132
|
readonly url: string;
|
132
133
|
readonly requestBodyValues: unknown;
|
133
134
|
readonly statusCode?: number;
|
@@ -169,9 +170,9 @@ declare class APICallError extends AISDKError {
|
|
169
170
|
};
|
170
171
|
}
|
171
172
|
|
172
|
-
declare const symbol$
|
173
|
+
declare const symbol$b: unique symbol;
|
173
174
|
declare class EmptyResponseBodyError extends AISDKError {
|
174
|
-
private readonly [symbol$
|
175
|
+
private readonly [symbol$b];
|
175
176
|
constructor({ message }?: {
|
176
177
|
message?: string;
|
177
178
|
});
|
@@ -184,6 +185,21 @@ declare class EmptyResponseBodyError extends AISDKError {
|
|
184
185
|
|
185
186
|
declare function getErrorMessage(error: unknown | undefined): string;
|
186
187
|
|
188
|
+
declare const symbol$a: unique symbol;
|
189
|
+
/**
|
190
|
+
* A function argument is invalid.
|
191
|
+
*/
|
192
|
+
declare class InvalidArgumentError extends AISDKError {
|
193
|
+
private readonly [symbol$a];
|
194
|
+
readonly argument: string;
|
195
|
+
constructor({ message, cause, argument, }: {
|
196
|
+
argument: string;
|
197
|
+
message: string;
|
198
|
+
cause?: unknown;
|
199
|
+
});
|
200
|
+
static isInstance(error: unknown): error is InvalidArgumentError;
|
201
|
+
}
|
202
|
+
|
187
203
|
declare const symbol$9: unique symbol;
|
188
204
|
/**
|
189
205
|
* A prompt is invalid. This error should be thrown by providers when they cannot
|
@@ -535,8 +551,7 @@ map the user-facing tool definitions to this format.
|
|
535
551
|
*/
|
536
552
|
type LanguageModelV1FunctionTool = {
|
537
553
|
/**
|
538
|
-
The type of the tool
|
539
|
-
add more specific tool types in the future and use a discriminated union.
|
554
|
+
The type of the tool (always 'function').
|
540
555
|
*/
|
541
556
|
type: 'function';
|
542
557
|
/**
|
@@ -591,7 +606,7 @@ type LanguageModelV1Message = ({
|
|
591
606
|
content: string;
|
592
607
|
} | {
|
593
608
|
role: 'user';
|
594
|
-
content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart>;
|
609
|
+
content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart | LanguageModelV1FilePart>;
|
595
610
|
} | {
|
596
611
|
role: 'assistant';
|
597
612
|
content: Array<LanguageModelV1TextPart | LanguageModelV1ToolCallPart>;
|
@@ -643,6 +658,26 @@ interface LanguageModelV1ImagePart {
|
|
643
658
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
644
659
|
}
|
645
660
|
/**
|
661
|
+
File content part of a prompt. It contains a file.
|
662
|
+
*/
|
663
|
+
interface LanguageModelV1FilePart {
|
664
|
+
type: 'file';
|
665
|
+
/**
|
666
|
+
File data as base64 encoded string or as a URL.
|
667
|
+
*/
|
668
|
+
data: string | URL;
|
669
|
+
/**
|
670
|
+
Mime type of the file.
|
671
|
+
*/
|
672
|
+
mimeType: string;
|
673
|
+
/**
|
674
|
+
* Additional provider-specific metadata. They are passed through
|
675
|
+
* to the provider from the AI SDK and enable provider-specific
|
676
|
+
* functionality that can be fully encapsulated in the provider.
|
677
|
+
*/
|
678
|
+
providerMetadata?: LanguageModelV1ProviderMetadata;
|
679
|
+
}
|
680
|
+
/**
|
646
681
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
647
682
|
*/
|
648
683
|
interface LanguageModelV1ToolCallPart {
|
@@ -688,6 +723,27 @@ interface LanguageModelV1ToolResultPart {
|
|
688
723
|
*/
|
689
724
|
isError?: boolean;
|
690
725
|
/**
|
726
|
+
Tool results as an array of parts. This enables advanced tool results including images.
|
727
|
+
When this is used, the `result` field should be ignored (if the provider supports content).
|
728
|
+
*/
|
729
|
+
content?: Array<{
|
730
|
+
type: 'text';
|
731
|
+
/**
|
732
|
+
Text content.
|
733
|
+
*/
|
734
|
+
text: string;
|
735
|
+
} | {
|
736
|
+
type: 'image';
|
737
|
+
/**
|
738
|
+
base-64 encoded image data
|
739
|
+
*/
|
740
|
+
data: string;
|
741
|
+
/**
|
742
|
+
Mime type of the image.
|
743
|
+
*/
|
744
|
+
mimeType?: string;
|
745
|
+
}>;
|
746
|
+
/**
|
691
747
|
* Additional provider-specific metadata. They are passed through
|
692
748
|
* to the provider from the AI SDK and enable provider-specific
|
693
749
|
* functionality that can be fully encapsulated in the provider.
|
@@ -695,6 +751,28 @@ interface LanguageModelV1ToolResultPart {
|
|
695
751
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
696
752
|
}
|
697
753
|
|
754
|
+
/**
|
755
|
+
The configuration of a tool that is defined by the provider.
|
756
|
+
*/
|
757
|
+
type LanguageModelV1ProviderDefinedTool = {
|
758
|
+
/**
|
759
|
+
The type of the tool (always 'provider-defined').
|
760
|
+
*/
|
761
|
+
type: 'provider-defined';
|
762
|
+
/**
|
763
|
+
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
|
764
|
+
*/
|
765
|
+
id: `${string}.${string}`;
|
766
|
+
/**
|
767
|
+
The name of the tool. Unique within this model call.
|
768
|
+
*/
|
769
|
+
name: string;
|
770
|
+
/**
|
771
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
772
|
+
*/
|
773
|
+
args: Record<string, unknown>;
|
774
|
+
};
|
775
|
+
|
698
776
|
type LanguageModelV1ToolChoice = {
|
699
777
|
type: 'auto';
|
700
778
|
} | {
|
@@ -731,7 +809,7 @@ type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
|
|
731
809
|
/**
|
732
810
|
The tools that are available for the model.
|
733
811
|
*/
|
734
|
-
tools?: Array<LanguageModelV1FunctionTool>;
|
812
|
+
tools?: Array<LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool>;
|
735
813
|
/**
|
736
814
|
Specifies how the tool should be selected. Defaults to 'auto'.
|
737
815
|
*/
|
@@ -764,9 +842,9 @@ Specifies how the tool should be selected. Defaults to 'auto'.
|
|
764
842
|
*/
|
765
843
|
prompt: LanguageModelV1Prompt;
|
766
844
|
/**
|
767
|
-
|
768
|
-
|
769
|
-
|
845
|
+
Additional provider-specific metadata.
|
846
|
+
The metadata is passed through to the provider from the AI SDK and enables
|
847
|
+
provider-specific functionality that can be fully encapsulated in the provider.
|
770
848
|
*/
|
771
849
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
772
850
|
};
|
@@ -779,6 +857,10 @@ type LanguageModelV1CallWarning = {
|
|
779
857
|
type: 'unsupported-setting';
|
780
858
|
setting: keyof LanguageModelV1CallSettings;
|
781
859
|
details?: string;
|
860
|
+
} | {
|
861
|
+
type: 'unsupported-tool';
|
862
|
+
tool: LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool;
|
863
|
+
details?: string;
|
782
864
|
} | {
|
783
865
|
type: 'other';
|
784
866
|
message: string;
|
@@ -875,6 +957,14 @@ type LanguageModelV1 = {
|
|
875
957
|
*/
|
876
958
|
readonly supportsStructuredOutputs?: boolean;
|
877
959
|
/**
|
960
|
+
Checks if the model supports the given URL for file parts natively.
|
961
|
+
If the model does not support the URL,
|
962
|
+
the AI SDK will download the file and pass the file data to the model.
|
963
|
+
|
964
|
+
When undefined, the AI SDK will download the file.
|
965
|
+
*/
|
966
|
+
supportsUrl?(url: URL): boolean;
|
967
|
+
/**
|
878
968
|
Generates a language model output (non-streaming).
|
879
969
|
|
880
970
|
Naming: "do" prefix to prevent accidental direct usage of the method
|
@@ -926,6 +1016,19 @@ type LanguageModelV1 = {
|
|
926
1016
|
*/
|
927
1017
|
headers?: Record<string, string>;
|
928
1018
|
};
|
1019
|
+
/**
|
1020
|
+
Optional request information for telemetry and debugging purposes.
|
1021
|
+
*/
|
1022
|
+
request?: {
|
1023
|
+
/**
|
1024
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
1025
|
+
Non-HTTP(s) providers should not set this.
|
1026
|
+
*/
|
1027
|
+
body?: string;
|
1028
|
+
};
|
1029
|
+
/**
|
1030
|
+
Optional response information for telemetry and debugging purposes.
|
1031
|
+
*/
|
929
1032
|
response?: {
|
930
1033
|
/**
|
931
1034
|
ID for the generated response, if the provider sends one.
|
@@ -989,6 +1092,16 @@ type LanguageModelV1 = {
|
|
989
1092
|
*/
|
990
1093
|
headers?: Record<string, string>;
|
991
1094
|
};
|
1095
|
+
/**
|
1096
|
+
Optional request information for telemetry and debugging purposes.
|
1097
|
+
*/
|
1098
|
+
request?: {
|
1099
|
+
/**
|
1100
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
1101
|
+
Non-HTTP(s) providers should not set this.
|
1102
|
+
*/
|
1103
|
+
body?: string;
|
1104
|
+
};
|
992
1105
|
warnings?: LanguageModelV1CallWarning[];
|
993
1106
|
}>;
|
994
1107
|
};
|
@@ -1030,7 +1143,7 @@ interface ProviderV1 {
|
|
1030
1143
|
Returns the language model with the given id.
|
1031
1144
|
The model id is then passed to the provider function to get the model.
|
1032
1145
|
|
1033
|
-
@param {string}
|
1146
|
+
@param {string} modelId - The id of the model to return.
|
1034
1147
|
|
1035
1148
|
@returns {LanguageModel} The language model associated with the id
|
1036
1149
|
|
@@ -1041,7 +1154,7 @@ interface ProviderV1 {
|
|
1041
1154
|
Returns the text embedding model with the given id.
|
1042
1155
|
The model id is then passed to the provider function to get the model.
|
1043
1156
|
|
1044
|
-
@param {string}
|
1157
|
+
@param {string} modelId - The id of the model to return.
|
1045
1158
|
|
1046
1159
|
@returns {LanguageModel} The language model associated with the id
|
1047
1160
|
|
@@ -1050,4 +1163,4 @@ interface ProviderV1 {
|
|
1050
1163
|
textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
|
1051
1164
|
}
|
1052
1165
|
|
1053
|
-
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
1166
|
+
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|