aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander_Kabui2024-05-23 14:47:27 +0300
committerAlexander_Kabui2024-08-29 11:49:18 +0300
commite30029041b3f533f5563f3d63f4cba6d1e31519d (patch)
tree2a136134e16fb6649041c95cd11e812409e9876c
parent7c727d76049de8b58de020357e172d30458ef47d (diff)
downloadgenenetwork2-e30029041b3f533f5563f3d63f4cba6d1e31519d.tar.gz
Update endpoints and add search history functionality.
-rw-r--r--gn2/wqflask/templates/gnqa_search_history.html29
-rw-r--r--gn2/wqflask/views.py11
2 files changed, 22 insertions, 18 deletions
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 @@
<section class="container-fluid gnqa-copy">
<header class="row">
-
<div class="panel panel default col-sm-6 col-sm-offset-3">
<div class="panel panel-default">
<div class="panel-heading">
<div>
- <h4 class="text-primary">You search History </h4>
+ <h4 class="text-secondary" style="font-family: 'Linux Libertine','Georgia','Times','Source Serif Pro',serif;font-size:2.3rem">Your AI search History </h4>
</div>
</div>
</div>
</div>
</header>
<div class="container row">
- <div class="panel panel-default col-sm-6 col-sm-offset-3 ">
- {% for (key,val) in prev_queries.items() %}
- <div class="panel-body">
- <div class="row">
- <input name="" type="checkbox" value="" class="col-sm-1">
+ <div class="panel panel-default col-sm-6 col-sm-offset-3 ">
+ <div>
+ <ul class="list-group list-group-flush">
+ {% for item in prev_queries %}
+ <li class="row list-group-item">
+ <input name="" type="checkbox" value="" class="col-sm-1" style="height: 20px;
+ width: 20px;">
<div class="col-sm-10">
<button
- hx-get="/gnqna/hist?search_term={{key}}"
+ hx-get="/gnqna/hist?query={{item['query']}}&search_term={{item['task_id']}}"
hx-target="#swap"
hx-swap="innerHTML"
hx-trigger= "click"
data-bs-toggle="tooltip"
data-bs-placement="left"
- title="/gnqna/hist?search_term={{key}}"
+ title="/gnqna/hist?query={{item['query']}}&search_term={{item['task_id']}}"
style="background:transparent;border:none;cursor:pointer"
>
- <b class="text-info">{{val.get('query')}} </b>
+ <p class="text-info">{{item.get('query')}} </p>
</button>
- </div>
- </div>
- </div>
- {% endfor %}
+ </div>
+ </li>
+ {% endfor %}
+ </ul>
</div>
</div>
</div>
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index 2a6eba44..215837af 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)