Skip to content

Commit

Permalink
fix: return 'true' from enabled if API call returns 405 Method Not Al…
Browse files Browse the repository at this point in the history
…lowed

The backend intentionally returns a 405 if a GET request
is sent to the search endpoint, so we can count that as correctly enabled.
  • Loading branch information
sd2k committed Sep 14, 2023
1 parent 2e65635 commit 474a32a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/llms/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
};

0 comments on commit 474a32a

Please sign in to comment.