Skip to content

Commit

Permalink
add inferface for message thumbup (infiniflow#2091)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

infiniflow#2088

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
KevinHuSh authored Aug 26, 2024
1 parent 0272185 commit 704ff5b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion api/apps/conversation_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def stream():
@manager.route('/delete_msg', methods=['POST'])
@login_required
@validate_request("conversation_id", "message_id")
def completion():
def delete_msg():
req = request.json
e, conv = ConversationService.get_by_id(req["conversation_id"])
if not e:
Expand All @@ -196,3 +196,26 @@ def completion():

ConversationService.update_by_id(conv["id"], conv)
return get_json_result(data=conv)


@manager.route('/thumbup', methods=['POST'])
@login_required
@validate_request("conversation_id", "message_id")
def thumbup():
req = request.json
e, conv = ConversationService.get_by_id(req["conversation_id"])
if not e:
return get_data_error_result(retmsg="Conversation not found!")
up_down = req.get("set")
feedback = req.get("feedback", "")
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
else:
msg["thumbup"] = False
msg["feedback"] = feedback
break

ConversationService.update_by_id(conv["id"], conv)
return get_json_result(data=conv)

0 comments on commit 704ff5b

Please sign in to comment.