From ba188d9803988f5579ea5aa2ba2d139c2c000b9b Mon Sep 17 00:00:00 2001 From: rawpixel-vincent Date: Sun, 31 Dec 2023 19:52:42 +0700 Subject: [PATCH] fix missing authentication header in chroma client rawGet --- .../vectordatabases/providers/chroma/index.js | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/utils/vectordatabases/providers/chroma/index.js b/backend/utils/vectordatabases/providers/chroma/index.js index 67bd455b..f0db1626 100644 --- a/backend/utils/vectordatabases/providers/chroma/index.js +++ b/backend/utils/vectordatabases/providers/chroma/index.js @@ -36,12 +36,12 @@ class Chroma { path: settings.instanceURL, ...(settings?.authToken ? { - fetchOptions: { - headers: { - [settings.authTokenHeader || "X-Api-Key"]: settings.authToken, - }, + fetchOptions: { + headers: { + [settings.authTokenHeader || "X-Api-Key"]: settings.authToken, }, - } + }, + } : {}), }); @@ -114,13 +114,23 @@ class Chroma { } async rawGet(collectionId, pageSize = 10, offset = 0) { + const { settings } = this.config; return await fetch( `${this.config.settings.instanceURL}/api/v1/collections/${collectionId}/get`, { method: "POST", headers: { + accept: "application/json", "Content-Type": "application/json", + ...(settings?.authToken + ? { + [settings.authTokenHeader || "X-Api-Key"]: + settings.authTokenHeader === 'Authorization' + ? `Bearer ${settings.authToken}` : + settings.authToken, + } + : {}), }, body: JSON.stringify({ limit: pageSize,