ai 3.1.15 → 3.1.16
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 +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +31 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/rsc/dist/index.d.ts +18 -1
- package/rsc/dist/rsc-server.d.mts +18 -1
- package/rsc/dist/rsc-server.mjs +29 -6
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/dist/index.mjs
CHANGED
@@ -1168,6 +1168,33 @@ var StreamObjectResult = class {
|
|
1168
1168
|
};
|
1169
1169
|
var experimental_streamObject = streamObject;
|
1170
1170
|
|
1171
|
+
// core/util/is-non-empty-object.ts
|
1172
|
+
function isNonEmptyObject(object) {
|
1173
|
+
return object != null && Object.keys(object).length > 0;
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
// core/prompt/prepare-tools-and-tool-choice.ts
|
1177
|
+
function prepareToolsAndToolChoice({
|
1178
|
+
tools,
|
1179
|
+
toolChoice
|
1180
|
+
}) {
|
1181
|
+
if (!isNonEmptyObject(tools)) {
|
1182
|
+
return {
|
1183
|
+
tools: void 0,
|
1184
|
+
toolChoice: void 0
|
1185
|
+
};
|
1186
|
+
}
|
1187
|
+
return {
|
1188
|
+
tools: Object.entries(tools).map(([name, tool2]) => ({
|
1189
|
+
type: "function",
|
1190
|
+
name,
|
1191
|
+
description: tool2.description,
|
1192
|
+
parameters: convertZodToJSONSchema(tool2.parameters)
|
1193
|
+
})),
|
1194
|
+
toolChoice: toolChoice == null ? { type: "auto" } : typeof toolChoice === "string" ? { type: toolChoice } : { type: "tool", toolName: toolChoice.toolName }
|
1195
|
+
};
|
1196
|
+
}
|
1197
|
+
|
1171
1198
|
// core/generate-text/tool-call.ts
|
1172
1199
|
import {
|
1173
1200
|
InvalidToolArgumentsError,
|
@@ -1212,6 +1239,7 @@ function parseToolCall({
|
|
1212
1239
|
async function generateText({
|
1213
1240
|
model,
|
1214
1241
|
tools,
|
1242
|
+
toolChoice,
|
1215
1243
|
system,
|
1216
1244
|
prompt,
|
1217
1245
|
messages,
|
@@ -1226,12 +1254,7 @@ async function generateText({
|
|
1226
1254
|
return model.doGenerate({
|
1227
1255
|
mode: {
|
1228
1256
|
type: "regular",
|
1229
|
-
|
1230
|
-
type: "function",
|
1231
|
-
name,
|
1232
|
-
description: tool2.description,
|
1233
|
-
parameters: convertZodToJSONSchema(tool2.parameters)
|
1234
|
-
}))
|
1257
|
+
...prepareToolsAndToolChoice({ tools, toolChoice })
|
1235
1258
|
},
|
1236
1259
|
...prepareCallSettings(settings),
|
1237
1260
|
inputFormat: validatedPrompt.type,
|
@@ -1444,6 +1467,7 @@ function runToolsTransformation({
|
|
1444
1467
|
async function streamText({
|
1445
1468
|
model,
|
1446
1469
|
tools,
|
1470
|
+
toolChoice,
|
1447
1471
|
system,
|
1448
1472
|
prompt,
|
1449
1473
|
messages,
|
@@ -1458,12 +1482,7 @@ async function streamText({
|
|
1458
1482
|
() => model.doStream({
|
1459
1483
|
mode: {
|
1460
1484
|
type: "regular",
|
1461
|
-
|
1462
|
-
type: "function",
|
1463
|
-
name,
|
1464
|
-
description: tool2.description,
|
1465
|
-
parameters: convertZodToJSONSchema(tool2.parameters)
|
1466
|
-
}))
|
1485
|
+
...prepareToolsAndToolChoice({ tools, toolChoice })
|
1467
1486
|
},
|
1468
1487
|
...prepareCallSettings(settings),
|
1469
1488
|
inputFormat: validatedPrompt.type,
|