@ai-sdk/llamaindex 3.0.0-beta.98 → 3.0.0-canary.117

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 CHANGED
@@ -1,5 +1,175 @@
1
1
  # @ai-sdk/llamaindex
2
2
 
3
+ ## 3.0.0-canary.117
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c4c275: trigger initial canary release
8
+ - Updated dependencies [0c4c275]
9
+ - ai@7.0.0-canary.117
10
+
11
+ ## 3.0.0-beta.116
12
+
13
+ ### Patch Changes
14
+
15
+ - ai@7.0.0-beta.116
16
+
17
+ ## 3.0.0-beta.115
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [08d2129]
22
+ - Updated dependencies [202f107]
23
+ - ai@7.0.0-beta.115
24
+
25
+ ## 3.0.0-beta.114
26
+
27
+ ### Patch Changes
28
+
29
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
30
+ - Updated dependencies [43a6750]
31
+ - Updated dependencies [81caa5d]
32
+ - Updated dependencies [1f7db50]
33
+ - Updated dependencies [9bd6512]
34
+ - Updated dependencies [258c093]
35
+ - Updated dependencies [6147cdf]
36
+ - ai@7.0.0-beta.114
37
+
38
+ ## 3.0.0-beta.113
39
+
40
+ ### Patch Changes
41
+
42
+ - 9f0e36c: trigger release for all packages after provenance setup
43
+ - Updated dependencies [9f0e36c]
44
+ - ai@7.0.0-beta.113
45
+
46
+ ## 3.0.0-beta.112
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [5f3749c]
51
+ - Updated dependencies [0a51f7d]
52
+ - Updated dependencies [71d3022]
53
+ - Updated dependencies [67df0a0]
54
+ - Updated dependencies [4181cfe]
55
+ - Updated dependencies [51ce232]
56
+ - Updated dependencies [cf93359]
57
+ - Updated dependencies [befb78c]
58
+ - Updated dependencies [29d8cf4]
59
+ - Updated dependencies [58a2ad7]
60
+ - Updated dependencies [37d69b2]
61
+ - Updated dependencies [1043274]
62
+ - Updated dependencies [7f59f04]
63
+ - Updated dependencies [7677c1e]
64
+ - Updated dependencies [116c89f]
65
+ - Updated dependencies [f58f9bc]
66
+ - Updated dependencies [e1bfb9c]
67
+ - Updated dependencies [e87d71b]
68
+ - Updated dependencies [9d486aa]
69
+ - Updated dependencies [9b0bc8a]
70
+ - Updated dependencies [fc92055]
71
+ - Updated dependencies [4e095b0]
72
+ - ai@7.0.0-beta.112
73
+
74
+ ## 3.0.0-beta.111
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [f319fde]
79
+ - Updated dependencies [1949571]
80
+ - Updated dependencies [511902c]
81
+ - Updated dependencies [6542d93]
82
+ - Updated dependencies [2e98477]
83
+ - Updated dependencies [876fd3e]
84
+ - Updated dependencies [f32c750]
85
+ - ai@7.0.0-beta.111
86
+
87
+ ## 3.0.0-beta.110
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies [72cb801]
92
+ - ai@7.0.0-beta.110
93
+
94
+ ## 3.0.0-beta.109
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [ec98264]
99
+ - Updated dependencies [eea8d98]
100
+ - Updated dependencies [75ef93e]
101
+ - ai@7.0.0-beta.109
102
+
103
+ ## 3.0.0-beta.108
104
+
105
+ ### Patch Changes
106
+
107
+ - ai@7.0.0-beta.108
108
+
109
+ ## 3.0.0-beta.107
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [350ea38]
114
+ - ai@7.0.0-beta.107
115
+
116
+ ## 3.0.0-beta.106
117
+
118
+ ### Patch Changes
119
+
120
+ - ai@7.0.0-beta.106
121
+
122
+ ## 3.0.0-beta.105
123
+
124
+ ### Patch Changes
125
+
126
+ - Updated dependencies [33d099c]
127
+ - ai@7.0.0-beta.105
128
+
129
+ ## 3.0.0-beta.104
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [2a74d43]
134
+ - ai@7.0.0-beta.104
135
+
136
+ ## 3.0.0-beta.103
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [382d53b]
141
+ - Updated dependencies [7bf7d7f]
142
+ - Updated dependencies [c3d4019]
143
+ - Updated dependencies [083947b]
144
+ - ai@7.0.0-beta.103
145
+
146
+ ## 3.0.0-beta.102
147
+
148
+ ### Patch Changes
149
+
150
+ - ai@7.0.0-beta.102
151
+
152
+ ## 3.0.0-beta.101
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies [4873966]
157
+ - ai@7.0.0-beta.101
158
+
159
+ ## 3.0.0-beta.100
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies [add1126]
164
+ - ai@7.0.0-beta.100
165
+
166
+ ## 3.0.0-beta.99
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [2a9c144]
171
+ - ai@7.0.0-beta.99
172
+
3
173
  ## 3.0.0-beta.98
