ai 7.0.177 → 7.0.179
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 +33 -0
- package/dist/default-stop-condition-wtuJTiTo.js +4213 -0
- package/dist/default-stop-condition-wtuJTiTo.js.map +1 -0
- package/dist/index-CM_8u8gB.d.ts +12107 -0
- package/dist/index-CM_8u8gB.d.ts.map +1 -0
- package/dist/index.d.ts +3 -11788
- package/dist/index.js +680 -4732
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +4 -3301
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +2 -3819
- package/dist/simulate-readable-stream-Bi5kQKbv.js +25 -0
- package/dist/simulate-readable-stream-Bi5kQKbv.js.map +1 -0
- package/dist/simulate-readable-stream-BuwR4IbD.d.ts +21 -0
- package/dist/simulate-readable-stream-BuwR4IbD.d.ts.map +1 -0
- package/dist/test/index.d.ts +2 -20
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +3 -23
- package/dist/test/index.js.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/03-agents/06-policy-tool-approvals.mdx +27 -2
- package/docs/03-agents/06-tool-approvals.mdx +2 -1
- package/docs/03-ai-sdk-core/18-tools.mdx +7 -2
- package/docs/03-ai-sdk-core/33-extractions.mdx +21 -4
- package/docs/03-ai-sdk-core/36-realtime.mdx +3 -1
- package/docs/03-ai-sdk-core/36-transcription.mdx +2 -2
- package/docs/03-ai-sdk-core/37-speech.mdx +1 -0
- package/docs/03-ai-sdk-core/60-telemetry.mdx +52 -4
- package/docs/03-ai-sdk-core/65-lifecycle-callbacks.mdx +124 -2
- package/docs/07-reference/01-ai-sdk-core/14-extract.mdx +13 -4
- package/docs/07-reference/02-ai-sdk-ui/05-use-realtime.mdx +6 -2
- package/docs/07-reference/05-ai-sdk-errors/ai-extraction-refusal-error.mdx +33 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-extraction-unsupported-field-type-error.mdx +36 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-tool-approval-signature-error.mdx +1 -0
- package/package.json +13 -13
- package/src/agent/tool-loop-agent-settings.ts +2 -1
- package/src/extract/extract-events.ts +135 -0
- package/src/extract/extract.ts +177 -74
- package/src/extract/index.ts +6 -0
- package/src/extract/restricted-telemetry-dispatcher.ts +97 -0
- package/src/generate-text/execute-tools-from-stream.ts +14 -8
- package/src/generate-text/generate-text.ts +26 -10
- package/src/generate-text/stream-language-model-call.ts +3 -0
- package/src/generate-text/stream-text.ts +11 -2
- package/src/realtime/browser-realtime-live-websocket.ts +23 -5
- package/src/realtime/realtime-session.ts +68 -29
- package/src/telemetry/create-telemetry-dispatcher.ts +12 -0
- package/src/telemetry/filter-telemetry-event.ts +2 -0
- package/src/telemetry/redact-telemetry-credentials.ts +13 -1
- package/src/telemetry/telemetry.ts +34 -0
- package/src/telemetry/tracing-channel.ts +2 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/internal/index.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { delay } from "@ai-sdk/provider-utils";
|
|
2
|
+
//#region src/util/simulate-readable-stream.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
5
|
+
*
|
|
6
|
+
* @param options - The configuration options
|
|
7
|
+
* @param options.chunks - Array of values to be emitted by the stream
|
|
8
|
+
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
9
|
+
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
10
|
+
* @returns A ReadableStream that emits the provided values
|
|
11
|
+
*/
|
|
12
|
+
function simulateReadableStream({ chunks, initialDelayInMs = 0, chunkDelayInMs = 0, _internal }) {
|
|
13
|
+
const delay$1 = _internal?.delay ?? delay;
|
|
14
|
+
let index = 0;
|
|
15
|
+
return new ReadableStream({ async pull(controller) {
|
|
16
|
+
if (index < chunks.length) {
|
|
17
|
+
await delay$1(index === 0 ? initialDelayInMs : chunkDelayInMs);
|
|
18
|
+
controller.enqueue(chunks[index++]);
|
|
19
|
+
} else controller.close();
|
|
20
|
+
} });
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { simulateReadableStream as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=simulate-readable-stream-Bi5kQKbv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate-readable-stream-Bi5kQKbv.js","names":["delay","delayFunction"],"sources":["../src/util/simulate-readable-stream.ts"],"sourcesContent":["import { delay as delayFunction } from '@ai-sdk/provider-utils';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,uBAA0B,EACxC,QACA,mBAAmB,GACnB,iBAAiB,GACjB,aAQoB;CACpB,MAAMA,UAAQ,WAAW,SAASC;CAElC,IAAI,QAAQ;CAEZ,OAAO,IAAI,eAAe,EACxB,MAAM,KAAK,YAAY;EACrB,IAAI,QAAQ,OAAO,QAAQ;GACzB,MAAMD,QAAM,UAAU,IAAI,mBAAmB,cAAc;GAC3D,WAAW,QAAQ,OAAO,QAAQ;EACpC,OACE,WAAW,MAAM;CAErB,EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/util/simulate-readable-stream.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
4
|
+
*
|
|
5
|
+
* @param options - The configuration options
|
|
6
|
+
* @param options.chunks - Array of values to be emitted by the stream
|
|
7
|
+
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
8
|
+
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
9
|
+
* @returns A ReadableStream that emits the provided values
|
|
10
|
+
*/
|
|
11
|
+
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal }: {
|
|
12
|
+
chunks: T[];
|
|
13
|
+
initialDelayInMs?: number | null;
|
|
14
|
+
chunkDelayInMs?: number | null;
|
|
15
|
+
_internal?: {
|
|
16
|
+
delay?: (ms: number | null) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
}): ReadableStream<T>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { simulateReadableStream as t };
|
|
21
|
+
//# sourceMappingURL=simulate-readable-stream-BuwR4IbD.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulate-readable-stream-BuwR4IbD.d.ts","names":[],"sources":["../src/util/simulate-readable-stream.ts"],"mappings":";;;;;;;;;;iBAWgB,uBAAuB,KACrC,QACA,kBACA,gBACA;EAEA,QAAQ;EACR;EACA;EACA;IACE,SAAS,sBAAsB;;IAE/B,eAAe"}
|
package/dist/test/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { t as simulateReadableStream$1 } from "../simulate-readable-stream-BuwR4IbD.js";
|
|
1
2
|
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from "@ai-sdk/provider-utils";
|
|
2
|
-
import { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from "@ai-sdk/provider-utils/test";
|
|
3
3
|
import { EmbeddingModelV3, EmbeddingModelV4, Experimental_DecisionModelV4, Experimental_ExtractionModelV4, Experimental_SpeechTranslationModelV4, Experimental_StreamingSpeechModelV4, Experimental_VideoModelV3, Experimental_VideoModelV4, ImageModelV3, ImageModelV4, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, ProviderV3, ProviderV4, RerankingModelV3, RerankingModelV4, SpeechModelV3, SpeechModelV4, TranscriptionModelV3, TranscriptionModelV4 } from "@ai-sdk/provider";
|
|
4
|
+
import { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from "@ai-sdk/provider-utils/test";
|
|
4
5
|
//#region src/test/decision-mock-model-v4.d.ts
|
|
5
6
|
declare class DecisionMockModelV4 implements Experimental_DecisionModelV4 {
|
|
6
7
|
readonly specificationVersion = "v4";
|
|
@@ -20,25 +21,6 @@ declare class DecisionMockModelV4 implements Experimental_DecisionModelV4 {
|
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
//#endregion
|
|
23
|
-
//#region src/util/simulate-readable-stream.d.ts
|
|
24
|
-
/**
|
|
25
|
-
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
26
|
-
*
|
|
27
|
-
* @param options - The configuration options
|
|
28
|
-
* @param options.chunks - Array of values to be emitted by the stream
|
|
29
|
-
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
30
|
-
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
31
|
-
* @returns A ReadableStream that emits the provided values
|
|
32
|
-
*/
|
|
33
|
-
declare function simulateReadableStream$1<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal }: {
|
|
34
|
-
chunks: T[];
|
|
35
|
-
initialDelayInMs?: number | null;
|
|
36
|
-
chunkDelayInMs?: number | null;
|
|
37
|
-
_internal?: {
|
|
38
|
-
delay?: (ms: number | null) => Promise<void>;
|
|
39
|
-
};
|
|
40
|
-
}): ReadableStream<T>;
|
|
41
|
-
//#endregion
|
|
42
24
|
//#region src/test/mock-embedding-model-v3.d.ts
|
|
43
25
|
export declare class MockEmbeddingModelV3 implements EmbeddingModelV3 {
|
|
44
26
|
readonly specificationVersion = "v3";
|
package/dist/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["DecisionModelV4","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["DecisionModelV4","ExtractionModelV4","originalSimulateReadableStream"],"sources":["../../src/test/decision-mock-model-v4.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/extraction-mock-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-speech-translation-model-v4.ts","../../src/test/mock-streaming-speech-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts","../../test/index.ts"],"mappings":";;;;;cAGa,+BAA+BA;WACjC;WACA;WACA;WACA,wBAAwBA;EACjC,UAAUA;;EAGV,WAAW,SAAS,WAAWA,+CAA+B,uCAAA;EAIlD,cACV,UACA,SACA,wBACA,UACA;IAEA;IACA;IACA,yBAAyBA;IACzB,WAAWA;;IAEX,aAAaA;;;;;qBCxBJ,gCAAgC;WAClC;WAEA,UAAU;WACV,SAAS;WACT,sBAAsB;WACtB,uBAAuB;EAEhC,SAAS;EAET,cAAc,WAAW;EAEb,cACV,UACA,SACA,sBACA,uBACA;IAEA,WAAW;IACX,UAAU;IACV,uBAAuB;IACvB,wBAAwB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IACX,UAAU;IACV,aAAa;;;;;qBCdJ,oCAAoC;WACtC;WACA,UAAU;WACV,SAAS;EAElB,YAAY;EACZ,UAAU;EACV,mBAAmB;EAEP,cACV,UACA,SACA,YACA,UACA;IAEA,WAAW;IACX,UAAU;IACV,aAAa;IACb,WAAW;IACX,oBAAoB;;;;;qBCpBX,gCAAgC;WAClC;WAEA,UAAU;WACV,SAAS;EAElB,UAAU;EAEE,cACV,UACA,SACA;IAEA,WAAW;IACX,UAAU;IACV,WAAW;;;;;qBCfF,gCAAgC;WAClC;WAEA,UAAU;WACV,SAAS;EAElB,UAAU;EAEE,cACV,UACA,SACA;IAEA,WAAW;IACX,UAAU;IACV,WAAW;;;;;qBCfF,4BAA4B;WAC9B;WACA,UAAU;WACV,SAAS;WACT,kBAAkB;EAE3B,YAAY;EAEA,cACV,UACA,SACA,kBACA;IAEA,WAAW;IACX,UAAU;IACV,mBAAmB;IACnB,aAAa;;;;;qBCjBJ,4BAA4B;WAC9B;WACA,UAAU;WACV,SAAS;WACT,kBAAkB;EAE3B,YAAY;EACZ,qBAAqB;EACrB,SAAS;EACT,UAAU;EAGR,YAAA;IACE,WAAW;IACX,UAAU;IACV,mBAAmB;IACnB,aAAa;IACb,sBAAsB;IACtB,UAAU;IACV,WAAW;;;;;wBCtBD,WAAW,MAAM,QAAQ,YAAY;;;;;;qBCmCxC,+BAAsBC;;qBAGtB,2CAAkC;;YAEnC,qCAAqC"}
|
package/dist/test/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as simulateReadableStream$1 } from "../simulate-readable-stream-Bi5kQKbv.js";
|
|
2
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { NoSuchModelError } from "@ai-sdk/provider";
|
|
4
|
+
import { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from "@ai-sdk/provider-utils/test";
|
|
4
5
|
//#region src/test/not-implemented.ts
|
|
5
6
|
function notImplemented() {
|
|
6
7
|
throw new Error("Not implemented");
|
|
@@ -25,27 +26,6 @@ var DecisionMockModelV4 = class {
|
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
28
|
//#endregion
|
|
28
|
-
//#region src/util/simulate-readable-stream.ts
|
|
29
|
-
/**
|
|
30
|
-
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
31
|
-
*
|
|
32
|
-
* @param options - The configuration options
|
|
33
|
-
* @param options.chunks - Array of values to be emitted by the stream
|
|
34
|
-
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
35
|
-
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.
|
|
36
|
-
* @returns A ReadableStream that emits the provided values
|
|
37
|
-
*/
|
|
38
|
-
function simulateReadableStream$1({ chunks, initialDelayInMs = 0, chunkDelayInMs = 0, _internal }) {
|
|
39
|
-
const delay$1 = _internal?.delay ?? delay;
|
|
40
|
-
let index = 0;
|
|
41
|
-
return new ReadableStream({ async pull(controller) {
|
|
42
|
-
if (index < chunks.length) {
|
|
43
|
-
await delay$1(index === 0 ? initialDelayInMs : chunkDelayInMs);
|
|
44
|
-
controller.enqueue(chunks[index++]);
|
|
45
|
-
} else controller.close();
|
|
46
|
-
} });
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
29
|
//#region src/test/mock-embedding-model-v3.ts
|
|
50
30
|
var MockEmbeddingModelV3 = class {
|
|
51
31
|
constructor({ provider = "mock-provider", modelId = "mock-model-id", maxEmbeddingsPerCall = 1, supportsParallelCalls = false, doEmbed = notImplemented } = {}) {
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["simulateReadableStream","delay","delayFunction","originalSimulateReadableStream"],"sources":["../../src/test/not-implemented.ts","../../src/test/decision-mock-model-v4.ts","../../src/util/simulate-readable-stream.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/extraction-mock-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-speech-translation-model-v4.ts","../../src/test/mock-streaming-speech-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts","../../test/index.ts"],"sourcesContent":["export function notImplemented(): never {\n throw new Error('Not implemented');\n}\n","import type { Experimental_DecisionModelV4 as DecisionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class DecisionMockModelV4 implements DecisionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedQuestionTypes: DecisionModelV4['supportedQuestionTypes'];\n doDecide: DecisionModelV4['doDecide'];\n\n /** @deprecated Use `doDecide` instead. */\n doEvaluate(options: Parameters<DecisionModelV4['doDecide']>[0]) {\n return this.doDecide(options);\n }\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedQuestionTypes = ['choice', 'score', 'boolean'],\n doDecide,\n doEvaluate,\n }: {\n provider?: string;\n modelId?: string;\n supportedQuestionTypes?: DecisionModelV4['supportedQuestionTypes'];\n doDecide?: DecisionModelV4['doDecide'];\n /** @deprecated Use `doDecide` instead. */\n doEvaluate?: DecisionModelV4['doDecide'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.supportedQuestionTypes = supportedQuestionTypes;\n this.doDecide = doDecide ?? doEvaluate ?? notImplemented;\n }\n}\n","import { delay as delayFunction } from '@ai-sdk/provider-utils';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n","import type { EmbeddingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV3 implements EmbeddingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: EmbeddingModelV3['provider'];\n readonly modelId: EmbeddingModelV3['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV3['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV3['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV3['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV3['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV3['provider'];\n modelId?: EmbeddingModelV3['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV3['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV3['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV3['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { EmbeddingModelV4 } from '@ai-sdk/provider';\nimport { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV4 implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: EmbeddingModelV4['provider'];\n readonly modelId: EmbeddingModelV4['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];\n readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL]:\n | PromiseLike<number | undefined>\n | number\n | undefined;\n readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV4['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n maxInputBytesPerCall,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\n maxInputBytesPerCall?: PromiseLike<number | undefined> | number | undefined;\n supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV4['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] =\n maxInputBytesPerCall;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { Experimental_ExtractionModelV4 as ExtractionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class ExtractionMockModelV4 implements ExtractionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedFieldTypes: ExtractionModelV4['supportedFieldTypes'];\n doExtract: ExtractionModelV4['doExtract'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedFieldTypes = [\n 'text',\n 'number',\n 'date',\n 'time',\n 'datetime',\n 'duration',\n 'list',\n ],\n doExtract = notImplemented,\n }: {\n provider?: string;\n modelId?: string;\n supportedFieldTypes?: ExtractionModelV4['supportedFieldTypes'];\n doExtract?: ExtractionModelV4['doExtract'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.supportedFieldTypes = supportedFieldTypes;\n this.doExtract = doExtract;\n }\n}\n","import type { ImageModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV3 implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: ImageModelV3['provider'];\n readonly modelId: ImageModelV3['modelId'];\n readonly maxImagesPerCall: ImageModelV3['maxImagesPerCall'];\n\n doGenerate: ImageModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV3['provider'];\n modelId?: ImageModelV3['modelId'];\n maxImagesPerCall?: ImageModelV3['maxImagesPerCall'];\n doGenerate?: ImageModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { ImageModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV4 implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: ImageModelV4['provider'];\n readonly modelId: ImageModelV4['modelId'];\n readonly maxImagesPerCall: ImageModelV4['maxImagesPerCall'];\n readonly supportsFileInputs: ImageModelV4['supportsFileInputs'];\n readonly supportsMaskInputs: ImageModelV4['supportsMaskInputs'];\n\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n supportsFileInputs,\n supportsMaskInputs,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n supportsFileInputs?: ImageModelV4['supportsFileInputs'];\n supportsMaskInputs?: ImageModelV4['supportsMaskInputs'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.supportsFileInputs = supportsFileInputs;\n this.supportsMaskInputs = supportsMaskInputs;\n this.doGenerate = doGenerate;\n }\n}\n","import type {\n LanguageModelV3,\n LanguageModelV3CallOptions,\n LanguageModelV3GenerateResult,\n LanguageModelV3StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV3 implements LanguageModelV3 {\n readonly specificationVersion = 'v3';\n\n private _supportedUrls: () => LanguageModelV3['supportedUrls'];\n\n readonly provider: LanguageModelV3['provider'];\n readonly modelId: LanguageModelV3['modelId'];\n\n doGenerate: LanguageModelV3['doGenerate'];\n doStream: LanguageModelV3['doStream'];\n\n doGenerateCalls: LanguageModelV3CallOptions[] = [];\n doStreamCalls: LanguageModelV3CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV3['provider'];\n modelId?: LanguageModelV3['modelId'];\n supportedUrls?:\n | LanguageModelV3['supportedUrls']\n | (() => LanguageModelV3['supportedUrls']);\n doGenerate?:\n | LanguageModelV3['doGenerate']\n | LanguageModelV3GenerateResult\n | LanguageModelV3GenerateResult[];\n doStream?:\n | LanguageModelV3['doStream']\n | LanguageModelV3StreamResult\n | LanguageModelV3StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV4 implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n private _supportedUrls: () => LanguageModelV4['supportedUrls'];\n\n readonly provider: LanguageModelV4['provider'];\n readonly modelId: LanguageModelV4['modelId'];\n\n doGenerate: LanguageModelV4['doGenerate'];\n doStream: LanguageModelV4['doStream'];\n\n doGenerateCalls: LanguageModelV4CallOptions[] = [];\n doStreamCalls: LanguageModelV4CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV4['provider'];\n modelId?: LanguageModelV4['modelId'];\n supportedUrls?:\n | LanguageModelV4['supportedUrls']\n | (() => LanguageModelV4['supportedUrls']);\n doGenerate?:\n | LanguageModelV4['doGenerate']\n | LanguageModelV4GenerateResult\n | LanguageModelV4GenerateResult[];\n doStream?:\n | LanguageModelV4['doStream']\n | LanguageModelV4StreamResult\n | LanguageModelV4StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV3,\n type ImageModelV3,\n type LanguageModelV3,\n type ProviderV3,\n type SpeechModelV3,\n type TranscriptionModelV3,\n type RerankingModelV3,\n} from '@ai-sdk/provider';\nexport class MockProviderV3 implements ProviderV3 {\n readonly specificationVersion = 'v3' as const;\n\n languageModel: ProviderV3['languageModel'];\n embeddingModel: ProviderV3['embeddingModel'];\n imageModel: ProviderV3['imageModel'];\n transcriptionModel: ProviderV3['transcriptionModel'];\n speechModel: ProviderV3['speechModel'];\n rerankingModel: ProviderV3['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV3>;\n embeddingModels?: Record<string, EmbeddingModelV3>;\n imageModels?: Record<string, ImageModelV3>;\n transcriptionModels?: Record<string, TranscriptionModelV3>;\n speechModels?: Record<string, SpeechModelV3>;\n rerankingModels?: Record<string, RerankingModelV3>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV3 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type ImageModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n type RerankingModelV4,\n} from '@ai-sdk/provider';\nexport class MockProviderV4 implements ProviderV4 {\n readonly specificationVersion = 'v4' as const;\n\n languageModel: ProviderV4['languageModel'];\n embeddingModel: ProviderV4['embeddingModel'];\n imageModel: ProviderV4['imageModel'];\n transcriptionModel: ProviderV4['transcriptionModel'];\n speechModel: ProviderV4['speechModel'];\n rerankingModel: ProviderV4['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV4>;\n embeddingModels?: Record<string, EmbeddingModelV4>;\n imageModels?: Record<string, ImageModelV4>;\n transcriptionModels?: Record<string, TranscriptionModelV4>;\n speechModels?: Record<string, SpeechModelV4>;\n rerankingModels?: Record<string, RerankingModelV4>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV4 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import type { SpeechModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV3 implements SpeechModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: SpeechModelV3['provider'];\n readonly modelId: SpeechModelV3['modelId'];\n\n doGenerate: SpeechModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV3['provider'];\n modelId?: SpeechModelV3['modelId'];\n doGenerate?: SpeechModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { SpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV4 implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: SpeechModelV4['provider'];\n readonly modelId: SpeechModelV4['modelId'];\n\n doGenerate: SpeechModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV4['provider'];\n modelId?: SpeechModelV4['modelId'];\n doGenerate?: SpeechModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_SpeechTranslationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechTranslationModelV4 implements Experimental_SpeechTranslationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_SpeechTranslationModelV4['provider'];\n readonly modelId: Experimental_SpeechTranslationModelV4['modelId'];\n\n doStream: Experimental_SpeechTranslationModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doStream = notImplemented,\n }: {\n provider?: Experimental_SpeechTranslationModelV4['provider'];\n modelId?: Experimental_SpeechTranslationModelV4['modelId'];\n doStream?: Experimental_SpeechTranslationModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doStream = doStream;\n }\n}\n","import type { Experimental_StreamingSpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockStreamingSpeechModelV4 implements Experimental_StreamingSpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_StreamingSpeechModelV4['provider'];\n readonly modelId: Experimental_StreamingSpeechModelV4['modelId'];\n\n doGenerate: Experimental_StreamingSpeechModelV4['doGenerate'];\n doStream: Experimental_StreamingSpeechModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: Experimental_StreamingSpeechModelV4['provider'];\n modelId?: Experimental_StreamingSpeechModelV4['modelId'];\n doGenerate?: Experimental_StreamingSpeechModelV4['doGenerate'];\n doStream?: Experimental_StreamingSpeechModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n }\n}\n","import type { TranscriptionModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV3 implements TranscriptionModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: TranscriptionModelV3['provider'];\n readonly modelId: TranscriptionModelV3['modelId'];\n\n doGenerate: TranscriptionModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: TranscriptionModelV3['provider'];\n modelId?: TranscriptionModelV3['modelId'];\n doGenerate?: TranscriptionModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV4 implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: TranscriptionModelV4['provider'];\n readonly modelId: TranscriptionModelV4['modelId'];\n\n doGenerate: TranscriptionModelV4['doGenerate'];\n doStream: TranscriptionModelV4['doStream'];\n doGenerateFromUrl: TranscriptionModelV4['doGenerateFromUrl'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n doGenerateFromUrl,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n doGenerateFromUrl?: TranscriptionModelV4['doGenerateFromUrl'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n this.doGenerateFromUrl = doGenerateFromUrl;\n }\n}\n","import type { RerankingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV3 implements RerankingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: RerankingModelV3['provider'];\n readonly modelId: RerankingModelV3['modelId'];\n\n doRerank: RerankingModelV3['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV3['provider'];\n modelId?: RerankingModelV3['modelId'];\n doRerank?: RerankingModelV3['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { RerankingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV4 implements RerankingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: RerankingModelV4['provider'];\n readonly modelId: RerankingModelV4['modelId'];\n\n doRerank: RerankingModelV4['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV4['provider'];\n modelId?: RerankingModelV4['modelId'];\n doRerank?: RerankingModelV4['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { Experimental_VideoModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV3 implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: Experimental_VideoModelV3['provider'];\n readonly modelId: Experimental_VideoModelV3['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV3['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV3['provider'];\n modelId?: Experimental_VideoModelV3['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV3['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_VideoModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV4 implements Experimental_VideoModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_VideoModelV4['provider'];\n readonly modelId: Experimental_VideoModelV4['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV4['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption: Experimental_VideoModelV4['handleWebhookOption'];\n doStart: Experimental_VideoModelV4['doStart'];\n doStatus: Experimental_VideoModelV4['doStatus'];\n\n constructor(\n options: {\n provider?: Experimental_VideoModelV4['provider'];\n modelId?: Experimental_VideoModelV4['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV4['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption?: Experimental_VideoModelV4['handleWebhookOption'];\n doStart?: Experimental_VideoModelV4['doStart'];\n doStatus?: Experimental_VideoModelV4['doStatus'];\n } = {},\n ) {\n this.provider = options.provider ?? 'mock-provider';\n this.modelId = options.modelId ?? 'mock-model-id';\n this.maxVideosPerCall = options.maxVideosPerCall ?? 1;\n this.doGenerate =\n 'doGenerate' in options ? options.doGenerate : notImplemented;\n this.handleWebhookOption = options.handleWebhookOption;\n this.doStart = options.doStart;\n this.doStatus = options.doStatus;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n","import { DecisionMockModelV4 } from '../src/test/decision-mock-model-v4';\n\nimport { simulateReadableStream as originalSimulateReadableStream } from '../src/util/simulate-readable-stream';\n\nexport {\n convertArrayToAsyncIterable,\n convertArrayToReadableStream,\n convertReadableStreamToArray,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV3 } from '../src/test/mock-embedding-model-v3';\nexport { MockEmbeddingModelV4 } from '../src/test/mock-embedding-model-v4';\nexport { DecisionMockModelV4 as Experimental_DecisionMockModelV4 } from '../src/test/decision-mock-model-v4';\nexport { ExtractionMockModelV4 as Experimental_ExtractionMockModelV4 } from '../src/test/extraction-mock-model-v4';\nexport { MockImageModelV3 } from '../src/test/mock-image-model-v3';\nexport { MockImageModelV4 } from '../src/test/mock-image-model-v4';\nexport { MockLanguageModelV3 } from '../src/test/mock-language-model-v3';\nexport { MockLanguageModelV4 } from '../src/test/mock-language-model-v4';\nexport { MockProviderV3 } from '../src/test/mock-provider-v3';\nexport { MockProviderV4 } from '../src/test/mock-provider-v4';\nexport { MockSpeechModelV3 } from '../src/test/mock-speech-model-v3';\nexport { MockSpeechModelV4 } from '../src/test/mock-speech-model-v4';\nexport { MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4 } from '../src/test/mock-speech-translation-model-v4';\nexport { MockStreamingSpeechModelV4 as Experimental_MockStreamingSpeechModelV4 } from '../src/test/mock-streaming-speech-model-v4';\nexport { MockTranscriptionModelV3 } from '../src/test/mock-transcription-model-v3';\nexport { MockTranscriptionModelV4 } from '../src/test/mock-transcription-model-v4';\nexport { MockRerankingModelV3 } from '../src/test/mock-reranking-model-v3';\nexport { MockRerankingModelV4 } from '../src/test/mock-reranking-model-v4';\nexport { MockVideoModelV3 } from '../src/test/mock-video-model-v3';\nexport { MockVideoModelV4 } from '../src/test/mock-video-model-v4';\nexport { mockValues } from '../src/test/mock-values';\n\n/**\n * @deprecated Use `simulateReadableStream` from `ai` instead.\n */\nexport const simulateReadableStream = originalSimulateReadableStream;\n\n/** @deprecated Use `Experimental_DecisionMockModelV4` instead. */\nexport const Experimental_EvaluationMockModelV4 = DecisionMockModelV4;\n/** @deprecated Use `Experimental_DecisionMockModelV4` instead. */\nexport type Experimental_EvaluationMockModelV4 = DecisionMockModelV4;\n"],"mappings":";;;;AAAA,SAAgB,iBAAwB;CACtC,MAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACCA,IAAa,sBAAb,MAA4D;;CAQ1D,WAAW,SAAqD;EAC9D,OAAO,KAAK,SAAS,OAAO;CAC9B;CAEA,YAAY,EACV,WAAW,iBACX,UAAU,iBACV,yBAAyB;EAAC;EAAU;EAAS;CAAS,GACtD,UACA,eAQE,CAAC,GAAG;EAxBwB,KAAA,uBAAA;EAyB9B,KAAK,WAAW;EAChB,KAAK,UAAU;EACf,KAAK,yBAAyB;EAC9B,KAAK,WAAW,YAAY,cA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UAAU,QAAQ,WAAW;EAClC,KAAK,mBAAmB,QAAQ,oBAAoB;EACpD,KAAK,aACH,gBAAgB,UAAU,QAAQ,aAAa;EACjD,KAAK,sBAAsB,QAAQ;EACnC,KAAK,UAAU,QAAQ;EACvB,KAAK,WAAW,QAAQ;CAC1B;AACF;;;AClCA,SAAgB,WAAc,GAAG,QAAsB;CACrD,IAAI,UAAU;CACd,aAAa,OAAO,cAAc,OAAO,OAAO,SAAS;AAC3D;;;;;;ACgCA,MAAa,yBAAyBE;;AAGtC,MAAa,qCAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["originalSimulateReadableStream"],"sources":["../../src/test/not-implemented.ts","../../src/test/decision-mock-model-v4.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-model-v4.ts","../../src/test/extraction-mock-model-v4.ts","../../src/test/mock-image-model-v3.ts","../../src/test/mock-image-model-v4.ts","../../src/test/mock-language-model-v3.ts","../../src/test/mock-language-model-v4.ts","../../src/test/mock-provider-v3.ts","../../src/test/mock-provider-v4.ts","../../src/test/mock-speech-model-v3.ts","../../src/test/mock-speech-model-v4.ts","../../src/test/mock-speech-translation-model-v4.ts","../../src/test/mock-streaming-speech-model-v4.ts","../../src/test/mock-transcription-model-v3.ts","../../src/test/mock-transcription-model-v4.ts","../../src/test/mock-reranking-model-v3.ts","../../src/test/mock-reranking-model-v4.ts","../../src/test/mock-video-model-v3.ts","../../src/test/mock-video-model-v4.ts","../../src/test/mock-values.ts","../../test/index.ts"],"sourcesContent":["export function notImplemented(): never {\n throw new Error('Not implemented');\n}\n","import type { Experimental_DecisionModelV4 as DecisionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class DecisionMockModelV4 implements DecisionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedQuestionTypes: DecisionModelV4['supportedQuestionTypes'];\n doDecide: DecisionModelV4['doDecide'];\n\n /** @deprecated Use `doDecide` instead. */\n doEvaluate(options: Parameters<DecisionModelV4['doDecide']>[0]) {\n return this.doDecide(options);\n }\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedQuestionTypes = ['choice', 'score', 'boolean'],\n doDecide,\n doEvaluate,\n }: {\n provider?: string;\n modelId?: string;\n supportedQuestionTypes?: DecisionModelV4['supportedQuestionTypes'];\n doDecide?: DecisionModelV4['doDecide'];\n /** @deprecated Use `doDecide` instead. */\n doEvaluate?: DecisionModelV4['doDecide'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.supportedQuestionTypes = supportedQuestionTypes;\n this.doDecide = doDecide ?? doEvaluate ?? notImplemented;\n }\n}\n","import type { EmbeddingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV3 implements EmbeddingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: EmbeddingModelV3['provider'];\n readonly modelId: EmbeddingModelV3['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV3['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV3['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV3['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV3['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV3['provider'];\n modelId?: EmbeddingModelV3['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV3['maxEmbeddingsPerCall'] | null;\n supportsParallelCalls?: EmbeddingModelV3['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV3['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { EmbeddingModelV4 } from '@ai-sdk/provider';\nimport { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV4 implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: EmbeddingModelV4['provider'];\n readonly modelId: EmbeddingModelV4['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];\n readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL]:\n | PromiseLike<number | undefined>\n | number\n | undefined;\n readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV4['doEmbed'];\n\n doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n maxInputBytesPerCall,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\n maxInputBytesPerCall?: PromiseLike<number | undefined> | number | undefined;\n supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];\n doEmbed?:\n | EmbeddingModelV4['doEmbed']\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] =\n maxInputBytesPerCall;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = async options => {\n this.doEmbedCalls.push(options);\n\n if (typeof doEmbed === 'function') {\n return doEmbed(options);\n } else if (Array.isArray(doEmbed)) {\n return doEmbed[this.doEmbedCalls.length - 1];\n } else {\n return doEmbed;\n }\n };\n }\n}\n","import type { Experimental_ExtractionModelV4 as ExtractionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class ExtractionMockModelV4 implements ExtractionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: string;\n readonly modelId: string;\n readonly supportedFieldTypes: ExtractionModelV4['supportedFieldTypes'];\n doExtract: ExtractionModelV4['doExtract'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedFieldTypes = [\n 'text',\n 'number',\n 'date',\n 'time',\n 'datetime',\n 'duration',\n 'list',\n ],\n doExtract = notImplemented,\n }: {\n provider?: string;\n modelId?: string;\n supportedFieldTypes?: ExtractionModelV4['supportedFieldTypes'];\n doExtract?: ExtractionModelV4['doExtract'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.supportedFieldTypes = supportedFieldTypes;\n this.doExtract = doExtract;\n }\n}\n","import type { ImageModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV3 implements ImageModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: ImageModelV3['provider'];\n readonly modelId: ImageModelV3['modelId'];\n readonly maxImagesPerCall: ImageModelV3['maxImagesPerCall'];\n\n doGenerate: ImageModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV3['provider'];\n modelId?: ImageModelV3['modelId'];\n maxImagesPerCall?: ImageModelV3['maxImagesPerCall'];\n doGenerate?: ImageModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { ImageModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockImageModelV4 implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: ImageModelV4['provider'];\n readonly modelId: ImageModelV4['modelId'];\n readonly maxImagesPerCall: ImageModelV4['maxImagesPerCall'];\n readonly supportsFileInputs: ImageModelV4['supportsFileInputs'];\n readonly supportsMaskInputs: ImageModelV4['supportsMaskInputs'];\n\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n supportsFileInputs,\n supportsMaskInputs,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n supportsFileInputs?: ImageModelV4['supportsFileInputs'];\n supportsMaskInputs?: ImageModelV4['supportsMaskInputs'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\n this.supportsFileInputs = supportsFileInputs;\n this.supportsMaskInputs = supportsMaskInputs;\n this.doGenerate = doGenerate;\n }\n}\n","import type {\n LanguageModelV3,\n LanguageModelV3CallOptions,\n LanguageModelV3GenerateResult,\n LanguageModelV3StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV3 implements LanguageModelV3 {\n readonly specificationVersion = 'v3';\n\n private _supportedUrls: () => LanguageModelV3['supportedUrls'];\n\n readonly provider: LanguageModelV3['provider'];\n readonly modelId: LanguageModelV3['modelId'];\n\n doGenerate: LanguageModelV3['doGenerate'];\n doStream: LanguageModelV3['doStream'];\n\n doGenerateCalls: LanguageModelV3CallOptions[] = [];\n doStreamCalls: LanguageModelV3CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV3['provider'];\n modelId?: LanguageModelV3['modelId'];\n supportedUrls?:\n | LanguageModelV3['supportedUrls']\n | (() => LanguageModelV3['supportedUrls']);\n doGenerate?:\n | LanguageModelV3['doGenerate']\n | LanguageModelV3GenerateResult\n | LanguageModelV3GenerateResult[];\n doStream?:\n | LanguageModelV3['doStream']\n | LanguageModelV3StreamResult\n | LanguageModelV3StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV4 implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n private _supportedUrls: () => LanguageModelV4['supportedUrls'];\n\n readonly provider: LanguageModelV4['provider'];\n readonly modelId: LanguageModelV4['modelId'];\n\n doGenerate: LanguageModelV4['doGenerate'];\n doStream: LanguageModelV4['doStream'];\n\n doGenerateCalls: LanguageModelV4CallOptions[] = [];\n doStreamCalls: LanguageModelV4CallOptions[] = [];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportedUrls = {},\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: LanguageModelV4['provider'];\n modelId?: LanguageModelV4['modelId'];\n supportedUrls?:\n | LanguageModelV4['supportedUrls']\n | (() => LanguageModelV4['supportedUrls']);\n doGenerate?:\n | LanguageModelV4['doGenerate']\n | LanguageModelV4GenerateResult\n | LanguageModelV4GenerateResult[];\n doStream?:\n | LanguageModelV4['doStream']\n | LanguageModelV4StreamResult\n | LanguageModelV4StreamResult[];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = async options => {\n this.doGenerateCalls.push(options);\n\n if (typeof doGenerate === 'function') {\n return await doGenerate(options);\n } else if (Array.isArray(doGenerate)) {\n return doGenerate[this.doGenerateCalls.length - 1];\n } else {\n return doGenerate;\n }\n };\n this.doStream = async options => {\n this.doStreamCalls.push(options);\n\n if (typeof doStream === 'function') {\n return await doStream(options);\n } else if (Array.isArray(doStream)) {\n return doStream[this.doStreamCalls.length - 1];\n } else {\n return doStream;\n }\n };\n this._supportedUrls =\n typeof supportedUrls === 'function'\n ? supportedUrls\n : async () => await supportedUrls;\n }\n\n get supportedUrls() {\n return this._supportedUrls();\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV3,\n type ImageModelV3,\n type LanguageModelV3,\n type ProviderV3,\n type SpeechModelV3,\n type TranscriptionModelV3,\n type RerankingModelV3,\n} from '@ai-sdk/provider';\nexport class MockProviderV3 implements ProviderV3 {\n readonly specificationVersion = 'v3' as const;\n\n languageModel: ProviderV3['languageModel'];\n embeddingModel: ProviderV3['embeddingModel'];\n imageModel: ProviderV3['imageModel'];\n transcriptionModel: ProviderV3['transcriptionModel'];\n speechModel: ProviderV3['speechModel'];\n rerankingModel: ProviderV3['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV3>;\n embeddingModels?: Record<string, EmbeddingModelV3>;\n imageModels?: Record<string, ImageModelV3>;\n transcriptionModels?: Record<string, TranscriptionModelV3>;\n speechModels?: Record<string, SpeechModelV3>;\n rerankingModels?: Record<string, RerankingModelV3>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV3 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type ImageModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n type RerankingModelV4,\n} from '@ai-sdk/provider';\nexport class MockProviderV4 implements ProviderV4 {\n readonly specificationVersion = 'v4' as const;\n\n languageModel: ProviderV4['languageModel'];\n embeddingModel: ProviderV4['embeddingModel'];\n imageModel: ProviderV4['imageModel'];\n transcriptionModel: ProviderV4['transcriptionModel'];\n speechModel: ProviderV4['speechModel'];\n rerankingModel: ProviderV4['rerankingModel'];\n\n constructor({\n languageModels,\n embeddingModels,\n imageModels,\n transcriptionModels,\n speechModels,\n rerankingModels,\n }: {\n languageModels?: Record<string, LanguageModelV4>;\n embeddingModels?: Record<string, EmbeddingModelV4>;\n imageModels?: Record<string, ImageModelV4>;\n transcriptionModels?: Record<string, TranscriptionModelV4>;\n speechModels?: Record<string, SpeechModelV4>;\n rerankingModels?: Record<string, RerankingModelV4>;\n } = {}) {\n this.languageModel = (modelId: string) => {\n if (!languageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'languageModel' });\n }\n return languageModels[modelId];\n };\n this.embeddingModel = (modelId: string) => {\n if (!embeddingModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n });\n }\n return embeddingModels[modelId];\n };\n this.imageModel = (modelId: string) => {\n if (!imageModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n }\n return imageModels[modelId];\n };\n this.transcriptionModel = (modelId: string) => {\n if (!transcriptionModels?.[modelId]) {\n throw new NoSuchModelError({\n modelId,\n modelType: 'transcriptionModel',\n });\n }\n return transcriptionModels[modelId];\n };\n this.speechModel = (modelId: string): SpeechModelV4 => {\n if (!speechModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'speechModel' });\n }\n return speechModels[modelId];\n };\n this.rerankingModel = (modelId: string) => {\n if (!rerankingModels?.[modelId]) {\n throw new NoSuchModelError({ modelId, modelType: 'rerankingModel' });\n }\n return rerankingModels[modelId];\n };\n }\n}\n","import type { SpeechModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV3 implements SpeechModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: SpeechModelV3['provider'];\n readonly modelId: SpeechModelV3['modelId'];\n\n doGenerate: SpeechModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV3['provider'];\n modelId?: SpeechModelV3['modelId'];\n doGenerate?: SpeechModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { SpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechModelV4 implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: SpeechModelV4['provider'];\n readonly modelId: SpeechModelV4['modelId'];\n\n doGenerate: SpeechModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: SpeechModelV4['provider'];\n modelId?: SpeechModelV4['modelId'];\n doGenerate?: SpeechModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_SpeechTranslationModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockSpeechTranslationModelV4 implements Experimental_SpeechTranslationModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_SpeechTranslationModelV4['provider'];\n readonly modelId: Experimental_SpeechTranslationModelV4['modelId'];\n\n doStream: Experimental_SpeechTranslationModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doStream = notImplemented,\n }: {\n provider?: Experimental_SpeechTranslationModelV4['provider'];\n modelId?: Experimental_SpeechTranslationModelV4['modelId'];\n doStream?: Experimental_SpeechTranslationModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doStream = doStream;\n }\n}\n","import type { Experimental_StreamingSpeechModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockStreamingSpeechModelV4 implements Experimental_StreamingSpeechModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_StreamingSpeechModelV4['provider'];\n readonly modelId: Experimental_StreamingSpeechModelV4['modelId'];\n\n doGenerate: Experimental_StreamingSpeechModelV4['doGenerate'];\n doStream: Experimental_StreamingSpeechModelV4['doStream'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream = notImplemented,\n }: {\n provider?: Experimental_StreamingSpeechModelV4['provider'];\n modelId?: Experimental_StreamingSpeechModelV4['modelId'];\n doGenerate?: Experimental_StreamingSpeechModelV4['doGenerate'];\n doStream?: Experimental_StreamingSpeechModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n }\n}\n","import type { TranscriptionModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV3 implements TranscriptionModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: TranscriptionModelV3['provider'];\n readonly modelId: TranscriptionModelV3['modelId'];\n\n doGenerate: TranscriptionModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n }: {\n provider?: TranscriptionModelV3['provider'];\n modelId?: TranscriptionModelV3['modelId'];\n doGenerate?: TranscriptionModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n }\n}\n","import type { TranscriptionModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockTranscriptionModelV4 implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: TranscriptionModelV4['provider'];\n readonly modelId: TranscriptionModelV4['modelId'];\n\n doGenerate: TranscriptionModelV4['doGenerate'];\n doStream: TranscriptionModelV4['doStream'];\n doGenerateFromUrl: TranscriptionModelV4['doGenerateFromUrl'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n doGenerateFromUrl,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n doGenerateFromUrl?: TranscriptionModelV4['doGenerateFromUrl'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n this.doGenerateFromUrl = doGenerateFromUrl;\n }\n}\n","import type { RerankingModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV3 implements RerankingModelV3 {\n readonly specificationVersion = 'v3';\n\n readonly provider: RerankingModelV3['provider'];\n readonly modelId: RerankingModelV3['modelId'];\n\n doRerank: RerankingModelV3['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV3['provider'];\n modelId?: RerankingModelV3['modelId'];\n doRerank?: RerankingModelV3['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { RerankingModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockRerankingModelV4 implements RerankingModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly provider: RerankingModelV4['provider'];\n readonly modelId: RerankingModelV4['modelId'];\n\n doRerank: RerankingModelV4['doRerank'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doRerank = notImplemented,\n }: {\n provider?: RerankingModelV4['provider'];\n modelId?: RerankingModelV4['modelId'];\n doRerank?: RerankingModelV4['doRerank'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doRerank = doRerank;\n }\n}\n","import type { Experimental_VideoModelV3 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV3 implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly provider: Experimental_VideoModelV3['provider'];\n readonly modelId: Experimental_VideoModelV3['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV3['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV3['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxVideosPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: Experimental_VideoModelV3['provider'];\n modelId?: Experimental_VideoModelV3['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV3['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV3['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxVideosPerCall = maxVideosPerCall;\n this.doGenerate = doGenerate;\n }\n}\n","import type { Experimental_VideoModelV4 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockVideoModelV4 implements Experimental_VideoModelV4 {\n readonly specificationVersion = 'v4';\n readonly provider: Experimental_VideoModelV4['provider'];\n readonly modelId: Experimental_VideoModelV4['modelId'];\n readonly maxVideosPerCall: Experimental_VideoModelV4['maxVideosPerCall'];\n\n doGenerate: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption: Experimental_VideoModelV4['handleWebhookOption'];\n doStart: Experimental_VideoModelV4['doStart'];\n doStatus: Experimental_VideoModelV4['doStatus'];\n\n constructor(\n options: {\n provider?: Experimental_VideoModelV4['provider'];\n modelId?: Experimental_VideoModelV4['modelId'];\n maxVideosPerCall?: Experimental_VideoModelV4['maxVideosPerCall'];\n doGenerate?: Experimental_VideoModelV4['doGenerate'];\n handleWebhookOption?: Experimental_VideoModelV4['handleWebhookOption'];\n doStart?: Experimental_VideoModelV4['doStart'];\n doStatus?: Experimental_VideoModelV4['doStatus'];\n } = {},\n ) {\n this.provider = options.provider ?? 'mock-provider';\n this.modelId = options.modelId ?? 'mock-model-id';\n this.maxVideosPerCall = options.maxVideosPerCall ?? 1;\n this.doGenerate =\n 'doGenerate' in options ? options.doGenerate : notImplemented;\n this.handleWebhookOption = options.handleWebhookOption;\n this.doStart = options.doStart;\n this.doStatus = options.doStatus;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n","import { DecisionMockModelV4 } from '../src/test/decision-mock-model-v4';\n\nimport { simulateReadableStream as originalSimulateReadableStream } from '../src/util/simulate-readable-stream';\n\nexport {\n convertArrayToAsyncIterable,\n convertArrayToReadableStream,\n convertReadableStreamToArray,\n mockId,\n} from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV3 } from '../src/test/mock-embedding-model-v3';\nexport { MockEmbeddingModelV4 } from '../src/test/mock-embedding-model-v4';\nexport { DecisionMockModelV4 as Experimental_DecisionMockModelV4 } from '../src/test/decision-mock-model-v4';\nexport { ExtractionMockModelV4 as Experimental_ExtractionMockModelV4 } from '../src/test/extraction-mock-model-v4';\nexport { MockImageModelV3 } from '../src/test/mock-image-model-v3';\nexport { MockImageModelV4 } from '../src/test/mock-image-model-v4';\nexport { MockLanguageModelV3 } from '../src/test/mock-language-model-v3';\nexport { MockLanguageModelV4 } from '../src/test/mock-language-model-v4';\nexport { MockProviderV3 } from '../src/test/mock-provider-v3';\nexport { MockProviderV4 } from '../src/test/mock-provider-v4';\nexport { MockSpeechModelV3 } from '../src/test/mock-speech-model-v3';\nexport { MockSpeechModelV4 } from '../src/test/mock-speech-model-v4';\nexport { MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4 } from '../src/test/mock-speech-translation-model-v4';\nexport { MockStreamingSpeechModelV4 as Experimental_MockStreamingSpeechModelV4 } from '../src/test/mock-streaming-speech-model-v4';\nexport { MockTranscriptionModelV3 } from '../src/test/mock-transcription-model-v3';\nexport { MockTranscriptionModelV4 } from '../src/test/mock-transcription-model-v4';\nexport { MockRerankingModelV3 } from '../src/test/mock-reranking-model-v3';\nexport { MockRerankingModelV4 } from '../src/test/mock-reranking-model-v4';\nexport { MockVideoModelV3 } from '../src/test/mock-video-model-v3';\nexport { MockVideoModelV4 } from '../src/test/mock-video-model-v4';\nexport { mockValues } from '../src/test/mock-values';\n\n/**\n * @deprecated Use `simulateReadableStream` from `ai` instead.\n */\nexport const simulateReadableStream = originalSimulateReadableStream;\n\n/** @deprecated Use `Experimental_DecisionMockModelV4` instead. */\nexport const Experimental_EvaluationMockModelV4 = DecisionMockModelV4;\n/** @deprecated Use `Experimental_DecisionMockModelV4` instead. */\nexport type Experimental_EvaluationMockModelV4 = DecisionMockModelV4;\n"],"mappings":";;;;;AAAA,SAAgB,iBAAwB;CACtC,MAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACCA,IAAa,sBAAb,MAA4D;;CAQ1D,WAAW,SAAqD;EAC9D,OAAO,KAAK,SAAS,OAAO;CAC9B;CAEA,YAAY,EACV,WAAW,iBACX,UAAU,iBACV,yBAAyB;EAAC;EAAU;EAAS;CAAS,GACtD,UACA,eAQE,CAAC,GAAG;EAxBwB,KAAA,uBAAA;EAyB9B,KAAK,WAAW;EAChB,KAAK,UAAU;EACf,KAAK,yBAAyB;EAC9B,KAAK,WAAW,YAAY,cAAc;CAC5C;AACF;;;AC/BA,IAAa,uBAAb,MAA8D;CAY5D,YAAY,EACV,WAAW,iBACX,UAAU,iBACV,uBAAuB,GACvB,wBAAwB,OACxB,UAAU,mBAUR,CAAC,GAAG;EA1BwB,KAAA,uBAAA;EAS6B,KAAA,eAAA,CAAC;EAkB5D,KAAK,WAAW;EAChB,KAAK,UAAU;EACf,KAAK,uBAAuB,wBAAwB,KAAA;EACpD,KAAK,wBAAwB;EAC7B,KAAK,UAAU,OAAM,YAAW;GAC9B,KAAK,aAAa,KAAK,OAAO;GAE9B,IAAI,OAAO,YAAY,YACrB,OAAO,QAAQ,OAAO;QACjB,IAAI,MAAM,QAAQ,OAAO,GAC9B,OAAO,QAAQ,KAAK,aAAa,SAAS;QAE1C,OAAO;EAEX;CACF;AACF;;;AC3CA,IAAa,uBAAb,MAA8D;CAgB5D,YAAY,EACV,WAAW,iBACX,UAAU,iBACV,uBAAuB,GACvB,sBACA,wBAAwB,OACxB,UAAU,mBAWR,CAAC,GAAG;EAhCwB,KAAA,uBAAA;EAa6B,KAAA,eAAA,CAAC;EAoB5D,K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9B,KAAK,WAAW;EAChB,KAAK,UAAU;EACf,KAAK,mBAAmB;EACxB,KAAK,aAAa;CACpB;AACF;;;ACxBA,IAAa,mBAAb,MAAmE;CAWjE,YACE,UAQI,CAAC,GACL;EApB8B,KAAA,uBAAA;EAqB9B,KAAK,WAAW,QAAQ,YAAY;EACpC,KAAK,UAAU,QAAQ,WAAW;EAClC,KAAK,mBAAmB,QAAQ,oBAAoB;EACpD,KAAK,aACH,gBAAgB,UAAU,QAAQ,aAAa;EACjD,KAAK,sBAAsB,QAAQ;EACnC,KAAK,UAAU,QAAQ;EACvB,KAAK,WAAW,QAAQ;CAC1B;AACF;;;AClCA,SAAgB,WAAc,GAAG,QAAsB;CACrD,IAAI,UAAU;CACd,aAAa,OAAO,cAAc,OAAO,OAAO,SAAS;AAC3D;;;;;;ACgCA,MAAa,yBAAyBA;;AAGtC,MAAa,qCAAqC"}
|
|
@@ -193,6 +193,7 @@ Here are the capabilities of popular models:
|
|
|
193
193
|
| [Google](/providers/ai-sdk-providers/google) | `gemini-4-argon` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
194
194
|
| [Google](/providers/ai-sdk-providers/google) | `gemini-4-carbon` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
195
195
|
| [Google](/providers/ai-sdk-providers/google) | `gemini-4-hydrogen` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
196
|
+
| [Google](/providers/ai-sdk-providers/google) | `gemini-4-neon` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
196
197
|
| [Google](/providers/ai-sdk-providers/google) | `gemini-3.8-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
197
198
|
| [Google](/providers/ai-sdk-providers/google) | `gemini-3.7-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
198
199
|
| [Google](/providers/ai-sdk-providers/google) | `gemini-3.6-flash` | <Check /> | <Check /> | <Check /> | <Check /> |
|
|
@@ -24,12 +24,16 @@ OPA is a general policy engine. If you can express a rule as code over structure
|
|
|
24
24
|
- Cost and usage: deny or require approval for calls that exceed a budget, token ceiling, or per-user quota.
|
|
25
25
|
- Compliance and change control: gate destructive or regulated actions on the right approver, environment, or time window.
|
|
26
26
|
|
|
27
|
-
The decision is not limited to the current call's arguments. The policy `input` also carries `messages
|
|
27
|
+
The decision is not limited to the current call's arguments. The policy `input` also carries `messages`: the conversation that was sent to the model for the step that produced the call, including the tool calls and tool results of earlier steps. A rule can factor in what already happened: prior tool calls, the sequence of actions so far, or a running total across the conversation. Examples:
|
|
28
28
|
|
|
29
29
|
- Require approval once a run has already performed N writes.
|
|
30
30
|
- Deny a second irreversible action (a push, a delete) in the same conversation.
|
|
31
31
|
- Track cumulative spend or token usage across steps and stop at a ceiling.
|
|
32
32
|
|
|
33
|
+
With `generateText`, `streamText`, and `ToolLoopAgent`, these rules also apply when the model returns several tool calls in one response. See [Several tool calls in one response](#several-tool-calls-in-one-response).
|
|
34
|
+
|
|
35
|
+
A rule over `messages` only sees what is sent to the model. When `prepareStep` replaces the messages of a step, for example to shorten a long conversation, the tool calls that are no longer in them do not count. In that case, keep a limit that must hold for the whole conversation in a store of your own and pass its state to the policy, for example through `runtimeContext`.
|
|
36
|
+
|
|
33
37
|
### Best fit: deterministic checks
|
|
34
38
|
|
|
35
39
|
Policy enforcement is strongest when the decision is deterministic and verifiable from structured fields, whether those fields come from the current call or the history in `messages`. The policy extracts a value and compares it, so the answer is the same every time.
|
|
@@ -60,6 +64,27 @@ The policy is consulted before every tool dispatch and maps to one of the standa
|
|
|
60
64
|
- `requires-approval` pauses the run and waits for a human `tool-approval-response`.
|
|
61
65
|
- No matching rule normalizes to `not-applicable`, which the SDK treats as allow. Add `default decision := { "decision": "deny" }` to your policy to default-deny instead.
|
|
62
66
|
|
|
67
|
+
### Several tool calls in one response
|
|
68
|
+
|
|
69
|
+
A model can return several tool calls in one response. `generateText`, `streamText`, and `ToolLoopAgent` decide on all of them before they run any of them, and `messages` is the same for each call: it does not contain the response itself. A rule that counts earlier tool calls would see none of the other calls of that response.
|
|
70
|
+
|
|
71
|
+
`opaPolicy` therefore evaluates every tool call after the first one of a response twice, unless the first evaluation already denies it:
|
|
72
|
+
|
|
73
|
+
1. With `messages` as they were sent to the model.
|
|
74
|
+
2. With the earlier tool calls of the same response appended as an assistant message. Tool calls that the policy denied are followed by a tool message with their `execution-denied` result. The other tool calls have no result yet.
|
|
75
|
+
|
|
76
|
+
The more restrictive decision applies: `deny` before `requires-approval`, before no matching rule, before `allow`.
|
|
77
|
+
|
|
78
|
+
- A limit such as a budget, a quota, or "only one delete per conversation" counts the earlier tool calls of the same response.
|
|
79
|
+
- A rule that allows a tool call only after another one, such as "deploy only after the tests ran", is not satisfied by a tool call of the same response, because that call has not run yet.
|
|
80
|
+
- Base a limit that must hold within one response on tool calls, not on tool results. The earlier tool calls of a response have no results when the policy is evaluated.
|
|
81
|
+
- OPA receives two queries for such a tool call, so it appears twice in OPA decision logs. A custom `toInput` is called twice as well. When it returns the same input both times, for example because it does not use `messages`, the policy is evaluated once.
|
|
82
|
+
- `opaPolicy` recognizes the tool calls of one response by the `messages` array they are evaluated with. `generateText`, `streamText`, and `ToolLoopAgent` pass the same array for all tool calls of a response and a new array for every response. When a caller passes a separate array for each tool call, `opaPolicy` evaluates each tool call once, with `messages` as passed. A caller must not pass one array for several responses: the tool calls of the earlier responses would count as earlier tool calls of the later ones.
|
|
83
|
+
|
|
84
|
+
### Tool calls that a user approved
|
|
85
|
+
|
|
86
|
+
When the policy returns `requires-approval` and the user approves, the policy is evaluated for that tool call once more before the tool runs. In this evaluation, `messages` include the response with the tool call and the approval. A `deny` blocks the tool call. Any other decision lets it run, and `requires-approval` does not ask the user again.
|
|
87
|
+
|
|
63
88
|
## Quick start
|
|
64
89
|
|
|
65
90
|
```ts
|
|
@@ -120,7 +145,7 @@ decision := { "decision": "requires-approval", "reason": "kubectl by oncall" } {
|
|
|
120
145
|
Notes:
|
|
121
146
|
|
|
122
147
|
- The legacy boolean shape (`{ "allow": true | false, "reason": "..." }`) is also accepted, so existing rules migrate without rewriting.
|
|
123
|
-
- The default OPA `input` shape is `{ tool: { name }, args, messages, runtimeContext }`.
|
|
148
|
+
- The default OPA `input` shape is `{ tool: { name }, args, messages, runtimeContext }`. `messages` does not contain the response with the tool call, except when a tool call that a user approved is evaluated again. See [Several tool calls in one response](#several-tool-calls-in-one-response) and [Tool calls that a user approved](#tool-calls-that-a-user-approved).
|
|
124
149
|
- Override the input shape with `toInput`:
|
|
125
150
|
|
|
126
151
|
```ts
|
|
@@ -302,7 +302,7 @@ If your tools perform sensitive operations (modifying data, spending money, call
|
|
|
302
302
|
|
|
303
303
|
### Signing approvals with `experimental_toolApprovalSecret`
|
|
304
304
|
|
|
305
|
-
When you provide a secret, the server HMAC-signs
|
|
305
|
+
When you provide a secret, the server HMAC-signs approval requests at issuance, except for automatic denials, and verifies the signature when the approval is replayed. A forged or tampered approval is rejected before the tool executes. Configure the secret on `ToolLoopAgent` (or pass it directly to `generateText` or `streamText`).
|
|
306
306
|
|
|
307
307
|
```ts highlight="6"
|
|
308
308
|
const agent = new ToolLoopAgent({
|
|
@@ -336,6 +336,7 @@ Every serverless instance that might handle a request needs the same secret, sin
|
|
|
336
336
|
**Behavior when configured:**
|
|
337
337
|
|
|
338
338
|
- Approval requests without a valid signature are rejected (fail-closed)
|
|
339
|
+
- Approval requests for tool calls that the approval policy denied automatically are not signed, so a client cannot send a denied tool call back as approved
|
|
339
340
|
- No secret configured: approvals work as before (backward compatible)
|
|
340
341
|
- The secret is never sent to the client or included in the stream
|
|
341
342
|
|
|
@@ -134,8 +134,13 @@ Raw runtime instances need their respective adapters; a custom
|
|
|
134
134
|
The model calls the tool with `{ command: string }` and receives
|
|
135
135
|
`{ stdout, stderr, exitCode }`. Nonzero exit codes are returned so the model can
|
|
136
136
|
inspect failures and recover. AI SDK cancellation is forwarded to the session.
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
The tool keeps the first `maxOutputLength` characters from stdout and stderr and
|
|
138
|
+
reports how many characters it omitted. The command still runs to completion.
|
|
139
|
+
|
|
140
|
+
Vercel Sandbox discards extra output as it arrives. just-bash buffers output
|
|
141
|
+
within its own limits, and custom sandboxes may return full output before the
|
|
142
|
+
tool truncates it. This setting does not limit command duration or memory used
|
|
143
|
+
inside the sandbox.
|
|
139
144
|
|
|
140
145
|
### Command timeout
|
|
141
146
|
|
|
@@ -206,12 +206,29 @@ List answers can include `items`, one `{ confidence?, source? }` entry per value
|
|
|
206
206
|
|
|
207
207
|
## Errors
|
|
208
208
|
|
|
209
|
-
Unsupported field types throw
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
209
|
+
Unsupported field types throw
|
|
210
|
+
[`Experimental_ExtractionUnsupportedFieldTypeError`](/docs/reference/ai-sdk-errors/ai-extraction-unsupported-field-type-error),
|
|
211
|
+
before provider I/O or, for AI Gateway models, after the gateway rejects the
|
|
212
|
+
field. Invalid inputs throw `InvalidArgumentError`; malformed answers throw
|
|
213
|
+
`InvalidResponseDataError`. Fields the model refuses throw
|
|
214
|
+
[`Experimental_ExtractionRefusalError`](/docs/reference/ai-sdk-errors/ai-extraction-refusal-error). Invalid answers and refusals are not
|
|
213
215
|
retried, and partial results are not supported.
|
|
214
216
|
|
|
217
|
+
## Telemetry
|
|
218
|
+
|
|
219
|
+
`experimental_extract` accepts the standard `telemetry` option, `runtimeContext`,
|
|
220
|
+
and [`onStart` and `onEnd` callbacks](/docs/ai-sdk-core/lifecycle-callbacks#experimental_extract).
|
|
221
|
+
Because extraction is experimental, custom integrations receive its lifecycle
|
|
222
|
+
through `experimental_onExtractStart`, `experimental_onExtractionModelCallStart`,
|
|
223
|
+
`experimental_onExtractionModelCallEnd`, and `experimental_onExtractEnd`; errors
|
|
224
|
+
use `onError`. With `recordInputs: false`, integrations do not receive the state,
|
|
225
|
+
fields, or reference date, and with `recordOutputs: false` they do not receive
|
|
226
|
+
answers. Request headers and provider options are never sent to telemetry
|
|
227
|
+
because they can contain credentials, and file URLs and references in the state
|
|
228
|
+
are replaced with `[redacted]`; `onStart` and `onEnd` still receive the
|
|
229
|
+
original values. See [Telemetry](/docs/ai-sdk-core/telemetry#experimental_extract) for
|
|
230
|
+
the OpenTelemetry spans.
|
|
231
|
+
|
|
215
232
|
## Testing
|
|
216
233
|
|
|
217
234
|
Use `Experimental_ExtractionMockModelV4` from `ai/test`:
|
|
@@ -30,7 +30,9 @@ The typical flow is:
|
|
|
30
30
|
1. Tool calls are handled by your application with `onToolCall`.
|
|
31
31
|
|
|
32
32
|
For continuous **OpenAI Live** conversations, use an application-owned WebSocket
|
|
33
|
-
relay or optional WebRTC via `api.session`.
|
|
33
|
+
relay or optional WebRTC via `api.session`. With
|
|
34
|
+
[AI Gateway](/providers/ai-sdk-providers/ai-gateway#live-models), the browser can
|
|
35
|
+
also connect straight to the Gateway with a token from `api.token`. Live uses client delegation: your
|
|
34
36
|
application handles delegated work and submits context rather than using the
|
|
35
37
|
turn-based tool loop below. See the
|
|
36
38
|
[`experimental_useRealtime` reference](/docs/reference/ai-sdk-ui/use-realtime)
|
|
@@ -417,8 +417,8 @@ try {
|
|
|
417
417
|
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `nova-2` (+ variants) |
|
|
418
418
|
| [Deepgram](/providers/ai-sdk-providers/deepgram#transcription-models) | `nova-3` (+ variants) |
|
|
419
419
|
| [Gladia](/providers/ai-sdk-providers/gladia#transcription-models) | `default` |
|
|
420
|
-
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#transcription-models) | `
|
|
421
|
-
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#transcription-models) | `universal-
|
|
420
|
+
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#transcription-models) | `assemblyai-stt-3-7` |
|
|
421
|
+
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#transcription-models) | `universal-2` |
|
|
422
422
|
| [Fal](/providers/ai-sdk-providers/fal#transcription-models) | `whisper` |
|
|
423
423
|
| [Fal](/providers/ai-sdk-providers/fal#transcription-models) | `wizper` |
|
|
424
424
|
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#transcription-models) | `chirp_2` |
|
|
@@ -255,5 +255,6 @@ try {
|
|
|
255
255
|
| [Fish Audio](/providers/ai-sdk-providers/fish-audio#speech-models) | `s1` |
|
|
256
256
|
| [Fish Audio](/providers/ai-sdk-providers/fish-audio#speech-models) | `s2-pro` |
|
|
257
257
|
| [Fish Audio](/providers/ai-sdk-providers/fish-audio#speech-models) | `s2.1-pro` |
|
|
258
|
+
| [AssemblyAI](/providers/ai-sdk-providers/assemblyai#speech-models) | `assemblyai-tts-1` |
|
|
258
259
|
|
|
259
260
|
Above are a small subset of the speech models supported by the AI SDK providers. For more, see the respective provider documentation.
|