Fixed the feedback issue

This commit is contained in:
Niharika Goulikar
2024-11-26 12:16:21 +00:00
parent 8d8423b6e0
commit e9a2b8f03a
4 changed files with 36 additions and 14 deletions

View File

@@ -111,7 +111,7 @@ export default function Conversation() {
const handleFeedback = (query: Query, feedback: FEEDBACK, index: number) => {
const prevFeedback = query.feedback;
dispatch(updateQuery({ index, query: { feedback } }));
handleSendFeedback(query.prompt, query.response!, feedback).catch(() =>
handleSendFeedback(query.prompt, query.response!, feedback,conversationId as string,index).catch(() =>
dispatch(updateQuery({ index, query: { feedback: prevFeedback } })),
);
};

View File

@@ -429,6 +429,11 @@ const ConversationBubble = forwardRef<
feedback === 'LIKE' || type !== 'ERROR'
? 'group-hover:lg:visible'
: ''
}
${
feedback === 'DISLIKE' && type !== 'ERROR'
? ' hidden'
: ''
}`}
>
<div>
@@ -445,11 +450,14 @@ const ConversationBubble = forwardRef<
isLikeClicked || feedback === 'LIKE'
? 'fill-white-3000 stroke-purple-30 dark:fill-transparent'
: 'fill-none stroke-gray-4000'
}`}
} `}
onClick={() => {
if(feedback===undefined){
console.log("liked")
handleFeedback?.('LIKE');
setIsLikeClicked(true);
setIsDislikeClicked(false);
}
}}
onMouseEnter={() => setIsLikeHovered(true)}
onMouseLeave={() => setIsLikeHovered(false)}
@@ -462,9 +470,13 @@ const ConversationBubble = forwardRef<
!isDislikeClicked ? 'lg:invisible' : ''
} ${
feedback === 'DISLIKE' || type !== 'ERROR'
? 'group-hover:lg:visible'
? ' group-hover:lg:visible'
: ''
}`}
} ${
feedback === 'LIKE' && type !== 'ERROR'
? ' hidden'
: ''
} `}
>
<div>
<div
@@ -481,9 +493,11 @@ const ConversationBubble = forwardRef<
: 'fill-none stroke-gray-4000'
}`}
onClick={() => {
if(feedback===undefined){
handleFeedback?.('DISLIKE');
setIsDislikeClicked(true);
setIsLikeClicked(false);
}
}}
onMouseEnter={() => setIsDislikeHovered(true)}
onMouseLeave={() => setIsDislikeHovered(false)}

View File

@@ -202,12 +202,16 @@ export function handleSendFeedback(
prompt: string,
response: string,
feedback: FEEDBACK,
conversation_id:string,
prompt_index:number
) {
return conversationService
.feedback({
question: prompt,
answer: response,
feedback: feedback,
conversation_id:conversation_id,
question_index:prompt_index
})
.then((response) => {
if (response.ok) {