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

Refactor for message action bar and add metrics for alerting summary #304

Merged
merged 48 commits into from
Sep 20, 2024

Conversation

000FLMS
Copy link
Contributor

@000FLMS 000FLMS commented Sep 12, 2024

Description

Refactor popover to add message action bar and add metrics to thumb-up and thumb-down

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test.
  • New functionality has user manual doc added.
  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Screenshots

Action buttons in alerting summary and insight

image image

Same component is used in chat bubbles

image

000FLMS and others added 30 commits August 13, 2024 09:58
Signed-off-by: Sihan He <[email protected]>
Signed-off-by: Sihan He <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Signed-off-by: Sihan He <[email protected]>
…ithRAG

# Conflicts:
#	CHANGELOG.md
#	common/constants/llm.ts
#	server/plugin.ts
Signed-off-by: Heng Qian <[email protected]>
@Hailong-am
Copy link
Collaborator

can you put a screenshot of this change? That would be much helpful to understand the change.

@000FLMS
Copy link
Contributor Author

000FLMS commented Sep 13, 2024

can you put a screenshot of this change? That would be much helpful to understand the change.

Sure, I've added some screenshots, feel free to check them

CHANGELOG.md Outdated Show resolved Hide resolved
opensearch_dashboards.json Outdated Show resolved Hide resolved
public/plugin.tsx Outdated Show resolved Hide resolved
);

const feedbackTip =
'Thank you for the feedback. Try again by adjusting your prompt so that I have the opportunity to better assist you.';
Copy link
Collaborator

Choose a reason for hiding this comment

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

the tips may confuse user as they can't specify prompt. Also please add i18n support

Copy link
Contributor Author

@000FLMS 000FLMS Sep 13, 2024

Choose a reason for hiding this comment

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

It just follows the UI design
So I do not know if we could change it.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that tip is probably for text2viz summary, which is not delivered by decision.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@000FLMS there has a updated one, please update here accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have changed the tip

public/components/incontext_insight/index.tsx Outdated Show resolved Hide resolved
@@ -98,6 +114,7 @@ export const GeneratePopoverBody: React.FC<{
`Please provide your insight on this ${summaryType}.`
);
}
reportGeneratedMetric('generated');
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should we have seprate metric for alert summary and insight?

Copy link
Contributor

@qianheng-aws qianheng-aws Sep 19, 2024

Choose a reason for hiding this comment

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

Should we report this metric if error happened? And what if summary succeed while insight fails?

If we need to report metrics no matter it succeed or not, we should move this logic to finally block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should only report when the summary is generated successfully.


type ButtonKey = 'copy' | 'regenerate' | 'thumbUp' | 'thumbDown' | 'trace';

export const MessageActions: React.FC<MessageActionsProps> = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

This component seems very general. Not only for chat but also insight, or maybe other cases. So I think it should be moved out of chat to a more proper directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about put it into a new "action_button" under the "component" directory? Any suggestion?

<MessageActions
contentToCopy={summary}
showFeedback
showTraceIcon={insightAvailable}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems weird to pass insight related status to Trace Icon and its related action function.

How about add a new parameter for the purpose of extending the MessageActions with customize buttons configuration? For this case, insight button should be passed in as a extending actions. You can think about which actions should be internal ones, and which should be extending ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems like that the only difference between insight and trace is just the click function, so I think adding a new button is a little redundent.

Copy link
Contributor

@qianheng-aws qianheng-aws Sep 20, 2024

Choose a reason for hiding this comment

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

Not exactly. insight button needs to show info "Insight With RAG" when moving your cursor over it. And what if you wants to have both trace button and insight button, or need other customized buttons like insight? Overall, they should be 2 different buttons.

It could be an enhancement since this PR has been merged.

opensearch_dashboards.json Outdated Show resolved Hide resolved
const [summary, setSummary] = useState('');
const [insight, setInsight] = useState('');
const [insightAvailable, setInsightAvailable] = useState(false);
const [showInsight, setShowInsight] = useState(false);
const metricAppName = 'alertSumm';
Copy link
Contributor

Choose a reason for hiding this comment

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

Does metric name have length restriction? If this is the case, you might need to add some protection check in util function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I do not really know any specific restriction

Copy link
Collaborator

Choose a reason for hiding this comment

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

should we use full name alertSummary?

public/utils/report_metric.ts Outdated Show resolved Hide resolved
@@ -98,6 +103,7 @@ export const GeneratePopoverBody: React.FC<{
`Please provide your insight on this ${summaryType}.`
);
}
reportMetric(usageCollection, metricAppName, 'generated');
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.

As we record generated metric, i think the metric type could be METRIC_TYPE.COUNT.

if we want to record click metric, it should not care the result of agent execution.

Copy link
Contributor Author

@000FLMS 000FLMS Sep 20, 2024

Choose a reason for hiding this comment

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

ok, I'll change it to METRIC_TYPE.COUNT.

