Fixed edit and resend issue

This commit is contained in:
Niharika Goulikar
2024-11-17 10:29:29 +00:00
parent bed4939652
commit a44319d815
5 changed files with 157 additions and 17 deletions

View File

@@ -168,6 +168,48 @@ class UpdateConversationName(Resource):
return make_response(jsonify({"success": True}), 200)
@user_ns.route("/api/update_conversation_queries")
class UpdateConversationQueries(Resource):
@api.expect(
api.model(
"UpdateConversationQueriesModel",
{
"id": fields.String(required=True, description="Conversation ID"),
"limit": fields.Integer(
required=True, description="Number by which queries should be sliced."
),
},
)
)
@api.doc(
description="Updates the queries in a conversation",
)
def post(self):
data = request.get_json()
required_fields = ["id", "limit"]
missing_fields = check_required_fields(data, required_fields)
if missing_fields:
return missing_fields
try:
conversations_collection.update_one(
{"_id": ObjectId(data["id"])},[{
"$set": {
"queries": {
"$slice": ["$queries", data["limit"]]
}
}
}])
conversation = conversations_collection.find_one(
{"_id": ObjectId(data["id"])}
)
if not conversation:
return make_response(jsonify({"status": "not found"}), 404)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
return make_response(jsonify(conversation["queries"]), 200)
@user_ns.route("/api/feedback")
class SubmitFeedback(Resource):