mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LLMApp: Skip 404 requests to know if the plugin exists (#85226)
--------- Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user