diff options
author | Alexander_Kabui | 2024-04-04 02:45:29 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-04-05 15:13:24 +0300 |
commit | cfd8f5b77448971470cd136d1920b7964450dd44 (patch) | |
tree | a3149fe3393cb38226674515eadf003d64d9b1f8 /gn2 | |
parent | b28ebc5a5fe34525801d29332a89bb4ed2e260d0 (diff) | |
download | genenetwork2-cfd8f5b77448971470cd136d1920b7964450dd44.tar.gz |
Refactor gnqa history endpoint.
* require gn-auth
Diffstat (limited to 'gn2')
-rw-r--r-- | gn2/wqflask/views.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index fce009ba..0dee5b27 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -299,12 +299,34 @@ def gnqna(): return render_template("gnqa.html", prev_queries=prev_queries) +@app.route("/gnqna/hist/", methods=["GET"]) +@require_oauth2 +def get_hist_titles(): + token = session_info()["user"]["token"].either( + lambda err: err, lambda tok: tok["access_token"]) + response = monad_requests.get(urljoin(GN3_LOCAL_URL, + "/api/llm/hist/titles"), + headers={ + "Authorization": f"Bearer {token}" + } + ).then(lambda resp: resp).either( + lambda x: x.json(), lambda x: x.json()) + return render_template("gnqa_search_history.html", **response) + + @app.route("/gnqna/hist/search/<search_term>", methods=["GET"]) @require_oauth2 -def gnqna_hist(search_term): - response = monad_requests.get(urljoin(GN3_LOCAL_URL, f"/api/llm/historys/{search_term}")).then(lambda resp: resp).either( +def fetch_hist_records(search_term): + token = session_info()["user"]["token"].either( + lambda err: err, lambda tok: tok["access_token"]) + response = monad_requests.get(urljoin(GN3_LOCAL_URL, + f"/api/llm/history/{search_term}"), + headers={ + "Authorization": f"Bearer {token}" + } + ).then(lambda resp: resp).either( lambda x: x.json(), lambda x: x.json()) - return render_template("gnqa_answer.html", **{"gn_server_url": GN3_LOCAL_URL, **response}) + return render_template("gnqa_answer.html", **response) @app.route("/gnqna/rating/<task_id>/<int(signed=True):weight>", |