feat(@grafana/assistant): bump assistant sdk (#109911)
Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
This commit is contained in:
co-authored by
Sven Grossmann
parent
018e810d43
commit
0262a23d7f
+1
-1
@@ -273,7 +273,7 @@
|
||||
"@formatjs/intl-durationformat": "^0.7.0",
|
||||
"@glideapps/glide-data-grid": "^6.0.0",
|
||||
"@grafana/alerting": "workspace:*",
|
||||
"@grafana/assistant": "0.0.14",
|
||||
"@grafana/assistant": "0.0.16",
|
||||
"@grafana/aws-sdk": "0.7.1",
|
||||
"@grafana/azure-sdk": "0.0.7",
|
||||
"@grafana/data": "workspace:*",
|
||||
|
||||
@@ -19,6 +19,7 @@ export function AnalyzeFlameGraphButton(props: Props) {
|
||||
className={className}
|
||||
onClick={() =>
|
||||
openAssistant({
|
||||
origin: 'analyze-flame-graph',
|
||||
prompt: 'Analyze Flame Graph',
|
||||
context: assistantContext,
|
||||
})
|
||||
|
||||
@@ -11,12 +11,7 @@ import {
|
||||
useState,
|
||||
} from 'react';
|
||||
|
||||
import {
|
||||
createContext as createAssistantContext,
|
||||
ItemDataType,
|
||||
OpenAssistantProps,
|
||||
useAssistant,
|
||||
} from '@grafana/assistant';
|
||||
import { createAssistantContextItem, OpenAssistantProps, useAssistant } from '@grafana/assistant';
|
||||
import {
|
||||
CoreApp,
|
||||
DataFrame,
|
||||
@@ -728,25 +723,19 @@ async function handleOpenAssistant(openAssistant: (props: OpenAssistantProps) =>
|
||||
const datasource = await getDataSourceSrv().get(log.datasourceUid);
|
||||
const context = [];
|
||||
if (datasource) {
|
||||
context.push(
|
||||
createAssistantContext(ItemDataType.Datasource, {
|
||||
datasourceUid: datasource.uid,
|
||||
datasourceName: datasource.name,
|
||||
datasourceType: datasource.type,
|
||||
img: datasource.meta?.info?.logos?.small,
|
||||
})
|
||||
);
|
||||
context.push(createAssistantContextItem('datasource', { datasourceUid: datasource.uid }));
|
||||
}
|
||||
openAssistant({
|
||||
prompt: `${t('logs.log-line-menu.log-line-explainer', 'Explain this log line in a concise way')}:
|
||||
|
||||
\`\`\`
|
||||
${log.entry.replaceAll('`', '\\`')}
|
||||
\`\`\`
|
||||
`,
|
||||
|
||||
\`\`\`
|
||||
${log.entry.replaceAll('`', '\\`')}
|
||||
\`\`\`
|
||||
`,
|
||||
origin: 'explain-log-line',
|
||||
context: [
|
||||
...context,
|
||||
createAssistantContext(ItemDataType.Structured, {
|
||||
createAssistantContextItem('structured', {
|
||||
title: t('logs.log-line-menu.log-line', 'Log line'),
|
||||
data: {
|
||||
labels: log.labels,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createContext, ItemDataType } from '@grafana/assistant';
|
||||
import { createAssistantContextItem } from '@grafana/assistant';
|
||||
import {
|
||||
DataFrame,
|
||||
DataQueryResponse,
|
||||
@@ -14,14 +14,10 @@ import { enrichDataFrameWithAssistantContentMapper } from './utils';
|
||||
|
||||
// Mock the createContext function
|
||||
jest.mock('@grafana/assistant', () => ({
|
||||
createContext: jest.fn(),
|
||||
ItemDataType: {
|
||||
Datasource: 'datasource',
|
||||
Structured: 'structured',
|
||||
},
|
||||
createAssistantContextItem: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockCreateContext = createContext as jest.MockedFunction<typeof createContext>;
|
||||
const mockCreateContext = createAssistantContextItem as jest.MockedFunction<typeof createAssistantContextItem>;
|
||||
|
||||
describe('enrichDataFrameWithAssistantContentMapper', () => {
|
||||
beforeEach(() => {
|
||||
@@ -113,14 +109,12 @@ describe('enrichDataFrameWithAssistantContentMapper', () => {
|
||||
expect(mockCreateContext).toHaveBeenCalledTimes(2);
|
||||
|
||||
// Verify datasource context
|
||||
expect(mockCreateContext).toHaveBeenCalledWith(ItemDataType.Datasource, {
|
||||
datasourceName: 'PyroscopeDatasource',
|
||||
expect(mockCreateContext).toHaveBeenCalledWith('datasource', {
|
||||
datasourceUid: 'test-uid',
|
||||
datasourceType: 'grafana-pyroscope-datasource',
|
||||
});
|
||||
|
||||
// Verify structured context
|
||||
expect(mockCreateContext).toHaveBeenCalledWith(ItemDataType.Structured, {
|
||||
expect(mockCreateContext).toHaveBeenCalledWith('structured', {
|
||||
title: 'Analyze Flame Graph',
|
||||
data: {
|
||||
start: request.range.from.valueOf(),
|
||||
@@ -327,7 +321,7 @@ describe('enrichDataFrameWithAssistantContentMapper', () => {
|
||||
const mapper = enrichDataFrameWithAssistantContentMapper(request, 'TestDatasource');
|
||||
mapper(response);
|
||||
|
||||
expect(mockCreateContext).toHaveBeenCalledWith(ItemDataType.Structured, {
|
||||
expect(mockCreateContext).toHaveBeenCalledWith('structured', {
|
||||
title: 'Analyze Flame Graph',
|
||||
data: {
|
||||
start: fromTime.valueOf(),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { invert } from 'lodash';
|
||||
import Prism, { Grammar, Token } from 'prismjs';
|
||||
|
||||
import { createContext, ItemDataType } from '@grafana/assistant';
|
||||
import { createAssistantContextItem } from '@grafana/assistant';
|
||||
import {
|
||||
AbstractLabelMatcher,
|
||||
AbstractLabelOperator,
|
||||
@@ -158,12 +158,10 @@ export function enrichDataFrameWithAssistantContentMapper(
|
||||
}
|
||||
|
||||
const context = [
|
||||
createContext(ItemDataType.Datasource, {
|
||||
datasourceName: datasourceName,
|
||||
createAssistantContextItem('datasource', {
|
||||
datasourceUid: query.datasource.uid,
|
||||
datasourceType: query.datasource.type,
|
||||
}),
|
||||
createContext(ItemDataType.Structured, {
|
||||
createAssistantContextItem('structured', {
|
||||
title: 'Analyze Flame Graph',
|
||||
data: {
|
||||
start: request.range.from.valueOf(),
|
||||
|
||||
@@ -3056,9 +3056,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@grafana/assistant@npm:0.0.14":
|
||||
version: 0.0.14
|
||||
resolution: "@grafana/assistant@npm:0.0.14"
|
||||
"@grafana/assistant@npm:0.0.16":
|
||||
version: 0.0.16
|
||||
resolution: "@grafana/assistant@npm:0.0.16"
|
||||
peerDependencies:
|
||||
"@grafana/data": ">=12.1.0"
|
||||
"@grafana/runtime": ">=12.1.0"
|
||||
@@ -3066,7 +3066,7 @@ __metadata:
|
||||
"@grafana/ui": ">=12.1.0"
|
||||
react: ">=18.0.0"
|
||||
rxjs: ">=7.0.0"
|
||||
checksum: 10/3e85effd69494b023d395940f5f926da1d2868850db613581d7b2f398e8f00fe07339fdb6fa12b3029603cd394d012104f187f2fd2fcb85196dac72cd6e072df
|
||||
checksum: 10/8482e09d3e86a865a8cf90908ae1438317b994798b5bf5d1a2369154b786e1ba20f30e208d48bed249c8427f11f87307b338c5307a8cb5143cffb2ef02050847
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -18299,7 +18299,7 @@ __metadata:
|
||||
"@formatjs/intl-durationformat": "npm:^0.7.0"
|
||||
"@glideapps/glide-data-grid": "npm:^6.0.0"
|
||||
"@grafana/alerting": "workspace:*"
|
||||
"@grafana/assistant": "npm:0.0.14"
|
||||
"@grafana/assistant": "npm:0.0.16"
|
||||
"@grafana/aws-sdk": "npm:0.7.1"
|
||||
"@grafana/azure-sdk": "npm:0.0.7"
|
||||
"@grafana/data": "workspace:*"
|
||||
|
||||
Reference in New Issue
Block a user