ai 7.0.120 → 7.0.123

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/index.d.ts +7423 -7247
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +19263 -22470
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +2044 -2004
  7. package/dist/internal/index.d.ts.map +1 -0
  8. package/dist/internal/index.js +3255 -3921
  9. package/dist/internal/index.js.map +1 -1
  10. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  11. package/dist/test/index.d.ts +294 -273
  12. package/dist/test/index.d.ts.map +1 -0
  13. package/dist/test/index.js +325 -469
  14. package/dist/test/index.js.map +1 -1
  15. package/docs/02-foundations/03-prompts.mdx +3 -1
  16. package/docs/02-foundations/06-provider-options.mdx +1 -1
  17. package/docs/02-getting-started/06-nodejs.mdx +4 -4
  18. package/docs/02-getting-started/08-tanstack-start.mdx +1 -1
  19. package/docs/03-agents/05-configuring-call-options.mdx +1 -1
  20. package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +1 -1
  21. package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +3 -0
  22. package/docs/03-ai-sdk-core/17-mcp-apps.mdx +5 -5
  23. package/docs/03-ai-sdk-core/37-speech.mdx +1 -1
  24. package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
  25. package/docs/03-ai-sdk-core/60-telemetry.mdx +2 -2
  26. package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +24 -0
  27. package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +12 -12
  28. package/docs/04-ai-sdk-ui/02-chatbot.mdx +9 -0
  29. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +17 -7
  30. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +12 -5
  31. package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +17 -10
  32. package/docs/04-ai-sdk-ui/05-completion.mdx +1 -1
  33. package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +2 -2
  34. package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +8 -7
  35. package/docs/05-ai-sdk-rsc/04-multistep-interfaces.mdx +1 -1
  36. package/docs/05-ai-sdk-rsc/06-loading-state.mdx +19 -10
  37. package/docs/05-ai-sdk-rsc/08-error-handling.mdx +2 -0
  38. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +4 -3
  39. package/docs/06-advanced/02-stopping-streams.mdx +2 -2
  40. package/docs/06-advanced/04-caching.mdx +9 -5
  41. package/docs/06-advanced/05-multiple-streamables.mdx +1 -1
  42. package/docs/06-advanced/07-rendering-ui-with-language-models.mdx +16 -16
  43. package/docs/06-advanced/09-multistep-interfaces.mdx +1 -1
  44. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +4 -4
  45. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +5 -5
  46. package/docs/07-reference/01-ai-sdk-core/14-upload-file.mdx +4 -4
  47. package/docs/07-reference/01-ai-sdk-core/14-upload-skill.mdx +1 -1
  48. package/docs/07-reference/01-ai-sdk-core/15-agent.mdx +1 -1
  49. package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +1 -4
  50. package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +1 -1
  51. package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +1 -1
  52. package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +2 -2
  53. package/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +1 -1
  54. package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +1 -1
  55. package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +5 -4
  56. package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +3 -2
  57. package/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +7 -0
  58. package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +7 -0
  59. package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +2 -2
  60. package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +2 -2
  61. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +1 -1
  62. package/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +4 -5
  63. package/docs/08-migration-guides/26-migration-guide-5-0.mdx +2 -1
  64. package/docs/08-migration-guides/29-migration-guide-4-0.mdx +9 -9
  65. package/docs/08-migration-guides/37-migration-guide-3-3.mdx +1 -1
  66. package/docs/08-migration-guides/38-migration-guide-3-2.mdx +1 -1
  67. package/docs/08-migration-guides/39-migration-guide-3-1.mdx +1 -1
  68. package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +8 -6
  69. package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +6 -6
  70. package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +1 -1
  71. package/package.json +17 -17
  72. package/src/agent/create-agent-ui-stream-response.ts +3 -0
  73. package/src/agent/pipe-agent-ui-stream-to-response.ts +3 -0
  74. package/src/embed/embed-many.ts +5 -3
  75. package/src/generate-image/generate-image.ts +8 -3
  76. package/src/generate-text/prune-messages.ts +1 -1
  77. package/src/generate-text/smooth-stream.ts +24 -9
  78. package/src/generate-text/stream-text-result.ts +5 -0
  79. package/src/generate-video/generate-video.ts +6 -4
  80. package/src/middleware/extract-reasoning-middleware.ts +27 -11
  81. package/src/registry/provider-registry.ts +1 -1
  82. package/src/ui/chat.ts +13 -4
  83. package/src/ui/convert-to-model-messages.ts +18 -6
  84. package/src/ui/http-chat-transport.ts +19 -3
  85. package/src/ui/last-assistant-message-is-complete-with-tool-calls.ts +15 -3
  86. package/src/ui/process-ui-message-stream.ts +51 -14
  87. package/src/ui/ui-messages.ts +14 -0
  88. package/src/ui/validate-ui-messages.ts +2 -0
  89. package/src/ui-message-stream/create-sse-stream-with-keep-alive.ts +89 -0
  90. package/src/ui-message-stream/create-ui-message-stream-response.ts +7 -1
  91. package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +7 -1
  92. package/src/ui-message-stream/to-ui-message-chunk.ts +9 -1
  93. package/src/ui-message-stream/to-ui-message-stream.ts +1 -1
  94. package/src/ui-message-stream/ui-message-stream-response-init.ts +7 -0
  95. package/src/util/set-own.ts +16 -0
