Skip to content

Commit

Permalink
Resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Niharika0104 committed Dec 18, 2024
1 parent 9d4aee5 commit 47ecf98
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion application/api/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1791,4 +1791,4 @@ def post(self):
200,
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
return make_response(jsonify({"success": False, "error": str(err)}), 400)
19 changes: 16 additions & 3 deletions frontend/src/conversation/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { useDarkTheme, useMediaQuery } from '../hooks';
import { ShareConversationModal } from '../modals/ShareConversationModal';
import { selectConversationId } from '../preferences/preferenceSlice';
import { AppDispatch } from '../store';
import conversationService from '../api/services/conversationService';
import ConversationBubble from './ConversationBubble';
import { handleSendFeedback } from './conversationHandlers';
import { FEEDBACK, Query } from './conversationModels';
Expand Down Expand Up @@ -111,8 +110,22 @@ 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,conversationId as string,index).catch(() =>
dispatch(updateQuery({ index, query: { feedback: prevFeedback } })),
handleSendFeedback(
query.prompt,
query.response!,
feedback,
conversationId as string,
index,
).catch(() =>
handleSendFeedback(
query.prompt,
query.response!,
feedback,
conversationId as string,
index,
).catch(() =>
dispatch(updateQuery({ index, query: { feedback: prevFeedback } })),
),
);
};

Expand Down
12 changes: 10 additions & 2 deletions frontend/src/conversation/ConversationBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,14 @@ const ConversationBubble = forwardRef<
: 'fill-none stroke-gray-4000'
}`}
onClick={() => {
if (feedback === undefined) {
if (feedback === undefined || feedback === null) {
handleFeedback?.('LIKE');
setIsLikeClicked(true);
setIsDislikeClicked(false);
} else if (feedback === 'LIKE') {
handleFeedback?.(null);
setIsLikeClicked(false);
setIsDislikeClicked(false);
}
}}
onMouseEnter={() => setIsLikeHovered(true)}
Expand Down Expand Up @@ -484,10 +488,14 @@ const ConversationBubble = forwardRef<
: 'fill-none stroke-gray-4000'
}`}
onClick={() => {
if (feedback === undefined) {
if (feedback === undefined || feedback === null) {
handleFeedback?.('DISLIKE');
setIsDislikeClicked(true);
setIsLikeClicked(false);
} else if (feedback === 'DISLIKE') {
handleFeedback?.(null);
setIsLikeClicked(false);
setIsDislikeClicked(false);
}
}}
onMouseEnter={() => setIsDislikeHovered(true)}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/conversation/conversationHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ export function handleSendFeedback(
prompt: string,
response: string,
feedback: FEEDBACK,
conversation_id:string,
prompt_index:number
conversation_id: string,
prompt_index: number,
) {
return conversationService
.feedback({
question: prompt,
answer: response,
feedback: feedback,
conversation_id:conversation_id,
question_index:prompt_index
conversation_id: conversation_id,
question_index: prompt_index,
})
.then((response) => {
if (response.ok) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/conversation/conversationModels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type MESSAGE_TYPE = 'QUESTION' | 'ANSWER' | 'ERROR';
export type Status = 'idle' | 'loading' | 'failed';
export type FEEDBACK = 'LIKE' | 'DISLIKE';
export type FEEDBACK = 'LIKE' | 'DISLIKE' | null;

export interface Message {
text: string;
Expand Down

0 comments on commit 47ecf98

Please sign in to comment.