@aleph-alpha/chat-kit 3.1.0 → 3.1.2
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/dist/composables/fileUpload/index.d.ts.map +1 -1
- package/dist/composables/fileUpload/useFileUploadWrapper.d.ts.map +1 -1
- package/dist/composables/index.js +1 -1
- package/dist/{index-THzZwfMU.js → index-BgQf4bMm.js} +21 -18
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/composables/fileUpload/index.spec.ts +0 -5
- package/src/composables/fileUpload/index.ts +0 -1
- package/src/composables/fileUpload/useFileUploadWrapper.spec.ts +10 -2
- package/src/composables/fileUpload/useFileUploadWrapper.ts +32 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/fileUpload/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAItE,eAAO,MAAM,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/composables/fileUpload/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAItE,eAAO,MAAM,2BAA2B,EAAE,oBAyFzC,CAAC;AAEF,QAAA,MAA2B,kCAAkC,+FACF,CAAC;AAE5D,OAAO,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,CAAC;AAE5E,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,0BAA0B,EAC1B,SAAS,EACT,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFileUploadWrapper.d.ts","sourceRoot":"","sources":["../../../src/composables/fileUpload/useFileUploadWrapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAOV,oBAAoB,EACpB,sBAAsB,EAIvB,MAAM,SAAS,CAAC;AAiJjB,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,oBAAoB,GAC3B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useFileUploadWrapper.d.ts","sourceRoot":"","sources":["../../../src/composables/fileUpload/useFileUploadWrapper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAOV,oBAAoB,EACpB,sBAAsB,EAIvB,MAAM,SAAS,CAAC;AAiJjB,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,oBAAoB,GAC3B,sBAAsB,CAqQxB"}
|
|
@@ -1342,11 +1342,10 @@ function createDocumentUploadProvider(config) {
|
|
|
1342
1342
|
let resolvedStoreId = null;
|
|
1343
1343
|
let resolvePromise = null;
|
|
1344
1344
|
async function createSearchStoreWithWorkflow() {
|
|
1345
|
-
const name =
|
|
1345
|
+
const name = `store-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
|
|
1346
1346
|
const storeRes = await httpClient.post("search-stores", {
|
|
1347
1347
|
name,
|
|
1348
|
-
...searchStoreConfig
|
|
1349
|
-
metadata: { created_by: userId }
|
|
1348
|
+
...searchStoreConfig
|
|
1350
1349
|
});
|
|
1351
1350
|
const newStoreId = storeRes.id;
|
|
1352
1351
|
await httpClient.post(
|
|
@@ -1355,23 +1354,28 @@ function createDocumentUploadProvider(config) {
|
|
|
1355
1354
|
);
|
|
1356
1355
|
return newStoreId;
|
|
1357
1356
|
}
|
|
1357
|
+
async function fetchOrCreateStore() {
|
|
1358
|
+
try {
|
|
1359
|
+
const response = await httpClient.get("search-stores");
|
|
1360
|
+
const expectedModel = searchStoreConfig.models[0]?.embedding_model;
|
|
1361
|
+
const match = response.items.find(
|
|
1362
|
+
(store) => store.models.some((m) => m.embedding_model === expectedModel)
|
|
1363
|
+
);
|
|
1364
|
+
if (match) {
|
|
1365
|
+
resolvedStoreId = match.id;
|
|
1366
|
+
return resolvedStoreId;
|
|
1367
|
+
}
|
|
1368
|
+
resolvedStoreId = await createSearchStoreWithWorkflow();
|
|
1369
|
+
return resolvedStoreId;
|
|
1370
|
+
} catch (err) {
|
|
1371
|
+
resolvePromise = null;
|
|
1372
|
+
throw err;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1358
1375
|
async function resolveSearchStore() {
|
|
1359
1376
|
if (resolvedStoreId) return resolvedStoreId;
|
|
1360
1377
|
if (resolvePromise) return resolvePromise;
|
|
1361
|
-
resolvePromise = (
|
|
1362
|
-
try {
|
|
1363
|
-
const stores = await httpClient.get("search-stores");
|
|
1364
|
-
if (stores.length > 0 && stores[0]) {
|
|
1365
|
-
resolvedStoreId = stores[0].id;
|
|
1366
|
-
return resolvedStoreId;
|
|
1367
|
-
}
|
|
1368
|
-
resolvedStoreId = await createSearchStoreWithWorkflow();
|
|
1369
|
-
return resolvedStoreId;
|
|
1370
|
-
} catch (err) {
|
|
1371
|
-
resolvePromise = null;
|
|
1372
|
-
throw err;
|
|
1373
|
-
}
|
|
1374
|
-
})();
|
|
1378
|
+
resolvePromise = fetchOrCreateStore();
|
|
1375
1379
|
return resolvePromise;
|
|
1376
1380
|
}
|
|
1377
1381
|
let instance = null;
|
|
@@ -1519,7 +1523,6 @@ function createDocumentUploadProvider(config) {
|
|
|
1519
1523
|
const WORKFLOW_ID = "my-doc-ai";
|
|
1520
1524
|
const defaultDocumentUploadConfig = {
|
|
1521
1525
|
baseUrl: "/file-upload",
|
|
1522
|
-
userId: "chat-user",
|
|
1523
1526
|
workflowId: WORKFLOW_ID,
|
|
1524
1527
|
searchStoreConfig: {
|
|
1525
1528
|
models: [
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u } from "./useMessageHandler-CMdy-lm0.js";
|
|
2
2
|
import { C, d, p, u as u2, a } from "./useChatKitLabels-CLsWWwgG.js";
|
|
3
|
-
import { S, c, d as d2, a as a2, u as u3, b, e, f } from "./index-
|
|
3
|
+
import { S, c, d as d2, a as a2, u as u3, b, e, f } from "./index-BgQf4bMm.js";
|
|
4
4
|
import { _, a as a3, b as b2, C as C2, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s, t, u as u4, v } from "./CkInput.vue_vue_type_script_setup_true_lang-DKzc21Yp.js";
|
|
5
5
|
export {
|
|
6
6
|
C as CHAT_KIT_LABELS,
|
package/package.json
CHANGED
|
@@ -29,10 +29,6 @@ describe('fileUpload index', () => {
|
|
|
29
29
|
expect(defaultDocumentUploadConfig.baseUrl).toBe('/file-upload');
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
it('uses the correct userId', () => {
|
|
33
|
-
expect(defaultDocumentUploadConfig.userId).toBe('chat-user');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
32
|
it('uses the correct workflowId', () => {
|
|
37
33
|
expect(defaultDocumentUploadConfig.workflowId).toBe('my-doc-ai');
|
|
38
34
|
});
|
|
@@ -178,7 +174,6 @@ describe('fileUpload index', () => {
|
|
|
178
174
|
it('passes the config to createDocumentUploadProvider', () => {
|
|
179
175
|
const customConfig: DocumentUploadConfig = {
|
|
180
176
|
baseUrl: '/custom-url',
|
|
181
|
-
userId: 'custom-user',
|
|
182
177
|
workflowId: 'custom-workflow',
|
|
183
178
|
searchStoreConfig: {
|
|
184
179
|
models: [
|
|
@@ -30,7 +30,6 @@ function buildConfig(
|
|
|
30
30
|
): DocumentUploadConfig {
|
|
31
31
|
return {
|
|
32
32
|
baseUrl: 'https://test.example.com',
|
|
33
|
-
userId: 'user-1',
|
|
34
33
|
workflowId: 'wf-1',
|
|
35
34
|
searchStoreConfig: {
|
|
36
35
|
models: [
|
|
@@ -60,7 +59,16 @@ describe('useFileUploadWrapper handleFilesSelected', () => {
|
|
|
60
59
|
const method = init?.method ?? 'GET';
|
|
61
60
|
|
|
62
61
|
if (method === 'GET' && url.includes('search-stores')) {
|
|
63
|
-
return createMockFetchResponse(
|
|
62
|
+
return createMockFetchResponse({
|
|
63
|
+
items: [
|
|
64
|
+
{
|
|
65
|
+
id: 'store-1',
|
|
66
|
+
name: 'test-store',
|
|
67
|
+
models: [{ embedding_model: 'test-model' }],
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
total: 1,
|
|
71
|
+
});
|
|
64
72
|
}
|
|
65
73
|
if (method === 'POST' && url.includes('/files')) {
|
|
66
74
|
return createMockFetchResponse([{ id: 'remote-1' }]);
|
|
@@ -183,11 +183,10 @@ export function createDocumentUploadProvider(
|
|
|
183
183
|
let resolvePromise: Promise<string> | null = null;
|
|
184
184
|
|
|
185
185
|
async function createSearchStoreWithWorkflow(): Promise<string> {
|
|
186
|
-
const name =
|
|
186
|
+
const name = `store-${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
|
187
187
|
const storeRes = await httpClient.post<{ id: string }>('search-stores', {
|
|
188
188
|
name,
|
|
189
189
|
...searchStoreConfig,
|
|
190
|
-
metadata: { created_by: userId },
|
|
191
190
|
});
|
|
192
191
|
const newStoreId = storeRes.id;
|
|
193
192
|
|
|
@@ -199,27 +198,43 @@ export function createDocumentUploadProvider(
|
|
|
199
198
|
return newStoreId;
|
|
200
199
|
}
|
|
201
200
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
interface SearchStoreListResponse {
|
|
202
|
+
items: Array<{
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
models: Array<{ embedding_model: string }>;
|
|
206
|
+
}>;
|
|
207
|
+
total: number;
|
|
208
|
+
}
|
|
205
209
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
async function fetchOrCreateStore(): Promise<string> {
|
|
211
|
+
try {
|
|
212
|
+
const response =
|
|
213
|
+
await httpClient.get<SearchStoreListResponse>('search-stores');
|
|
209
214
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
const expectedModel = searchStoreConfig.models[0]?.embedding_model;
|
|
216
|
+
const match = response.items.find((store) =>
|
|
217
|
+
store.models.some((m) => m.embedding_model === expectedModel),
|
|
218
|
+
);
|
|
214
219
|
|
|
215
|
-
|
|
220
|
+
if (match) {
|
|
221
|
+
resolvedStoreId = match.id;
|
|
216
222
|
return resolvedStoreId;
|
|
217
|
-
} catch (err) {
|
|
218
|
-
resolvePromise = null;
|
|
219
|
-
throw err;
|
|
220
223
|
}
|
|
221
|
-
})();
|
|
222
224
|
|
|
225
|
+
resolvedStoreId = await createSearchStoreWithWorkflow();
|
|
226
|
+
return resolvedStoreId;
|
|
227
|
+
} catch (err) {
|
|
228
|
+
resolvePromise = null;
|
|
229
|
+
throw err;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function resolveSearchStore(): Promise<string> {
|
|
234
|
+
if (resolvedStoreId) return resolvedStoreId;
|
|
235
|
+
if (resolvePromise) return resolvePromise;
|
|
236
|
+
|
|
237
|
+
resolvePromise = fetchOrCreateStore();
|
|
223
238
|
return resolvePromise;
|
|
224
239
|
}
|
|
225
240
|
|