Skip to content

Commit 7b9ba48

Browse files
authored
Use conversationId from props for feedback. (#3336)
Change category to categories
1 parent a7da983 commit 7b9ba48

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

libs/chatbot/lib/components/ChatBot/MessageEntry.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,29 @@ export type MessageEntryProps = {
2121
message: MessageType<LightSpeedCoreAdditionalProperties>;
2222
avatar: string;
2323
onApiCall: typeof fetch;
24+
conversationId: string | undefined;
2425
};
2526

26-
const MessageEntry = ({ message, avatar, openClusterDetails, onApiCall }: MessageEntryProps) => {
27+
const MessageEntry = ({
28+
message,
29+
avatar,
30+
openClusterDetails,
31+
onApiCall,
32+
conversationId,
33+
}: MessageEntryProps) => {
2734
const [openFeedback, setOpenFeedback] = React.useState(false);
35+
2836
const onFeedbackSubmit = React.useCallback(
2937
async (req: FeedbackRequest): Promise<void> => {
3038
const resp = await onApiCall('/v1/feedback', {
3139
method: 'POST',
3240
body: JSON.stringify({
33-
conversation_id: message.additionalAttributes?.conversationId,
34-
user_question: 'TODO',
41+
conversation_id: conversationId,
42+
user_question: '',
3543
user_feedback: req.userFeedback,
3644
llm_response: message.answer,
3745
sentiment: req.sentiment,
38-
category: req.category,
46+
categories: req.category ? [req.category] : undefined,
3947
}),
4048
headers: {
4149
'Content-Type': 'application/json',
@@ -45,7 +53,7 @@ const MessageEntry = ({ message, avatar, openClusterDetails, onApiCall }: Messag
4553
throw new Error(`${resp.status} ${resp.statusText}`);
4654
}
4755
},
48-
[onApiCall, message],
56+
[onApiCall, message, conversationId],
4957
);
5058

5159
const messageDate = `${message.date?.toLocaleDateString()} ${message.date?.toLocaleTimeString()}`;

0 commit comments

Comments
 (0)