4
174
 
5
175
  ### Patch Changes
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/llamaindex-adapter.ts","../src/stream-callbacks.ts"],"sourcesContent":["import { UIMessageChunk } from 'ai';\nimport { convertAsyncIteratorToReadableStream } from 'ai/internal';\nimport {\n createCallbacksTransformer,\n StreamCallbacks,\n} from './stream-callbacks';\n\ntype EngineResponse = {\n delta: string;\n};\n\nexport function toUIMessageStream(\n stream: AsyncIterable<EngineResponse>,\n callbacks?: StreamCallbacks,\n) {\n const trimStart = trimStartOfStream();\n\n return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]())\n .pipeThrough(\n new TransformStream({\n async transform(message, controller): Promise<void> {\n controller.enqueue(trimStart(message.delta));\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, UIMessageChunk>({\n start: async controller => {\n controller.enqueue({ type: 'text-start', id: '1' });\n },\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text-delta', delta: chunk, id: '1' });\n },\n flush: async controller => {\n controller.enqueue({ type: 'text-end', id: '1' });\n },\n }),\n );\n}\n\nfunction trimStartOfStream(): (text: string) => string {\n let isStreamStart = true;\n\n return (text: string): string => {\n if (isStreamStart) {\n text = text.trimStart();\n if (text) isStreamStart = false;\n }\n return text;\n };\n}\n","/**\n * Configuration options and helper callback methods for stream lifecycle events.\n */\nexport interface StreamCallbacks {\n /** `onStart`: Called once when the stream is initialized. */\n onStart?: () => Promise<void> | void;\n\n /** `onFinal`: Called once when the stream is closed with the final completion message. */\n onFinal?: (completion: string) => Promise<void> | void;\n\n /** `onToken`: Called for each tokenized message. */\n onToken?: (token: string) => Promise<void> | void;\n\n /** `onText`: Called for each text chunk. */\n onText?: (text: string) => Promise<void> | void;\n}\n\n/**\n * Creates a transform stream that encodes input messages and invokes optional callback functions.\n * The transform stream uses the provided callbacks to execute custom logic at different stages of the stream's lifecycle.\n * - `onStart`: Called once when the stream is initialized.\n * - `onToken`: Called for each tokenized message.\n * - `onFinal`: Called once when the stream is closed with the final completion message.\n *\n * This function is useful when you want to process a stream of messages and perform specific actions during the stream's lifecycle.\n *\n * @param {StreamCallbacks} [callbacks] - An object containing the callback functions.\n * @return {TransformStream<string, Uint8Array>} A transform stream that encodes input messages as Uint8Array and allows the execution of custom logic through callbacks.\n *\n * @example\n * const callbacks = {\n * onStart: async () => console.log('Stream started'),\n * onToken: async (token) => console.log(`Token: ${token}`),\n * onFinal: async () => data.close()\n * };\n * const transformer = createCallbacksTransformer(callbacks);\n */\nexport function createCallbacksTransformer(\n callbacks: StreamCallbacks | undefined = {},\n): TransformStream<string, string> {\n let aggregatedResponse = '';\n\n return new TransformStream({\n async start(): Promise<void> {\n if (callbacks.onStart) await callbacks.onStart();\n },\n\n async transform(message, controller): Promise<void> {\n controller.enqueue(message);\n\n aggregatedResponse += message;\n\n if (callbacks.onToken) await callbacks.onToken(message);\n if (callbacks.onText && typeof message === 'string') {\n await callbacks.onText(message);\n }\n },\n\n async flush(): Promise<void> {\n if (callbacks.onFinal) {\n await callbacks.onFinal(aggregatedResponse);\n }\n },\n });\n}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EA,SAAS,oBAA8C;AACrD,MAAI,gBAAgB;AAEpB,SAAO,CAAC,SAAyB;AAC/B,QAAI,eAAe;AACjB,aAAO,KAAK,UAAU;AACtB,UAAI,KAAM,iBAAgB;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/llamaindex-adapter.ts","../src/stream-callbacks.ts"],"sourcesContent":["import type { UIMessageChunk } from 'ai';\nimport { convertAsyncIteratorToReadableStream } from 'ai/internal';\nimport {\n createCallbacksTransformer,\n type StreamCallbacks,\n} from './stream-callbacks';\ntype EngineResponse = {\n delta: string;\n};\n\nexport function toUIMessageStream(\n stream: AsyncIterable<EngineResponse>,\n callbacks?: StreamCallbacks,\n) {\n const trimStart = trimStartOfStream();\n\n return convertAsyncIteratorToReadableStream(stream[Symbol.asyncIterator]())\n .pipeThrough(\n new TransformStream({\n async transform(message, controller): Promise<void> {\n controller.enqueue(trimStart(message.delta));\n },\n }),\n )\n .pipeThrough(createCallbacksTransformer(callbacks))\n .pipeThrough(\n new TransformStream<string, UIMessageChunk>({\n start: async controller => {\n controller.enqueue({ type: 'text-start', id: '1' });\n },\n transform: async (chunk, controller) => {\n controller.enqueue({ type: 'text-delta', delta: chunk, id: '1' });\n },\n flush: async controller => {\n controller.enqueue({ type: 'text-end', id: '1' });\n },\n }),\n );\n}\n\nfunction trimStartOfStream(): (text: string) => string {\n let isStreamStart = true;\n\n return (text: string): string => {\n if (isStreamStart) {\n text = text.trimStart();\n if (text) isStreamStart = false;\n }\n return text;\n };\n}\n","/**\n * Configuration options and helper callback methods for stream lifecycle events.\n */\nexport interface StreamCallbacks {\n /** `onStart`: Called once when the stream is initialized. */\n onStart?: () => Promise<void> | void;\n\n /** `onFinal`: Called once when the stream is closed with the final completion message. */\n onFinal?: (completion: string) => Promise<void> | void;\n\n /** `onToken`: Called for each tokenized message. */\n onToken?: (token: string) => Promise<void> | void;\n\n /** `onText`: Called for each text chunk. */\n onText?: (text: string) => Promise<void> | void;\n}\n\n/**\n * Creates a transform stream that encodes input messages and invokes optional callback functions.\n * The transform stream uses the provided callbacks to execute custom logic at different stages of the stream's lifecycle.\n * - `onStart`: Called once when the stream is initialized.\n * - `onToken`: Called for each tokenized message.\n * - `onFinal`: Called once when the stream is closed with the final completion message.\n *\n * This function is useful when you want to process a stream of messages and perform specific actions during the stream's lifecycle.\n *\n * @param {StreamCallbacks} [callbacks] - An object containing the callback functions.\n * @return {TransformStream<string, Uint8Array>} A transform stream that encodes input messages as Uint8Array and allows the execution of custom logic through callbacks.\n *\n * @example\n * const callbacks = {\n * onStart: async () => console.log('Stream started'),\n * onToken: async (token) => console.log(`Token: ${token}`),\n * onFinal: async () => data.close()\n * };\n * const transformer = createCallbacksTransformer(callbacks);\n */\nexport function createCallbacksTransformer(\n callbacks: StreamCallbacks | undefined = {},\n): TransformStream<string, string> {\n let aggregatedResponse = '';\n\n return new TransformStream({\n async start(): Promise<void> {\n if (callbacks.onStart) await callbacks.onStart();\n },\n\n async transform(message, controller): Promise<void> {\n controller.enqueue(message);\n\n aggregatedResponse += message;\n\n if (callbacks.onToken) await callbacks.onToken(message);\n if (callbacks.onText && typeof message === 'string') {\n await callbacks.onText(message);\n }\n },\n\n async flush(): Promise<void> {\n if (callbacks.onFinal) {\n await callbacks.onFinal(aggregatedResponse);\n }\n },\n });\n}\n"],"mappings":";AACA,SAAS,4CAA4C;;;ACoC9C,SAAS,2BACd,YAAyC,CAAC,GACT;AACjC,MAAI,qBAAqB;AAEzB,SAAO,IAAI,gBAAgB;AAAA,IACzB,MAAM,QAAuB;AAC3B,UAAI,UAAU,QAAS,OAAM,UAAU,QAAQ;AAAA,IACjD;AAAA,IAEA,MAAM,UAAU,SAAS,YAA2B;AAClD,iBAAW,QAAQ,OAAO;AAE1B,4BAAsB;AAEtB,UAAI,UAAU,QAAS,OAAM,UAAU,QAAQ,OAAO;AACtD,UAAI,UAAU,UAAU,OAAO,YAAY,UAAU;AACnD,cAAM,UAAU,OAAO,OAAO;AAAA,MAChC;AAAA,IACF;AAAA,IAEA,MAAM,QAAuB;AAC3B,UAAI,UAAU,SAAS;AACrB,cAAM,UAAU,QAAQ,kBAAkB;AAAA,MAC5C;AAAA,IACF;AAAA,EACF,CAAC;AACH;;;ADtDO,SAAS,kBACd,QACA,WACA;AACA,QAAM,YAAY,kBAAkB;AAEpC,SAAO,qCAAqC,OAAO,OAAO,aAAa,EAAE,CAAC,EACvE;AAAA,IACC,IAAI,gBAAgB;AAAA,MAClB,MAAM,UAAU,SAAS,YAA2B;AAClD,mBAAW,QAAQ,UAAU,QAAQ,KAAK,CAAC;AAAA,MAC7C;AAAA,IACF,CAAC;AAAA,EACH,EACC,YAAY,2BAA2B,SAAS,CAAC,EACjD;AAAA,IACC,IAAI,gBAAwC;AAAA,MAC1C,OAAO,OAAM,eAAc;AACzB,mBAAW,QAAQ,EAAE,MAAM,cAAc,IAAI,IAAI,CAAC;AAAA,MACpD;AAAA,MACA,WAAW,OAAO,OAAO,eAAe;AACtC,mBAAW,QAAQ,EAAE,MAAM,cAAc,OAAO,OAAO,IAAI,IAAI,CAAC;AAAA,MAClE;AAAA,MACA,OAAO,OAAM,eAAc;AACzB,mBAAW,QAAQ,EAAE,MAAM,YAAY,IAAI,IAAI,CAAC;AAAA,MAClD;AAAA,IACF,CAAC;AAAA,EACH;AACJ;AAEA,SAAS,oBAA8C;AACrD,MAAI,gBAAgB;AAEpB,SAAO,CAAC,SAAyB;AAC/B,QAAI,eAAe;AACjB,aAAO,KAAK,UAAU;AACtB,UAAI,KAAM,iBAAgB;AAAA,IAC5B;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/llamaindex",
3
- "version": "3.0.0-beta.98",
3
+ "version": "3.0.0-canary.117",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -25,7 +25,7 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "ai": "7.0.0-beta.98"
28
+ "ai": "7.0.0-canary.117"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "20.17.24",
@@ -37,12 +37,14 @@
37
37
  "node": ">=18"
38
38
  },
39
39
  "publishConfig": {
40
- "access": "public"
40
+ "access": "public",
41
+ "provenance": true
41
42
  },
42
43
  "homepage": "https://ai-sdk.dev/docs",
43
44
  "repository": {
44
45
  "type": "git",
45
- "url": "git+https://github.com/vercel/ai.git"
46
+ "url": "https://github.com/vercel/ai",
47
+ "directory": "packages/llamaindex"
46
48
  },
47
49
  "bugs": {
48
50
  "url": "https://github.com/vercel/ai/issues"
@@ -1,10 +1,9 @@
1
- import { UIMessageChunk } from 'ai';
1
+ import type { UIMessageChunk } from 'ai';
2
2
  import { convertAsyncIteratorToReadableStream } from 'ai/internal';
3
3
  import {
4
4
  createCallbacksTransformer,
5
- StreamCallbacks,
5
+ type StreamCallbacks,
6
6
  } from './stream-callbacks';
7
-
8
7
  type EngineResponse = {
9
8
  delta: string;
10
9
  };