From 13a554a9744bc70da9606c0348ec675276147a29 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 23 May 2024 14:47:27 +0300 Subject: Update endpoints and add search history functionality. --- gn2/wqflask/templates/gnqa_search_history.html | 29 +++++++++++++------------- gn2/wqflask/views.py | 11 ++++++---- 2 files changed, 22 insertions(+), 18 deletions(-) (limited to 'gn2') diff --git a/gn2/wqflask/templates/gnqa_search_history.html b/gn2/wqflask/templates/gnqa_search_history.html index af38392a..890a3995 100644 --- a/gn2/wqflask/templates/gnqa_search_history.html +++ b/gn2/wqflask/templates/gnqa_search_history.html @@ -1,39 +1,40 @@
-
-

You search History

+

Your AI search History

-
- {% for (key,val) in prev_queries.items() %} -
-
- +
+
+
    + {% for item in prev_queries %} +
  • +
    -
    -
-
- {% endfor %} +
+ + {% endfor %} +
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 5d0075c5..5bb443c1 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -270,7 +270,7 @@ def gnqna(): lambda err: err, lambda tok: tok["access_token"]) return monad_requests.post( urljoin(GN3_LOCAL_URL, - "/api/llm/gnqna"), + "/api/llm/search"), json=dict(request.form), headers={ "Authorization": f"Bearer {token}" @@ -287,6 +287,10 @@ def gnqna(): @app.route("/gnqna/hist", methods=["GET"]) @require_oauth2 def get_gnqa_history(): + def _error_(resp): + return render_template("gnqa_errors.html", + **{"status_code": resp.status_code, + **resp.json()}) token = session_info()["user"]["token"].either( lambda err: err, lambda tok: tok["access_token"]) response = monad_requests.get(urljoin(GN3_LOCAL_URL, @@ -296,10 +300,9 @@ def get_gnqa_history(): "Authorization": f"Bearer {token}" } ).then(lambda resp: resp).either( - lambda x: x.json(), lambda x: x.json()) + _error_, lambda x: x.json()) if request.args.get("search_term"): - return render_template("gnqa_answer.html", - **{"gn_server_url": "GN3_LOCAL_URL", **response}) + return render_template("gnqa_answer.html", **response) return render_template("gnqa_search_history.html", prev_queries=response) -- cgit v1.2.3