From 9fdf562360c23e8e739e1a3e08bcc80cefdad70d Mon Sep 17 00:00:00 2001 From: Somesh Joshi Date: Thu, 17 Oct 2024 18:38:47 +0530 Subject: [PATCH 1/2] "Updated error messages in chat history API to provide more user-friendly error descriptions" --- code/backend/api/chat_history.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/code/backend/api/chat_history.py b/code/backend/api/chat_history.py index e43616e95..7a14d8467 100644 --- a/code/backend/api/chat_history.py +++ b/code/backend/api/chat_history.py @@ -101,7 +101,8 @@ async def list_conversations(): except Exception as e: logger.exception("Exception in /list") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error While listing historical conversations"}), 500) + @bp_chat_history_response.route("/history/rename", methods=["POST"]) @@ -153,7 +154,7 @@ async def rename_conversation(): except Exception as e: logger.exception("Exception in /rename") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error renameing is fail"}), 500) @bp_chat_history_response.route("/history/read", methods=["POST"]) @@ -218,7 +219,7 @@ async def get_conversation(): ) except Exception as e: logger.exception("Exception in /read") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error while fatching history conversation"}), 500) @bp_chat_history_response.route("/history/delete", methods=["DELETE"]) @@ -267,7 +268,7 @@ async def delete_conversation(): ) except Exception as e: logger.exception("Exception in /delete") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error while deleting history conversation"}), 500) @bp_chat_history_response.route("/history/delete_all", methods=["DELETE"]) @@ -321,7 +322,7 @@ async def delete_all_conversations(): except Exception as e: logger.exception("Exception in /delete") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error while deleting all history conversation"}), 500) @bp_chat_history_response.route("/history/update", methods=["POST"]) @@ -413,7 +414,7 @@ async def update_conversation(): except Exception as e: logger.exception("Exception in /update") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error while update the history conversation"}), 500) @bp_chat_history_response.route("/history/frontend_settings", methods=["GET"]) @@ -429,7 +430,7 @@ def get_frontend_settings(): return jsonify({"CHAT_HISTORY_ENABLED": chat_history_enabled}), 200 except Exception as e: logger.exception("Exception in /frontend_settings") - return (jsonify({"error": str(e)}), 500) + return (jsonify({"error": "Error while getting frontend settings"}), 500) async def generate_title(conversation_messages): From 4feb9991fe56141bd123a483cf33cfc25fb2035f Mon Sep 17 00:00:00 2001 From: Somesh Joshi Date: Mon, 21 Oct 2024 12:06:49 +0530 Subject: [PATCH 2/2] Fix typos in error messages in chat history API --- code/backend/api/chat_history.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/backend/api/chat_history.py b/code/backend/api/chat_history.py index 7a14d8467..0ca98e6e9 100644 --- a/code/backend/api/chat_history.py +++ b/code/backend/api/chat_history.py @@ -154,7 +154,7 @@ async def rename_conversation(): except Exception as e: logger.exception("Exception in /rename") - return (jsonify({"error": "Error renameing is fail"}), 500) + return (jsonify({"error": "Error renaming is fail"}), 500) @bp_chat_history_response.route("/history/read", methods=["POST"]) @@ -219,7 +219,7 @@ async def get_conversation(): ) except Exception as e: logger.exception("Exception in /read") - return (jsonify({"error": "Error while fatching history conversation"}), 500) + return (jsonify({"error": "Error while fetching history conversation"}), 500) @bp_chat_history_response.route("/history/delete", methods=["DELETE"])