add thumb up api (#2092)

### What problem does this PR solve?

#2088

### Type of change
 
- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Kevin Hu 2024-08-26 13:27:41 +08:00 committed by GitHub
parent eb20b60b13
commit e953f01951
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)