From 3630c81c0745930bec498018eb31fc2002529c58 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 29 Dec 2023 17:05:17 +0300 Subject: handle exception for request error --- gn3/api/llm.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'gn3') diff --git a/gn3/api/llm.py b/gn3/api/llm.py index 72d78b6..83b5e85 100644 --- a/gn3/api/llm.py +++ b/gn3/api/llm.py @@ -14,9 +14,14 @@ def gnqa(): query = request.json.get("querygnqa", "") if not query: return jsonify({"error": "querygnqa is missing in the request"}), 400 - answer, refs = getGNQA(query) - return jsonify({ - "query": query, - "answer": answer, - "references": refs - }) + + try: + answer, refs = getGNQA(query) + return jsonify({ + "query": query, + "answer": answer, + "references": refs + }) + + except Exception as error: + return jsonify({"query": query, "error": "Internal server error"}), 500 -- cgit v1.2.3