-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Motivation and Context <!-- Thank you for your contribution to the copilot-chat repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Added RLFH UI to demonstrate users can easily add this capability to their chatbot if they wanted. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> > This feature is for demonstration purposes only. We don't actually hook up to the server to store the human feedback or send it to the model. Details: - RLFH actions will only show on the most recent chat message in which the author is `bot`. - If user takes action, icon will be rendered to reflect action. - Data is only stored in frontend state. If app refreshes, all RLFH across all chats will be reset. Actions on chat message: ![image](https:/microsoft/chat-copilot/assets/125500434/1b730018-ccf3-4356-a173-9c7d50c0cec8) Once user takes actions: ![image](https:/microsoft/chat-copilot/assets/125500434/0d691a1a-970a-4847-98cb-c6f05e23941f) Future work - Add ability to turn of RLHF in settings dialog + add help link to docs there ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https:/microsoft/copilot-chat/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https:/microsoft/copilot-chat/blob/main/CONTRIBUTING.md#development-scripts) raises no violations ~~- [ ] All unit tests pass, and I have added new tests where possible~~ - [x] I didn't break anyone 😄
- Loading branch information
1 parent
5f84e0f
commit 46f48cc
Showing
7 changed files
with
156 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
webapp/src/components/chat/chat-history/UserFeedbackActions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Button, Text, Tooltip, makeStyles } from '@fluentui/react-components'; | ||
import { useCallback } from 'react'; | ||
import { UserFeedback } from '../../../libs/models/ChatMessage'; | ||
import { useAppDispatch, useAppSelector } from '../../../redux/app/hooks'; | ||
import { RootState } from '../../../redux/app/store'; | ||
import { setUserFeedback } from '../../../redux/features/conversations/conversationsSlice'; | ||
import { ThumbDislike16, ThumbLike16 } from '../../shared/BundledIcons'; | ||
|
||
const useClasses = makeStyles({ | ||
root: { | ||
display: 'flex', | ||
'place-content': 'flex-end', | ||
alignItems: 'center', | ||
}, | ||
}); | ||
|
||
interface IUserFeedbackProps { | ||
messageIndex: number; | ||
} | ||
|
||
export const UserFeedbackActions: React.FC<IUserFeedbackProps> = ({ messageIndex }) => { | ||
const classes = useClasses(); | ||
|
||
const dispatch = useAppDispatch(); | ||
const { selectedId } = useAppSelector((state: RootState) => state.conversations); | ||
|
||
const onUserFeedbackProvided = useCallback( | ||
(positive: boolean) => { | ||
dispatch( | ||
setUserFeedback({ | ||
userFeedback: positive ? UserFeedback.Positive : UserFeedback.Negative, | ||
messageIndex, | ||
chatId: selectedId, | ||
}), | ||
); | ||
}, | ||
[dispatch, messageIndex, selectedId], | ||
); | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Text color="gray" size={200}> | ||
AI-generated content may be incorrect | ||
</Text> | ||
<Tooltip content={'Like bot message'} relationship="label"> | ||
<Button | ||
icon={<ThumbLike16 />} | ||
appearance="transparent" | ||
aria-label="Edit" | ||
onClick={() => onUserFeedbackProvided(true)} | ||
/> | ||
</Tooltip> | ||
<Tooltip content={'Dislike bot message'} relationship="label"> | ||
<Button | ||
icon={<ThumbDislike16 />} | ||
appearance="transparent" | ||
aria-label="Edit" | ||
onClick={() => onUserFeedbackProvided(false)} | ||
/> | ||
</Tooltip> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { | ||
Add20Filled, | ||
Add20Regular, | ||
AppsAddIn24Filled, | ||
AppsAddIn24Regular, | ||
ArrowDownload16Filled, | ||
ArrowDownload16Regular, | ||
BotAdd20Filled, | ||
BotAdd20Regular, | ||
Checkmark20Filled, | ||
Checkmark20Regular, | ||
Delete16Filled, | ||
Delete16Regular, | ||
Dismiss16Filled, | ||
Dismiss16Regular, | ||
Dismiss20Filled, | ||
Dismiss20Regular, | ||
EditFilled, | ||
EditRegular, | ||
Filter20Filled, | ||
Filter20Regular, | ||
Info16Filled, | ||
Info16Regular, | ||
Share20Filled, | ||
Share20Regular, | ||
ThumbDislike16Filled, | ||
ThumbDislike16Regular, | ||
ThumbLike16Filled, | ||
ThumbLike16Regular, | ||
bundleIcon, | ||
} from '@fluentui/react-icons'; | ||
|
||
export const Add20 = bundleIcon(Add20Filled, Add20Regular); | ||
export const AppsAddIn24 = bundleIcon(AppsAddIn24Filled, AppsAddIn24Regular); | ||
export const BotAdd20 = bundleIcon(BotAdd20Filled, BotAdd20Regular); | ||
export const Checkmark20 = bundleIcon(Checkmark20Filled, Checkmark20Regular); | ||
export const Delete16 = bundleIcon(Delete16Filled, Delete16Regular); | ||
export const Dismiss16 = bundleIcon(Dismiss16Filled, Dismiss16Regular); | ||
export const Dismiss20 = bundleIcon(Dismiss20Filled, Dismiss20Regular); | ||
export const Filter20 = bundleIcon(Filter20Filled, Filter20Regular); | ||
export const Edit = bundleIcon(EditFilled, EditRegular); | ||
export const ArrowDownload16 = bundleIcon(ArrowDownload16Filled, ArrowDownload16Regular); | ||
export const Share20 = bundleIcon(Share20Filled, Share20Regular); | ||
export const Info16 = bundleIcon(Info16Filled, Info16Regular); | ||
export const ThumbLike16 = bundleIcon(ThumbLike16Filled, ThumbLike16Regular); | ||
export const ThumbDislike16 = bundleIcon(ThumbDislike16Filled, ThumbDislike16Regular); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters