ai 3.1.15 → 3.1.17
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 +64 -5
- package/dist/index.d.ts +64 -5
- package/dist/index.js +40 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/prompts/dist/index.d.mts +14 -2
- package/prompts/dist/index.d.ts +14 -2
- package/react/dist/index.d.mts +42 -3
- package/react/dist/index.d.ts +42 -3
- package/react/dist/index.js +16 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +16 -1
- package/react/dist/index.mjs.map +1 -1
- package/rsc/dist/index.d.ts +20 -3
- package/rsc/dist/rsc-server.d.mts +20 -3
- package/rsc/dist/rsc-server.mjs +29 -6
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/solid/dist/index.d.mts +41 -2
- package/solid/dist/index.d.ts +41 -2
- package/solid/dist/index.js +11 -0
- package/solid/dist/index.js.map +1 -1
- package/solid/dist/index.mjs +11 -0
- package/solid/dist/index.mjs.map +1 -1
- package/svelte/dist/index.d.mts +41 -2
- package/svelte/dist/index.d.ts +41 -2
- package/svelte/dist/index.js +11 -0
- package/svelte/dist/index.js.map +1 -1
- package/svelte/dist/index.mjs +11 -0
- package/svelte/dist/index.mjs.map +1 -1
- package/vue/dist/index.d.mts +41 -2
- package/vue/dist/index.d.ts +41 -2
- package/vue/dist/index.js +11 -0
- package/vue/dist/index.js.map +1 -1
- package/vue/dist/index.mjs +11 -0
- package/vue/dist/index.mjs.map +1 -1
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -500,6 +500,33 @@ function convertZodToJSONSchema(zodSchema) {
|
|
500
500
|
return zodToJsonSchema(zodSchema);
|
501
501
|
}
|
502
502
|
|
503
|
+
// core/util/is-non-empty-object.ts
|
504
|
+
function isNonEmptyObject(object) {
|
505
|
+
return object != null && Object.keys(object).length > 0;
|
506
|
+
}
|
507
|
+
|
508
|
+
// core/prompt/prepare-tools-and-tool-choice.ts
|
509
|
+
function prepareToolsAndToolChoice({
|
510
|
+
tools,
|
511
|
+
toolChoice
|
512
|
+
}) {
|
513
|
+
if (!isNonEmptyObject(tools)) {
|
514
|
+
return {
|
515
|
+
tools: void 0,
|
516
|
+
toolChoice: void 0
|
517
|
+
};
|
518
|
+
}
|
519
|
+
return {
|
520
|
+
tools: Object.entries(tools).map(([name, tool]) => ({
|
521
|
+
type: "function",
|
522
|
+
name,
|
523
|
+
description: tool.description,
|
524
|
+
parameters: convertZodToJSONSchema(tool.parameters)
|
525
|
+
})),
|
526
|
+
toolChoice: toolChoice == null ? { type: "auto" } : typeof toolChoice === "string" ? { type: toolChoice } : { type: "tool", toolName: toolChoice.toolName }
|
527
|
+
};
|
528
|
+
}
|
529
|
+
|
503
530
|
// shared/stream-parts.ts
|
504
531
|
var textStreamPart = {
|
505
532
|
code: "0",
|
@@ -1641,6 +1668,7 @@ var defaultTextRenderer = ({ content }) => content;
|
|
1641
1668
|
async function streamUI({
|
1642
1669
|
model,
|
1643
1670
|
tools,
|
1671
|
+
toolChoice,
|
1644
1672
|
system,
|
1645
1673
|
prompt,
|
1646
1674
|
messages,
|
@@ -1720,12 +1748,7 @@ async function streamUI({
|
|
1720
1748
|
() => model.doStream({
|
1721
1749
|
mode: {
|
1722
1750
|
type: "regular",
|
1723
|
-
|
1724
|
-
type: "function",
|
1725
|
-
name,
|
1726
|
-
description: tool.description,
|
1727
|
-
parameters: convertZodToJSONSchema(tool.parameters)
|
1728
|
-
}))
|
1751
|
+
...prepareToolsAndToolChoice({ tools, toolChoice })
|
1729
1752
|
},
|
1730
1753
|
...prepareCallSettings(settings),
|
1731
1754
|
inputFormat: validatedPrompt.type,
|