mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 17:39:06 +08:00
add inferface for message thumbup (#2091)
### What problem does this PR solve? #2088 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
d48731ac8c
commit
eb20b60b13
@ -178,7 +178,7 @@ def completion():
|
|||||||
@manager.route('/delete_msg', methods=['POST'])
|
@manager.route('/delete_msg', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
@validate_request("conversation_id", "message_id")
|
@validate_request("conversation_id", "message_id")
|
||||||
def completion():
|
def delete_msg():
|
||||||
req = request.json
|
req = request.json
|
||||||
e, conv = ConversationService.get_by_id(req["conversation_id"])
|
e, conv = ConversationService.get_by_id(req["conversation_id"])
|
||||||
if not e:
|
if not e:
|
||||||
@ -196,3 +196,26 @@ def completion():
|
|||||||
|
|
||||||
ConversationService.update_by_id(conv["id"], conv)
|
ConversationService.update_by_id(conv["id"], conv)
|
||||||
return get_json_result(data=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)
|
Loading…
x
Reference in New Issue
Block a user