From 86f18b45cc1bcb2ef1e1b4c88681c0a0654085a9 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 3 Apr 2024 14:32:01 +0300 Subject: Add pubmed info and styling --- gn2/wqflask/templates/gnqa_answer.html | 51 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/templates/gnqa_answer.html b/gn2/wqflask/templates/gnqa_answer.html index 6759ef72..825b994c 100644 --- a/gn2/wqflask/templates/gnqa_answer.html +++ b/gn2/wqflask/templates/gnqa_answer.html @@ -32,15 +32,18 @@

{{ reference.comboTxt }}

-
+
{% if reference.pubmed %} -
- See PubMed Info -

{{ reference.pubmed[0].get('title') }}

-

Authors: {{ reference.pubmed[0].get('authors') }}

-

PMID: {{ reference.pubmed[0].get('pub_id') }}

-

Abstract: {{ reference.pubmed[0].get('abstract')|safe }}

-

See full Article on Pubmed

+
+ See PubMed Info +
+

{{ reference.pubmed[0].get('title') }}:

+

Authors:{{ reference.pubmed[0].get('authors') }}

+

PMID: {{ reference.pubmed[0].get('pub_id') }}

+

Abstract:

+

{{ reference.pubmed[0].get('abstract')|safe }}

+

See full Article on Pubmed

+
{% endif %}
@@ -54,26 +57,24 @@
-
-
- - +

{{reference.comboTxt}}

+
{% if reference.pubmed %} - - -
- - -
- +
+ See PubMed Info +
+

{{ reference.pubmed[0].get('title') }}:

+

Authors:{{ reference.pubmed[0].get('authors') }}

+

PMID: {{ reference.pubmed[0].get('pub_id') }}

+

Abstract:

+

{{ reference.pubmed[0].get('abstract')|safe }}

+

See full Article on Pubmed

+
+
{% endif %} - -

{{reference.comboTxt}}

- +
{% endif %} @@ -82,11 +83,9 @@ {% endfor %} - {% else %}

No references available.

{% endif %} -
-- cgit v1.2.3 From 9f37a05627c37ceab0c438082e4a1edd84b9eac4 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 3 Apr 2024 17:12:05 +0300 Subject: Update gnqa rating route. --- gn2/wqflask/views.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py index 47233099..fce009ba 100644 --- a/gn2/wqflask/views.py +++ b/gn2/wqflask/views.py @@ -307,20 +307,24 @@ def gnqna_hist(search_term): return render_template("gnqa_answer.html", **{"gn_server_url": GN3_LOCAL_URL, **response}) - -@app.route("/gnqna/rating/",methods=["POST"]) -def gnqna_rating(task_id): +@app.route("/gnqna/rating//", + methods=["POST"]) +@require_oauth2 +def gnqna_rating(task_id, weight): token = session_info()["user"]["token"].either( - lambda err: err, lambda tok: tok["access_token"]) + lambda err: err, lambda tok: tok["access_token"]) return monad_requests.post( urljoin(GN3_LOCAL_URL, f"/api/llm/rating/{task_id}"), - json= request.json, + json={**dict(request.form), "weight": weight}, headers={ "Authorization": f"Bearer {token}" } ).then( - lambda resp: resp).either(lambda x: (x.json(),x.status_code),lambda x:(x.json(),x.status_code)) + lambda resp: resp).either(lambda x: (x.json(), x.status_code), + lambda x: (x.json(), x.status_code)) + + @app.route("/gsearch_updating", methods=('POST',)) def gsearch_updating(): result = UpdateGSearch(request.args).__dict__ -- cgit v1.2.3 From f586774026565f10772b342521af8eb90cfb687a Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 3 Apr 2024 17:13:08 +0300 Subject: Update UI for gnqa rating to use htmx. --- gn2/wqflask/templates/gnqa_answer.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/templates/gnqa_answer.html b/gn2/wqflask/templates/gnqa_answer.html index 825b994c..bde39329 100644 --- a/gn2/wqflask/templates/gnqa_answer.html +++ b/gn2/wqflask/templates/gnqa_answer.html @@ -5,16 +5,19 @@ {{ query }}
{{ answer }}