Comment on lines 300 to 309
const usageCollection = setupDeps.usageCollection || null;
return (
<IncontextInsightComponent
{...props}
httpSetup={httpSetup}
usageCollection={usageCollection}
/>
);
},
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const usageCollection = setupDeps.usageCollection || null;
return (
<IncontextInsightComponent
{...props}
httpSetup={httpSetup}
usageCollection={usageCollection}
/>
);
},
};
return (
<IncontextInsightComponent
{...props}
httpSetup={httpSetup}
usageCollection={setupDeps.usageCollection}
/>
);
},
};

@Hailong-am Hailong-am added the backport 2.x Trigger the backport flow to 2.x label Sep 20, 2024
@Hailong-am Hailong-am merged commit db5155b into opensearch-project:main Sep 20, 2024
13 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 20, 2024
…304)

* Add message action module

Signed-off-by: Sihan He <[email protected]>

* Finish basic function of feedback buttons

Signed-off-by: Sihan He <[email protected]>

* Add test cases and fix bugs

Signed-off-by: Sihan He <[email protected]>

* Refactor the code to deal with core loss and fix the regenerate bug

Signed-off-by: Sihan He <[email protected]>

* Update CHANGELOG.md

Signed-off-by: Sihan He <[email protected]>

* Update for smaller buttons

Signed-off-by: Sihan He <[email protected]>

* Update for ui-metric

Signed-off-by: Sihan He <[email protected]>

* Support insight with RAG

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

* Add change in CHANGELOG.md

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

* Put footer in the same panel with content to match UX design

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

* Refine alert prompt

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

* set CSS scrollbar-width to thin

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

* Hide insight agent id from front-end

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

* Change summary agent config id

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

* Address comments

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

* Incorporate message action buttons into alerting summary

Signed-off-by: Sihan He <[email protected]>

* Add hover tips and rearrange buttons

Signed-off-by: Sihan He <[email protected]>

* Fix UT

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

* Add ui-metric for alerting summary

Signed-off-by: Sihan He <[email protected]>

* fix testing bugs

Signed-off-by: Sihan He <[email protected]>

* Change agent execute API

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

* Remove prompt from node JS server

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

* Replace CSS with component property

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

* Save the status when switch between summary and insight

Signed-off-by: Sihan He <[email protected]>

* Add tests for metrics

Signed-off-by: Sihan He <[email protected]>

* Use usageCollectionPluginMock in tests

Signed-off-by: Sihan He <[email protected]>

* Refactor reportMetric as util funciton

Signed-off-by: Sihan He <[email protected]>

* Remove telementry plugin

Signed-off-by: Sihan He <[email protected]>

* Fix metric type

Signed-off-by: Sihan He <[email protected]>

---------

Signed-off-by: Sihan He <[email protected]>
Signed-off-by: 000FLMS <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Co-authored-by: Heng Qian <[email protected]>
(cherry picked from commit db5155b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
Hailong-am added a commit that referenced this pull request Sep 20, 2024
…304) (#320)

* Add message action module

Signed-off-by: Sihan He <[email protected]>

* Finish basic function of feedback buttons

Signed-off-by: Sihan He <[email protected]>

* Add test cases and fix bugs

Signed-off-by: Sihan He <[email protected]>

* Refactor the code to deal with core loss and fix the regenerate bug

Signed-off-by: Sihan He <[email protected]>

* Update CHANGELOG.md

Signed-off-by: Sihan He <[email protected]>

* Update for smaller buttons

Signed-off-by: Sihan He <[email protected]>

* Update for ui-metric

Signed-off-by: Sihan He <[email protected]>

* Support insight with RAG

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

* Add change in CHANGELOG.md

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

* Put footer in the same panel with content to match UX design

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

* Refine alert prompt

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

* set CSS scrollbar-width to thin

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

* Hide insight agent id from front-end

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

* Change summary agent config id

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

* Address comments

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

* Incorporate message action buttons into alerting summary

Signed-off-by: Sihan He <[email protected]>

* Add hover tips and rearrange buttons

Signed-off-by: Sihan He <[email protected]>

* Fix UT

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

* Add ui-metric for alerting summary

Signed-off-by: Sihan He <[email protected]>

* fix testing bugs

Signed-off-by: Sihan He <[email protected]>

* Change agent execute API

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

* Remove prompt from node JS server

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

* Replace CSS with component property

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

* Save the status when switch between summary and insight

Signed-off-by: Sihan He <[email protected]>

* Add tests for metrics

Signed-off-by: Sihan He <[email protected]>

* Use usageCollectionPluginMock in tests

Signed-off-by: Sihan He <[email protected]>

* Refactor reportMetric as util funciton

Signed-off-by: Sihan He <[email protected]>

* Remove telementry plugin

Signed-off-by: Sihan He <[email protected]>

* Fix metric type

Signed-off-by: Sihan He <[email protected]>

---------

Signed-off-by: Sihan He <[email protected]>
Signed-off-by: 000FLMS <[email protected]>
Signed-off-by: Heng Qian <[email protected]>
Co-authored-by: Heng Qian <[email protected]>
(cherry picked from commit db5155b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Hailong Cui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Trigger the backport flow to 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants