ai 3.2.10 → 3.2.12
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 +27 -6
- package/dist/index.d.ts +27 -6
- package/dist/index.js +23 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/rsc/dist/index.d.ts +6 -1
- package/rsc/dist/rsc-server.d.mts +6 -1
- package/rsc/dist/rsc-server.mjs +3 -1
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/svelte/dist/index.js +11 -6
- package/svelte/dist/index.js.map +1 -1
- package/svelte/dist/index.mjs +11 -6
- package/svelte/dist/index.mjs.map +1 -1
package/dist/index.d.mts
CHANGED
@@ -63,10 +63,11 @@ Embed a value using an embedding model. The type of the value is defined by the
|
|
63
63
|
|
64
64
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
65
65
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
66
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
66
67
|
|
67
68
|
@returns A result object that contains the embedding, the value, and additional information.
|
68
69
|
*/
|
69
|
-
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, }: {
|
70
|
+
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers, }: {
|
70
71
|
/**
|
71
72
|
The embedding model to use.
|
72
73
|
*/
|
@@ -85,6 +86,11 @@ declare function embed<VALUE>({ model, value, maxRetries, abortSignal, }: {
|
|
85
86
|
Abort signal.
|
86
87
|
*/
|
87
88
|
abortSignal?: AbortSignal;
|
89
|
+
/**
|
90
|
+
Additional headers to include in the request.
|
91
|
+
Only applicable for HTTP-based providers.
|
92
|
+
*/
|
93
|
+
headers?: Record<string, string>;
|
88
94
|
}): Promise<EmbedResult<VALUE>>;
|
89
95
|
/**
|
90
96
|
The result of a `embed` call.
|
@@ -129,10 +135,11 @@ has a limit on how many embeddings can be generated in a single call.
|
|
129
135
|
|
130
136
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
131
137
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
138
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
132
139
|
|
133
140
|
@returns A result object that contains the embeddings, the value, and additional information.
|
134
141
|
*/
|
135
|
-
declare function embedMany<VALUE>({ model, values, maxRetries, abortSignal, }: {
|
142
|
+
declare function embedMany<VALUE>({ model, values, maxRetries, abortSignal, headers, }: {
|
136
143
|
/**
|
137
144
|
The embedding model to use.
|
138
145
|
*/
|
@@ -151,6 +158,11 @@ declare function embedMany<VALUE>({ model, values, maxRetries, abortSignal, }: {
|
|
151
158
|
Abort signal.
|
152
159
|
*/
|
153
160
|
abortSignal?: AbortSignal;
|
161
|
+
/**
|
162
|
+
Additional headers to include in the request.
|
163
|
+
Only applicable for HTTP-based providers.
|
164
|
+
*/
|
165
|
+
headers?: Record<string, string>;
|
154
166
|
}): Promise<EmbedManyResult<VALUE>>;
|
155
167
|
/**
|
156
168
|
The result of a `embedMany` call.
|
@@ -247,6 +259,11 @@ type CallSettings = {
|
|
247
259
|
Abort signal.
|
248
260
|
*/
|
249
261
|
abortSignal?: AbortSignal;
|
262
|
+
/**
|
263
|
+
Additional HTTP headers to be sent with the request.
|
264
|
+
Only applicable for HTTP-based providers.
|
265
|
+
*/
|
266
|
+
headers?: Record<string, string | undefined>;
|
250
267
|
};
|
251
268
|
|
252
269
|
/**
|
@@ -452,11 +469,12 @@ If set and supported by the model, calls will generate deterministic results.
|
|
452
469
|
|
453
470
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
454
471
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
472
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
455
473
|
|
456
474
|
@returns
|
457
475
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
458
476
|
*/
|
459
|
-
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, ...settings }: CallSettings & Prompt & {
|
477
|
+
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, ...settings }: CallSettings & Prompt & {
|
460
478
|
/**
|
461
479
|
The language model to use.
|
462
480
|
*/
|
@@ -570,11 +588,12 @@ If set and supported by the model, calls will generate deterministic results.
|
|
570
588
|
|
571
589
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
572
590
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
591
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
573
592
|
|
574
593
|
@return
|
575
594
|
A result object for accessing the partial object stream and additional information.
|
576
595
|
*/
|
577
|
-
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, onFinish, ...settings }: CallSettings & Prompt & {
|
596
|
+
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: CallSettings & Prompt & {
|
578
597
|
/**
|
579
598
|
The language model to use.
|
580
599
|
*/
|
@@ -919,13 +938,14 @@ If set and supported by the model, calls will generate deterministic results.
|
|
919
938
|
|
920
939
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
921
940
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
941
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
922
942
|
|
923
943
|
@param maxToolRoundtrips - Maximal number of automatic roundtrips for tool calls.
|
924
944
|
|
925
945
|
@returns
|
926
946
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
927
947
|
*/
|
928
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, maxAutomaticRoundtrips, maxToolRoundtrips, ...settings }: CallSettings & Prompt & {
|
948
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, ...settings }: CallSettings & Prompt & {
|
929
949
|
/**
|
930
950
|
The language model to use.
|
931
951
|
*/
|
@@ -1056,6 +1076,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1056
1076
|
|
1057
1077
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
1058
1078
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1079
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1059
1080
|
|
1060
1081
|
@param onFinish - Callback that is called when the LLM response and all request tool executions
|
1061
1082
|
(for tools that have an `execute` function) are finished.
|
@@ -1063,7 +1084,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1063
1084
|
@return
|
1064
1085
|
A result object for accessing different stream types and additional information.
|
1065
1086
|
*/
|
1066
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, onFinish, ...settings }: CallSettings & Prompt & {
|
1087
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: CallSettings & Prompt & {
|
1067
1088
|
/**
|
1068
1089
|
The language model to use.
|
1069
1090
|
*/
|
package/dist/index.d.ts
CHANGED
@@ -63,10 +63,11 @@ Embed a value using an embedding model. The type of the value is defined by the
|
|
63
63
|
|
64
64
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
65
65
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
66
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
66
67
|
|
67
68
|
@returns A result object that contains the embedding, the value, and additional information.
|
68
69
|
*/
|
69
|
-
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, }: {
|
70
|
+
declare function embed<VALUE>({ model, value, maxRetries, abortSignal, headers, }: {
|
70
71
|
/**
|
71
72
|
The embedding model to use.
|
72
73
|
*/
|
@@ -85,6 +86,11 @@ declare function embed<VALUE>({ model, value, maxRetries, abortSignal, }: {
|
|
85
86
|
Abort signal.
|
86
87
|
*/
|
87
88
|
abortSignal?: AbortSignal;
|
89
|
+
/**
|
90
|
+
Additional headers to include in the request.
|
91
|
+
Only applicable for HTTP-based providers.
|
92
|
+
*/
|
93
|
+
headers?: Record<string, string>;
|
88
94
|
}): Promise<EmbedResult<VALUE>>;
|
89
95
|
/**
|
90
96
|
The result of a `embed` call.
|
@@ -129,10 +135,11 @@ has a limit on how many embeddings can be generated in a single call.
|
|
129
135
|
|
130
136
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
131
137
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
138
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
132
139
|
|
133
140
|
@returns A result object that contains the embeddings, the value, and additional information.
|
134
141
|
*/
|
135
|
-
declare function embedMany<VALUE>({ model, values, maxRetries, abortSignal, }: {
|
142
|
+
declare function embedMany<VALUE>({ model, values, maxRetries, abortSignal, headers, }: {
|
136
143
|
/**
|
137
144
|
The embedding model to use.
|
138
145
|
*/
|
@@ -151,6 +158,11 @@ declare function embedMany<VALUE>({ model, values, maxRetries, abortSignal, }: {
|
|
151
158
|
Abort signal.
|
152
159
|
*/
|
153
160
|
abortSignal?: AbortSignal;
|
161
|
+
/**
|
162
|
+
Additional headers to include in the request.
|
163
|
+
Only applicable for HTTP-based providers.
|
164
|
+
*/
|
165
|
+
headers?: Record<string, string>;
|
154
166
|
}): Promise<EmbedManyResult<VALUE>>;
|
155
167
|
/**
|
156
168
|
The result of a `embedMany` call.
|
@@ -247,6 +259,11 @@ type CallSettings = {
|
|
247
259
|
Abort signal.
|
248
260
|
*/
|
249
261
|
abortSignal?: AbortSignal;
|
262
|
+
/**
|
263
|
+
Additional HTTP headers to be sent with the request.
|
264
|
+
Only applicable for HTTP-based providers.
|
265
|
+
*/
|
266
|
+
headers?: Record<string, string | undefined>;
|
250
267
|
};
|
251
268
|
|
252
269
|
/**
|
@@ -452,11 +469,12 @@ If set and supported by the model, calls will generate deterministic results.
|
|
452
469
|
|
453
470
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
454
471
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
472
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
455
473
|
|
456
474
|
@returns
|
457
475
|
A result object that contains the generated object, the finish reason, the token usage, and additional information.
|
458
476
|
*/
|
459
|
-
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, ...settings }: CallSettings & Prompt & {
|
477
|
+
declare function generateObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, ...settings }: CallSettings & Prompt & {
|
460
478
|
/**
|
461
479
|
The language model to use.
|
462
480
|
*/
|
@@ -570,11 +588,12 @@ If set and supported by the model, calls will generate deterministic results.
|
|
570
588
|
|
571
589
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
572
590
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
591
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
573
592
|
|
574
593
|
@return
|
575
594
|
A result object for accessing the partial object stream and additional information.
|
576
595
|
*/
|
577
|
-
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, onFinish, ...settings }: CallSettings & Prompt & {
|
596
|
+
declare function streamObject<T>({ model, schema, mode, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: CallSettings & Prompt & {
|
578
597
|
/**
|
579
598
|
The language model to use.
|
580
599
|
*/
|
@@ -919,13 +938,14 @@ If set and supported by the model, calls will generate deterministic results.
|
|
919
938
|
|
920
939
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
921
940
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
941
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
922
942
|
|
923
943
|
@param maxToolRoundtrips - Maximal number of automatic roundtrips for tool calls.
|
924
944
|
|
925
945
|
@returns
|
926
946
|
A result object that contains the generated text, the results of the tool calls, and additional information.
|
927
947
|
*/
|
928
|
-
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, maxAutomaticRoundtrips, maxToolRoundtrips, ...settings }: CallSettings & Prompt & {
|
948
|
+
declare function generateText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, maxAutomaticRoundtrips, maxToolRoundtrips, ...settings }: CallSettings & Prompt & {
|
929
949
|
/**
|
930
950
|
The language model to use.
|
931
951
|
*/
|
@@ -1056,6 +1076,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1056
1076
|
|
1057
1077
|
@param maxRetries - Maximum number of retries. Set to 0 to disable retries. Default: 2.
|
1058
1078
|
@param abortSignal - An optional abort signal that can be used to cancel the call.
|
1079
|
+
@param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
1059
1080
|
|
1060
1081
|
@param onFinish - Callback that is called when the LLM response and all request tool executions
|
1061
1082
|
(for tools that have an `execute` function) are finished.
|
@@ -1063,7 +1084,7 @@ If set and supported by the model, calls will generate deterministic results.
|
|
1063
1084
|
@return
|
1064
1085
|
A result object for accessing different stream types and additional information.
|
1065
1086
|
*/
|
1066
|
-
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, onFinish, ...settings }: CallSettings & Prompt & {
|
1087
|
+
declare function streamText<TOOLS extends Record<string, CoreTool>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, headers, onFinish, ...settings }: CallSettings & Prompt & {
|
1067
1088
|
/**
|
1068
1089
|
The language model to use.
|
1069
1090
|
*/
|
package/dist/index.js
CHANGED
@@ -178,14 +178,12 @@ async function embed({
|
|
178
178
|
model,
|
179
179
|
value,
|
180
180
|
maxRetries,
|
181
|
-
abortSignal
|
181
|
+
abortSignal,
|
182
|
+
headers
|
182
183
|
}) {
|
183
184
|
const retry = retryWithExponentialBackoff({ maxRetries });
|
184
185
|
const modelResponse = await retry(
|
185
|
-
() => model.doEmbed({
|
186
|
-
values: [value],
|
187
|
-
abortSignal
|
188
|
-
})
|
186
|
+
() => model.doEmbed({ values: [value], abortSignal, headers })
|
189
187
|
);
|
190
188
|
return new EmbedResult({
|
191
189
|
value,
|
@@ -218,13 +216,14 @@ async function embedMany({
|
|
218
216
|
model,
|
219
217
|
values,
|
220
218
|
maxRetries,
|
221
|
-
abortSignal
|
219
|
+
abortSignal,
|
220
|
+
headers
|
222
221
|
}) {
|
223
222
|
const retry = retryWithExponentialBackoff({ maxRetries });
|
224
223
|
const maxEmbeddingsPerCall = model.maxEmbeddingsPerCall;
|
225
224
|
if (maxEmbeddingsPerCall == null) {
|
226
225
|
const modelResponse = await retry(
|
227
|
-
() => model.doEmbed({ values, abortSignal })
|
226
|
+
() => model.doEmbed({ values, abortSignal, headers })
|
228
227
|
);
|
229
228
|
return new EmbedManyResult({
|
230
229
|
values,
|
@@ -235,7 +234,7 @@ async function embedMany({
|
|
235
234
|
const embeddings = [];
|
236
235
|
for (const chunk of valueChunks) {
|
237
236
|
const modelResponse = await retry(
|
238
|
-
() => model.doEmbed({ values: chunk, abortSignal })
|
237
|
+
() => model.doEmbed({ values: chunk, abortSignal, headers })
|
239
238
|
);
|
240
239
|
embeddings.push(...modelResponse.embeddings);
|
241
240
|
}
|
@@ -643,6 +642,7 @@ async function generateObject({
|
|
643
642
|
messages,
|
644
643
|
maxRetries,
|
645
644
|
abortSignal,
|
645
|
+
headers,
|
646
646
|
...settings
|
647
647
|
}) {
|
648
648
|
var _a, _b;
|
@@ -670,7 +670,8 @@ async function generateObject({
|
|
670
670
|
...prepareCallSettings(settings),
|
671
671
|
inputFormat: validatedPrompt.type,
|
672
672
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
673
|
-
abortSignal
|
673
|
+
abortSignal,
|
674
|
+
headers
|
674
675
|
});
|
675
676
|
});
|
676
677
|
if (generateResult.text === void 0) {
|
@@ -822,6 +823,7 @@ async function streamObject({
|
|
822
823
|
messages,
|
823
824
|
maxRetries,
|
824
825
|
abortSignal,
|
826
|
+
headers,
|
825
827
|
onFinish,
|
826
828
|
...settings
|
827
829
|
}) {
|
@@ -844,7 +846,8 @@ async function streamObject({
|
|
844
846
|
...prepareCallSettings(settings),
|
845
847
|
inputFormat: validatedPrompt.type,
|
846
848
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
847
|
-
abortSignal
|
849
|
+
abortSignal,
|
850
|
+
headers
|
848
851
|
};
|
849
852
|
transformer = {
|
850
853
|
transform: (chunk, controller) => {
|
@@ -872,7 +875,8 @@ async function streamObject({
|
|
872
875
|
...prepareCallSettings(settings),
|
873
876
|
inputFormat: validatedPrompt.type,
|
874
877
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
875
|
-
abortSignal
|
878
|
+
abortSignal,
|
879
|
+
headers
|
876
880
|
};
|
877
881
|
transformer = {
|
878
882
|
transform: (chunk, controller) => {
|
@@ -908,7 +912,8 @@ async function streamObject({
|
|
908
912
|
...prepareCallSettings(settings),
|
909
913
|
inputFormat: validatedPrompt.type,
|
910
914
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
911
|
-
abortSignal
|
915
|
+
abortSignal,
|
916
|
+
headers
|
912
917
|
};
|
913
918
|
transformer = {
|
914
919
|
transform(chunk, controller) {
|
@@ -1229,6 +1234,7 @@ async function generateText({
|
|
1229
1234
|
messages,
|
1230
1235
|
maxRetries,
|
1231
1236
|
abortSignal,
|
1237
|
+
headers,
|
1232
1238
|
maxAutomaticRoundtrips = 0,
|
1233
1239
|
maxToolRoundtrips = maxAutomaticRoundtrips,
|
1234
1240
|
...settings
|
@@ -1255,7 +1261,8 @@ async function generateText({
|
|
1255
1261
|
// once we have a roundtrip, we need to switch to messages format:
|
1256
1262
|
inputFormat: roundtrips === 0 ? validatedPrompt.type : "messages",
|
1257
1263
|
prompt: promptMessages,
|
1258
|
-
abortSignal
|
1264
|
+
abortSignal,
|
1265
|
+
headers
|
1259
1266
|
});
|
1260
1267
|
});
|
1261
1268
|
currentToolCalls = ((_a = currentModelResponse.toolCalls) != null ? _a : []).map(
|
@@ -1500,6 +1507,7 @@ async function streamText({
|
|
1500
1507
|
messages,
|
1501
1508
|
maxRetries,
|
1502
1509
|
abortSignal,
|
1510
|
+
headers,
|
1503
1511
|
onFinish,
|
1504
1512
|
...settings
|
1505
1513
|
}) {
|
@@ -1514,7 +1522,8 @@ async function streamText({
|
|
1514
1522
|
...prepareCallSettings(settings),
|
1515
1523
|
inputFormat: validatedPrompt.type,
|
1516
1524
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
1517
|
-
abortSignal
|
1525
|
+
abortSignal,
|
1526
|
+
headers
|
1518
1527
|
})
|
1519
1528
|
);
|
1520
1529
|
return new StreamTextResult({
|