@@ -1,512 +1,368 @@
1
- // src/util/simulate-readable-stream.ts
2
- import { delay as delayFunction } from "@ai-sdk/provider-utils";
3
- function simulateReadableStream({
4
- chunks,
5
- initialDelayInMs = 0,
6
- chunkDelayInMs = 0,
7
- _internal
8
- }) {
9
- const delay = _internal?.delay ?? delayFunction;
10
- let index = 0;
11
- return new ReadableStream({
12
- async pull(controller) {
13
- if (index < chunks.length) {
14
- await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);
15
- controller.enqueue(chunks[index++]);
16
- } else {
17
- controller.close();
18
- }
19
- }
20
- });
1
+ import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, delay } from "@ai-sdk/provider-utils";
2
+ import { convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId } from "@ai-sdk/provider-utils/test";
3
+ import { NoSuchModelError } from "@ai-sdk/provider";
4
+ //#region src/util/simulate-readable-stream.ts
5
+ /**
6
+ * Creates a ReadableStream that emits the provided values with an optional delay between each value.
7
+ *
8
+ * @param options - The configuration options
9
+ * @param options.chunks - Array of values to be emitted by the stream
10
+ * @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.
11
+ * @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.
12
+ * @returns A ReadableStream that emits the provided values
13
+ */
14
+ function simulateReadableStream$1({ chunks, initialDelayInMs = 0, chunkDelayInMs = 0, _internal }) {
15
+ const delay$1 = _internal?.delay ?? delay;
16
+ let index = 0;
17
+ return new ReadableStream({ async pull(controller) {
18
+ if (index < chunks.length) {
19
+ await delay$1(index === 0 ? initialDelayInMs : chunkDelayInMs);
20
+ controller.enqueue(chunks[index++]);
21
+ } else controller.close();
22
+ } });
21
23
  }
22
-
23
- // test/index.ts
24
- import {
25
- convertArrayToAsyncIterable,
26
- convertArrayToReadableStream,
27
- convertReadableStreamToArray,
28
- mockId
29
- } from "@ai-sdk/provider-utils/test";
30
-
31
- // src/test/not-implemented.ts
24
+ //#endregion
25
+ //#region src/test/not-implemented.ts
32
26
  function notImplemented() {
33
- throw new Error("Not implemented");
27
+ throw new Error("Not implemented");
34
28
  }
35
-
36
- // src/test/mock-embedding-model-v3.ts
29
+ //#endregion
30
+ //#region src/test/mock-embedding-model-v3.ts
37
31
  var MockEmbeddingModelV3 = class {
38
- constructor({
39
- provider = "mock-provider",
40
- modelId = "mock-model-id",
41
- maxEmbeddingsPerCall = 1,
42
- supportsParallelCalls = false,
43
- doEmbed = notImplemented
44
- } = {}) {
45
- this.specificationVersion = "v3";
46
- this.doEmbedCalls = [];
47
- this.provider = provider;
48
- this.modelId = modelId;
49
- this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? void 0;
50
- this.supportsParallelCalls = supportsParallelCalls;
51
- this.doEmbed = async (options) => {
52
- this.doEmbedCalls.push(options);
53
- if (typeof doEmbed === "function") {
54
- return doEmbed(options);
55
- } else if (Array.isArray(doEmbed)) {
56
- return doEmbed[this.doEmbedCalls.length - 1];
57
- } else {
58
- return doEmbed;
59
- }
60
- };
61
- }
32
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", maxEmbeddingsPerCall = 1, supportsParallelCalls = false, doEmbed = notImplemented } = {}) {
33
+ this.specificationVersion = "v3";
34
+ this.doEmbedCalls = [];
35
+ this.provider = provider;
36
+ this.modelId = modelId;
37
+ this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? void 0;
38
+ this.supportsParallelCalls = supportsParallelCalls;
39
+ this.doEmbed = async (options) => {
40
+ this.doEmbedCalls.push(options);
41
+ if (typeof doEmbed === "function") return doEmbed(options);
42
+ else if (Array.isArray(doEmbed)) return doEmbed[this.doEmbedCalls.length - 1];
43
+ else return doEmbed;
44
+ };
45
+ }
62
46
  };
