diff --git a/CHANGELOG.md b/CHANGELOG.md index b9b1d51e..cd4fbed1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - feat: only allow to select supported index patterns in text to visualization and code changes related to prompt updates([#310](https://github.com/opensearch-project/dashboards-assistant/pull/310)) - feat: exposed an API to check if a give agent config name has configured with agent id([#307](https://github.com/opensearch-project/dashboards-assistant/pull/307)) - feat: check all required agents before enabling index pattern selection for text to visualization([313](https://github.com/opensearch-project/dashboards-assistant/pull/313)) +- fix: pass data source id for alert summary/insight([#321](https://github.com/opensearch-project/dashboards-assistant/pull/321)) ### 📈 Features/Enhancements @@ -37,4 +38,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Support insight with RAG in alert analysis assistant and refine the UX ([#266](https://github.com/opensearch-project/dashboards-assistant/pull/266)) - Add assistant enabled capabilities to control rendering component([#267](https://github.com/opensearch-project/dashboards-assistant/pull/267)) - Add data to summary API([#295](https://github.com/opensearch-project/dashboards-assistant/pull/295)) -- Refactor popover to add message action bar and add metrics to thumb-up and thumb-down([#304](https://github.com/opensearch-project/dashboards-assistant/pull/304)) \ No newline at end of file +- Refactor popover to add message action bar and add metrics to thumb-up and thumb-down([#304](https://github.com/opensearch-project/dashboards-assistant/pull/304)) diff --git a/public/components/incontext_insight/generate_popover_body.tsx b/public/components/incontext_insight/generate_popover_body.tsx index 2bb39737..8a56f2c9 100644 --- a/public/components/incontext_insight/generate_popover_body.tsx +++ b/public/components/incontext_insight/generate_popover_body.tsx @@ -21,7 +21,7 @@ import { import { useEffectOnce } from 'react-use'; import { METRIC_TYPE } from '@osd/analytics'; import { MessageActions } from '../../tabs/chat/messages/message_action'; -import { IncontextInsight as IncontextInsightInput } from '../../types'; +import { ContextObj, IncontextInsight as IncontextInsightInput } from '../../types'; import { getNotifications } from '../../services'; import { HttpSetup } from '../../../../../src/core/public'; import { SUMMARY_ASSISTANT_API } from '../../../common/constants/llm'; @@ -53,7 +53,7 @@ export const GeneratePopoverBody: React.FC<{ const onGenerateSummary = (summarizationQuestion: string) => { const summarize = async () => { - let contextObj; + let contextObj: ContextObj | undefined; try { contextObj = (await incontextInsight.contextProvider?.()) ?? undefined; } catch (e) { @@ -67,6 +67,8 @@ export const GeneratePopoverBody: React.FC<{ return; } const contextContent = contextObj?.context || ''; + const dataSourceId = contextObj?.dataSourceId; + const dataSourceQuery = dataSourceId ? { dataSourceId } : {}; let summaryType: string; const endIndex = incontextInsight.key.indexOf('_', 0); if (endIndex !== -1) { @@ -89,6 +91,7 @@ export const GeneratePopoverBody: React.FC<{ question: summarizationQuestion, context: contextContent, }), + query: dataSourceQuery, }) .then((response) => { const summaryContent = response.summary; @@ -97,6 +100,7 @@ export const GeneratePopoverBody: React.FC<{ setInsightAvailable(insightAgentIdExists); if (insightAgentIdExists) { onGenerateInsightBasedOnSummary( + dataSourceQuery, summaryType, insightType, summaryContent, @@ -120,6 +124,7 @@ export const GeneratePopoverBody: React.FC<{ }; const onGenerateInsightBasedOnSummary = ( + dataSourceQuery: {}, summaryType: string, insightType: string, summaryContent: string, @@ -136,6 +141,7 @@ export const GeneratePopoverBody: React.FC<{ context, question: insightQuestion, }), + query: dataSourceQuery, }) .then((response) => { setInsight(response); diff --git a/public/types.ts b/public/types.ts index ee4bab4a..f6c279ae 100644 --- a/public/types.ts +++ b/public/types.ts @@ -110,6 +110,7 @@ export type IncontextInsights = Map; export interface ContextObj { context: string; additionalInfo: Record; + dataSourceId?: string; } export interface IncontextInsight {