ai 7.0.104 → 7.0.106
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 +31 -0
- package/dist/index.js +95 -33
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +3 -2
- package/dist/internal/index.js +10 -12
- package/dist/internal/index.js.map +1 -1
- package/docs/03-ai-sdk-core/32-evaluation.mdx +26 -7
- package/docs/03-ai-sdk-core/45-provider-management.mdx +4 -4
- package/docs/07-reference/01-ai-sdk-core/14-evaluate.mdx +9 -9
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +3 -2
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +7 -5
- package/package.json +11 -11
- package/src/batch/batch.ts +1 -0
- package/src/generate-object/generate-object.ts +1 -0
- package/src/generate-object/stream-object.ts +1 -0
- package/src/generate-text/generate-text.ts +1 -0
- package/src/generate-text/invoke-tool-callbacks-from-stream.ts +1 -1
- package/src/generate-text/prune-messages.ts +13 -0
- package/src/generate-text/stream-language-model-call.ts +1 -0
- package/src/generate-text/stream-text.ts +28 -11
- package/src/middleware/extract-json-middleware.ts +35 -9
- package/src/middleware/simulate-streaming-middleware.ts +7 -1
- package/src/model/resolve-model.ts +2 -4
- package/src/prompt/convert-to-language-model-prompt.ts +4 -2
- package/src/prompt/create-tool-model-output.ts +20 -11
- package/src/ui-message-stream/read-ui-message-stream.ts +13 -4
- package/src/util/download/download-function.ts +5 -2
package/dist/internal/index.d.ts
CHANGED
|
@@ -787,7 +787,7 @@ type DownloadFunction = (options: Array<{
|
|
|
787
787
|
* Default download function.
|
|
788
788
|
* Downloads the file if it is not supported by the model.
|
|
789
789
|
*/
|
|
790
|
-
declare const createDefaultDownloadFunction: (download?: typeof download) => DownloadFunction;
|
|
790
|
+
declare const createDefaultDownloadFunction: (download?: typeof download, abortSignal?: AbortSignal) => DownloadFunction;
|
|
791
791
|
|
|
792
792
|
/**
|
|
793
793
|
* A generated file.
|
|
@@ -2550,10 +2550,11 @@ declare global {
|
|
|
2550
2550
|
var AI_SDK_TELEMETRY_INTEGRATIONS: Telemetry[] | undefined;
|
|
2551
2551
|
}
|
|
2552
2552
|
|
|
2553
|
-
declare function convertToLanguageModelPrompt({ prompt, supportedUrls, download, provider, }: {
|
|
2553
|
+
declare function convertToLanguageModelPrompt({ prompt, supportedUrls, download, abortSignal, provider, }: {
|
|
2554
2554
|
prompt: StandardizedPrompt;
|
|
2555
2555
|
supportedUrls: Record<string, RegExp[]>;
|
|
2556
2556
|
download: DownloadFunction | undefined;
|
|
2557
|
+
abortSignal?: AbortSignal;
|
|
2557
2558
|
provider?: string;
|
|
2558
2559
|
}): Promise<LanguageModelV4Prompt>;
|
|
2559
2560
|
/**
|
package/dist/internal/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
} from "@ai-sdk/provider-utils";
|
|
92
92
|
|
|
93
93
|
// src/version.ts
|
|
94
|
-
var VERSION = true ? "7.0.
|
|
94
|
+
var VERSION = true ? "7.0.106" : "0.0.0-test";
|
|
95
95
|
|
|
96
96
|
// src/util/download/download.ts
|
|
97
97
|
var download = async ({
|
|
@@ -138,9 +138,9 @@ var download = async ({
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
// src/util/download/download-function.ts
|
|
141
|
-
var createDefaultDownloadFunction = (download2 = download) => (requestedDownloads) => Promise.all(
|
|
141
|
+
var createDefaultDownloadFunction = (download2 = download, abortSignal) => (requestedDownloads) => Promise.all(
|
|
142
142
|
requestedDownloads.map(
|
|
143
|
-
async (requestedDownload) => requestedDownload.isUrlSupportedByModel ? null : await download2(requestedDownload)
|
|
143
|
+
async (requestedDownload) => requestedDownload.isUrlSupportedByModel ? null : await download2({ ...requestedDownload, abortSignal })
|
|
144
144
|
)
|
|
145
145
|
);
|
|
146
146
|
|
|
@@ -430,14 +430,15 @@ var MissingToolResultsError = class extends (_b3 = AISDKError3, _a3 = symbol3, _
|
|
|
430
430
|
async function convertToLanguageModelPrompt({
|
|
431
431
|
prompt,
|
|
432
432
|
supportedUrls,
|
|
433
|
-
download: download2
|
|
433
|
+
download: download2,
|
|
434
|
+
abortSignal,
|
|
434
435
|
// `provider` is only needed here to convert legacy tool output types via `mapToolResultOutput`.
|
|
435
436
|
// TODO: remove in v8 when "file-id" and "image-file-id" types are removed
|
|
436
437
|
provider
|
|
437
438
|
}) {
|
|
438
439
|
const downloadedAssets = await downloadAssets(
|
|
439
440
|
prompt.messages,
|
|
440
|
-
download2,
|
|
441
|
+
download2 != null ? download2 : createDefaultDownloadFunction(void 0, abortSignal),
|
|
441
442
|
supportedUrls
|
|
442
443
|
);
|
|
443
444
|
const approvalIdToToolCallId = /* @__PURE__ */ new Map();
|
|
@@ -1061,9 +1062,6 @@ function getMediaTypeFromUrl(url, fallbackMediaType = "application/octet-stream"
|
|
|
1061
1062
|
|
|
1062
1063
|
// src/prompt/create-tool-model-output.ts
|
|
1063
1064
|
import { getErrorMessage } from "@ai-sdk/provider";
|
|
1064
|
-
import {
|
|
1065
|
-
parseJSON
|
|
1066
|
-
} from "@ai-sdk/provider-utils";
|
|
1067
1065
|
async function createToolModelOutput({
|
|
1068
1066
|
toolCallId,
|
|
1069
1067
|
input,
|
|
@@ -1074,19 +1072,19 @@ async function createToolModelOutput({
|
|
|
1074
1072
|
if (errorMode === "text") {
|
|
1075
1073
|
return { type: "error-text", value: getErrorMessage(output) };
|
|
1076
1074
|
} else if (errorMode === "json") {
|
|
1077
|
-
return { type: "error-json", value:
|
|
1075
|
+
return { type: "error-json", value: toJSONValue(output) };
|
|
1078
1076
|
}
|
|
1079
1077
|
if (tool == null ? void 0 : tool.toModelOutput) {
|
|
1080
1078
|
return await tool.toModelOutput({ toolCallId, input, output });
|
|
1081
1079
|
}
|
|
1082
|
-
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value:
|
|
1080
|
+
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
|
|
1083
1081
|
}
|
|
1084
|
-
|
|
1082
|
+
function toJSONValue(value) {
|
|
1085
1083
|
if (value === void 0) {
|
|
1086
1084
|
return null;
|
|
1087
1085
|
}
|
|
1088
1086
|
const serialized = JSON.stringify(value);
|
|
1089
|
-
return serialized === void 0 ? null :
|
|
1087
|
+
return serialized === void 0 ? null : JSON.parse(serialized);
|
|
1090
1088
|
}
|
|
1091
1089
|
|
|
1092
1090
|
// src/prompt/prepare-tool-choice.ts
|