63
-
64
- // src/test/mock-embedding-model-v4.ts
65
- import { EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from "@ai-sdk/provider-utils";
66
- EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL;
47
+ //#endregion
48
+ //#region src/test/mock-embedding-model-v4.ts
67
49
  var MockEmbeddingModelV4 = class {
68
- constructor({
69
- provider = "mock-provider",
70
- modelId = "mock-model-id",
71
- maxEmbeddingsPerCall = 1,
72
- maxInputBytesPerCall,
73
- supportsParallelCalls = false,
74
- doEmbed = notImplemented
75
- } = {}) {
76
- this.specificationVersion = "v4";
77
- this.doEmbedCalls = [];
78
- this.provider = provider;
79
- this.modelId = modelId;
80
- this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? void 0;
81
- this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] = maxInputBytesPerCall;
82
- this.supportsParallelCalls = supportsParallelCalls;
83
- this.doEmbed = async (options) => {
84
- this.doEmbedCalls.push(options);
85
- if (typeof doEmbed === "function") {
86
- return doEmbed(options);
87
- } else if (Array.isArray(doEmbed)) {
88
- return doEmbed[this.doEmbedCalls.length - 1];
89
- } else {
90
- return doEmbed;
91
- }
92
- };
93
- }
50
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", maxEmbeddingsPerCall = 1, maxInputBytesPerCall, supportsParallelCalls = false, doEmbed = notImplemented } = {}) {
51
+ this.specificationVersion = "v4";
52
+ this.doEmbedCalls = [];
53
+ this.provider = provider;
54
+ this.modelId = modelId;
55
+ this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? void 0;
56
+ this[EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL] = maxInputBytesPerCall;
57
+ this.supportsParallelCalls = supportsParallelCalls;
58
+ this.doEmbed = async (options) => {
59
+ this.doEmbedCalls.push(options);
60
+ if (typeof doEmbed === "function") return doEmbed(options);
61
+ else if (Array.isArray(doEmbed)) return doEmbed[this.doEmbedCalls.length - 1];
62
+ else return doEmbed;
63
+ };
64
+ }
94
65
  };
95
-
96
- // src/test/evaluation-mock-model-v4.ts
66
+ //#endregion
67
+ //#region src/test/evaluation-mock-model-v4.ts
97
68
  var EvaluationMockModelV4 = class {
98
- constructor({
99
- provider = "mock-provider",
100
- modelId = "mock-model-id",
101
- supportedQuestionTypes = ["choice", "score", "boolean"],
102
- doEvaluate = notImplemented
103
- } = {}) {
104
- this.specificationVersion = "v4";
105
- this.provider = provider;
106
- this.modelId = modelId;
107
- this.supportedQuestionTypes = supportedQuestionTypes;
108
- this.doEvaluate = doEvaluate;
109
- }
69
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", supportedQuestionTypes = [
70
+ "choice",
71
+ "score",
72
+ "boolean"
73
+ ], doEvaluate = notImplemented } = {}) {
74
+ this.specificationVersion = "v4";
75
+ this.provider = provider;
76
+ this.modelId = modelId;
77
+ this.supportedQuestionTypes = supportedQuestionTypes;
78
+ this.doEvaluate = doEvaluate;
79
+ }
110
80
  };
111
-
112
- // src/test/mock-image-model-v3.ts
81
+ //#endregion
82
+ //#region src/test/mock-image-model-v3.ts
113
83
  var MockImageModelV3 = class {
114
- constructor({
115
- provider = "mock-provider",
116
- modelId = "mock-model-id",
117
- maxImagesPerCall = 1,
118
- doGenerate = notImplemented
119
- } = {}) {
120
- this.specificationVersion = "v3";
121
- this.provider = provider;
122
- this.modelId = modelId;
123
- this.maxImagesPerCall = maxImagesPerCall;
124
- this.doGenerate = doGenerate;
125
- }
84
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", maxImagesPerCall = 1, doGenerate = notImplemented } = {}) {
85
+ this.specificationVersion = "v3";
86
+ this.provider = provider;
87
+ this.modelId = modelId;
88
+ this.maxImagesPerCall = maxImagesPerCall;
89
+ this.doGenerate = doGenerate;
90
+ }
126
91
  };
127
-
128
- // src/test/mock-image-model-v4.ts
92
+ //#endregion
93
+ //#region src/test/mock-image-model-v4.ts
129
94
  var MockImageModelV4 = class {
130
- constructor({
131
- provider = "mock-provider",
132
- modelId = "mock-model-id",
133
- maxImagesPerCall = 1,
134
- supportsFileInputs,
135
- supportsMaskInputs,
136
- doGenerate = notImplemented
137
- } = {}) {
138
- this.specificationVersion = "v4";
139
- this.provider = provider;
140
- this.modelId = modelId;
141
- this.maxImagesPerCall = maxImagesPerCall;
142
- this.supportsFileInputs = supportsFileInputs;
143
- this.supportsMaskInputs = supportsMaskInputs;
144
- this.doGenerate = doGenerate;
145
- }
95
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", maxImagesPerCall = 1, supportsFileInputs, supportsMaskInputs, doGenerate = notImplemented } = {}) {
96
+ this.specificationVersion = "v4";
97
+ this.provider = provider;
98
+ this.modelId = modelId;
99
+ this.maxImagesPerCall = maxImagesPerCall;
100
+ this.supportsFileInputs = supportsFileInputs;
101
+ this.supportsMaskInputs = supportsMaskInputs;
102
+ this.doGenerate = doGenerate;
103
+ }
146
104
  };
