aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/templates/gnqa_answer.html
blob: 597ed78bc681c3cb348e1b0efed5dcb2d6b2f76a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
{% extends "base.html" %}
{% block title %}GNQNA{% endblock %}

{% block content %} <!-- Start of body -->
 

{% block css %}
<link rel="stylesheet" type="text/css" href="/static/new/css/markdown.css" />
<link rel="stylesheet" type="text/css" href="/static/new/css/llm.css">
{% endblock %}


<style type="text/css">

  #loader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    background: rgba(0,0,0,0.75) url("/static/gif/loader.gif") no-repeat center center;
    z-index: 10000;
}


.btn{
  cursor: pointer;
  outline: 0;
  color: #AAA;

}

.btn:focus {
  outline: none;
}


.blue{
  color: blue;
}

.red{
  color: red;
}


</style>

<div style="height: 90vh;width: 100vw; margin-bottom: 10px;">

  <div id="loader">
    
  </div>
<div style="margin:10px; border:1px solid #ccc;padding: 15px;">
  <div >
    <h1 id="gnqa_query" style="font-weight: bolder">{{query}}<h1>
  </div>

  <div style="width:80vw;overflow-wrap: normal; margin-top: 5px;">
    <p style="word-spacing: 0.7em;" id="gnqa_answer">{{answer}} <p>
  </div>
</div>

<div>



      <div class="container" style="overflow-y: hidden;">
        <h4> <a href="#">References</a></h4>
        {% if references %}
            <ul id="gnqa_ref">
                {% for reference in references %}
                    <li id="gnqa_ref_item">
                        <h2 style="font-weight:bolder;">{{ reference.bibInfo }} </h2>
                        <p>{{reference.comboTxt}}</p>

                        <div class="rating" style="margin-right:20px;padding:5px;text-align: right;" data-doc-id="{{reference.doc_id}}" data-task-id="{{task_id['task_id']}}">

                             <button class="btn" id="green" data-toggle="tooltip" data-placement="top" title="rate this reference +1 "><i class="fa fa-thumbs-up fa-lg" aria-hidden="true"></i></button>
                             <button class="btn" id="red" data-toggle="tooltip" data-placement="top" title="rate this reference  -1"><i class="fa fa-thumbs-down fa-lg" aria-hidden="true"></i></button>
                            
                        </div>
                    </li>
                {% endfor %}
            </ul>
        {% else %}
            <p>No references available.</p>
        {% endif %}
    </div>
</div>
</div>

<script src="https://use.fontawesome.com/fe459689b4.js"></script>
<script type="text/javascript">


     document.addEventListener('DOMContentLoaded', function() {
      const GN_SERVER_URL = {{gn_server_url|tojson}}
      console.log(GN_SERVER_URL)
        $('#globalsearchform').hide()
        $('#gnqna_search_home').show()
         $('footer').hide()
          $("#gnqna_search_home_input").keypress(function(event) {
            if (event.keyCode === 13) {
                console.log("clicked this button")
            $('#gnqna_search_home').submit();
            let spinner = $("#loader")
            spinner.show();

            }
        })


     $(".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")
    dislikeBtn.hasClass("red") ? voteRequest(GN_SERVER_URL,item.data("taskId"),item.data("docId"),-1):0
})
 })
 })
</script>

{% endblock %}