ai 0.0.0-85f9a635-20240518005312 → 0.0.0-8777c42a-20250115032312

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 (58) hide show
  1. package/CHANGELOG.md +2863 -0
  2. package/README.md +99 -22
  3. package/dist/index.d.mts +1925 -1592
  4. package/dist/index.d.ts +1925 -1592
  5. package/dist/index.js +5500 -2961
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +5497 -2916
  8. package/dist/index.mjs.map +1 -1
  9. package/package.json +39 -100
  10. package/react/dist/index.d.mts +8 -563
  11. package/react/dist/index.d.ts +8 -580
  12. package/react/dist/index.js +7 -1395
  13. package/react/dist/index.js.map +1 -1
  14. package/react/dist/index.mjs +12 -1383
  15. package/react/dist/index.mjs.map +1 -1
  16. package/rsc/dist/index.d.ts +340 -197
  17. package/rsc/dist/rsc-server.d.mts +339 -197
  18. package/rsc/dist/rsc-server.mjs +1295 -1347
  19. package/rsc/dist/rsc-server.mjs.map +1 -1
  20. package/rsc/dist/rsc-shared.d.mts +30 -23
  21. package/rsc/dist/rsc-shared.mjs +69 -105
  22. package/rsc/dist/rsc-shared.mjs.map +1 -1
  23. package/test/dist/index.d.mts +67 -0
  24. package/test/dist/index.d.ts +67 -0
  25. package/test/dist/index.js +131 -0
  26. package/test/dist/index.js.map +1 -0
  27. package/test/dist/index.mjs +101 -0
  28. package/test/dist/index.mjs.map +1 -0
  29. package/prompts/dist/index.d.mts +0 -324
  30. package/prompts/dist/index.d.ts +0 -324
  31. package/prompts/dist/index.js +0 -178
  32. package/prompts/dist/index.js.map +0 -1
  33. package/prompts/dist/index.mjs +0 -146
  34. package/prompts/dist/index.mjs.map +0 -1
  35. package/react/dist/index.server.d.mts +0 -17
  36. package/react/dist/index.server.d.ts +0 -17
  37. package/react/dist/index.server.js +0 -50
  38. package/react/dist/index.server.js.map +0 -1
  39. package/react/dist/index.server.mjs +0 -23
  40. package/react/dist/index.server.mjs.map +0 -1
  41. package/solid/dist/index.d.mts +0 -408
  42. package/solid/dist/index.d.ts +0 -408
  43. package/solid/dist/index.js +0 -1072
  44. package/solid/dist/index.js.map +0 -1
  45. package/solid/dist/index.mjs +0 -1044
  46. package/solid/dist/index.mjs.map +0 -1
  47. package/svelte/dist/index.d.mts +0 -484
  48. package/svelte/dist/index.d.ts +0 -484
  49. package/svelte/dist/index.js +0 -1778
  50. package/svelte/dist/index.js.map +0 -1
  51. package/svelte/dist/index.mjs +0 -1749
  52. package/svelte/dist/index.mjs.map +0 -1
  53. package/vue/dist/index.d.mts +0 -402
  54. package/vue/dist/index.d.ts +0 -402
  55. package/vue/dist/index.js +0 -1072
  56. package/vue/dist/index.js.map +0 -1
  57. package/vue/dist/index.mjs +0 -1034
  58. package/vue/dist/index.mjs.map +0 -1
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // test/index.ts
21
+ var test_exports = {};
22
+ __export(test_exports, {
23
+ MockEmbeddingModelV1: () => MockEmbeddingModelV1,
24
+ MockLanguageModelV1: () => MockLanguageModelV1,
25
+ convertArrayToReadableStream: () => import_test.convertArrayToReadableStream,
26
+ mockId: () => mockId,
27
+ mockValues: () => mockValues,
28
+ simulateReadableStream: () => simulateReadableStream2
29
+ });
30
+ module.exports = __toCommonJS(test_exports);
31
+ var import_test = require("@ai-sdk/provider-utils/test");
32
+
33
+ // core/test/not-implemented.ts
34
+ function notImplemented() {
35
+ throw new Error("Not implemented");
36
+ }
37
+
38
+ // core/test/mock-embedding-model-v1.ts
39
+ var MockEmbeddingModelV1 = class {
40
+ constructor({
41
+ provider = "mock-provider",
42
+ modelId = "mock-model-id",
43
+ maxEmbeddingsPerCall = 1,
44
+ supportsParallelCalls = false,
45
+ doEmbed = notImplemented
46
+ } = {}) {
47
+ this.specificationVersion = "v1";
48
+ this.provider = provider;
49
+ this.modelId = modelId;
50
+ this.maxEmbeddingsPerCall = maxEmbeddingsPerCall != null ? maxEmbeddingsPerCall : void 0;
51
+ this.supportsParallelCalls = supportsParallelCalls;
52
+ this.doEmbed = doEmbed;
53
+ }
54
+ };
55
+
56
+ // core/test/mock-id.ts
57
+ function mockId() {
58
+ let counter = 0;
59
+ return () => `id-${counter++}`;
60
+ }
61
+
62
+ // core/test/mock-language-model-v1.ts
63
+ var MockLanguageModelV1 = class {
64
+ constructor({
65
+ provider = "mock-provider",
66
+ modelId = "mock-model-id",
67
+ supportsUrl = void 0,
68
+ doGenerate = notImplemented,
69
+ doStream = notImplemented,
70
+ defaultObjectGenerationMode = void 0,
71
+ supportsStructuredOutputs = void 0
72
+ } = {}) {
73
+ this.specificationVersion = "v1";
74
+ this.provider = provider;
75
+ this.modelId = modelId;
76
+ this.doGenerate = doGenerate;
77
+ this.doStream = doStream;
78
+ this.supportsUrl = supportsUrl;
79
+ this.defaultObjectGenerationMode = defaultObjectGenerationMode;
80
+ this.supportsStructuredOutputs = supportsStructuredOutputs;
81
+ }
82
+ };
83
+
84
+ // core/test/mock-values.ts
85
+ function mockValues(...values) {
86
+ let counter = 0;
87
+ return () => {
88
+ var _a;
89
+ return (_a = values[counter++]) != null ? _a : values[values.length - 1];
90
+ };
91
+ }
92
+
93
+ // util/delay.ts
94
+ async function delay(delayInMs) {
95
+ return delayInMs == null ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, delayInMs));
96
+ }
97
+
98
+ // core/util/simulate-readable-stream.ts
99
+ function simulateReadableStream({
100
+ chunks,
101
+ initialDelayInMs = 0,
102
+ chunkDelayInMs = 0,
103
+ _internal
104
+ }) {
105
+ var _a;
106
+ const delay2 = (_a = _internal == null ? void 0 : _internal.delay) != null ? _a : delay;
107
+ let index = 0;
108
+ return new ReadableStream({
109
+ async pull(controller) {
110
+ if (index < chunks.length) {
111
+ await delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);
112
+ controller.enqueue(chunks[index++]);
113
+ } else {
114
+ controller.close();
115
+ }
116
+ }
117
+ });
118
+ }
119
+
120
+ // test/index.ts
121
+ var simulateReadableStream2 = simulateReadableStream;
122
+ // Annotate the CommonJS export names for ESM import in node:
123
+ 0 && (module.exports = {
124
+ MockEmbeddingModelV1,
125
+ MockLanguageModelV1,
126
+ convertArrayToReadableStream,
127
+ mockId,
128
+ mockValues,
129
+ simulateReadableStream
130
+ });
131
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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/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"]}
@@ -0,0 +1,101 @@
1
+ // test/index.ts
2
+ import { convertArrayToReadableStream } from "@ai-sdk/provider-utils/test";
3
+
4
+ // core/test/not-implemented.ts
5
+ function notImplemented() {
6
+ throw new Error("Not implemented");
7
+ }
8
+
9
+ // core/test/mock-embedding-model-v1.ts
10
+ var MockEmbeddingModelV1 = class {
11
+ constructor({
12
+ provider = "mock-provider",
13
+ modelId = "mock-model-id",
14
+ maxEmbeddingsPerCall = 1,
15
+ supportsParallelCalls = false,
16
+ doEmbed = notImplemented
17
+ } = {}) {
18
+ this.specificationVersion = "v1";
19
+ this.provider = provider;
20
+ this.modelId = modelId;
21
+ this.maxEmbeddingsPerCall = maxEmbeddingsPerCall != null ? maxEmbeddingsPerCall : void 0;
22
+ this.supportsParallelCalls = supportsParallelCalls;
23
+ this.doEmbed = doEmbed;
24
+ }
25
+ };
26
+
27
+ // core/test/mock-id.ts
28
+ function mockId() {
29
+ let counter = 0;
30
+ return () => `id-${counter++}`;
31
+ }
32
+
33
+ // core/test/mock-language-model-v1.ts
34
+ var MockLanguageModelV1 = class {
35
+ constructor({
36
+ provider = "mock-provider",
37
+ modelId = "mock-model-id",
38
+ supportsUrl = void 0,
39
+ doGenerate = notImplemented,
40
+ doStream = notImplemented,
41
+ defaultObjectGenerationMode = void 0,
42
+ supportsStructuredOutputs = void 0
43
+ } = {}) {
44
+ this.specificationVersion = "v1";
45
+ this.provider = provider;
46
+ this.modelId = modelId;
47
+ this.doGenerate = doGenerate;
48
+ this.doStream = doStream;
49
+ this.supportsUrl = supportsUrl;
50
+ this.defaultObjectGenerationMode = defaultObjectGenerationMode;
51
+ this.supportsStructuredOutputs = supportsStructuredOutputs;
52
+ }
53
+ };
54
+
55
+ // core/test/mock-values.ts
56
+ function mockValues(...values) {
57
+ let counter = 0;
58
+ return () => {
59
+ var _a;
60
+ return (_a = values[counter++]) != null ? _a : values[values.length - 1];
61
+ };
62
+ }
63
+
64
+ // util/delay.ts
65
+ async function delay(delayInMs) {
66
+ return delayInMs == null ? Promise.resolve() : new Promise((resolve) => setTimeout(resolve, delayInMs));
67
+ }
68
+
69
+ // core/util/simulate-readable-stream.ts
70
+ function simulateReadableStream({
71
+ chunks,
72
+ initialDelayInMs = 0,
73
+ chunkDelayInMs = 0,
74
+ _internal
75
+ }) {
76
+ var _a;
77
+ const delay2 = (_a = _internal == null ? void 0 : _internal.delay) != null ? _a : delay;
78
+ let index = 0;
79
+ return new ReadableStream({
80
+ async pull(controller) {
81
+ if (index < chunks.length) {
82
+ await delay2(index === 0 ? initialDelayInMs : chunkDelayInMs);
83
+ controller.enqueue(chunks[index++]);
84
+ } else {
85
+ controller.close();
86
+ }
87
+ }
88
+ });
89
+ }
90
+
91
+ // test/index.ts
92
+ var simulateReadableStream2 = simulateReadableStream;
93
+ export {
94
+ MockEmbeddingModelV1,
95
+ MockLanguageModelV1,
96
+ convertArrayToReadableStream,
97
+ mockId,
98
+ mockValues,
99
+ simulateReadableStream2 as simulateReadableStream
100
+ };
101
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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/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"]}
@@ -1,324 +0,0 @@
1
- /**
2
- Typed tool call that is returned by generateText and streamText.
3
- It contains the tool call ID, the tool name, and the tool arguments.
4
- */
5
- interface ToolCall$1<NAME extends string, ARGS> {
6
- /**
7
- ID of the tool call. This ID is used to match the tool call with the tool result.
8
- */
9
- toolCallId: string;
10
- /**
11
- Name of the tool that is being called.
12
- */
13
- toolName: NAME;
14
- /**
15
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
16
- */
17
- args: ARGS;
18
- }
19
-
20
- /**
21
- Typed tool result that is returned by generateText and streamText.
22
- It contains the tool call ID, the tool name, the tool arguments, and the tool result.
23
- */
24
- interface ToolResult<NAME extends string, ARGS, RESULT> {
25
- /**
26
- ID of the tool call. This ID is used to match the tool call with the tool result.
27
- */
28
- toolCallId: string;
29
- /**
30
- Name of the tool that was called.
31
- */
32
- toolName: NAME;
33
- /**
34
- Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
35
- */
36
- args: ARGS;
37
- /**
38
- Result of the tool call. This is the result of the tool's execution.
39
- */
40
- result: RESULT;
41
- }
42
-
43
- interface FunctionCall {
44
- /**
45
- * The arguments to call the function with, as generated by the model in JSON
46
- * format. Note that the model does not always generate valid JSON, and may
47
- * hallucinate parameters not defined by your function schema. Validate the
48
- * arguments in your code before calling your function.
49
- */
50
- arguments?: string;
51
- /**
52
- * The name of the function to call.
53
- */
54
- name?: string;
55
- }
56
- /**
57
- * The tool calls generated by the model, such as function calls.
58
- */
59
- interface ToolCall {
60
- id: string;
61
- type: string;
62
- function: {
63
- name: string;
64
- arguments: string;
65
- };
66
- }
67
- /**
68
- Tool invocations are either tool calls or tool results. For each assistant tool call,
69
- there is one tool invocation. While the call is in progress, the invocation is a tool call.
70
- Once the call is complete, the invocation is a tool result.
71
- */
72
- type ToolInvocation = ToolCall$1<string, any> | ToolResult<string, any, any>;
73
- /**
74
- * Shared types between the API and UI packages.
75
- */
76
- interface Message {
77
- id: string;
78
- tool_call_id?: string;
79
- createdAt?: Date;
80
- content: string;
81
- /**
82
- @deprecated Use AI SDK RSC instead: https://sdk.vercel.ai/docs/ai-sdk-rsc
83
- */
84
- ui?: string | JSX.Element | JSX.Element[] | null | undefined;
85
- role: 'system' | 'user' | 'assistant' | 'function' | 'data' | 'tool';
86
- /**
87
- *
88
- * If the message has a role of `function`, the `name` field is the name of the function.
89
- * Otherwise, the name field should not be set.
90
- */
91
- name?: string;
92
- /**
93
- * If the assistant role makes a function call, the `function_call` field
94
- * contains the function call name and arguments. Otherwise, the field should
95
- * not be set. (Deprecated and replaced by tool_calls.)
96
- */
97
- function_call?: string | FunctionCall;
98
- data?: JSONValue;
99
- /**
100
- * If the assistant role makes a tool call, the `tool_calls` field contains
101
- * the tool call name and arguments. Otherwise, the field should not be set.
102
- */
103
- tool_calls?: string | ToolCall[];
104
- /**
105
- * Additional message-specific information added on the server via StreamData
106
- */
107
- annotations?: JSONValue[] | undefined;
108
- /**
109
- Tool invocations (that can be tool calls or tool results, depending on whether or not the invocation has finished)
110
- that the assistant made as part of this message.
111
- */
112
- toolInvocations?: Array<ToolInvocation>;
113
- }
114
- type JSONValue = null | string | number | boolean | {
115
- [x: string]: JSONValue;
116
- } | Array<JSONValue>;
117
-
118
- /**
119
- * A prompt constructor for Anthropic models.
120
- * Does not support `function` messages.
121
- * @see https://docs.anthropic.com/claude/reference/getting-started-with-the-api
122
- */
123
- declare function experimental_buildAnthropicPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
124
- /**
125
- * A prompt constructor for Anthropic V3 models which require Messages API.
126
- * Does not support message with image content
127
- * @see https://docs.anthropic.com/claude/reference/messages_post
128
- */
129
- declare function experimental_buildAnthropicMessages(messages: Pick<Message, 'content' | 'role'>[]): {
130
- role: "function" | "system" | "user" | "assistant" | "data" | "tool";
131
- content: {
132
- type: string;
133
- text: string;
134
- }[];
135
- }[];
136
-
137
- /**
138
- * A prompt constructor for the HuggingFace StarChat Beta model.
139
- * Does not support `function` messages.
140
- * @see https://huggingface.co/HuggingFaceH4/starchat-beta
141
- */
142
- declare function experimental_buildStarChatBetaPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
143
- /**
144
- * A prompt constructor for HuggingFace OpenAssistant models.
145
- * Does not support `function` or `system` messages.
146
- * @see https://huggingface.co/OpenAssistant/oasst-sft-4-pythia-12b-epoch-3.5
147
- */
148
- declare function experimental_buildOpenAssistantPrompt(messages: Pick<Message, 'content' | 'role'>[]): string;
149
- /**
150
- * A prompt constructor for HuggingFace LLama 2 chat models.
151
- * Does not support `function` messages.
152
- * @see https://huggingface.co/meta-llama/Llama-2-70b-chat-hf and https://huggingface.co/blog/llama2#how-to-prompt-llama-2
153
- */
154
- declare function experimental_buildLlama2Prompt(messages: Pick<Message, 'content' | 'role'>[]): string;
155
-
156
- declare function experimental_buildOpenAIMessages(messages: Message[]): ChatCompletionMessageParam[];
157
- type ChatCompletionMessageParam = ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam | ChatCompletionToolMessageParam | ChatCompletionFunctionMessageParam;
158
- interface ChatCompletionSystemMessageParam {
159
- /**
160
- * The contents of the system message.
161
- */
162
- content: string;
163
- /**
164
- * The role of the messages author, in this case `system`.
165
- */
166
- role: 'system';
167
- /**
168
- * An optional name for the participant. Provides the model information to
169
- * differentiate between participants of the same role.
170
- */
171
- name?: string;
172
- }
173
- interface ChatCompletionUserMessageParam {
174
- /**
175
- * The contents of the user message.
176
- */
177
- content: string | Array<ChatCompletionContentPart>;
178
- /**
179
- * The role of the messages author, in this case `user`.
180
- */
181
- role: 'user';
182
- /**
183
- * An optional name for the participant. Provides the model information to
184
- * differentiate between participants of the same role.
185
- */
186
- name?: string;
187
- }
188
- type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage;
189
- interface ChatCompletionContentPartText {
190
- /**
191
- * The text content.
192
- */
193
- text: string;
194
- /**
195
- * The type of the content part.
196
- */
197
- type: 'text';
198
- }
199
- interface ChatCompletionContentPartImage {
200
- image_url: ChatCompletionContentPartImage.ImageURL;
201
- /**
202
- * The type of the content part.
203
- */
204
- type: 'image_url';
205
- }
206
- declare namespace ChatCompletionContentPartImage {
207
- interface ImageURL {
208
- /**
209
- * Either a URL of the image or the base64 encoded image data.
210
- */
211
- url: string;
212
- /**
213
- * Specifies the detail level of the image. Learn more in the
214
- * [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).
215
- */
216
- detail?: 'auto' | 'low' | 'high';
217
- }
218
- }
219
- interface ChatCompletionAssistantMessageParam {
220
- /**
221
- * The role of the messages author, in this case `assistant`.
222
- */
223
- role: 'assistant';
224
- /**
225
- * The contents of the assistant message. Required unless `tool_calls` or
226
- * `function_call` is specified.
227
- */
228
- content?: string | null;
229
- /**
230
- * @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
231
- * a function that should be called, as generated by the model.
232
- */
233
- function_call?: ChatCompletionAssistantMessageParam.FunctionCall;
234
- /**
235
- * An optional name for the participant. Provides the model information to
236
- * differentiate between participants of the same role.
237
- */
238
- name?: string;
239
- /**
240
- * The tool calls generated by the model, such as function calls.
241
- */
242
- tool_calls?: Array<ChatCompletionMessageToolCall>;
243
- }
244
- declare namespace ChatCompletionAssistantMessageParam {
245
- /**
246
- * @deprecated: Deprecated and replaced by `tool_calls`. The name and arguments of
247
- * a function that should be called, as generated by the model.
248
- */
249
- interface FunctionCall {
250
- /**
251
- * The arguments to call the function with, as generated by the model in JSON
252
- * format. Note that the model does not always generate valid JSON, and may
253
- * hallucinate parameters not defined by your function schema. Validate the
254
- * arguments in your code before calling your function.
255
- */
256
- arguments: string;
257
- /**
258
- * The name of the function to call.
259
- */
260
- name: string;
261
- }
262
- }
263
- interface ChatCompletionMessageToolCall {
264
- /**
265
- * The ID of the tool call.
266
- */
267
- id: string;
268
- /**
269
- * The function that the model called.
270
- */
271
- function: ChatCompletionMessageToolCall.Function;
272
- /**
273
- * The type of the tool. Currently, only `function` is supported.
274
- */
275
- type: 'function';
276
- }
277
- declare namespace ChatCompletionMessageToolCall {
278
- /**
279
- * The function that the model called.
280
- */
281
- interface Function {
282
- /**
283
- * The arguments to call the function with, as generated by the model in JSON
284
- * format. Note that the model does not always generate valid JSON, and may
285
- * hallucinate parameters not defined by your function schema. Validate the
286
- * arguments in your code before calling your function.
287
- */
288
- arguments: string;
289
- /**
290
- * The name of the function to call.
291
- */
292
- name: string;
293
- }
294
- }
295
- interface ChatCompletionToolMessageParam {
296
- /**
297
- * The contents of the tool message.
298
- */
299
- content: string;
300
- /**
301
- * The role of the messages author, in this case `tool`.
302
- */
303
- role: 'tool';
304
- /**
305
- * Tool call that this message is responding to.
306
- */
307
- tool_call_id: string;
308
- }
309
- interface ChatCompletionFunctionMessageParam {
310
- /**
311
- * The return value from the function call, to return to the model.
312
- */
313
- content: string | null;
314
- /**
315
- * The name of the function to call.
316
- */
317
- name: string;
318
- /**
319
- * The role of the messages author, in this case `function`.
320
- */
321
- role: 'function';
322
- }
323
-
324
- export { ChatCompletionAssistantMessageParam, ChatCompletionContentPart, ChatCompletionContentPartImage, ChatCompletionContentPartText, ChatCompletionFunctionMessageParam, ChatCompletionMessageParam, ChatCompletionMessageToolCall, ChatCompletionSystemMessageParam, ChatCompletionToolMessageParam, ChatCompletionUserMessageParam, experimental_buildAnthropicMessages, experimental_buildAnthropicPrompt, experimental_buildLlama2Prompt, experimental_buildOpenAIMessages, experimental_buildOpenAssistantPrompt, experimental_buildStarChatBetaPrompt };