From ade1b4cb03de8a1c670a3e876b8a18692dfc7694 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 29 Aug 2024 10:26:05 +0300 Subject: Check for empty values when fetching search history. --- gn3/api/llm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gn3') diff --git a/gn3/api/llm.py b/gn3/api/llm.py index a94badd..5901ef5 100644 --- a/gn3/api/llm.py +++ b/gn3/api/llm.py @@ -107,7 +107,10 @@ def fetch_prev_history(): Where task_id=? and user_id=?""", (request.args.get("search_term"), str(token.user.user_id),)) - return dict(cursor.fetchone())["results"] + record = cursor.fetchone() + if record: + return dict(record).get("results") + return {} cursor.execute( """SELECT task_id,query from history WHERE user_id=?""", (str(token.user.user_id),)) -- cgit v1.2.3