ai 7.0.31 → 7.0.33
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 +23 -0
- package/dist/index.d.ts +3 -150
- package/dist/index.js +164 -120
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +45 -1
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +10 -2
- package/docs/03-ai-sdk-harnesses/03-tools.mdx +40 -0
- package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +1 -1
- package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/32-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/33-safe-validate-ui-messages.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/71-has-tool-call.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +1 -1
- package/docs/09-troubleshooting/05-tool-invocation-missing-result.mdx +1 -1
- package/docs/09-troubleshooting/13-repeated-assistant-messages.mdx +2 -2
- package/package.json +3 -3
- package/src/generate-text/generate-text.ts +4 -0
- package/src/prompt/convert-to-language-model-prompt.ts +13 -0
- package/src/ui/chat.ts +2 -2
- package/src/ui/process-ui-message-stream.ts +109 -61
- package/src/ui-message-stream/ui-message-chunks.ts +29 -29
package/dist/internal/index.js
CHANGED
|
@@ -85,7 +85,7 @@ import {
|
|
|
85
85
|
} from "@ai-sdk/provider-utils";
|
|
86
86
|
|
|
87
87
|
// src/version.ts
|
|
88
|
-
var VERSION = true ? "7.0.
|
|
88
|
+
var VERSION = true ? "7.0.33" : "0.0.0-test";
|
|
89
89
|
|
|
90
90
|
// src/util/download/download.ts
|
|
91
91
|
var download = async ({
|
|
@@ -138,6 +138,42 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
|
|
|
138
138
|
)
|
|
139
139
|
);
|
|
140
140
|
|
|
141
|
+
// src/util/merge-objects.ts
|
|
142
|
+
function mergeObjects(base, overrides) {
|
|
143
|
+
if (base === void 0 && overrides === void 0) {
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
if (base === void 0) {
|
|
147
|
+
return overrides;
|
|
148
|
+
}
|
|
149
|
+
if (overrides === void 0) {
|
|
150
|
+
return base;
|
|
151
|
+
}
|
|
152
|
+
const result = { ...base };
|
|
153
|
+
for (const key in overrides) {
|
|
154
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (Object.prototype.hasOwnProperty.call(overrides, key)) {
|
|
158
|
+
const overridesValue = overrides[key];
|
|
159
|
+
if (overridesValue === void 0)
|
|
160
|
+
continue;
|
|
161
|
+
const baseValue = key in base ? base[key] : void 0;
|
|
162
|
+
const isSourceObject = overridesValue !== null && typeof overridesValue === "object" && !Array.isArray(overridesValue) && !(overridesValue instanceof Date) && !(overridesValue instanceof RegExp);
|
|
163
|
+
const isTargetObject = baseValue !== null && baseValue !== void 0 && typeof baseValue === "object" && !Array.isArray(baseValue) && !(baseValue instanceof Date) && !(baseValue instanceof RegExp);
|
|
164
|
+
if (isSourceObject && isTargetObject) {
|
|
165
|
+
result[key] = mergeObjects(
|
|
166
|
+
baseValue,
|
|
167
|
+
overridesValue
|
|
168
|
+
);
|
|
169
|
+
} else {
|
|
170
|
+
result[key] = overridesValue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
|
|
141
177
|
// src/prompt/file-part-data.ts
|
|
142
178
|
import {
|
|
143
179
|
isBuffer,
|
|
@@ -437,7 +473,15 @@ async function convertToLanguageModelPrompt({
|
|
|
437
473
|
}
|
|
438
474
|
const lastCombinedMessage = combinedMessages.at(-1);
|
|
439
475
|
if ((lastCombinedMessage == null ? void 0 : lastCombinedMessage.role) === "tool") {
|
|
476
|
+
const lastContentPart = lastCombinedMessage.content.at(-1);
|
|
477
|
+
if (lastContentPart != null && lastCombinedMessage.providerOptions != null) {
|
|
478
|
+
lastContentPart.providerOptions = mergeObjects(
|
|
479
|
+
lastCombinedMessage.providerOptions,
|
|
480
|
+
lastContentPart.providerOptions
|
|
481
|
+
);
|
|
482
|
+
}
|
|
440
483
|
lastCombinedMessage.content.push(...message.content);
|
|
484
|
+
lastCombinedMessage.providerOptions = message.providerOptions;
|
|
441
485
|
} else {
|
|
442
486
|
combinedMessages.push(message);
|
|
443
487
|
}
|