147
-
148
- // src/test/mock-language-model-v3.ts
105
+ //#endregion
106
+ //#region src/test/mock-language-model-v3.ts
149
107
  var MockLanguageModelV3 = class {
150
- constructor({
151
- provider = "mock-provider",
152
- modelId = "mock-model-id",
153
- supportedUrls = {},
154
- doGenerate = notImplemented,
155
- doStream = notImplemented
156
- } = {}) {
157
- this.specificationVersion = "v3";
158
- this.doGenerateCalls = [];
159
- this.doStreamCalls = [];
160
- this.provider = provider;
161
- this.modelId = modelId;
162
- this.doGenerate = async (options) => {
163
- this.doGenerateCalls.push(options);
164
- if (typeof doGenerate === "function") {
165
- return await doGenerate(options);
166
- } else if (Array.isArray(doGenerate)) {
167
- return doGenerate[this.doGenerateCalls.length - 1];
168
- } else {
169
- return doGenerate;
170
- }
171
- };
172
- this.doStream = async (options) => {
173
- this.doStreamCalls.push(options);
174
- if (typeof doStream === "function") {
175
- return await doStream(options);
176
- } else if (Array.isArray(doStream)) {
177
- return doStream[this.doStreamCalls.length - 1];
178
- } else {
179
- return doStream;
180
- }
181
- };
182
- this._supportedUrls = typeof supportedUrls === "function" ? supportedUrls : async () => await supportedUrls;
183
- }
184
- get supportedUrls() {
185
- return this._supportedUrls();
186
- }
108
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", supportedUrls = {}, doGenerate = notImplemented, doStream = notImplemented } = {}) {
109
+ this.specificationVersion = "v3";
110
+ this.doGenerateCalls = [];
111
+ this.doStreamCalls = [];
112
+ this.provider = provider;
113
+ this.modelId = modelId;
114
+ this.doGenerate = async (options) => {
115
+ this.doGenerateCalls.push(options);
116
+ if (typeof doGenerate === "function") return await doGenerate(options);
117
+ else if (Array.isArray(doGenerate)) return doGenerate[this.doGenerateCalls.length - 1];
118
+ else return doGenerate;
119
+ };
120
+ this.doStream = async (options) => {
121
+ this.doStreamCalls.push(options);
122
+ if (typeof doStream === "function") return await doStream(options);
123
+ else if (Array.isArray(doStream)) return doStream[this.doStreamCalls.length - 1];
124
+ else return doStream;
125
+ };
126
+ this._supportedUrls = typeof supportedUrls === "function" ? supportedUrls : async () => await supportedUrls;
127
+ }
128
+ get supportedUrls() {
129
+ return this._supportedUrls();
130
+ }
187
131
  };
188
-
189
- // src/test/mock-language-model-v4.ts
132
+ //#endregion
133
+ //#region src/test/mock-language-model-v4.ts
190
134
  var MockLanguageModelV4 = class {
191
- constructor({
192
- provider = "mock-provider",
193
- modelId = "mock-model-id",
194
- supportedUrls = {},
195
- doGenerate = notImplemented,
196
- doStream = notImplemented
197
- } = {}) {
198
- this.specificationVersion = "v4";
199
- this.doGenerateCalls = [];
200
- this.doStreamCalls = [];
201
- this.provider = provider;
202
- this.modelId = modelId;
203
- this.doGenerate = async (options) => {
204
- this.doGenerateCalls.push(options);
205
- if (typeof doGenerate === "function") {
206
- return await doGenerate(options);
207
- } else if (Array.isArray(doGenerate)) {
208
- return doGenerate[this.doGenerateCalls.length - 1];
209
- } else {
210
- return doGenerate;
211
- }
212
- };
213
- this.doStream = async (options) => {
214
- this.doStreamCalls.push(options);
215
- if (typeof doStream === "function") {
216
- return await doStream(options);
217
- } else if (Array.isArray(doStream)) {
218
- return doStream[this.doStreamCalls.length - 1];
219
- } else {
220
- return doStream;
221
- }
222
- };
223
- this._supportedUrls = typeof supportedUrls === "function" ? supportedUrls : async () => await supportedUrls;
224
- }
225
- get supportedUrls() {
226
- return this._supportedUrls();
227
- }
135
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", supportedUrls = {}, doGenerate = notImplemented, doStream = notImplemented } = {}) {
136
+ this.specificationVersion = "v4";
137
+ this.doGenerateCalls = [];
138
+ this.doStreamCalls = [];
139
+ this.provider = provider;
140
+ this.modelId = modelId;
141
+ this.doGenerate = async (options) => {
142
+ this.doGenerateCalls.push(options);
143
+ if (typeof doGenerate === "function") return await doGenerate(options);
144
+ else if (Array.isArray(doGenerate)) return doGenerate[this.doGenerateCalls.length - 1];
145
+ else return doGenerate;
146
+ };
147
+ this.doStream = async (options) => {
148
+ this.doStreamCalls.push(options);
149
+ if (typeof doStream === "function") return await doStream(options);
150
+ else if (Array.isArray(doStream)) return doStream[this.doStreamCalls.length - 1];
151
+ else return doStream;
152
+ };
153
+ this._supportedUrls = typeof supportedUrls === "function" ? supportedUrls : async () => await supportedUrls;
154
+ }
155
+ get supportedUrls() {
156
+ return this._supportedUrls();
157
+ }
228
158
  };
