[v11.0.x] LLMApp: Skip 404 requests to know if the plugin exists (#85269)

LLMApp: Skip 404 requests to know if the plugin exists (#85226)

---------

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
(cherry picked from commit 61e67423ff)

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-16 14:51:26 +02:00
committed by GitHub
co-authored by Torkel Ödegaard
parent 389b734da1
commit b2f5eb1d87
2 changed files with 15 additions and 0 deletions
@@ -16,6 +16,16 @@ jest.mock('@grafana/experimental', () => ({
},
}));
jest.mock('@grafana/runtime', () => ({
...jest.requireActual('@grafana/runtime'),
config: {
...jest.requireActual('@grafana/runtime').config,
apps: {
'grafana-llm-app': true,
},
},
}));
describe('getDashboardChanges', () => {
it('should correctly split user changes and migration changes', () => {
// Mock data for testing
@@ -1,6 +1,7 @@
import { pick } from 'lodash';
import { llms } from '@grafana/experimental';
import { config } from '@grafana/runtime';
import { Panel } from '@grafana/schema';
import { DashboardModel, PanelModel } from '../../state';
@@ -63,6 +64,10 @@ export function getDashboardChanges(dashboard: DashboardModel): {
* @returns true if the LLM plugin is enabled.
*/
export async function isLLMPluginEnabled() {
if (!config.apps['grafana-llm-app']) {
return false;
}
// Check if the LLM plugin is enabled.
// If not, we won't be able to make requests, so return early.
return llms.openai.health().then((response) => response.ok);