Skip to content

Commit

Permalink
Pass dataSourceId for alert summary/insight (#321)
Browse files Browse the repository at this point in the history
* Pass dataSourceId for alert summary/insight

Signed-off-by: Heng Qian <[email protected]>

* Add CHANGELOG.md

Signed-off-by: Heng Qian <[email protected]>

---------

Signed-off-by: Heng Qian <[email protected]>
  • Loading branch information
qianheng-aws committed Sep 20, 2024
1 parent db5155b commit 32a3255
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
- 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))
10 changes: 8 additions & 2 deletions public/components/incontext_insight/generate_popover_body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -89,6 +91,7 @@ export const GeneratePopoverBody: React.FC<{
question: summarizationQuestion,
context: contextContent,
}),
query: dataSourceQuery,
})
.then((response) => {
const summaryContent = response.summary;
Expand All @@ -97,6 +100,7 @@ export const GeneratePopoverBody: React.FC<{
setInsightAvailable(insightAgentIdExists);
if (insightAgentIdExists) {
onGenerateInsightBasedOnSummary(
dataSourceQuery,
summaryType,
insightType,
summaryContent,
Expand All @@ -120,6 +124,7 @@ export const GeneratePopoverBody: React.FC<{
};

const onGenerateInsightBasedOnSummary = (
dataSourceQuery: {},
summaryType: string,
insightType: string,
summaryContent: string,
Expand All @@ -136,6 +141,7 @@ export const GeneratePopoverBody: React.FC<{
context,
question: insightQuestion,
}),
query: dataSourceQuery,
})
.then((response) => {
setInsight(response);
Expand Down
1 change: 1 addition & 0 deletions public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type IncontextInsights = Map<string, IncontextInsight>;
export interface ContextObj {
context: string;
additionalInfo: Record<string, string>;
dataSourceId?: string;
}

export interface IncontextInsight {
Expand Down

0 comments on commit 32a3255

Please sign in to comment.