From 8e2640ec14f4bc37ea829fb4c9d4ad187ed44718 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Tue, 16 Jan 2024 15:17:21 +0300 Subject: add UI for reference rating gn-llm documents --- gn2/wqflask/templates/gnqa_answer.html | 80 ++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 9 deletions(-) (limited to 'gn2/wqflask/templates/gnqa_answer.html') diff --git a/gn2/wqflask/templates/gnqa_answer.html b/gn2/wqflask/templates/gnqa_answer.html index c8ec9bbb..7d313eb6 100644 --- a/gn2/wqflask/templates/gnqa_answer.html +++ b/gn2/wqflask/templates/gnqa_answer.html @@ -2,8 +2,6 @@ {% block title %}GNQNA{% endblock %} {% block content %} - - {% block css %} @@ -27,6 +25,26 @@ } +.btn{ + cursor: pointer; + outline: 0; + color: #AAA; + +} + +.btn:focus { + outline: none; +} + + +.blue{ + color: blue; +} + +.red{ + color: red; +} + @@ -47,8 +65,8 @@
- - + +

References

{% if references %} @@ -57,6 +75,13 @@
  • {{ reference.bibInfo }}

    {{reference.comboTxt}}

    + +
    + + + + +
  • {% endfor %} @@ -66,9 +91,14 @@
    + + - - + $(".rating").each(function() { + let item = $(this); + let likeBtn = item.find("#green") + let dislikeBtn = item.find("#red") + + +let voteRequest = (gn_server_url,task_id,doc_id,vote_count)=>{ + try{ + fetch(`${GN_SERVER_URL}/api/llm/rating/${task_id}/${doc_id}/${vote_count}`,{ + method:"POST", + body:"" + }) + .then(response => response.text()) + .then(data=> console.log(data)); + } + catch { + alert("An error occurred") + } +} + likeBtn.on("click",function() { + if(dislikeBtn.hasClass("red")){ + dislikeBtn.removeClass("red") + } + likeBtn.toggleClass("blue") + likeBtn.hasClass("blue")? voteRequest(GN_SERVER_URL,item.data("taskId"),item.data("docId"),1) : 0 +}) + +dislikeBtn.on("click",function(){ +if(likeBtn.hasClass("blue")){ + likeBtn.removeClass("blue") + } + dislikeBtn.toggleClass("red") + likeBtn.hasClass("red") ? voteRequest(GN_SERVER_URL,item.data("taskId"),item.data("docId"),-1):0 +}) + }) + }) + {% endblock %} -- cgit v1.2.3