ai 3.2.11 → 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/dist/index.mjs
CHANGED
@@ -80,14 +80,12 @@ async function embed({
|
|
80
80
|
model,
|
81
81
|
value,
|
82
82
|
maxRetries,
|
83
|
-
abortSignal
|
83
|
+
abortSignal,
|
84
|
+
headers
|
84
85
|
}) {
|
85
86
|
const retry = retryWithExponentialBackoff({ maxRetries });
|
86
87
|
const modelResponse = await retry(
|
87
|
-
() => model.doEmbed({
|
88
|
-
values: [value],
|
89
|
-
abortSignal
|
90
|
-
})
|
88
|
+
() => model.doEmbed({ values: [value], abortSignal, headers })
|
91
89
|
);
|
92
90
|
return new EmbedResult({
|
93
91
|
value,
|
@@ -120,13 +118,14 @@ async function embedMany({
|
|
120
118
|
model,
|
121
119
|
values,
|
122
120
|
maxRetries,
|
123
|
-
abortSignal
|
121
|
+
abortSignal,
|
122
|
+
headers
|
124
123
|
}) {
|
125
124
|
const retry = retryWithExponentialBackoff({ maxRetries });
|
126
125
|
const maxEmbeddingsPerCall = model.maxEmbeddingsPerCall;
|
127
126
|
if (maxEmbeddingsPerCall == null) {
|
128
127
|
const modelResponse = await retry(
|
129
|
-
() => model.doEmbed({ values, abortSignal })
|
128
|
+
() => model.doEmbed({ values, abortSignal, headers })
|
130
129
|
);
|
131
130
|
return new EmbedManyResult({
|
132
131
|
values,
|
@@ -137,7 +136,7 @@ async function embedMany({
|
|
137
136
|
const embeddings = [];
|
138
137
|
for (const chunk of valueChunks) {
|
139
138
|
const modelResponse = await retry(
|
140
|
-
() => model.doEmbed({ values: chunk, abortSignal })
|
139
|
+
() => model.doEmbed({ values: chunk, abortSignal, headers })
|
141
140
|
);
|
142
141
|
embeddings.push(...modelResponse.embeddings);
|
143
142
|
}
|
@@ -548,6 +547,7 @@ async function generateObject({
|
|
548
547
|
messages,
|
549
548
|
maxRetries,
|
550
549
|
abortSignal,
|
550
|
+
headers,
|
551
551
|
...settings
|
552
552
|
}) {
|
553
553
|
var _a, _b;
|
@@ -575,7 +575,8 @@ async function generateObject({
|
|
575
575
|
...prepareCallSettings(settings),
|
576
576
|
inputFormat: validatedPrompt.type,
|
577
577
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
578
|
-
abortSignal
|
578
|
+
abortSignal,
|
579
|
+
headers
|
579
580
|
});
|
580
581
|
});
|
581
582
|
if (generateResult.text === void 0) {
|
@@ -730,6 +731,7 @@ async function streamObject({
|
|
730
731
|
messages,
|
731
732
|
maxRetries,
|
732
733
|
abortSignal,
|
734
|
+
headers,
|
733
735
|
onFinish,
|
734
736
|
...settings
|
735
737
|
}) {
|
@@ -752,7 +754,8 @@ async function streamObject({
|
|
752
754
|
...prepareCallSettings(settings),
|
753
755
|
inputFormat: validatedPrompt.type,
|
754
756
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
755
|
-
abortSignal
|
757
|
+
abortSignal,
|
758
|
+
headers
|
756
759
|
};
|
757
760
|
transformer = {
|
758
761
|
transform: (chunk, controller) => {
|
@@ -780,7 +783,8 @@ async function streamObject({
|
|
780
783
|
...prepareCallSettings(settings),
|
781
784
|
inputFormat: validatedPrompt.type,
|
782
785
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
783
|
-
abortSignal
|
786
|
+
abortSignal,
|
787
|
+
headers
|
784
788
|
};
|
785
789
|
transformer = {
|
786
790
|
transform: (chunk, controller) => {
|
@@ -816,7 +820,8 @@ async function streamObject({
|
|
816
820
|
...prepareCallSettings(settings),
|
817
821
|
inputFormat: validatedPrompt.type,
|
818
822
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
819
|
-
abortSignal
|
823
|
+
abortSignal,
|
824
|
+
headers
|
820
825
|
};
|
821
826
|
transformer = {
|
822
827
|
transform(chunk, controller) {
|
@@ -1140,6 +1145,7 @@ async function generateText({
|
|
1140
1145
|
messages,
|
1141
1146
|
maxRetries,
|
1142
1147
|
abortSignal,
|
1148
|
+
headers,
|
1143
1149
|
maxAutomaticRoundtrips = 0,
|
1144
1150
|
maxToolRoundtrips = maxAutomaticRoundtrips,
|
1145
1151
|
...settings
|
@@ -1166,7 +1172,8 @@ async function generateText({
|
|
1166
1172
|
// once we have a roundtrip, we need to switch to messages format:
|
1167
1173
|
inputFormat: roundtrips === 0 ? validatedPrompt.type : "messages",
|
1168
1174
|
prompt: promptMessages,
|
1169
|
-
abortSignal
|
1175
|
+
abortSignal,
|
1176
|
+
headers
|
1170
1177
|
});
|
1171
1178
|
});
|
1172
1179
|
currentToolCalls = ((_a = currentModelResponse.toolCalls) != null ? _a : []).map(
|
@@ -1411,6 +1418,7 @@ async function streamText({
|
|
1411
1418
|
messages,
|
1412
1419
|
maxRetries,
|
1413
1420
|
abortSignal,
|
1421
|
+
headers,
|
1414
1422
|
onFinish,
|
1415
1423
|
...settings
|
1416
1424
|
}) {
|
@@ -1425,7 +1433,8 @@ async function streamText({
|
|
1425
1433
|
...prepareCallSettings(settings),
|
1426
1434
|
inputFormat: validatedPrompt.type,
|
1427
1435
|
prompt: convertToLanguageModelPrompt(validatedPrompt),
|
1428
|
-
abortSignal
|
1436
|
+
abortSignal,
|
1437
|
+
headers
|
1429
1438
|
})
|
1430
1439
|
);
|
1431
1440
|
return new StreamTextResult({
|