ai 7.0.79 → 7.0.82
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 +36 -0
- package/dist/index.d.ts +95 -35
- package/dist/index.js +601 -418
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +9 -1
- package/dist/internal/index.js +4 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/test/index.d.ts +4 -1
- package/dist/test/index.js +4 -0
- package/dist/test/index.js.map +1 -1
- package/docs/03-agents/06-policy-tool-approvals.mdx +1 -1
- package/docs/03-agents/06-tool-approvals.mdx +6 -0
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +6 -4
- package/docs/03-ai-sdk-core/50-error-handling.mdx +17 -2
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +6 -0
- package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +1 -1
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -4
- package/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +6 -2
- package/docs/07-reference/01-ai-sdk-core/16-tool-loop-agent.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +2 -2
- package/docs/07-reference/04-ai-sdk-workflow/03-generate-video.mdx +157 -0
- package/docs/07-reference/04-ai-sdk-workflow/index.mdx +6 -0
- package/docs/07-reference/05-ai-sdk-errors/ai-stream-provider-error.mdx +52 -0
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +1 -0
- package/package.json +14 -3
- package/src/embed/embed-many.ts +78 -8
- package/src/error/index.ts +1 -0
- package/src/error/stream-provider-error.ts +78 -0
- package/src/generate-text/execute-tools-from-stream.ts +3 -0
- package/src/generate-text/generate-text-result.ts +2 -1
- package/src/generate-text/generate-text.ts +6 -3
- package/src/generate-text/stream-language-model-call.ts +8 -0
- package/src/generate-text/to-response-messages.ts +1 -0
- package/src/generate-text/tool-approval-configuration.ts +5 -1
- package/src/generate-text/tool-approval-request-output.ts +5 -0
- package/src/middleware/wrap-embedding-model.ts +11 -2
- package/src/model/get-embedding-model-max-input-bytes-per-call.ts +15 -0
- package/src/prompt/content-part.ts +1 -0
- package/src/prompt/normalize-stream-provider-error.ts +131 -0
- package/src/test/mock-embedding-model-v4.ts +9 -0
- package/src/ui/convert-to-model-messages.ts +3 -0
- package/src/ui/process-ui-message-stream.ts +6 -0
- package/src/ui/ui-messages.ts +10 -0
- package/src/ui/validate-ui-messages.ts +10 -0
- package/src/ui-message-stream/to-ui-message-chunk.ts +1 -0
- package/src/ui-message-stream/ui-message-chunks.ts +2 -0
package/dist/test/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from '@ai-sdk/provider-utils/test';
|
|
2
2
|
import { EmbeddingModelV3, EmbeddingModelV4, ImageModelV3, ImageModelV4, LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, ProviderV3, TranscriptionModelV3, SpeechModelV3, RerankingModelV3, ProviderV4, TranscriptionModelV4, SpeechModelV4, RerankingModelV4, Experimental_SpeechTranslationModelV4, Experimental_VideoModelV3, Experimental_VideoModelV4 } from '@ai-sdk/provider';
|
|
3
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from '@ai-sdk/provider-utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Creates a ReadableStream that emits the provided values with an optional delay between each value.
|
|
@@ -41,13 +42,15 @@ declare class MockEmbeddingModelV4 implements EmbeddingModelV4 {
|
|
|
41
42
|
readonly provider: EmbeddingModelV4['provider'];
|
|
42
43
|
readonly modelId: EmbeddingModelV4['modelId'];
|
|
43
44
|
readonly maxEmbeddingsPerCall: EmbeddingModelV4['maxEmbeddingsPerCall'];
|
|
45
|
+
readonly [EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL]: PromiseLike<number | undefined> | number | undefined;
|
|
44
46
|
readonly supportsParallelCalls: EmbeddingModelV4['supportsParallelCalls'];
|
|
45
47
|
doEmbed: EmbeddingModelV4['doEmbed'];
|
|
46
48
|
doEmbedCalls: Parameters<EmbeddingModelV4['doEmbed']>[0][];
|
|
47
|
-
constructor({ provider, modelId, maxEmbeddingsPerCall, supportsParallelCalls, doEmbed, }?: {
|
|
49
|
+
constructor({ provider, modelId, maxEmbeddingsPerCall, maxInputBytesPerCall, supportsParallelCalls, doEmbed, }?: {
|
|
48
50
|
provider?: EmbeddingModelV4['provider'];
|
|
49
51
|
modelId?: EmbeddingModelV4['modelId'];
|
|
50
52
|
maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;
|
|
53
|
+
maxInputBytesPerCall?: PromiseLike<number | undefined> | number | undefined;
|
|
51
54
|
supportsParallelCalls?: EmbeddingModelV4['supportsParallelCalls'];
|
|
52
55
|
doEmbed?: EmbeddingModelV4['doEmbed'] | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>> | Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>[];
|
|
53
56
|
});
|
package/dist/test/index.js
CHANGED
|
@@ -62,11 +62,13 @@ var MockEmbeddingModelV3 = class {
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
// src/test/mock-embedding-model-v4.ts
|
|
65
|
+
import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from "@ai-sdk/provider-utils";
|
|
65
66
|
var MockEmbeddingModelV4 = class {
|
|
66
67
|
constructor({
|
|
67
68
|
provider = "mock-provider",
|
|
68
69
|
modelId = "mock-model-id",
|
|
69
70
|
maxEmbeddingsPerCall = 1,
|
|
71
|
+
maxInputBytesPerCall,
|
|
70
72
|
supportsParallelCalls = false,
|
|
71
73
|
doEmbed = notImplemented
|
|
72
74
|
} = {}) {
|
|
@@ -75,6 +77,7 @@ var MockEmbeddingModelV4 = class {
|
|
|
75
77
|
this.provider = provider;
|
|
76
78
|
this.modelId = modelId;
|
|
77
79
|
this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? void 0;
|
|
80
|
+
this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] = maxInputBytesPerCall;
|
|
78
81
|
this.supportsParallelCalls = supportsParallelCalls;
|
|
79
82
|
this.doEmbed = async (options) => {
|
|
80
83
|
this.doEmbedCalls.push(options);
|
|
@@ -88,6 +91,7 @@ var MockEmbeddingModelV4 = class {
|
|
|
88
91
|
};
|
|
89
92
|
}
|
|
90
93
|
};
|
|
94
|
+
EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL;
|
|
91
95
|
|
|
92
96
|
// src/test/mock-image-model-v3.ts
|
|
93
97
|
var MockImageModelV3 = class {
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/simulate-readable-stream.ts","../../test/index.ts","../../src/test/not-implemented.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-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-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"],"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","import { 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 { 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 { 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","export function notImplemented(): never {\n throw new Error('Not implemented');\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 { 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 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 supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV4['provider'];\n modelId?: EmbeddingModelV4['modelId'];\n maxEmbeddingsPerCall?: EmbeddingModelV4['maxEmbeddingsPerCall'] | null;\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.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 { 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\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\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 { 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\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\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"],"mappings":";AAAA,SAAS,SAAS,qBAAqB;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AACpB,QAAM,QAAQ,WAAW,SAAS;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAM,MAAM,UAAU,IAAI,mBAAmB,cAAc;AAC3D,mBAAW,QAAQ,OAAO,OAAO,CAAC;AAAA,MACpC,OAAO;AACL,mBAAW,MAAM;AAAA,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SuchModelError","simulateReadableStream"]}
|
|
1
|
+
{"version":3,"sources":["../../src/util/simulate-readable-stream.ts","../../test/index.ts","../../src/test/not-implemented.ts","../../src/test/mock-embedding-model-v3.ts","../../src/test/mock-embedding-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-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"],"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","import { 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 { 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 { 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","export function notImplemented(): never {\n throw new Error('Not implemented');\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 { 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\n doGenerate: ImageModelV4['doGenerate'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxImagesPerCall = 1,\n doGenerate = notImplemented,\n }: {\n provider?: ImageModelV4['provider'];\n modelId?: ImageModelV4['modelId'];\n maxImagesPerCall?: ImageModelV4['maxImagesPerCall'];\n doGenerate?: ImageModelV4['doGenerate'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxImagesPerCall = maxImagesPerCall;\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 { 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\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n doGenerate = notImplemented,\n doStream,\n }: {\n provider?: TranscriptionModelV4['provider'];\n modelId?: TranscriptionModelV4['modelId'];\n doGenerate?: TranscriptionModelV4['doGenerate'];\n doStream?: TranscriptionModelV4['doStream'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\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"],"mappings":";AAAA,SAAS,SAAS,qBAAqB;AAWhC,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AACpB,QAAM,QAAQ,WAAW,SAAS;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAM,MAAM,UAAU,IAAI,mBAAmB,cAAc;AAC3D,mBAAW,QAAQ,OAAO,OAAO,CAAC;AAAA,MACpC,OAAO;AACL,mBAAW,MAAM;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ACpCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACPA,SAAS,iBAAwB;AACtC,QAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACCO,IAAM,uBAAN,MAAuD;AAAA,EAY5D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,UAAU;AAAA,EACZ,IASI,CAAC,GAAG;AA1BR,SAAS,uBAAuB;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,uBAAN,MAAuD;AAAA,EAQ5D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,EACb,IAII,CAAC,GAAG;AAfR,SAAS,uBAAuB;AAgB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AACF;;;ACrBO,IAAM,mBAAN,MAA4D;AAAA,EAQjE,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,aAAa;AAAA,EACf,IAKI,CAAC,GAAG;AAjBR,SAAS,uBAAuB;AAkB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,mBAAmB;AACxB,SAAK,aAAa;AAAA,EACpB;AACF;;;ACxBO,IAAM,mBAAN,MAA4D;AAAA,EAWjE,YACE,UAQI,CAAC,GACL;AApBF,SAAS,uBAAuB;AAqB9B,SAAK,WAAW,QAAQ,YAAY;AACpC,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,mBAAmB,QAAQ,oBAAoB;AACpD,SAAK,aACH,gBAAgB,UAAU,QAAQ,aAAa;AACjD,SAAK,sBAAsB,QAAQ;AACnC,SAAK,UAAU,QAAQ;AACvB,SAAK,WAAW,QAAQ;AAAA,EAC1B;AACF;;;AClCO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAM,OAAO,SAAS,KAAK,OAAO,OAAO,SAAS,CAAC;AAC5D;;;AnB2BO,IAAMC,0BAAyB;","names":["NoSuchModelError","simulateReadableStream"]}
|
|
@@ -89,7 +89,7 @@ const result = await generateText({
|
|
|
89
89
|
|
|
90
90
|
## Writing the Rego policy
|
|
91
91
|
|
|
92
|
-
The policy emits a decision object. `reason` is optional and is surfaced back to the model (for `deny`) or to the human approver (for `requires-approval`).
|
|
92
|
+
The policy emits a decision object. `reason` is optional and is surfaced back to the model (for `deny`) or to the human approver (for `requires-approval`). A manual approval request exposes it as `reason` in core results and as `approval.requestReason` in UI messages.
|
|
93
93
|
|
|
94
94
|
```rego
|
|
95
95
|
package agent.call
|
|
@@ -236,6 +236,9 @@ export default function Chat() {
|
|
|
236
236
|
if (part.state === 'approval-requested' && !part.approval.isAutomatic) {
|
|
237
237
|
return (
|
|
238
238
|
<div key={part.toolCallId}>
|
|
239
|
+
{part.approval.requestReason && (
|
|
240
|
+
<p>{part.approval.requestReason}</p>
|
|
241
|
+
)}
|
|
239
242
|
<button
|
|
240
243
|
onClick={() =>
|
|
241
244
|
addToolApprovalResponse({
|
|
@@ -265,6 +268,9 @@ export default function Chat() {
|
|
|
265
268
|
```
|
|
266
269
|
|
|
267
270
|
Only call `addToolApprovalResponse` for manual approvals. Automatic approvals and denials already include approval state in the stream.
|
|
271
|
+
When a manual approval status includes a reason, it is available as
|
|
272
|
+
`part.approval.requestReason`. A reason supplied with
|
|
273
|
+
`addToolApprovalResponse` is stored separately as `part.approval.reason`.
|
|
268
274
|
|
|
269
275
|
## Security Considerations
|
|
270
276
|
|
|
@@ -188,14 +188,15 @@ string or as an object with a `type` field:
|
|
|
188
188
|
- `'denied'`: record an automatic denial by emitting approval request/response parts in the output, then surface a denied tool output
|
|
189
189
|
- `'user-approval'`: emit an approval request and wait for an explicit response
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
reason
|
|
191
|
+
Object statuses can also include a reason. For automatic approvals and denials,
|
|
192
|
+
the reason is emitted on the approval response. For manual approval, the reason
|
|
193
|
+
is emitted on the approval request so it can be shown to the approver:
|
|
193
194
|
|
|
194
195
|
```ts
|
|
195
196
|
toolApproval: {
|
|
196
197
|
runCommand: {
|
|
197
|
-
type: '
|
|
198
|
-
reason: '
|
|
198
|
+
type: 'user-approval',
|
|
199
|
+
reason: 'filesystem changes require operator review',
|
|
199
200
|
},
|
|
200
201
|
}
|
|
201
202
|
```
|
|
@@ -285,6 +286,7 @@ for (const part of result.content) {
|
|
|
285
286
|
if (part.type === 'tool-approval-request' && !part.isAutomatic) {
|
|
286
287
|
console.log(part.approvalId); // Unique ID for this approval request
|
|
287
288
|
console.log(part.toolCall); // Contains toolName, input, etc.
|
|
289
|
+
console.log(part.reason); // Why this tool call requires approval
|
|
288
290
|
}
|
|
289
291
|
}
|
|
290
292
|
```
|
|
@@ -57,7 +57,7 @@ It is recommended to also add a try-catch block for errors that
|
|
|
57
57
|
happen outside of the streaming.
|
|
58
58
|
|
|
59
59
|
```ts highlight="14-22"
|
|
60
|
-
import { streamText } from 'ai';
|
|
60
|
+
import { StreamProviderError, streamText } from 'ai';
|
|
61
61
|
__PROVIDER_IMPORT__;
|
|
62
62
|
|
|
63
63
|
try {
|
|
@@ -72,7 +72,15 @@ try {
|
|
|
72
72
|
|
|
73
73
|
case 'error': {
|
|
74
74
|
const error = part.error;
|
|
75
|
-
|
|
75
|
+
|
|
76
|
+
if (StreamProviderError.isInstance(error)) {
|
|
77
|
+
console.error(error.message, {
|
|
78
|
+
type: error.type,
|
|
79
|
+
code: error.code,
|
|
80
|
+
statusCode: error.statusCode,
|
|
81
|
+
isRetryable: error.isRetryable,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
76
84
|
break;
|
|
77
85
|
}
|
|
78
86
|
|
|
@@ -93,6 +101,13 @@ try {
|
|
|
93
101
|
}
|
|
94
102
|
```
|
|
95
103
|
|
|
104
|
+
Well-formed provider error events that arrive after streaming starts are
|
|
105
|
+
normalized into [`StreamProviderError`](/docs/reference/ai-sdk-errors/ai-stream-provider-error)
|
|
106
|
+
instances. The same instance is supplied to callbacks such as `onError` and to
|
|
107
|
+
the `error` part in the full stream. The SDK does not automatically restart a
|
|
108
|
+
partially consumed stream; use `isRetryable` to implement application-managed
|
|
109
|
+
retries and decide how to handle any partial output.
|
|
110
|
+
|
|
96
111
|
## Handling stream aborts
|
|
97
112
|
|
|
98
113
|
When streams are aborted (e.g., via chat stop button), you may want to perform cleanup operations like updating stored messages in your UI. Use the `onAbort` callback to handle these cases.
|
|
@@ -471,6 +471,9 @@ export default function Chat() {
|
|
|
471
471
|
return (
|
|
472
472
|
<div key={part.toolCallId}>
|
|
473
473
|
<p>Get weather for {part.input.city}?</p>
|
|
474
|
+
{part.approval.requestReason && (
|
|
475
|
+
<p>{part.approval.requestReason}</p>
|
|
476
|
+
)}
|
|
474
477
|
<button
|
|
475
478
|
onClick={() =>
|
|
476
479
|
addToolApprovalResponse({
|
|
@@ -536,6 +539,9 @@ decisions already arrive in the UI stream as `approval-requested` and
|
|
|
536
539
|
`approval-responded` states, and denied executions continue to `output-denied`.
|
|
537
540
|
If you return a `reason` from an automatic approval or denial, it is available
|
|
538
541
|
as `part.approval.reason`.
|
|
542
|
+
For manual approval requests, the reason for requiring approval is available as
|
|
543
|
+
`part.approval.requestReason`. It remains separate from an optional response
|
|
544
|
+
reason supplied to `addToolApprovalResponse`.
|
|
539
545
|
|
|
540
546
|
### Securing Approvals for Sensitive Tools
|
|
541
547
|
|
|
@@ -367,11 +367,11 @@ Format: Server-Sent Event with JSON object
|
|
|
367
367
|
Example:
|
|
368
368
|
|
|
369
369
|
```
|
|
370
|
-
data: {"type":"tool-approval-request","toolCallId":"call_fJdQDqnXeGxTmr4E3YPSR7Ar","approvalId":"approval_123","
|
|
370
|
+
data: {"type":"tool-approval-request","toolCallId":"call_fJdQDqnXeGxTmr4E3YPSR7Ar","approvalId":"approval_123","reason":"Requires operator review"}
|
|
371
371
|
|
|
372
372
|
```
|
|
373
373
|
|
|
374
|
-
When `isAutomatic` is omitted, the request expects an explicit approval response from the client.
|
|
374
|
+
When `isAutomatic` is omitted, the request expects an explicit approval response from the client. `reason` is optional and explains why the tool call requires approval.
|
|
375
375
|
|
|
376
376
|
### Tool Approval Response Part
|
|
377
377
|
|
|
@@ -576,7 +576,7 @@ To see `generateText` in action, check out [these examples](#examples).
|
|
|
576
576
|
type: 'ToolApprovalConfiguration<TOOLS, RUNTIME_CONTEXT>',
|
|
577
577
|
isOptional: true,
|
|
578
578
|
description:
|
|
579
|
-
"Approval configuration for this call. Pass a `GenericToolApprovalFunction` to handle all tool calls in one callback with `toolCall`, `tools`, `toolsContext`, `messages`, and `runtimeContext`, or pass a per-tool object where each key can be a status (`'not-applicable'`, `'approved'`, `'denied'`, or `'user-approval'`), an object form such as `{ type: 'denied', reason: 'blocked by policy' }`, or a `SingleToolApprovalFunction` that receives the tool input and options `toolCallId`, `messages`, `toolContext`, and `runtimeContext` (same shape as tool execution options without `abortSignal`, with `context` renamed to `toolContext`). The `RUNTIME_CONTEXT` type parameter matches the call's `runtimeContext`. A `GenericToolApprovalFunction` or `SingleToolApprovalFunction` may return `undefined` for the same effect as `'not-applicable'`. `'not-applicable'` is the default execution path and runs the tool without approval metadata. Use `'approved'`, `'denied'`, or their object forms when you want explicit automatic approval request/response parts in the output.
|
|
579
|
+
"Approval configuration for this call. Pass a `GenericToolApprovalFunction` to handle all tool calls in one callback with `toolCall`, `tools`, `toolsContext`, `messages`, and `runtimeContext`, or pass a per-tool object where each key can be a status (`'not-applicable'`, `'approved'`, `'denied'`, or `'user-approval'`), an object form such as `{ type: 'denied', reason: 'blocked by policy' }`, or a `SingleToolApprovalFunction` that receives the tool input and options `toolCallId`, `messages`, `toolContext`, and `runtimeContext` (same shape as tool execution options without `abortSignal`, with `context` renamed to `toolContext`). The `RUNTIME_CONTEXT` type parameter matches the call's `runtimeContext`. A `GenericToolApprovalFunction` or `SingleToolApprovalFunction` may return `undefined` for the same effect as `'not-applicable'`. `'not-applicable'` is the default execution path and runs the tool without approval metadata. Use `'approved'`, `'denied'`, or their object forms when you want explicit automatic approval request/response parts in the output. Object statuses can include a `reason`: automatic approvals and denials forward it to the approval response, while manual user approvals forward it to the approval request for the human approver. This setting takes precedence over a tool's `needsApproval` default.",
|
|
580
580
|
},
|
|
581
581
|
{
|
|
582
582
|
name: 'experimental_toolCallers',
|
|
@@ -620,7 +620,7 @@ To see `streamText` in action, check out [these examples](#examples).
|
|
|
620
620
|
type: 'ToolApprovalConfiguration<TOOLS, RUNTIME_CONTEXT>',
|
|
621
621
|
isOptional: true,
|
|
622
622
|
description:
|
|
623
|
-
"Approval configuration for this call. Pass a `GenericToolApprovalFunction` to handle all tool calls in one callback with `toolCall`, `tools`, `toolsContext`, `messages`, and `runtimeContext`, or pass a per-tool object where each key can be a status (`'not-applicable'`, `'approved'`, `'denied'`, or `'user-approval'`), an object form such as `{ type: 'denied', reason: 'blocked by policy' }`, or a `SingleToolApprovalFunction` that receives the tool input and options `toolCallId`, `messages`, `toolContext`, and `runtimeContext` (same shape as tool execution options without `abortSignal`, with `context` renamed to `toolContext`). The `RUNTIME_CONTEXT` type parameter matches the call's `runtimeContext`. A `GenericToolApprovalFunction` or `SingleToolApprovalFunction` may return `undefined` for the same effect as `'not-applicable'`. `'not-applicable'` is the default execution path and runs the tool without approval metadata. Use `'approved'`, `'denied'`, or their object forms when you want explicit automatic approval request/response parts in the output.
|
|
623
|
+
"Approval configuration for this call. Pass a `GenericToolApprovalFunction` to handle all tool calls in one callback with `toolCall`, `tools`, `toolsContext`, `messages`, and `runtimeContext`, or pass a per-tool object where each key can be a status (`'not-applicable'`, `'approved'`, `'denied'`, or `'user-approval'`), an object form such as `{ type: 'denied', reason: 'blocked by policy' }`, or a `SingleToolApprovalFunction` that receives the tool input and options `toolCallId`, `messages`, `toolContext`, and `runtimeContext` (same shape as tool execution options without `abortSignal`, with `context` renamed to `toolContext`). The `RUNTIME_CONTEXT` type parameter matches the call's `runtimeContext`. A `GenericToolApprovalFunction` or `SingleToolApprovalFunction` may return `undefined` for the same effect as `'not-applicable'`. `'not-applicable'` is the default execution path and runs the tool without approval metadata. Use `'approved'`, `'denied'`, or their object forms when you want explicit automatic approval request/response parts in the output. Object statuses can include a `reason`: automatic approvals and denials forward it to the approval response, while manual user approvals forward it to the approval request for the human approver. This setting takes precedence over a tool's `needsApproval` default.",
|
|
624
624
|
},
|
|
625
625
|
{
|
|
626
626
|
name: 'experimental_toolCallers',
|
|
@@ -1187,7 +1187,7 @@ To see `streamText` in action, check out [these examples](#examples).
|
|
|
1187
1187
|
type: '(event: OnErrorResult) => Promise<void> |void',
|
|
1188
1188
|
isOptional: true,
|
|
1189
1189
|
description:
|
|
1190
|
-
'Callback that is called when an error occurs during streaming.
|
|
1190
|
+
'Callback that is called when an error occurs during streaming. Well-formed mid-stream provider error events are exposed as StreamProviderError instances.',
|
|
1191
1191
|
properties: [
|
|
1192
1192
|
{
|
|
1193
1193
|
type: 'OnErrorResult',
|
|
@@ -1195,7 +1195,8 @@ To see `streamText` in action, check out [these examples](#examples).
|
|
|
1195
1195
|
{
|
|
1196
1196
|
name: 'error',
|
|
1197
1197
|
type: 'unknown',
|
|
1198
|
-
description:
|
|
1198
|
+
description:
|
|
1199
|
+
'The error that occurred. Use StreamProviderError.isInstance to identify normalized provider error events and inspect their retry metadata.',
|
|
1199
1200
|
},
|
|
1200
1201
|
],
|
|
1201
1202
|
},
|
|
@@ -3299,7 +3300,7 @@ To see `streamText` in action, check out [these examples](#examples).
|
|
|
3299
3300
|
name: 'stream',
|
|
3300
3301
|
type: 'AsyncIterable<TextStreamPart<TOOLS>> & ReadableStream<TextStreamPart<TOOLS>>',
|
|
3301
3302
|
description:
|
|
3302
|
-
'A stream with all events, including text deltas, tool calls, tool results, and errors. You can use it as either an AsyncIterable or a ReadableStream. Only errors that stop the stream, such as network errors, are thrown.',
|
|
3303
|
+
'A stream with all events, including text deltas, tool calls, tool results, and errors. Well-formed mid-stream provider failures are emitted in error parts as StreamProviderError instances. You can use it as either an AsyncIterable or a ReadableStream. Only errors that stop the stream, such as network errors, are thrown.',
|
|
3303
3304
|
properties: [
|
|
3304
3305
|
{
|
|
3305
3306
|
type: 'TextStreamPart',
|
|
@@ -7,8 +7,12 @@ description: API Reference for embedMany.
|
|
|
7
7
|
|
|
8
8
|
Embed several values using an embedding model.
|
|
9
9
|
|
|
10
|
-
`embedMany` automatically splits large requests into smaller chunks
|
|
11
|
-
has a limit on
|
|
10
|
+
`embedMany` automatically splits large requests into smaller chunks when the
|
|
11
|
+
model has a limit on either the number of embeddings or the UTF-8 input bytes
|
|
12
|
+
that can be processed in a single call. Providers can use a conservative byte
|
|
13
|
+
budget to keep requests below aggregate token limits without adding a tokenizer
|
|
14
|
+
to the AI SDK core package. An individual value larger than the byte budget is
|
|
15
|
+
sent in its own call because splitting it would change the resulting embedding.
|
|
12
16
|
|
|
13
17
|
```ts
|
|
14
18
|
import { embedMany } from 'ai';
|
|
@@ -109,7 +109,7 @@ To see `ToolLoopAgent` in action, check out [these examples](#examples).
|
|
|
109
109
|
type: 'ToolApprovalConfiguration<TOOLS, RUNTIME_CONTEXT>',
|
|
110
110
|
isOptional: true,
|
|
111
111
|
description:
|
|
112
|
-
"Approval configuration for the agent. Pass a `GenericToolApprovalFunction` to handle all tool calls in one callback with `toolCall`, `tools`, `toolsContext`, `messages`, and `runtimeContext`, or pass a per-tool object where each key can be a status (`'not-applicable'`, `'approved'`, `'denied'`, or `'user-approval'`), an object form such as `{ type: 'denied', reason: 'blocked by policy' }`, or a `SingleToolApprovalFunction` that receives the tool input and options `toolCallId`, `messages`, `toolContext`, and `runtimeContext` (same shape as tool execution options without `abortSignal`, with `context` renamed to `toolContext`). The `RUNTIME_CONTEXT` type parameter matches the agent's `runtimeContext`. A `GenericToolApprovalFunction` or `SingleToolApprovalFunction` may return `undefined` for the same effect as `'not-applicable'`. `'not-applicable'` is the default execution path and runs the tool without approval metadata. Use `'approved'`, `'denied'`, or their object forms when you want explicit automatic approval request/response parts in the output.
|
|
112
|
+
"Approval configuration for the agent. Pass a `GenericToolApprovalFunction` to handle all tool calls in one callback with `toolCall`, `tools`, `toolsContext`, `messages`, and `runtimeContext`, or pass a per-tool object where each key can be a status (`'not-applicable'`, `'approved'`, `'denied'`, or `'user-approval'`), an object form such as `{ type: 'denied', reason: 'blocked by policy' }`, or a `SingleToolApprovalFunction` that receives the tool input and options `toolCallId`, `messages`, `toolContext`, and `runtimeContext` (same shape as tool execution options without `abortSignal`, with `context` renamed to `toolContext`). The `RUNTIME_CONTEXT` type parameter matches the agent's `runtimeContext`. A `GenericToolApprovalFunction` or `SingleToolApprovalFunction` may return `undefined` for the same effect as `'not-applicable'`. `'not-applicable'` is the default execution path and runs the tool without approval metadata. Use `'approved'`, `'denied'`, or their object forms when you want explicit automatic approval request/response parts in the output. Object statuses can include a `reason`: automatic approvals and denials forward it to the approval response, while manual user approvals forward it to the approval request for the human approver. This setting takes precedence over a tool's `needsApproval` default.",
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
name: 'experimental_toolCallers',
|
|
@@ -74,8 +74,8 @@ A Promise that resolves to an array of [`ModelMessage`](/docs/reference/ai-sdk-c
|
|
|
74
74
|
|
|
75
75
|
`convertToModelMessages` preserves tool approval state from UI messages when converting them back into `ModelMessage`s for a follow-up `generateText` or `streamText` call.
|
|
76
76
|
|
|
77
|
-
- Tool parts
|
|
78
|
-
- Tool parts in `approval-responded` state become `tool-approval-response` content parts
|
|
77
|
+
- Tool parts with approval metadata produce `tool-approval-request` content parts. `approval.requestReason` is forwarded as the request `reason` when present.
|
|
78
|
+
- Tool parts in `approval-responded` state also become `tool-approval-response` content parts. The separate response `reason` is forwarded when present.
|
|
79
79
|
- Automatic approval metadata is preserved by forwarding `approval.isAutomatic` to the `tool-approval-request` part.
|
|
80
80
|
- Denied tool approvals also produce a synthetic `tool-result` with `output: { type: 'execution-denied', reason?: string }`, so the model receives a complete tool lifecycle and can respond to the denial in the next step.
|
|
81
81
|
|