Skip to content

Commit

Permalink
Merge pull request #79 from grafana/vector-check-method-not-allowed
Browse files Browse the repository at this point in the history
fix: return 'true' from enabled if API call returns 405 Method Not Allowed
  • Loading branch information
codeincarnate authored Sep 14, 2023
2 parents 7a0b51d + 5d5ca54 commit f4369c9
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 f4369c9

Please sign in to comment.