@ai-sdk/provider 0.0.21 → 0.0.23
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 +144 -0
- package/dist/index.d.mts +112 -26
- package/dist/index.d.ts +112 -26
- package/dist/index.js +74 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# @ai-sdk/provider
|
2
|
+
|
3
|
+
## 0.0.23
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 03313cd: feat (ai): expose response id, response model, response timestamp in telemetry and api
|
8
|
+
- 3be7c1c: fix (provider/anthropic): support prompt caching on assistant messages
|
9
|
+
|
10
|
+
## 0.0.22
|
11
|
+
|
12
|
+
### Patch Changes
|
13
|
+
|
14
|
+
- 26515cb: feat (ai/provider): introduce ProviderV1 specification
|
15
|
+
|
16
|
+
## 0.0.21
|
17
|
+
|
18
|
+
### Patch Changes
|
19
|
+
|
20
|
+
- f2c025e: feat (ai/core): prompt validation
|
21
|
+
|
22
|
+
## 0.0.20
|
23
|
+
|
24
|
+
### Patch Changes
|
25
|
+
|
26
|
+
- 6ac355e: feat (provider/anthropic): add cache control support
|
27
|
+
|
28
|
+
## 0.0.19
|
29
|
+
|
30
|
+
### Patch Changes
|
31
|
+
|
32
|
+
- dd4a0f5: fix (ai/provider): remove invalid check in isJSONParseError
|
33
|
+
|
34
|
+
## 0.0.18
|
35
|
+
|
36
|
+
### Patch Changes
|
37
|
+
|
38
|
+
- 4bd27a9: chore (ai/provider): refactor type validation
|
39
|
+
|
40
|
+
## 0.0.17
|
41
|
+
|
42
|
+
### Patch Changes
|
43
|
+
|
44
|
+
- 029af4c: feat (ai/core): support schema name & description in generateObject & streamObject
|
45
|
+
|
46
|
+
## 0.0.16
|
47
|
+
|
48
|
+
### Patch Changes
|
49
|
+
|
50
|
+
- d58517b: feat (ai/openai): structured outputs
|
51
|
+
|
52
|
+
## 0.0.15
|
53
|
+
|
54
|
+
### Patch Changes
|
55
|
+
|
56
|
+
- 96aed25: fix (ai/provider): release new version
|
57
|
+
|
58
|
+
## 0.0.14
|
59
|
+
|
60
|
+
### Patch Changes
|
61
|
+
|
62
|
+
- a8d1c9e9: feat (ai/core): parallel image download
|
63
|
+
|
64
|
+
## 0.0.13
|
65
|
+
|
66
|
+
### Patch Changes
|
67
|
+
|
68
|
+
- 2b9da0f0: feat (core): support stopSequences setting.
|
69
|
+
- a5b58845: feat (core): support topK setting
|
70
|
+
- 4aa8deb3: feat (provider): support responseFormat setting in provider api
|
71
|
+
- 13b27ec6: chore (ai/core): remove grammar mode
|
72
|
+
|
73
|
+
## 0.0.12
|
74
|
+
|
75
|
+
### Patch Changes
|
76
|
+
|
77
|
+
- b7290943: feat (ai/core): add token usage to embed and embedMany
|
78
|
+
|
79
|
+
## 0.0.11
|
80
|
+
|
81
|
+
### Patch Changes
|
82
|
+
|
83
|
+
- 5edc6110: feat (provider): add headers support to language and embedding model spec
|
84
|
+
|
85
|
+
## 0.0.10
|
86
|
+
|
87
|
+
### Patch Changes
|
88
|
+
|
89
|
+
- 102ca22f: fix (@ai-sdk/provider): fix TypeValidationError.isTypeValidationError
|
90
|
+
|
91
|
+
## 0.0.9
|
92
|
+
|
93
|
+
### Patch Changes
|
94
|
+
|
95
|
+
- 09295e2e: feat (@ai-sdk/provider): add DownloadError
|
96
|
+
|
97
|
+
## 0.0.8
|
98
|
+
|
99
|
+
### Patch Changes
|
100
|
+
|
101
|
+
- f39c0dd2: feat (provider): add toolChoice to language model specification
|
102
|
+
|
103
|
+
## 0.0.7
|
104
|
+
|
105
|
+
### Patch Changes
|
106
|
+
|
107
|
+
- 8e780288: feat (ai/provider): add "unknown" finish reason (for models that don't provide a finish reason)
|
108
|
+
|
109
|
+
## 0.0.6
|
110
|
+
|
111
|
+
### Patch Changes
|
112
|
+
|
113
|
+
- 6a50ac4: feat (provider): add additional error types
|
114
|
+
|
115
|
+
## 0.0.5
|
116
|
+
|
117
|
+
### Patch Changes
|
118
|
+
|
119
|
+
- 0f6bc4e: feat (ai/core): add embed function
|
120
|
+
|
121
|
+
## 0.0.4
|
122
|
+
|
123
|
+
### Patch Changes
|
124
|
+
|
125
|
+
- 325ca55: feat (ai/core): improve image content part error message
|
126
|
+
|
127
|
+
## 0.0.3
|
128
|
+
|
129
|
+
### Patch Changes
|
130
|
+
|
131
|
+
- 41d5736: ai/core: re-expose language model types.
|
132
|
+
|
133
|
+
## 0.0.2
|
134
|
+
|
135
|
+
### Patch Changes
|
136
|
+
|
137
|
+
- d6431ae: ai/core: add logprobs support (thanks @SamStenner for the contribution)
|
138
|
+
- 25f3350: ai/core: add support for getting raw response headers.
|
139
|
+
|
140
|
+
## 0.0.1
|
141
|
+
|
142
|
+
### Patch Changes
|
143
|
+
|
144
|
+
- eb150a6: ai/core: remove scaling of setting values (breaking change). If you were using the temperature, frequency penalty, or presence penalty settings, you need to update the providers and adjust the setting values.
|
package/dist/index.d.mts
CHANGED
@@ -82,13 +82,13 @@ type EmbeddingModelV1<VALUE> = {
|
|
82
82
|
}>;
|
83
83
|
};
|
84
84
|
|
85
|
-
declare const symbol$
|
85
|
+
declare const symbol$c: unique symbol;
|
86
86
|
/**
|
87
87
|
* Custom error class for AI SDK related errors.
|
88
88
|
* @extends Error
|
89
89
|
*/
|
90
90
|
declare class AISDKError extends Error {
|
91
|
-
private readonly [symbol$
|
91
|
+
private readonly [symbol$c];
|
92
92
|
/**
|
93
93
|
* The underlying cause of the error, if any.
|
94
94
|
*/
|
@@ -125,9 +125,9 @@ declare class AISDKError extends Error {
|
|
125
125
|
};
|
126
126
|
}
|
127
127
|
|
128
|
-
declare const symbol$
|
128
|
+
declare const symbol$b: unique symbol;
|
129
129
|
declare class APICallError extends AISDKError {
|
130
|
-
private readonly [symbol$
|
130
|
+
private readonly [symbol$b];
|
131
131
|
readonly url: string;
|
132
132
|
readonly requestBodyValues: unknown;
|
133
133
|
readonly statusCode?: number;
|
@@ -169,9 +169,9 @@ declare class APICallError extends AISDKError {
|
|
169
169
|
};
|
170
170
|
}
|
171
171
|
|
172
|
-
declare const symbol$
|
172
|
+
declare const symbol$a: unique symbol;
|
173
173
|
declare class EmptyResponseBodyError extends AISDKError {
|
174
|
-
private readonly [symbol$
|
174
|
+
private readonly [symbol$a];
|
175
175
|
constructor({ message }?: {
|
176
176
|
message?: string;
|
177
177
|
});
|
@@ -184,13 +184,13 @@ declare class EmptyResponseBodyError extends AISDKError {
|
|
184
184
|
|
185
185
|
declare function getErrorMessage(error: unknown | undefined): string;
|
186
186
|
|
187
|
-
declare const symbol$
|
187
|
+
declare const symbol$9: unique symbol;
|
188
188
|
/**
|
189
189
|
* A prompt is invalid. This error should be thrown by providers when they cannot
|
190
190
|
* process a prompt.
|
191
191
|
*/
|
192
192
|
declare class InvalidPromptError extends AISDKError {
|
193
|
-
private readonly [symbol$
|
193
|
+
private readonly [symbol$9];
|
194
194
|
readonly prompt: unknown;
|
195
195
|
constructor({ prompt, message, cause, }: {
|
196
196
|
prompt: unknown;
|
@@ -213,13 +213,13 @@ declare class InvalidPromptError extends AISDKError {
|
|
213
213
|
};
|
214
214
|
}
|
215
215
|
|
216
|
-
declare const symbol$
|
216
|
+
declare const symbol$8: unique symbol;
|
217
217
|
/**
|
218
218
|
* Server returned a response with invalid data content.
|
219
219
|
* This should be thrown by providers when they cannot parse the response from the API.
|
220
220
|
*/
|
221
221
|
declare class InvalidResponseDataError extends AISDKError {
|
222
|
-
private readonly [symbol$
|
222
|
+
private readonly [symbol$8];
|
223
223
|
readonly data: unknown;
|
224
224
|
constructor({ data, message, }: {
|
225
225
|
data: unknown;
|
@@ -241,9 +241,9 @@ declare class InvalidResponseDataError extends AISDKError {
|
|
241
241
|
};
|
242
242
|
}
|
243
243
|
|
244
|
-
declare const symbol$
|
244
|
+
declare const symbol$7: unique symbol;
|
245
245
|
declare class JSONParseError extends AISDKError {
|
246
|
-
private readonly [symbol$
|
246
|
+
private readonly [symbol$7];
|
247
247
|
readonly text: string;
|
248
248
|
constructor({ text, cause }: {
|
249
249
|
text: string;
|
@@ -266,9 +266,9 @@ declare class JSONParseError extends AISDKError {
|
|
266
266
|
};
|
267
267
|
}
|
268
268
|
|
269
|
-
declare const symbol$
|
269
|
+
declare const symbol$6: unique symbol;
|
270
270
|
declare class LoadAPIKeyError extends AISDKError {
|
271
|
-
private readonly [symbol$
|
271
|
+
private readonly [symbol$6];
|
272
272
|
constructor({ message }: {
|
273
273
|
message: string;
|
274
274
|
});
|
@@ -279,9 +279,9 @@ declare class LoadAPIKeyError extends AISDKError {
|
|
279
279
|
static isLoadAPIKeyError(error: unknown): error is LoadAPIKeyError;
|
280
280
|
}
|
281
281
|
|
282
|
-
declare const symbol$
|
282
|
+
declare const symbol$5: unique symbol;
|
283
283
|
declare class LoadSettingError extends AISDKError {
|
284
|
-
private readonly [symbol$
|
284
|
+
private readonly [symbol$5];
|
285
285
|
constructor({ message }: {
|
286
286
|
message: string;
|
287
287
|
});
|
@@ -292,12 +292,12 @@ declare class LoadSettingError extends AISDKError {
|
|
292
292
|
static isLoadSettingError(error: unknown): error is LoadSettingError;
|
293
293
|
}
|
294
294
|
|
295
|
-
declare const symbol$
|
295
|
+
declare const symbol$4: unique symbol;
|
296
296
|
/**
|
297
297
|
Thrown when the AI provider fails to generate any content.
|
298
298
|
*/
|
299
299
|
declare class NoContentGeneratedError extends AISDKError {
|
300
|
-
private readonly [symbol$
|
300
|
+
private readonly [symbol$4];
|
301
301
|
constructor({ message, }?: {
|
302
302
|
message?: string;
|
303
303
|
});
|
@@ -317,6 +317,34 @@ declare class NoContentGeneratedError extends AISDKError {
|
|
317
317
|
};
|
318
318
|
}
|
319
319
|
|
320
|
+
declare const symbol$3: unique symbol;
|
321
|
+
declare class NoSuchModelError extends AISDKError {
|
322
|
+
private readonly [symbol$3];
|
323
|
+
readonly modelId: string;
|
324
|
+
readonly modelType: 'languageModel' | 'textEmbeddingModel';
|
325
|
+
constructor({ errorName, modelId, modelType, message, }: {
|
326
|
+
errorName?: string;
|
327
|
+
modelId: string;
|
328
|
+
modelType: 'languageModel' | 'textEmbeddingModel';
|
329
|
+
message?: string;
|
330
|
+
});
|
331
|
+
static isInstance(error: unknown): error is NoSuchModelError;
|
332
|
+
/**
|
333
|
+
* @deprecated use `isInstance` instead
|
334
|
+
*/
|
335
|
+
static isNoSuchModelError(error: unknown): error is NoSuchModelError;
|
336
|
+
/**
|
337
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
338
|
+
*/
|
339
|
+
toJSON(): {
|
340
|
+
name: string;
|
341
|
+
message: string;
|
342
|
+
stack: string | undefined;
|
343
|
+
modelId: string;
|
344
|
+
modelType: "languageModel" | "textEmbeddingModel";
|
345
|
+
};
|
346
|
+
}
|
347
|
+
|
320
348
|
declare const symbol$2: unique symbol;
|
321
349
|
declare class TooManyEmbeddingValuesForCallError extends AISDKError {
|
322
350
|
private readonly [symbol$2];
|
@@ -631,6 +659,12 @@ interface LanguageModelV1ToolCallPart {
|
|
631
659
|
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
632
660
|
*/
|
633
661
|
args: unknown;
|
662
|
+
/**
|
663
|
+
* Additional provider-specific metadata. They are passed through
|
664
|
+
* to the provider from the AI SDK and enable provider-specific
|
665
|
+
* functionality that can be fully encapsulated in the provider.
|
666
|
+
*/
|
667
|
+
providerMetadata?: LanguageModelV1ProviderMetadata;
|
634
668
|
}
|
635
669
|
/**
|
636
670
|
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
@@ -729,6 +763,12 @@ Specifies how the tool should be selected. Defaults to 'auto'.
|
|
729
763
|
the language model interface.
|
730
764
|
*/
|
731
765
|
prompt: LanguageModelV1Prompt;
|
766
|
+
/**
|
767
|
+
* Additional provider-specific metadata. They are passed through
|
768
|
+
* to the provider from the AI SDK and enable provider-specific
|
769
|
+
* functionality that can be fully encapsulated in the provider.
|
770
|
+
*/
|
771
|
+
providerMetadata?: LanguageModelV1ProviderMetadata;
|
732
772
|
};
|
733
773
|
|
734
774
|
/**
|
@@ -832,8 +872,6 @@ type LanguageModelV1 = {
|
|
832
872
|
use further optimizations if this flag is set to `true`.
|
833
873
|
|
834
874
|
Defaults to `false`.
|
835
|
-
|
836
|
-
TODO rename to supportsGrammarGuidedGeneration in v2
|
837
875
|
*/
|
838
876
|
readonly supportsStructuredOutputs?: boolean;
|
839
877
|
/**
|
@@ -880,7 +918,7 @@ type LanguageModelV1 = {
|
|
880
918
|
rawSettings: Record<string, unknown>;
|
881
919
|
};
|
882
920
|
/**
|
883
|
-
Optional
|
921
|
+
Optional response information for telemetry and debugging purposes.
|
884
922
|
*/
|
885
923
|
rawResponse?: {
|
886
924
|
/**
|
@@ -888,6 +926,20 @@ type LanguageModelV1 = {
|
|
888
926
|
*/
|
889
927
|
headers?: Record<string, string>;
|
890
928
|
};
|
929
|
+
response?: {
|
930
|
+
/**
|
931
|
+
ID for the generated response, if the provider sends one.
|
932
|
+
*/
|
933
|
+
id?: string;
|
934
|
+
/**
|
935
|
+
Timestamp for the start of the generated response, if the provider sends one.
|
936
|
+
*/
|
937
|
+
timestamp?: Date;
|
938
|
+
/**
|
939
|
+
The ID of the response model that was used to generate the response, if the provider sends one.
|
940
|
+
*/
|
941
|
+
modelId?: string;
|
942
|
+
};
|
891
943
|
warnings?: LanguageModelV1CallWarning[];
|
892
944
|
/**
|
893
945
|
Additional provider-specific metadata. They are passed through
|
@@ -896,8 +948,10 @@ type LanguageModelV1 = {
|
|
896
948
|
*/
|
897
949
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
898
950
|
/**
|
899
|
-
|
900
|
-
|
951
|
+
Logprobs for the completion.
|
952
|
+
`undefined` if the mode does not support logprobs or if was not enabled
|
953
|
+
|
954
|
+
@deprecated will be changed into a provider-specific extension in v2
|
901
955
|
*/
|
902
956
|
logprobs?: LanguageModelV1LogProbs;
|
903
957
|
}>;
|
@@ -949,19 +1003,51 @@ type LanguageModelV1StreamPart = {
|
|
949
1003
|
toolCallId: string;
|
950
1004
|
toolName: string;
|
951
1005
|
argsTextDelta: string;
|
1006
|
+
} | {
|
1007
|
+
type: 'response-metadata';
|
1008
|
+
id?: string;
|
1009
|
+
timestamp?: Date;
|
1010
|
+
modelId?: string;
|
952
1011
|
} | {
|
953
1012
|
type: 'finish';
|
954
1013
|
finishReason: LanguageModelV1FinishReason;
|
955
|
-
logprobs?: LanguageModelV1LogProbs;
|
956
1014
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
957
1015
|
usage: {
|
958
1016
|
promptTokens: number;
|
959
1017
|
completionTokens: number;
|
960
1018
|
};
|
1019
|
+
logprobs?: LanguageModelV1LogProbs;
|
961
1020
|
} | {
|
962
1021
|
type: 'error';
|
963
1022
|
error: unknown;
|
964
1023
|
};
|
965
|
-
type LanguageModelV1ResponseMetadata = {};
|
966
1024
|
|
967
|
-
|
1025
|
+
/**
|
1026
|
+
* Provider for language and text embedding models.
|
1027
|
+
*/
|
1028
|
+
interface ProviderV1 {
|
1029
|
+
/**
|
1030
|
+
Returns the language model with the given id.
|
1031
|
+
The model id is then passed to the provider function to get the model.
|
1032
|
+
|
1033
|
+
@param {string} id - The id of the model to return.
|
1034
|
+
|
1035
|
+
@returns {LanguageModel} The language model associated with the id
|
1036
|
+
|
1037
|
+
@throws {NoSuchModelError} If no such model exists.
|
1038
|
+
*/
|
1039
|
+
languageModel(modelId: string): LanguageModelV1;
|
1040
|
+
/**
|
1041
|
+
Returns the text embedding model with the given id.
|
1042
|
+
The model id is then passed to the provider function to get the model.
|
1043
|
+
|
1044
|
+
@param {string} id - The id of the model to return.
|
1045
|
+
|
1046
|
+
@returns {LanguageModel} The language model associated with the id
|
1047
|
+
|
1048
|
+
@throws {NoSuchModelError} If no such model exists.
|
1049
|
+
*/
|
1050
|
+
textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
|
1051
|
+
}
|
1052
|
+
|
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 };
|