From e953f0195121de67a1ec879ca9d2bf3d04f9777e Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Mon, 26 Aug 2024 13:27:41 +0800 Subject: [PATCH] add thumb up api (#2092) ### What problem does this PR solve? #2088 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- api/apps/conversation_app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/apps/conversation_app.py b/api/apps/conversation_app.py index 5fd7c2692..3678c18e6 100644 --- a/api/apps/conversation_app.py +++ b/api/apps/conversation_app.py @@ -211,10 +211,12 @@ def thumbup(): conv = conv.to_dict() for i, msg in enumerate(conv["message"]): if req["message_id"] == msg.get("id", "") and msg.get("role", "") == "assistant": - if up_down: msg["thumbup"] = True + if up_down: + msg["thumbup"] = True + if "feedback" in msg: del msg["feedback"] else: msg["thumbup"] = False - msg["feedback"] = feedback + if feedback: msg["feedback"] = feedback break ConversationService.update_by_id(conv["id"], conv)