229
-
230
- // src/test/mock-provider-v3.ts
231
- import {
232
- NoSuchModelError
233
- } from "@ai-sdk/provider";
159
+ //#endregion
160
+ //#region src/test/mock-provider-v3.ts
234
161
  var MockProviderV3 = class {
235
- constructor({
236
- languageModels,
237
- embeddingModels,
238
- imageModels,
239
- transcriptionModels,
240
- speechModels,
241
- rerankingModels
242
- } = {}) {
243
- this.specificationVersion = "v3";
244
- this.languageModel = (modelId) => {
245
- if (!languageModels?.[modelId]) {
246
- throw new NoSuchModelError({ modelId, modelType: "languageModel" });
247
- }
248
- return languageModels[modelId];
249
- };
250
- this.embeddingModel = (modelId) => {
251
- if (!embeddingModels?.[modelId]) {
252
- throw new NoSuchModelError({
253
- modelId,
254
- modelType: "embeddingModel"
255
- });
256
- }
257
- return embeddingModels[modelId];
258
- };
259
- this.imageModel = (modelId) => {
260
- if (!imageModels?.[modelId]) {
261
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
262
- }
263
- return imageModels[modelId];
264
- };
265
- this.transcriptionModel = (modelId) => {
266
- if (!transcriptionModels?.[modelId]) {
267
- throw new NoSuchModelError({
268
- modelId,
269
- modelType: "transcriptionModel"
270
- });
271
- }
272
- return transcriptionModels[modelId];
273
- };
274
- this.speechModel = (modelId) => {
275
- if (!speechModels?.[modelId]) {
276
- throw new NoSuchModelError({ modelId, modelType: "speechModel" });
277
- }
278
- return speechModels[modelId];
279
- };
280
- this.rerankingModel = (modelId) => {
281
- if (!rerankingModels?.[modelId]) {
282
- throw new NoSuchModelError({ modelId, modelType: "rerankingModel" });
283
- }
284
- return rerankingModels[modelId];
285
- };
286
- }
162
+ constructor({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, rerankingModels } = {}) {
163
+ this.specificationVersion = "v3";
164
+ this.languageModel = (modelId) => {
165
+ if (!languageModels?.[modelId]) throw new NoSuchModelError({
166
+ modelId,
167
+ modelType: "languageModel"
168
+ });
169
+ return languageModels[modelId];
170
+ };
171
+ this.embeddingModel = (modelId) => {
172
+ if (!embeddingModels?.[modelId]) throw new NoSuchModelError({
173
+ modelId,
174
+ modelType: "embeddingModel"
175
+ });
176
+ return embeddingModels[modelId];
177
+ };
178
+ this.imageModel = (modelId) => {
179
+ if (!imageModels?.[modelId]) throw new NoSuchModelError({
180
+ modelId,
181
+ modelType: "imageModel"
182
+ });
183
+ return imageModels[modelId];
184
+ };
185
+ this.transcriptionModel = (modelId) => {
186
+ if (!transcriptionModels?.[modelId]) throw new NoSuchModelError({
187
+ modelId,
188
+ modelType: "transcriptionModel"
189
+ });
190
+ return transcriptionModels[modelId];
191
+ };
192
+ this.speechModel = (modelId) => {
193
+ if (!speechModels?.[modelId]) throw new NoSuchModelError({
194
+ modelId,
195
+ modelType: "speechModel"
196
+ });
197
+ return speechModels[modelId];
198
+ };
199
+ this.rerankingModel = (modelId) => {
200
+ if (!rerankingModels?.[modelId]) throw new NoSuchModelError({
201
+ modelId,
202
+ modelType: "rerankingModel"
203
+ });
204
+ return rerankingModels[modelId];
205
+ };
206
+ }
287
207
  };
