aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorAlexander_Kabui2023-12-29 17:05:17 +0300
committerAlexander_Kabui2023-12-29 17:05:17 +0300
commit3630c81c0745930bec498018eb31fc2002529c58 (patch)
tree47d4ce1f486a929ee2b3272dcec6061dd0a96bda /gn3
parent20ec28980a0a003cac408f6d8efcf4ef1c9c1ec8 (diff)
downloadgenenetwork3-3630c81c0745930bec498018eb31fc2002529c58.tar.gz
handle exception for request error
Diffstat (limited to 'gn3')
-rw-r--r--gn3/api/llm.py17
1 files changed, 11 insertions, 6 deletions
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