@aleph-alpha/chat-kit 3.1.1 → 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.
@@ -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,CAqPxB"}
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"}
@@ -1,4 +1,4 @@
1
- import { c, d, u, b, e, f } from "../index-CnuiV5vd.js";
1
+ import { c, d, u, b, e, f } from "../index-BgQf4bMm.js";
2
2
  export {
3
3
  c as createDocumentUploadProvider,
4
4
  d as defaultDocumentUploadConfig,
@@ -1354,23 +1354,28 @@ function createDocumentUploadProvider(config) {
1354
1354
  );
1355
1355
  return newStoreId;
1356
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
+ }
1357
1375
  async function resolveSearchStore() {
1358
1376
  if (resolvedStoreId) return resolvedStoreId;
1359
1377
  if (resolvePromise) return resolvePromise;
1360
- resolvePromise = (async () => {
1361
- try {
1362
- const stores = await httpClient.get("search-stores");
1363
- if (stores.length > 0 && stores[0]) {
1364
- resolvedStoreId = stores[0].id;
1365
- return resolvedStoreId;
1366
- }
1367
- resolvedStoreId = await createSearchStoreWithWorkflow();
1368
- return resolvedStoreId;
1369
- } catch (err) {
1370
- resolvePromise = null;
1371
- throw err;
1372
- }
1373
- })();
1378
+ resolvePromise = fetchOrCreateStore();
1374
1379
  return resolvePromise;
1375
1380
  }
1376
1381
  let instance = null;
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-CnuiV5vd.js";
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/chat-kit",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
4
4
  "description": "Chat kit package for building chat interfaces with Vue",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -59,7 +59,16 @@ describe('useFileUploadWrapper handleFilesSelected', () => {
59
59
  const method = init?.method ?? 'GET';
60
60
 
61
61
  if (method === 'GET' && url.includes('search-stores')) {
62
- return createMockFetchResponse([{ id: 'store-1' }]);
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
+ });
63
72
  }
64
73
  if (method === 'POST' && url.includes('/files')) {
65
74
  return createMockFetchResponse([{ id: 'remote-1' }]);
@@ -198,27 +198,43 @@ export function createDocumentUploadProvider(
198
198
  return newStoreId;
199
199
  }
200
200
 
201
- async function resolveSearchStore(): Promise<string> {
202
- if (resolvedStoreId) return resolvedStoreId;
203
- if (resolvePromise) return resolvePromise;
201
+ interface SearchStoreListResponse {
202
+ items: Array<{
203
+ id: string;
204
+ name: string;
205
+ models: Array<{ embedding_model: string }>;
206
+ }>;
207
+ total: number;
208
+ }
204
209
 
205
- resolvePromise = (async () => {
206
- try {
207
- const stores = await httpClient.get<{ id: string }[]>('search-stores');
210
+ async function fetchOrCreateStore(): Promise<string> {
211
+ try {
212
+ const response =
213
+ await httpClient.get<SearchStoreListResponse>('search-stores');
208
214
 
209
- if (stores.length > 0 && stores[0]) {
210
- resolvedStoreId = stores[0].id;
211
- return resolvedStoreId;
212
- }
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
+ );
213
219
 
214
- resolvedStoreId = await createSearchStoreWithWorkflow();
220
+ if (match) {
221
+ resolvedStoreId = match.id;
215
222
  return resolvedStoreId;
216
- } catch (err) {
217
- resolvePromise = null;
218
- throw err;
219
223
  }
220
- })();
221
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();
222
238
  return resolvePromise;
223
239
  }
224
240