ai 4.0.25 → 4.0.27
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 +15 -0
- package/dist/index.d.mts +26 -5
- package/dist/index.d.ts +26 -5
- package/dist/index.js +71 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/rsc/dist/rsc-server.mjs +1 -1
- package/rsc/dist/rsc-server.mjs.map +1 -1
- package/test/dist/index.d.mts +11 -6
- package/test/dist/index.d.ts +11 -6
- package/test/dist/index.js +6 -3
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +6 -3
- package/test/dist/index.mjs.map +1 -1
package/test/dist/index.d.mts
CHANGED
@@ -46,17 +46,22 @@ declare function mockValues<T>(...values: T[]): () => T;
|
|
46
46
|
*
|
47
47
|
* @param options - The configuration options
|
48
48
|
* @param options.chunks - Array of values to be emitted by the stream
|
49
|
-
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0)
|
50
|
-
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0)
|
49
|
+
* @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.
|
50
|
+
* @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.
|
51
51
|
* @returns A ReadableStream that emits the provided values
|
52
52
|
*/
|
53
|
-
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
53
|
+
declare function simulateReadableStream$1<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
54
54
|
chunks: T[];
|
55
|
-
initialDelayInMs?: number;
|
56
|
-
chunkDelayInMs?: number;
|
55
|
+
initialDelayInMs?: number | null;
|
56
|
+
chunkDelayInMs?: number | null;
|
57
57
|
_internal?: {
|
58
|
-
delay?: (ms: number) => Promise<void>;
|
58
|
+
delay?: (ms: number | null) => Promise<void>;
|
59
59
|
};
|
60
60
|
}): ReadableStream<T>;
|
61
61
|
|
62
|
+
/**
|
63
|
+
* @deprecated Use `simulateReadableStream` from `ai` instead.
|
64
|
+
*/
|
65
|
+
declare const simulateReadableStream: typeof simulateReadableStream$1;
|
66
|
+
|
62
67
|
export { MockEmbeddingModelV1, MockLanguageModelV1, mockId, mockValues, simulateReadableStream };
|
package/test/dist/index.d.ts
CHANGED
@@ -46,17 +46,22 @@ declare function mockValues<T>(...values: T[]): () => T;
|
|
46
46
|
*
|
47
47
|
* @param options - The configuration options
|
48
48
|
* @param options.chunks - Array of values to be emitted by the stream
|
49
|
-
* @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0)
|
50
|
-
* @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0)
|
49
|
+
* @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.
|
50
|
+
* @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.
|
51
51
|
* @returns A ReadableStream that emits the provided values
|
52
52
|
*/
|
53
|
-
declare function simulateReadableStream<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
53
|
+
declare function simulateReadableStream$1<T>({ chunks, initialDelayInMs, chunkDelayInMs, _internal, }: {
|
54
54
|
chunks: T[];
|
55
|
-
initialDelayInMs?: number;
|
56
|
-
chunkDelayInMs?: number;
|
55
|
+
initialDelayInMs?: number | null;
|
56
|
+
chunkDelayInMs?: number | null;
|
57
57
|
_internal?: {
|
58
|
-
delay?: (ms: number) => Promise<void>;
|
58
|
+
delay?: (ms: number | null) => Promise<void>;
|
59
59
|
};
|
60
60
|
}): ReadableStream<T>;
|
61
61
|
|
62
|
+
/**
|
63
|
+
* @deprecated Use `simulateReadableStream` from `ai` instead.
|
64
|
+
*/
|
65
|
+
declare const simulateReadableStream: typeof simulateReadableStream$1;
|
66
|
+
|
62
67
|
export { MockEmbeddingModelV1, MockLanguageModelV1, mockId, mockValues, simulateReadableStream };
|
package/test/dist/index.js
CHANGED
@@ -25,7 +25,7 @@ __export(test_exports, {
|
|
25
25
|
convertArrayToReadableStream: () => import_test.convertArrayToReadableStream,
|
26
26
|
mockId: () => mockId,
|
27
27
|
mockValues: () => mockValues,
|
28
|
-
simulateReadableStream: () =>
|
28
|
+
simulateReadableStream: () => simulateReadableStream2
|
29
29
|
});
|
30
30
|
module.exports = __toCommonJS(test_exports);
|
31
31
|
var import_test = require("@ai-sdk/provider-utils/test");
|
@@ -92,10 +92,10 @@ function mockValues(...values) {
|
|
92
92
|
|
93
93
|
// util/delay.ts
|
94
94
|
async function delay(delayInMs) {
|
95
|
-
return delayInMs
|
95
|
+
return delayInMs == null ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, delayInMs));
|
96
96
|
}
|
97
97
|
|
98
|
-
// core/
|
98
|
+
// core/util/simulate-readable-stream.ts
|
99
99
|
function simulateReadableStream({
|
100
100
|
chunks,
|
101
101
|
initialDelayInMs = 0,
|
@@ -116,6 +116,9 @@ function simulateReadableStream({
|
|
116
116
|
}
|
117
117
|
});
|
118
118
|
}
|
119
|
+
|
120
|
+
// test/index.ts
|
121
|
+
var simulateReadableStream2 = simulateReadableStream;
|
119
122
|
// Annotate the CommonJS export names for ESM import in node:
|
120
123
|
0 && (module.exports = {
|
121
124
|
MockEmbeddingModelV1,
|
package/test/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../index.ts","../../core/test/not-implemented.ts","../../core/test/mock-embedding-model-v1.ts","../../core/test/mock-id.ts","../../core/test/mock-language-model-v1.ts","../../core/test/mock-values.ts","../../util/delay.ts","../../core/
|
1
|
+
{"version":3,"sources":["../index.ts","../../core/test/not-implemented.ts","../../core/test/mock-embedding-model-v1.ts","../../core/test/mock-id.ts","../../core/test/mock-language-model-v1.ts","../../core/test/mock-values.ts","../../util/delay.ts","../../core/util/simulate-readable-stream.ts"],"sourcesContent":["export { convertArrayToReadableStream } from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV1 } from '../core/test/mock-embedding-model-v1';\nexport { mockId } from '../core/test/mock-id';\nexport { MockLanguageModelV1 } from '../core/test/mock-language-model-v1';\nexport { mockValues } from '../core/test/mock-values';\n\nimport { simulateReadableStream as originalSimulateReadableStream } from '../core/util/simulate-readable-stream';\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 { EmbeddingModelV1 } from '@ai-sdk/provider';\nimport { Embedding } from '../types';\nimport { EmbeddingModelUsage } from '../types/usage';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV1<VALUE> implements EmbeddingModelV1<VALUE> {\n readonly specificationVersion = 'v1';\n\n readonly provider: EmbeddingModelV1<VALUE>['provider'];\n readonly modelId: EmbeddingModelV1<VALUE>['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV1<VALUE>['doEmbed'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV1<VALUE>['provider'];\n modelId?: EmbeddingModelV1<VALUE>['modelId'];\n maxEmbeddingsPerCall?:\n | EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall']\n | null;\n supportsParallelCalls?: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n doEmbed?: EmbeddingModelV1<VALUE>['doEmbed'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = doEmbed;\n }\n}\n\nexport function mockEmbed<VALUE>(\n expectedValues: Array<VALUE>,\n embeddings: Array<Embedding>,\n usage?: EmbeddingModelUsage,\n): EmbeddingModelV1<VALUE>['doEmbed'] {\n return async ({ values }) => {\n assert.deepStrictEqual(expectedValues, values);\n return { embeddings, usage };\n };\n}\n","export function mockId(): () => string {\n let counter = 0;\n return () => `id-${counter++}`;\n}\n","import { LanguageModelV1 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV1 implements LanguageModelV1 {\n readonly specificationVersion = 'v1';\n\n readonly provider: LanguageModelV1['provider'];\n readonly modelId: LanguageModelV1['modelId'];\n\n supportsUrl: LanguageModelV1['supportsUrl'];\n doGenerate: LanguageModelV1['doGenerate'];\n doStream: LanguageModelV1['doStream'];\n\n readonly defaultObjectGenerationMode: LanguageModelV1['defaultObjectGenerationMode'];\n readonly supportsStructuredOutputs: LanguageModelV1['supportsStructuredOutputs'];\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportsUrl = undefined,\n doGenerate = notImplemented,\n doStream = notImplemented,\n defaultObjectGenerationMode = undefined,\n supportsStructuredOutputs = undefined,\n }: {\n provider?: LanguageModelV1['provider'];\n modelId?: LanguageModelV1['modelId'];\n supportsUrl?: LanguageModelV1['supportsUrl'];\n doGenerate?: LanguageModelV1['doGenerate'];\n doStream?: LanguageModelV1['doStream'];\n defaultObjectGenerationMode?: LanguageModelV1['defaultObjectGenerationMode'];\n supportsStructuredOutputs?: LanguageModelV1['supportsStructuredOutputs'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n this.supportsUrl = supportsUrl;\n\n this.defaultObjectGenerationMode = defaultObjectGenerationMode;\n this.supportsStructuredOutputs = supportsStructuredOutputs;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n","/**\n * Creates a Promise that resolves after a specified delay\n * @param delayInMs - The delay duration in milliseconds. If null or undefined, resolves immediately.\n * @returns A Promise that resolves after the specified delay\n */\nexport async function delay(delayInMs?: number | null): Promise<void> {\n return delayInMs == null\n ? Promise.resolve()\n : new Promise(resolve => setTimeout(resolve, delayInMs));\n}\n","import { delay as delayFunction } from '../../util/delay';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAAA;AAAA;AAAA;AAAA,kBAA6C;;;ACAtC,SAAS,iBAAwB;AACtC,QAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACGO,IAAM,uBAAN,MAAqE;AAAA,EAU1E,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,UAAU;AAAA,EACZ,IAQI,CAAC,GAAG;AAvBR,SAAS,uBAAuB;AAwB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,uBAAuB,sDAAwB;AACpD,SAAK,wBAAwB;AAC7B,SAAK,UAAU;AAAA,EACjB;AACF;;;ACpCO,SAAS,SAAuB;AACrC,MAAI,UAAU;AACd,SAAO,MAAM,MAAM,SAAS;AAC9B;;;ACAO,IAAM,sBAAN,MAAqD;AAAA,EAY1D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,IACd,aAAa;AAAA,IACb,WAAW;AAAA,IACX,8BAA8B;AAAA,IAC9B,4BAA4B;AAAA,EAC9B,IAQI,CAAC,GAAG;AA3BR,SAAS,uBAAuB;AA4B9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,WAAW;AAChB,SAAK,cAAc;AAEnB,SAAK,8BAA8B;AACnC,SAAK,4BAA4B;AAAA,EACnC;AACF;;;ACzCO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAG;AAFZ;AAEe,wBAAO,SAAS,MAAhB,YAAqB,OAAO,OAAO,SAAS,CAAC;AAAA;AAC5D;;;ACEA,eAAsB,MAAM,WAA0C;AACpE,SAAO,aAAa,OAChB,QAAQ,QAAQ,IAChB,IAAI,QAAQ,aAAW,WAAW,SAAS,SAAS,CAAC;AAC3D;;;ACEO,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AAvBtB;AAwBE,QAAMC,UAAQ,4CAAW,UAAX,YAAoB;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAMA,OAAM,UAAU,IAAI,mBAAmB,cAAc;AAC3D,mBAAW,QAAQ,OAAO,OAAO,CAAC;AAAA,MACpC,OAAO;AACL,mBAAW,MAAM;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;AP3BO,IAAMC,0BAAyB;","names":["simulateReadableStream","delay","simulateReadableStream"]}
|
package/test/dist/index.mjs
CHANGED
@@ -63,10 +63,10 @@ function mockValues(...values) {
|
|
63
63
|
|
64
64
|
// util/delay.ts
|
65
65
|
async function delay(delayInMs) {
|
66
|
-
return delayInMs
|
66
|
+
return delayInMs == null ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, delayInMs));
|
67
67
|
}
|
68
68
|
|
69
|
-
// core/
|
69
|
+
// core/util/simulate-readable-stream.ts
|
70
70
|
function simulateReadableStream({
|
71
71
|
chunks,
|
72
72
|
initialDelayInMs = 0,
|
@@ -87,12 +87,15 @@ function simulateReadableStream({
|
|
87
87
|
}
|
88
88
|
});
|
89
89
|
}
|
90
|
+
|
91
|
+
// test/index.ts
|
92
|
+
var simulateReadableStream2 = simulateReadableStream;
|
90
93
|
export {
|
91
94
|
MockEmbeddingModelV1,
|
92
95
|
MockLanguageModelV1,
|
93
96
|
convertArrayToReadableStream,
|
94
97
|
mockId,
|
95
98
|
mockValues,
|
96
|
-
simulateReadableStream
|
99
|
+
simulateReadableStream2 as simulateReadableStream
|
97
100
|
};
|
98
101
|
//# sourceMappingURL=index.mjs.map
|
package/test/dist/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../index.ts","../../core/test/not-implemented.ts","../../core/test/mock-embedding-model-v1.ts","../../core/test/mock-id.ts","../../core/test/mock-language-model-v1.ts","../../core/test/mock-values.ts","../../util/delay.ts","../../core/
|
1
|
+
{"version":3,"sources":["../index.ts","../../core/test/not-implemented.ts","../../core/test/mock-embedding-model-v1.ts","../../core/test/mock-id.ts","../../core/test/mock-language-model-v1.ts","../../core/test/mock-values.ts","../../util/delay.ts","../../core/util/simulate-readable-stream.ts"],"sourcesContent":["export { convertArrayToReadableStream } from '@ai-sdk/provider-utils/test';\nexport { MockEmbeddingModelV1 } from '../core/test/mock-embedding-model-v1';\nexport { mockId } from '../core/test/mock-id';\nexport { MockLanguageModelV1 } from '../core/test/mock-language-model-v1';\nexport { mockValues } from '../core/test/mock-values';\n\nimport { simulateReadableStream as originalSimulateReadableStream } from '../core/util/simulate-readable-stream';\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 { EmbeddingModelV1 } from '@ai-sdk/provider';\nimport { Embedding } from '../types';\nimport { EmbeddingModelUsage } from '../types/usage';\nimport { notImplemented } from './not-implemented';\n\nexport class MockEmbeddingModelV1<VALUE> implements EmbeddingModelV1<VALUE> {\n readonly specificationVersion = 'v1';\n\n readonly provider: EmbeddingModelV1<VALUE>['provider'];\n readonly modelId: EmbeddingModelV1<VALUE>['modelId'];\n readonly maxEmbeddingsPerCall: EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall'];\n readonly supportsParallelCalls: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n\n doEmbed: EmbeddingModelV1<VALUE>['doEmbed'];\n\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n maxEmbeddingsPerCall = 1,\n supportsParallelCalls = false,\n doEmbed = notImplemented,\n }: {\n provider?: EmbeddingModelV1<VALUE>['provider'];\n modelId?: EmbeddingModelV1<VALUE>['modelId'];\n maxEmbeddingsPerCall?:\n | EmbeddingModelV1<VALUE>['maxEmbeddingsPerCall']\n | null;\n supportsParallelCalls?: EmbeddingModelV1<VALUE>['supportsParallelCalls'];\n doEmbed?: EmbeddingModelV1<VALUE>['doEmbed'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.maxEmbeddingsPerCall = maxEmbeddingsPerCall ?? undefined;\n this.supportsParallelCalls = supportsParallelCalls;\n this.doEmbed = doEmbed;\n }\n}\n\nexport function mockEmbed<VALUE>(\n expectedValues: Array<VALUE>,\n embeddings: Array<Embedding>,\n usage?: EmbeddingModelUsage,\n): EmbeddingModelV1<VALUE>['doEmbed'] {\n return async ({ values }) => {\n assert.deepStrictEqual(expectedValues, values);\n return { embeddings, usage };\n };\n}\n","export function mockId(): () => string {\n let counter = 0;\n return () => `id-${counter++}`;\n}\n","import { LanguageModelV1 } from '@ai-sdk/provider';\nimport { notImplemented } from './not-implemented';\n\nexport class MockLanguageModelV1 implements LanguageModelV1 {\n readonly specificationVersion = 'v1';\n\n readonly provider: LanguageModelV1['provider'];\n readonly modelId: LanguageModelV1['modelId'];\n\n supportsUrl: LanguageModelV1['supportsUrl'];\n doGenerate: LanguageModelV1['doGenerate'];\n doStream: LanguageModelV1['doStream'];\n\n readonly defaultObjectGenerationMode: LanguageModelV1['defaultObjectGenerationMode'];\n readonly supportsStructuredOutputs: LanguageModelV1['supportsStructuredOutputs'];\n constructor({\n provider = 'mock-provider',\n modelId = 'mock-model-id',\n supportsUrl = undefined,\n doGenerate = notImplemented,\n doStream = notImplemented,\n defaultObjectGenerationMode = undefined,\n supportsStructuredOutputs = undefined,\n }: {\n provider?: LanguageModelV1['provider'];\n modelId?: LanguageModelV1['modelId'];\n supportsUrl?: LanguageModelV1['supportsUrl'];\n doGenerate?: LanguageModelV1['doGenerate'];\n doStream?: LanguageModelV1['doStream'];\n defaultObjectGenerationMode?: LanguageModelV1['defaultObjectGenerationMode'];\n supportsStructuredOutputs?: LanguageModelV1['supportsStructuredOutputs'];\n } = {}) {\n this.provider = provider;\n this.modelId = modelId;\n this.doGenerate = doGenerate;\n this.doStream = doStream;\n this.supportsUrl = supportsUrl;\n\n this.defaultObjectGenerationMode = defaultObjectGenerationMode;\n this.supportsStructuredOutputs = supportsStructuredOutputs;\n }\n}\n","export function mockValues<T>(...values: T[]): () => T {\n let counter = 0;\n return () => values[counter++] ?? values[values.length - 1];\n}\n","/**\n * Creates a Promise that resolves after a specified delay\n * @param delayInMs - The delay duration in milliseconds. If null or undefined, resolves immediately.\n * @returns A Promise that resolves after the specified delay\n */\nexport async function delay(delayInMs?: number | null): Promise<void> {\n return delayInMs == null\n ? Promise.resolve()\n : new Promise(resolve => setTimeout(resolve, delayInMs));\n}\n","import { delay as delayFunction } from '../../util/delay';\n\n/**\n * Creates a ReadableStream that emits the provided values with an optional delay between each value.\n *\n * @param options - The configuration options\n * @param options.chunks - Array of values to be emitted by the stream\n * @param options.initialDelayInMs - Optional initial delay in milliseconds before emitting the first value (default: 0). Can be set to `null` to skip the initial delay. The difference between `initialDelayInMs: null` and `initialDelayInMs: 0` is that `initialDelayInMs: null` will emit the values without any delay, while `initialDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @param options.chunkDelayInMs - Optional delay in milliseconds between emitting each value (default: 0). Can be set to `null` to skip the delay. The difference between `chunkDelayInMs: null` and `chunkDelayInMs: 0` is that `chunkDelayInMs: null` will emit the values without any delay, while `chunkDelayInMs: 0` will emit the values with a delay of 0 milliseconds.\n * @returns A ReadableStream that emits the provided values\n */\nexport function simulateReadableStream<T>({\n chunks,\n initialDelayInMs = 0,\n chunkDelayInMs = 0,\n _internal,\n}: {\n chunks: T[];\n initialDelayInMs?: number | null;\n chunkDelayInMs?: number | null;\n _internal?: {\n delay?: (ms: number | null) => Promise<void>;\n };\n}): ReadableStream<T> {\n const delay = _internal?.delay ?? delayFunction;\n\n let index = 0;\n\n return new ReadableStream({\n async pull(controller) {\n if (index < chunks.length) {\n await delay(index === 0 ? initialDelayInMs : chunkDelayInMs);\n controller.enqueue(chunks[index++]);\n } else {\n controller.close();\n }\n },\n });\n}\n"],"mappings":";AAAA,SAAS,oCAAoC;;;ACAtC,SAAS,iBAAwB;AACtC,QAAM,IAAI,MAAM,iBAAiB;AACnC;;;ACGO,IAAM,uBAAN,MAAqE;AAAA,EAU1E,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,uBAAuB;AAAA,IACvB,wBAAwB;AAAA,IACxB,UAAU;AAAA,EACZ,IAQI,CAAC,GAAG;AAvBR,SAAS,uBAAuB;AAwB9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,uBAAuB,sDAAwB;AACpD,SAAK,wBAAwB;AAC7B,SAAK,UAAU;AAAA,EACjB;AACF;;;ACpCO,SAAS,SAAuB;AACrC,MAAI,UAAU;AACd,SAAO,MAAM,MAAM,SAAS;AAC9B;;;ACAO,IAAM,sBAAN,MAAqD;AAAA,EAY1D,YAAY;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,IACd,aAAa;AAAA,IACb,WAAW;AAAA,IACX,8BAA8B;AAAA,IAC9B,4BAA4B;AAAA,EAC9B,IAQI,CAAC,GAAG;AA3BR,SAAS,uBAAuB;AA4B9B,SAAK,WAAW;AAChB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,WAAW;AAChB,SAAK,cAAc;AAEnB,SAAK,8BAA8B;AACnC,SAAK,4BAA4B;AAAA,EACnC;AACF;;;ACzCO,SAAS,cAAiB,QAAsB;AACrD,MAAI,UAAU;AACd,SAAO,MAAG;AAFZ;AAEe,wBAAO,SAAS,MAAhB,YAAqB,OAAO,OAAO,SAAS,CAAC;AAAA;AAC5D;;;ACEA,eAAsB,MAAM,WAA0C;AACpE,SAAO,aAAa,OAChB,QAAQ,QAAQ,IAChB,IAAI,QAAQ,aAAW,WAAW,SAAS,SAAS,CAAC;AAC3D;;;ACEO,SAAS,uBAA0B;AAAA,EACxC;AAAA,EACA,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB;AACF,GAOsB;AAvBtB;AAwBE,QAAMA,UAAQ,4CAAW,UAAX,YAAoB;AAElC,MAAI,QAAQ;AAEZ,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,KAAK,YAAY;AACrB,UAAI,QAAQ,OAAO,QAAQ;AACzB,cAAMA,OAAM,UAAU,IAAI,mBAAmB,cAAc;AAC3D,mBAAW,QAAQ,OAAO,OAAO,CAAC;AAAA,MACpC,OAAO;AACL,mBAAW,MAAM;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;AP3BO,IAAMC,0BAAyB;","names":["delay","simulateReadableStream"]}
|