ai 6.0.14 → 6.0.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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +27 -7
- package/dist/index.d.ts +27 -7
- package/dist/index.js +37 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +11 -1
- package/dist/internal/index.d.ts +11 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -700,6 +700,17 @@ function getGlobalProvider() {
|
|
|
700
700
|
return (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : gateway;
|
|
701
701
|
}
|
|
702
702
|
|
|
703
|
+
// src/prompt/call-settings.ts
|
|
704
|
+
function getTotalTimeoutMs(timeout) {
|
|
705
|
+
if (timeout == null) {
|
|
706
|
+
return void 0;
|
|
707
|
+
}
|
|
708
|
+
if (typeof timeout === "number") {
|
|
709
|
+
return timeout;
|
|
710
|
+
}
|
|
711
|
+
return timeout.totalMs;
|
|
712
|
+
}
|
|
713
|
+
|
|
703
714
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
704
715
|
import {
|
|
705
716
|
isUrlSupported
|
|
@@ -898,7 +909,7 @@ import {
|
|
|
898
909
|
} from "@ai-sdk/provider-utils";
|
|
899
910
|
|
|
900
911
|
// src/version.ts
|
|
901
|
-
var VERSION = true ? "6.0.
|
|
912
|
+
var VERSION = true ? "6.0.16" : "0.0.0-test";
|
|
902
913
|
|
|
903
914
|
// src/util/download/download.ts
|
|
904
915
|
var download = async ({ url }) => {
|
|
@@ -1829,7 +1840,16 @@ function getBaseTelemetryAttributes({
|
|
|
1829
1840
|
"ai.model.id": model.modelId,
|
|
1830
1841
|
// settings:
|
|
1831
1842
|
...Object.entries(settings).reduce((attributes, [key, value]) => {
|
|
1832
|
-
|
|
1843
|
+
if (key === "timeout") {
|
|
1844
|
+
const totalTimeoutMs = getTotalTimeoutMs(
|
|
1845
|
+
value
|
|
1846
|
+
);
|
|
1847
|
+
if (totalTimeoutMs != null) {
|
|
1848
|
+
attributes[`ai.settings.${key}`] = totalTimeoutMs;
|
|
1849
|
+
}
|
|
1850
|
+
} else {
|
|
1851
|
+
attributes[`ai.settings.${key}`] = value;
|
|
1852
|
+
}
|
|
1833
1853
|
return attributes;
|
|
1834
1854
|
}, {}),
|
|
1835
1855
|
// add metadata as attributes:
|
|
@@ -3564,9 +3584,10 @@ async function generateText({
|
|
|
3564
3584
|
}) {
|
|
3565
3585
|
const model = resolveLanguageModel(modelArg);
|
|
3566
3586
|
const stopConditions = asArray(stopWhen);
|
|
3587
|
+
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
3567
3588
|
const mergedAbortSignal = mergeAbortSignals(
|
|
3568
3589
|
abortSignal,
|
|
3569
|
-
|
|
3590
|
+
totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0
|
|
3570
3591
|
);
|
|
3571
3592
|
const { maxRetries, retry } = prepareRetries({
|
|
3572
3593
|
maxRetries: maxRetriesArg,
|
|
@@ -4575,7 +4596,8 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
4575
4596
|
messageMetadata: z7.unknown().optional()
|
|
4576
4597
|
}),
|
|
4577
4598
|
z7.strictObject({
|
|
4578
|
-
type: z7.literal("abort")
|
|
4599
|
+
type: z7.literal("abort"),
|
|
4600
|
+
reason: z7.string().optional()
|
|
4579
4601
|
}),
|
|
4580
4602
|
z7.strictObject({
|
|
4581
4603
|
type: z7.literal("message-metadata"),
|
|
@@ -5660,6 +5682,7 @@ function streamText({
|
|
|
5660
5682
|
} = {},
|
|
5661
5683
|
...settings
|
|
5662
5684
|
}) {
|
|
5685
|
+
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
5663
5686
|
return new DefaultStreamTextResult({
|
|
5664
5687
|
model: resolveLanguageModel(model),
|
|
5665
5688
|
telemetry,
|
|
@@ -5668,7 +5691,7 @@ function streamText({
|
|
|
5668
5691
|
maxRetries,
|
|
5669
5692
|
abortSignal: mergeAbortSignals(
|
|
5670
5693
|
abortSignal,
|
|
5671
|
-
|
|
5694
|
+
totalTimeoutMs != null ? AbortSignal.timeout(totalTimeoutMs) : void 0
|
|
5672
5695
|
),
|
|
5673
5696
|
system,
|
|
5674
5697
|
prompt,
|
|
@@ -6039,7 +6062,13 @@ var DefaultStreamTextResult = class {
|
|
|
6039
6062
|
async pull(controller) {
|
|
6040
6063
|
function abort() {
|
|
6041
6064
|
onAbort == null ? void 0 : onAbort({ steps: recordedSteps });
|
|
6042
|
-
controller.enqueue({
|
|
6065
|
+
controller.enqueue({
|
|
6066
|
+
type: "abort",
|
|
6067
|
+
// The `reason` is usually of type DOMException, but it can also be of any type,
|
|
6068
|
+
// so we use getErrorMessage for serialization because it is already designed to accept values of the unknown type.
|
|
6069
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/reason
|
|
6070
|
+
...(abortSignal == null ? void 0 : abortSignal.reason) !== void 0 ? { reason: getErrorMessage7(abortSignal.reason) } : {}
|
|
6071
|
+
});
|
|
6043
6072
|
controller.close();
|
|
6044
6073
|
}
|
|
6045
6074
|
try {
|
|
@@ -12061,6 +12090,7 @@ export {
|
|
|
12061
12090
|
getTextFromDataUrl,
|
|
12062
12091
|
getToolName,
|
|
12063
12092
|
getToolOrDynamicToolName,
|
|
12093
|
+
getTotalTimeoutMs,
|
|
12064
12094
|
hasToolCall,
|
|
12065
12095
|
isDataUIPart,
|
|
12066
12096
|
isDeepEqualData,
|