Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass dataSourceId for alert summary/insight #321

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Collaborator

@Hailong-am Hailong-am Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add test case to verify datasource has been set correctly?

})
.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
Loading