288
-
289
- // src/test/mock-provider-v4.ts
290
- import {
291
- NoSuchModelError as NoSuchModelError2
292
- } from "@ai-sdk/provider";
208
+ //#endregion
209
+ //#region src/test/mock-provider-v4.ts
293
210
  var MockProviderV4 = class {
294
- constructor({
295
- languageModels,
296
- embeddingModels,
297
- imageModels,
298
- transcriptionModels,
299
- speechModels,
300
- rerankingModels
301
- } = {}) {
302
- this.specificationVersion = "v4";
303
- this.languageModel = (modelId) => {
304
- if (!languageModels?.[modelId]) {
305
- throw new NoSuchModelError2({ modelId, modelType: "languageModel" });
306
- }
307
- return languageModels[modelId];
308
- };
309
- this.embeddingModel = (modelId) => {
310
- if (!embeddingModels?.[modelId]) {
311
- throw new NoSuchModelError2({
312
- modelId,
313
- modelType: "embeddingModel"
314
- });
315
- }
316
- return embeddingModels[modelId];
317
- };
318
- this.imageModel = (modelId) => {
319
- if (!imageModels?.[modelId]) {
320
- throw new NoSuchModelError2({ modelId, modelType: "imageModel" });
321
- }
322
- return imageModels[modelId];
323
- };
324
- this.transcriptionModel = (modelId) => {
325
- if (!transcriptionModels?.[modelId]) {
326
- throw new NoSuchModelError2({
327
- modelId,
328
- modelType: "transcriptionModel"
329
- });
330
- }
331
- return transcriptionModels[modelId];
332
- };
333
- this.speechModel = (modelId) => {
334
- if (!speechModels?.[modelId]) {
335
- throw new NoSuchModelError2({ modelId, modelType: "speechModel" });
336
- }
337
- return speechModels[modelId];
338
- };
339
- this.rerankingModel = (modelId) => {
340
- if (!rerankingModels?.[modelId]) {
341
- throw new NoSuchModelError2({ modelId, modelType: "rerankingModel" });
342
- }
343
- return rerankingModels[modelId];
344
- };
345
- }
211
+ constructor({ languageModels, embeddingModels, imageModels, transcriptionModels, speechModels, rerankingModels } = {}) {
212
+ this.specificationVersion = "v4";
213
+ this.languageModel = (modelId) => {
214
+ if (!languageModels?.[modelId]) throw new NoSuchModelError({
215
+ modelId,
216
+ modelType: "languageModel"
217
+ });
218
+ return languageModels[modelId];
219
+ };
220
+ this.embeddingModel = (modelId) => {
221
+ if (!embeddingModels?.[modelId]) throw new NoSuchModelError({
222
+ modelId,
223
+ modelType: "embeddingModel"
224
+ });
225
+ return embeddingModels[modelId];
226
+ };
227
+ this.imageModel = (modelId) => {
228
+ if (!imageModels?.[modelId]) throw new NoSuchModelError({
229
+ modelId,
230
+ modelType: "imageModel"
231
+ });
232
+ return imageModels[modelId];
233
+ };
234
+ this.transcriptionModel = (modelId) => {
235
+ if (!transcriptionModels?.[modelId]) throw new NoSuchModelError({
236
+ modelId,
237
+ modelType: "transcriptionModel"
238
+ });
239
+ return transcriptionModels[modelId];
240
+ };
241
+ this.speechModel = (modelId) => {
242
+ if (!speechModels?.[modelId]) throw new NoSuchModelError({
243
+ modelId,
244
+ modelType: "speechModel"
245
+ });
246
+ return speechModels[modelId];
247
+ };
248
+ this.rerankingModel = (modelId) => {
249
+ if (!rerankingModels?.[modelId]) throw new NoSuchModelError({
250
+ modelId,
251
+ modelType: "rerankingModel"
252
+ });
253
+ return rerankingModels[modelId];
254
+ };
255
+ }
346
256
  };
347
-
348
- // src/test/mock-speech-model-v3.ts
257
+ //#endregion
258
+ //#region src/test/mock-speech-model-v3.ts
349
259
  var MockSpeechModelV3 = class {
350
- constructor({
351
- provider = "mock-provider",
352
- modelId = "mock-model-id",
353
- doGenerate = notImplemented
354
- } = {}) {
355
- this.specificationVersion = "v3";
356
- this.provider = provider;
357
- this.modelId = modelId;
358
- this.doGenerate = doGenerate;
359
- }
260
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doGenerate = notImplemented } = {}) {
261
+ this.specificationVersion = "v3";
262
+ this.provider = provider;
263
+ this.modelId = modelId;
264
+ this.doGenerate = doGenerate;
265
+ }
360
266
  };
