@ai-sdk/llamaindex 3.0.0-beta.99 → 3.0.0-canary.118

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.118
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [47e65d6]
8
+ - ai@7.0.0-canary.118
9
+
10
+ ## 3.0.0-canary.117
11
+
12
+ ### Patch Changes
13
+
14
+ - 0c4c275: trigger initial canary release
15
+ - Updated dependencies [0c4c275]
16
+ - ai@7.0.0-canary.117
17
+
18
+ ## 3.0.0-beta.116
19
+
20
+ ### Patch Changes
21
+
22
+ - ai@7.0.0-beta.116
23
+
24
+ ## 3.0.0-beta.115
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [08d2129]
29
+ - Updated dependencies [202f107]
30
+ - ai@7.0.0-beta.115
31
+
32
+ ## 3.0.0-beta.114
33
+
34
+ ### Patch Changes
35
+
36
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
37
+ - Updated dependencies [43a6750]
38
+ - Updated dependencies [81caa5d]
39
+ - Updated dependencies [1f7db50]
40
+ - Updated dependencies [9bd6512]
41
+ - Updated dependencies [258c093]
42
+ - Updated dependencies [6147cdf]
43
+ - ai@7.0.0-beta.114
44
+
45
+ ## 3.0.0-beta.113
46
+
47
+ ### Patch Changes
48
+
49
+ - 9f0e36c: trigger release for all packages after provenance setup
50
+ - Updated dependencies [9f0e36c]
51
+ - ai@7.0.0-beta.113
52
+
53
+ ## 3.0.0-beta.112
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [5f3749c]
58
+ - Updated dependencies [0a51f7d]
59
+ - Updated dependencies [71d3022]
60
+ - Updated dependencies [67df0a0]
61
+ - Updated dependencies [4181cfe]
62
+ - Updated dependencies [51ce232]
63
+ - Updated dependencies [cf93359]
64
+ - Updated dependencies [befb78c]
65
+ - Updated dependencies [29d8cf4]
66
+ - Updated dependencies [58a2ad7]
67
+ - Updated dependencies [37d69b2]
68
+ - Updated dependencies [1043274]
69
+ - Updated dependencies [7f59f04]
70
+ - Updated dependencies [7677c1e]
71
+ - Updated dependencies [116c89f]
72
+ - Updated dependencies [f58f9bc]
73
+ - Updated dependencies [e1bfb9c]
74
+ - Updated dependencies [e87d71b]
75
+ - Updated dependencies [9d486aa]
76
+ - Updated dependencies [9b0bc8a]
77
+ - Updated dependencies [fc92055]
78
+ - Updated dependencies [4e095b0]
79
+ - ai@7.0.0-beta.112
80
+
81
+ ## 3.0.0-beta.111
82
+
83
+ ### Patch Changes
84
+
85
+ - Updated dependencies [f319fde]
86
+ - Updated dependencies [1949571]
87
+ - Updated dependencies [511902c]
88
+ - Updated dependencies [6542d93]
89
+ - Updated dependencies [2e98477]
90
+ - Updated dependencies [876fd3e]
91
+ - Updated dependencies [f32c750]
92
+ - ai@7.0.0-beta.111
93
+
94
+ ## 3.0.0-beta.110
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [72cb801]
99
+ - ai@7.0.0-beta.110
100
+
101
+ ## 3.0.0-beta.109
102
+
103
+ ### Patch Changes
104
+
105
+ - Updated dependencies [ec98264]
106
+ - Updated dependencies [eea8d98]
107
+ - Updated dependencies [75ef93e]
108
+ - ai@7.0.0-beta.109
109
+
110
+ ## 3.0.0-beta.108
111
+
112
+ ### Patch Changes
113
+
114
+ - ai@7.0.0-beta.108
115
+
116
+ ## 3.0.0-beta.107
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies [350ea38]
121
+ - ai@7.0.0-beta.107
122
+
123
+ ## 3.0.0-beta.106
124
+
125
+ ### Patch Changes
126
+
127
+ - ai@7.0.0-beta.106
128
+
129
+ ## 3.0.0-beta.105
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [33d099c]
134
+ - ai@7.0.0-beta.105
135
+
136
+ ## 3.0.0-beta.104
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [2a74d43]
141
+ - ai@7.0.0-beta.104
142
+
143
+ ## 3.0.0-beta.103
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies [382d53b]
148
+ - Updated dependencies [7bf7d7f]
149
+ - Updated dependencies [c3d4019]
150
+ - Updated dependencies [083947b]
151
+ - ai@7.0.0-beta.103
152
+
153
+ ## 3.0.0-beta.102
154
+
155
+ ### Patch Changes
156
+
157
+ - ai@7.0.0-beta.102
158
+
159
+ ## 3.0.0-beta.101
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies [4873966]
164
+ - ai@7.0.0-beta.101
165
+
166
+ ## 3.0.0-beta.100
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [add1126]
171
+ - ai@7.0.0-beta.100
172
+
3
173
  ## 3.0.0-beta.99
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.99",
3
+ "version": "3.0.0-canary.118",
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.99"
28
+ "ai": "7.0.0-canary.118"
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
  };