ai 4.1.48 → 4.1.50
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 +12 -0
- package/dist/index.js +71 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/rsc/dist/rsc-server.mjs +5 -5
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 4.1.50
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- ae98f0d: fix (ai/core): forward providerOptions for text, image, and file parts
|
8
|
+
|
9
|
+
## 4.1.49
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- dc027d3: fix (ai/core): add reasoning support to appendResponseMessages
|
14
|
+
|
3
15
|
## 4.1.48
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
@@ -1326,12 +1326,12 @@ async function downloadAssets(messages, downloadImplementation, modelSupportsIma
|
|
1326
1326
|
);
|
1327
1327
|
}
|
1328
1328
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
1329
|
-
var _a16;
|
1329
|
+
var _a16, _b, _c, _d;
|
1330
1330
|
if (part.type === "text") {
|
1331
1331
|
return {
|
1332
1332
|
type: "text",
|
1333
1333
|
text: part.text,
|
1334
|
-
providerMetadata: part.experimental_providerMetadata
|
1334
|
+
providerMetadata: (_a16 = part.providerOptions) != null ? _a16 : part.experimental_providerMetadata
|
1335
1335
|
};
|
1336
1336
|
}
|
1337
1337
|
let mimeType = part.mimeType;
|
@@ -1379,13 +1379,13 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1379
1379
|
switch (type) {
|
1380
1380
|
case "image": {
|
1381
1381
|
if (normalizedData instanceof Uint8Array) {
|
1382
|
-
mimeType = (
|
1382
|
+
mimeType = (_b = detectImageMimeType(normalizedData)) != null ? _b : mimeType;
|
1383
1383
|
}
|
1384
1384
|
return {
|
1385
1385
|
type: "image",
|
1386
1386
|
image: normalizedData,
|
1387
1387
|
mimeType,
|
1388
|
-
providerMetadata: part.experimental_providerMetadata
|
1388
|
+
providerMetadata: (_c = part.providerOptions) != null ? _c : part.experimental_providerMetadata
|
1389
1389
|
};
|
1390
1390
|
}
|
1391
1391
|
case "file": {
|
@@ -1396,7 +1396,7 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1396
1396
|
type: "file",
|
1397
1397
|
data: normalizedData instanceof Uint8Array ? convertDataContentToBase64String(normalizedData) : normalizedData,
|
1398
1398
|
mimeType,
|
1399
|
-
providerMetadata: part.experimental_providerMetadata
|
1399
|
+
providerMetadata: (_d = part.providerOptions) != null ? _d : part.experimental_providerMetadata
|
1400
1400
|
};
|
1401
1401
|
}
|
1402
1402
|
}
|
@@ -6180,7 +6180,7 @@ function appendResponseMessages({
|
|
6180
6180
|
const lastMessage = clonedMessages[clonedMessages.length - 1];
|
6181
6181
|
const isLastMessageAssistant = lastMessage.role === "assistant";
|
6182
6182
|
switch (role) {
|
6183
|
-
case "assistant":
|
6183
|
+
case "assistant": {
|
6184
6184
|
let getToolInvocations2 = function(step) {
|
6185
6185
|
return (typeof message.content === "string" ? [] : message.content.filter((part) => part.type === "tool-call")).map((call) => ({
|
6186
6186
|
state: "call",
|
@@ -6191,19 +6191,74 @@ function appendResponseMessages({
|
|
6191
6191
|
}));
|
6192
6192
|
};
|
6193
6193
|
var getToolInvocations = getToolInvocations2;
|
6194
|
-
const
|
6194
|
+
const parts = [];
|
6195
|
+
let textContent = "";
|
6196
|
+
let reasoningTextContent = void 0;
|
6197
|
+
if (typeof message.content === "string") {
|
6198
|
+
textContent = message.content;
|
6199
|
+
parts.push({
|
6200
|
+
type: "text",
|
6201
|
+
text: message.content
|
6202
|
+
});
|
6203
|
+
} else {
|
6204
|
+
let reasoningPart = void 0;
|
6205
|
+
for (const part of message.content) {
|
6206
|
+
switch (part.type) {
|
6207
|
+
case "text": {
|
6208
|
+
reasoningPart = void 0;
|
6209
|
+
textContent += part.text;
|
6210
|
+
parts.push({
|
6211
|
+
type: "text",
|
6212
|
+
text: part.text
|
6213
|
+
});
|
6214
|
+
break;
|
6215
|
+
}
|
6216
|
+
case "reasoning": {
|
6217
|
+
if (reasoningPart == null) {
|
6218
|
+
reasoningPart = {
|
6219
|
+
type: "reasoning",
|
6220
|
+
reasoning: "",
|
6221
|
+
details: []
|
6222
|
+
};
|
6223
|
+
parts.push(reasoningPart);
|
6224
|
+
}
|
6225
|
+
reasoningTextContent = (reasoningTextContent != null ? reasoningTextContent : "") + part.text;
|
6226
|
+
reasoningPart.reasoning += part.text;
|
6227
|
+
reasoningPart.details.push({
|
6228
|
+
type: "text",
|
6229
|
+
text: part.text,
|
6230
|
+
signature: part.signature
|
6231
|
+
});
|
6232
|
+
break;
|
6233
|
+
}
|
6234
|
+
case "redacted-reasoning": {
|
6235
|
+
if (reasoningPart == null) {
|
6236
|
+
reasoningPart = {
|
6237
|
+
type: "reasoning",
|
6238
|
+
reasoning: "",
|
6239
|
+
details: []
|
6240
|
+
};
|
6241
|
+
parts.push(reasoningPart);
|
6242
|
+
}
|
6243
|
+
reasoningPart.details.push({
|
6244
|
+
type: "redacted",
|
6245
|
+
data: part.data
|
6246
|
+
});
|
6247
|
+
break;
|
6248
|
+
}
|
6249
|
+
case "tool-call":
|
6250
|
+
break;
|
6251
|
+
}
|
6252
|
+
}
|
6253
|
+
}
|
6195
6254
|
if (isLastMessageAssistant) {
|
6196
6255
|
const maxStep = (0, import_ui_utils9.extractMaxToolInvocationStep)(
|
6197
6256
|
lastMessage.toolInvocations
|
6198
6257
|
);
|
6199
6258
|
(_a16 = lastMessage.parts) != null ? _a16 : lastMessage.parts = [];
|
6200
6259
|
lastMessage.content = textContent;
|
6201
|
-
|
6202
|
-
|
6203
|
-
type: "text",
|
6204
|
-
text: textContent
|
6205
|
-
});
|
6206
|
-
}
|
6260
|
+
lastMessage.reasoning = reasoningTextContent;
|
6261
|
+
lastMessage.parts.push(...parts);
|
6207
6262
|
lastMessage.toolInvocations = [
|
6208
6263
|
...(_b = lastMessage.toolInvocations) != null ? _b : [],
|
6209
6264
|
...getToolInvocations2(maxStep === void 0 ? 0 : maxStep + 1)
|
@@ -6221,9 +6276,10 @@ function appendResponseMessages({
|
|
6221
6276
|
createdAt: currentDate(),
|
6222
6277
|
// generate a createdAt date for the message, will be overridden by the client
|
6223
6278
|
content: textContent,
|
6279
|
+
reasoning: reasoningTextContent,
|
6224
6280
|
toolInvocations: getToolInvocations2(0),
|
6225
6281
|
parts: [
|
6226
|
-
...
|
6282
|
+
...parts,
|
6227
6283
|
...getToolInvocations2(0).map((call) => ({
|
6228
6284
|
type: "tool-invocation",
|
6229
6285
|
toolInvocation: call
|
@@ -6232,6 +6288,7 @@ function appendResponseMessages({
|
|
6232
6288
|
});
|
6233
6289
|
}
|
6234
6290
|
break;
|
6291
|
+
}
|
6235
6292
|
case "tool": {
|
6236
6293
|
(_c = lastMessage.toolInvocations) != null ? _c : lastMessage.toolInvocations = [];
|
6237
6294
|
if (lastMessage.role !== "assistant") {
|