361
-
362
- // src/test/mock-speech-model-v4.ts
267
+ //#endregion
268
+ //#region src/test/mock-speech-model-v4.ts
363
269
  var MockSpeechModelV4 = class {
364
- constructor({
365
- provider = "mock-provider",
366
- modelId = "mock-model-id",
367
- doGenerate = notImplemented
368
- } = {}) {
369
- this.specificationVersion = "v4";
370
- this.provider = provider;
371
- this.modelId = modelId;
372
- this.doGenerate = doGenerate;
373
- }
270
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doGenerate = notImplemented } = {}) {
271
+ this.specificationVersion = "v4";
272
+ this.provider = provider;
273
+ this.modelId = modelId;
274
+ this.doGenerate = doGenerate;
275
+ }
374
276
  };
375
-
376
- // src/test/mock-speech-translation-model-v4.ts
277
+ //#endregion
278
+ //#region src/test/mock-speech-translation-model-v4.ts
377
279
  var MockSpeechTranslationModelV4 = class {
378
- constructor({
379
- provider = "mock-provider",
380
- modelId = "mock-model-id",
381
- doStream = notImplemented
382
- } = {}) {
383
- this.specificationVersion = "v4";
384
- this.provider = provider;
385
- this.modelId = modelId;
386
- this.doStream = doStream;
387
- }
280
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doStream = notImplemented } = {}) {
281
+ this.specificationVersion = "v4";
282
+ this.provider = provider;
283
+ this.modelId = modelId;
284
+ this.doStream = doStream;
285
+ }
388
286
  };
389
-
390
- // src/test/mock-transcription-model-v3.ts
287
+ //#endregion
288
+ //#region src/test/mock-transcription-model-v3.ts
391
289
  var MockTranscriptionModelV3 = class {
392
- constructor({
393
- provider = "mock-provider",
394
- modelId = "mock-model-id",
395
- doGenerate = notImplemented
396
- } = {}) {
397
- this.specificationVersion = "v3";
398
- this.provider = provider;
399
- this.modelId = modelId;
400
- this.doGenerate = doGenerate;
401
- }
290
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doGenerate = notImplemented } = {}) {
291
+ this.specificationVersion = "v3";
292
+ this.provider = provider;
293
+ this.modelId = modelId;
294
+ this.doGenerate = doGenerate;
295
+ }
402
296
  };
403
-
404
- // src/test/mock-transcription-model-v4.ts
297
+ //#endregion
298
+ //#region src/test/mock-transcription-model-v4.ts
405
299
  var MockTranscriptionModelV4 = class {
406
- constructor({
407
- provider = "mock-provider",
408
- modelId = "mock-model-id",
409
- doGenerate = notImplemented,
410
- doStream
411
- } = {}) {
412
- this.specificationVersion = "v4";
413
- this.provider = provider;
414
- this.modelId = modelId;
415
- this.doGenerate = doGenerate;
416
- this.doStream = doStream;
417
- }
300
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doGenerate = notImplemented, doStream } = {}) {
301
+ this.specificationVersion = "v4";
302
+ this.provider = provider;
303
+ this.modelId = modelId;
304
+ this.doGenerate = doGenerate;
305
+ this.doStream = doStream;
306
+ }
418
307
  };
419
-
420
- // src/test/mock-reranking-model-v3.ts
308
+ //#endregion
309
+ //#region src/test/mock-reranking-model-v3.ts
421
310
  var MockRerankingModelV3 = class {
422
- constructor({
423
- provider = "mock-provider",
424
- modelId = "mock-model-id",
425
- doRerank = notImplemented
426
- } = {}) {
427
- this.specificationVersion = "v3";
428
- this.provider = provider;
429
- this.modelId = modelId;
430
- this.doRerank = doRerank;
431
- }
311
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doRerank = notImplemented } = {}) {
312
+ this.specificationVersion = "v3";
313
+ this.provider = provider;
314
+ this.modelId = modelId;
315
+ this.doRerank = doRerank;
316
+ }
432
317
  };
433
-
434
- // src/test/mock-reranking-model-v4.ts
318
+ //#endregion
319
+ //#region src/test/mock-reranking-model-v4.ts
435
320
  var MockRerankingModelV4 = class {
436
- constructor({
437
- provider = "mock-provider",
438
- modelId = "mock-model-id",
439
- doRerank = notImplemented
440
- } = {}) {
441
- this.specificationVersion = "v4";
442
- this.provider = provider;
443
- this.modelId = modelId;
444
- this.doRerank = doRerank;
445
- }
321
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", doRerank = notImplemented } = {}) {
322
+ this.specificationVersion = "v4";
323
+ this.provider = provider;
324
+ this.modelId = modelId;
325
+ this.doRerank = doRerank;
326
+ }
446
327
  };