-
- - +
+ + + +

References

{% if references %} -
    {% for reference in references %}
  • -- cgit v1.2.3 From 712a6a42d3c0d1e9b29a3c8352ca984a09cd79b1 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 4 Apr 2024 02:42:58 +0300 Subject: Add gnqa history search page. --- gn2/wqflask/templates/gnqa_search_history.html | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 gn2/wqflask/templates/gnqa_search_history.html (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/templates/gnqa_search_history.html b/gn2/wqflask/templates/gnqa_search_history.html new file mode 100644 index 00000000..ce6a01da --- /dev/null +++ b/gn2/wqflask/templates/gnqa_search_history.html @@ -0,0 +1,42 @@ +
    +
    + +
    +
    +
    +
    +

    You search History

    +
    +
    +
    +
    +
    +
    +
    + {% for record in prev_queries %} +
    +
    + +
    + {% for id,val in record.items() %} + + {% endfor %} +
    +
    +
    + {% endfor %} +
    +
    +
+ -- cgit v1.2.3 From b28ebc5a5fe34525801d29332a89bb4ed2e260d0 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 4 Apr 2024 02:44:09 +0300 Subject: Add get history fetch url on gnqa homepage. --- gn2/wqflask/templates/gnqa.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/templates/gnqa.html b/gn2/wqflask/templates/gnqa.html index 31a04aac..8bcb1b19 100644 --- a/gn2/wqflask/templates/gnqa.html +++ b/gn2/wqflask/templates/gnqa.html @@ -30,6 +30,12 @@ font-size: 14px; } + .search-hist-btn{ + background-color:transparent; + color:#3071a9; + border:none + } + .search-header sup { top: -2em; } @@ -117,7 +123,11 @@

AI Search - [Search History] + + +

@@ -142,7 +152,7 @@ value='' name="querygnqa" hx-post="/gnqna" - hx-target="#swap + hx-target="#swap" hx-swap="innerHTML" hx-indicator="#indicator" /> -- cgit v1.2.3 From cfd8f5b77448971470cd136d1920b7964450dd44 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 4 Apr 2024 02:45:29 +0300 Subject: Refactor gnqa history endpoint. * require gn-auth --- gn2/wqflask/views.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'gn2/wqflask') 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/", 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//", -- cgit v1.2.3 From 749ba361b2db03380e3bb84408d27feb7856805e Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 4 Apr 2024 02:56:19 +0300 Subject: Use bootstrap classes for ui. --- gn2/wqflask/templates/gnqa_search_history.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/templates/gnqa_search_history.html b/gn2/wqflask/templates/gnqa_search_history.html index ce6a01da..2c07b8c0 100644 --- a/gn2/wqflask/templates/gnqa_search_history.html +++ b/gn2/wqflask/templates/gnqa_search_history.html @@ -5,7 +5,7 @@
-

You search History

+

You search History

@@ -16,7 +16,7 @@ {% for record in prev_queries %}
- +
{% for id,val in record.items() %} {% endfor %}
-- cgit v1.2.3 From 83f4195997e17c89bcd5c8075af9b6cfdfdad843 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 4 Apr 2024 04:23:41 +0300 Subject: Delete redundant UI codebase. --- gn2/wqflask/templates/gnqa.html | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'gn2/wqflask') diff --git a/gn2/wqflask/templates/gnqa.html b/gn2/wqflask/templates/gnqa.html index 8bcb1b19..1268ef39 100644 --- a/gn2/wqflask/templates/gnqa.html +++ b/gn2/wqflask/templates/gnqa.html @@ -86,37 +86,6 @@ {% endblock %} {% block search %}{% endblock %} - - - {% block content %}
@@ -171,8 +140,6 @@
- - {% endblock %} -- cgit v1.2.3