From 474a32abec9ca119cf1aaa8c01cd856f1e84817f Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Thu, 14 Sep 2023 20:13:24 +0100 Subject: [PATCH] fix: return 'true' from enabled if API call returns 405 Method Not Allowed The backend intentionally returns a 405 if a GET request is sent to the search endpoint, so we can count that as correctly enabled. --- src/llms/vector.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/llms/vector.ts b/src/llms/vector.ts index 3e8fed6..876f928 100644 --- a/src/llms/vector.ts +++ b/src/llms/vector.ts @@ -103,7 +103,9 @@ export const enabled = async () => { // Finally, check if the vector search API is available. try { await getBackendSrv().get(`${LLM_PLUGIN_ROUTE}/resources/vector/search`, undefined, undefined, { - showSuccessAlert: false, showErrorAlert: false, + responseType: "text", + showSuccessAlert: false, + showErrorAlert: false, }); return true; } catch (e: unknown) { @@ -125,6 +127,11 @@ export const enabled = async () => { loggedWarning = true; } } + // If the backend returns 405 Method Not Allowed then we've made it through to the + // handler, and it must be enabled. + if ((e as FetchError).status === 405) { + return true; + } return false; } };