447
-
448
- // src/test/mock-video-model-v3.ts
328
+ //#endregion
329
+ //#region src/test/mock-video-model-v3.ts
449
330
  var MockVideoModelV3 = class {
450
- constructor({
451
- provider = "mock-provider",
452
- modelId = "mock-model-id",
453
- maxVideosPerCall = 1,
454
- doGenerate = notImplemented
455
- } = {}) {
456
- this.specificationVersion = "v3";
457
- this.provider = provider;
458
- this.modelId = modelId;
459
- this.maxVideosPerCall = maxVideosPerCall;
460
- this.doGenerate = doGenerate;
461
- }
331
+ constructor({ provider = "mock-provider", modelId = "mock-model-id", maxVideosPerCall = 1, doGenerate = notImplemented } = {}) {
332
+ this.specificationVersion = "v3";
333
+ this.provider = provider;
334
+ this.modelId = modelId;
335
+ this.maxVideosPerCall = maxVideosPerCall;
336
+ this.doGenerate = doGenerate;
337
+ }
462
338
  };
463
-
464
- // src/test/mock-video-model-v4.ts
339
+ //#endregion
340
+ //#region src/test/mock-video-model-v4.ts
465
341
  var MockVideoModelV4 = class {
466
- constructor(options = {}) {
467
- this.specificationVersion = "v4";
468
- this.provider = options.provider ?? "mock-provider";
469
- this.modelId = options.modelId ?? "mock-model-id";
470
- this.maxVideosPerCall = options.maxVideosPerCall ?? 1;
471
- this.doGenerate = "doGenerate" in options ? options.doGenerate : notImplemented;
472
- this.handleWebhookOption = options.handleWebhookOption;
473
- this.doStart = options.doStart;
474
- this.doStatus = options.doStatus;
475
- }
342
+ constructor(options = {}) {
343
+ this.specificationVersion = "v4";
344
+ this.provider = options.provider ?? "mock-provider";
345
+ this.modelId = options.modelId ?? "mock-model-id";
346
+ this.maxVideosPerCall = options.maxVideosPerCall ?? 1;
347
+ this.doGenerate = "doGenerate" in options ? options.doGenerate : notImplemented;
348
+ this.handleWebhookOption = options.handleWebhookOption;
349
+ this.doStart = options.doStart;
350
+ this.doStatus = options.doStatus;
351
+ }
476
352
  };
477
-
478
- // src/test/mock-values.ts
353
+ //#endregion
354
+ //#region src/test/mock-values.ts
479
355
  function mockValues(...values) {
480
- let counter = 0;
481
- return () => values[counter++] ?? values[values.length - 1];
356
+ let counter = 0;
357
+ return () => values[counter++] ?? values[values.length - 1];
482
358
  }
359
+ //#endregion
360
+ //#region test/index.ts
361
+ /**
362
+ * @deprecated Use `simulateReadableStream` from `ai` instead.
363
+ */
364
+ const simulateReadableStream = simulateReadableStream$1;
365
+ //#endregion
366
+ export { EvaluationMockModelV4 as Experimental_EvaluationMockModelV4, MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4, MockEmbeddingModelV3, MockEmbeddingModelV4, MockImageModelV3, MockImageModelV4, MockLanguageModelV3, MockLanguageModelV4, MockProviderV3, MockProviderV4, MockRerankingModelV3, MockRerankingModelV4, MockSpeechModelV3, MockSpeechModelV4, MockTranscriptionModelV3, MockTranscriptionModelV4, MockVideoModelV3, MockVideoModelV4, convertArrayToAsyncIterable, convertArrayToReadableStream, convertReadableStreamToArray, mockId, mockValues, simulateReadableStream };
483
367
 
484
- // test/index.ts
485
- var simulateReadableStream2 = simulateReadableStream;
486
- export {
487
- EvaluationMockModelV4 as Experimental_EvaluationMockModelV4,
488
- MockSpeechTranslationModelV4 as Experimental_MockSpeechTranslationModelV4,
489
- MockEmbeddingModelV3,
490
- MockEmbeddingModelV4,
491
- MockImageModelV3,
492
- MockImageModelV4,
493
- MockLanguageModelV3,
494
- MockLanguageModelV4,
495
- MockProviderV3,
496
- MockProviderV4,
497
- MockRerankingModelV3,
498
- MockRerankingModelV4,
499
- MockSpeechModelV3,
500
- MockSpeechModelV4,
501
- MockTranscriptionModelV3,
502
- MockTranscriptionModelV4,
503
- MockVideoModelV3,
504
- MockVideoModelV4,
505
- convertArrayToAsyncIterable,
506
- convertArrayToReadableStream,
507
- convertReadableStreamToArray,
508
- mockId,
509
- mockValues,
510
- simulateReadableStream2 as simulateReadableStream
511
- };
512
368
  //# sourceMappingURL=index.js.map