From 16ba1826095332b475e6ab4bbd4481204fae4401 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 20 Dec 2023 23:02:54 +0300 Subject: add gnqna search form for home page --- wqflask/wqflask/templates/base.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 8c29995d..e8690184 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -50,6 +50,7 @@ } + .btn-stc { padding:9px 8px; @@ -197,6 +198,13 @@
+
@@ -214,6 +222,10 @@ + + GNQNA Search + + @@ -224,6 +236,7 @@
+
{% block content %} {% endblock %} -- cgit 1.4.1 From cbdbb90de86cf20d0265fd37e24e473af562c7c1 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 20 Dec 2023 23:03:25 +0300 Subject: add template handler for gngna --- wqflask/wqflask/views.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 34574c10..ee4d6a59 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -262,6 +262,22 @@ def gsearchtable(): return flask.jsonify(current_page) + +@app.route("/gnqna",methods =["POST","GET"]) +def gnqna(): + if request.method == "POST": + results = dict(request.form) + try: + response = requests.post("http://localhost:5000/gnqa",json=results) + if response.status_code ==200: + return render_template("gnqa_answer.html",**response.json()) + return response.json() + except Exception as e: + return flask.jsonify({"error occurred":str(e)}) + + #return render_template("gnqa_answer.html") + return render_template("gnqa.html") + @app.route("/gsearch_updating", methods=('POST',)) def gsearch_updating(): result = UpdateGSearch(request.args).__dict__ -- cgit 1.4.1 From 026964990db4ce51a55dc6332a8abc2b6fd28d7e Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 20 Dec 2023 23:09:03 +0300 Subject: init gnqna ui implementation --- wqflask/wqflask/templates/gnqa.html | 117 ++++++++++++++++++++++ wqflask/wqflask/templates/gnqa_answer.html | 149 +++++++++++++++++++++++++++++ 2 files changed, 266 insertions(+) create mode 100644 wqflask/wqflask/templates/gnqa.html create mode 100644 wqflask/wqflask/templates/gnqa_answer.html diff --git a/wqflask/wqflask/templates/gnqa.html b/wqflask/wqflask/templates/gnqa.html new file mode 100644 index 00000000..58ece618 --- /dev/null +++ b/wqflask/wqflask/templates/gnqa.html @@ -0,0 +1,117 @@ +{% extends "base.html" %} +{% block title %}GNQNA{% endblock %} + +{% block content %} + + + + + +
+
+
+
+ + +
+
+ +
+ +
+ +
+ + + + + + + + + + +{% endblock %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wqflask/wqflask/templates/gnqa_answer.html b/wqflask/wqflask/templates/gnqa_answer.html new file mode 100644 index 00000000..e3d010f0 --- /dev/null +++ b/wqflask/wqflask/templates/gnqa_answer.html @@ -0,0 +1,149 @@ +{% extends "base.html" %} +{% block title %}GNQNA{% endblock %} + +{% block content %} + + + + +{% block css %} + +{% endblock %} + + + + +
+
+
+

{{query}}

+

+ +
+

{{answer}}

+

+
+ +
+ + + +
+

References

+ {% if references %} +
    + {% for reference in references %} +
  • +

    {{ reference.bibInfo }}

    +

    {{reference.comboTxt}}

    +
  • + {% endfor %} +
+ {% else %} +

No references available.

+ {% endif %} +
+
+
+ + + + + + +{% endblock %} + -- cgit 1.4.1 From df6d66288758e90d5a7d226c9f5de2aeeb8c23f8 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 20 Dec 2023 23:11:57 +0300 Subject: code formatting fixes --- wqflask/wqflask/templates/gnqa.html | 49 ------------------------------------- 1 file changed, 49 deletions(-) diff --git a/wqflask/wqflask/templates/gnqa.html b/wqflask/wqflask/templates/gnqa.html index 58ece618..bed2627d 100644 --- a/wqflask/wqflask/templates/gnqa.html +++ b/wqflask/wqflask/templates/gnqa.html @@ -63,55 +63,6 @@ required placeholder="Ask a Question or Topic ( Genes) " value='' name="querygnq - - - {% endblock %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit 1.4.1 From 035b503f28ee32b91e7f6ab09e586571c536609e Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Wed, 20 Dec 2023 23:45:53 +0300 Subject: code refactoring --- wqflask/wqflask/views.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index ee4d6a59..e7249b28 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -262,22 +262,28 @@ def gsearchtable(): return flask.jsonify(current_page) - @app.route("/gnqna",methods =["POST","GET"]) def gnqna(): if request.method == "POST": results = dict(request.form) try: - response = requests.post("http://localhost:5000/gnqa",json=results) - if response.status_code ==200: - return render_template("gnqa_answer.html",**response.json()) - return response.json() - except Exception as e: - return flask.jsonify({"error occurred":str(e)}) - - #return render_template("gnqa_answer.html") + def __error__(resp): + return resp.json() + def __success__(resp): + return render_template("gnqa_answer.html",**resp.json()) + return monad_requests.post( + urljoin("http://localhost:5000", + "/gnqa"), + json=results, + ).then( + lambda resp: resp + ).either( + __error__, __success__) + except Exception as error: + return flask.jsonify({"error":str(error)}) return render_template("gnqa.html") + @app.route("/gsearch_updating", methods=('POST',)) def gsearch_updating(): result = UpdateGSearch(request.args).__dict__ -- cgit 1.4.1 From 4ef02f138beffda44f86fec4a76a485e4cf4b0e3 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 21 Dec 2023 17:09:53 +0300 Subject: ui code refactoring --- wqflask/wqflask/templates/base.html | 4 +++- wqflask/wqflask/templates/gnqa_answer.html | 9 +++++++++ wqflask/wqflask/views.py | 8 ++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index e8690184..1ed47db8 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -201,7 +201,7 @@ @@ -388,6 +388,8 @@ required placeholder="Ask More Questions or Topics (E.g Genes) " value='' name=" let timeToLoad = document.createElement("p"); timeToLoad.innerHTML = "It took your browser " + ((Date.now() - pageLoadStart) / 1000) + " second(s) to render this page"; document.querySelector("footer .row .col-xs-6").appendChild(timeToLoad); + + }); diff --git a/wqflask/wqflask/templates/gnqa_answer.html b/wqflask/wqflask/templates/gnqa_answer.html index e3d010f0..4fb4b268 100644 --- a/wqflask/wqflask/templates/gnqa_answer.html +++ b/wqflask/wqflask/templates/gnqa_answer.html @@ -137,6 +137,15 @@ $('#globalsearchform').hide() $('#gnqna_search_home').show() $('footer').hide() + + $("#gnqna_search_home_input").keyup(function(event) { + + console.log("adding input") + if (event.keyCode === 13) { + console.log("clicked this button") + $('#gnqna_search_home').attr('action', "/gnqna").submit(); + } + }) }); diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index e7249b28..37be0e81 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -262,19 +262,19 @@ def gsearchtable(): return flask.jsonify(current_page) + @app.route("/gnqna",methods =["POST","GET"]) def gnqna(): if request.method == "POST": - results = dict(request.form) try: def __error__(resp): return resp.json() def __success__(resp): return render_template("gnqa_answer.html",**resp.json()) return monad_requests.post( - urljoin("http://localhost:5000", - "/gnqa"), - json=results, + urljoin(current_app.config["GN_SERVER_URL"], + "/api/llm/gnqna"), + json=dict(request.form), ).then( lambda resp: resp ).either( -- cgit 1.4.1