Jorge Henao commited on
Commit
9129bee
β€’
1 Parent(s): e018421
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ query = ExtractiveProposalQueries(es_host = Config.es_host, es_index = Config.proposals_index,
4
+ es_user = Config.es_user, es_password = Config.es_password,
5
+ reader_name_or_path = Config.reader_model_name_or_path,
6
+ use_gpu = Config.use_gpu)
7
+
8
+
9
+ def update(query):
10
+ return f"{query}", f"{query}", f"{query}", f"{query}"
11
+
12
+ def search(question):
13
+ p1_result = query.search_by_query(query = question, retriever_top_k = 5, reader_top_k = 3, es_index = "petro")
14
+ p2_result = query.search_by_query(query = question, retriever_top_k = 5, reader_top_k = 3, es_index = "rodolfo")
15
+
16
+ return [p1_result[0].answer,
17
+ p1_result[0].context,
18
+ p2_result[0].answer,
19
+ p2_result[0].context]
20
+
21
+ demo = gr.Blocks()
22
+
23
+ with demo:
24
+ gr.Markdown(
25
+ """
26
+ # Ask2Democracy
27
+ Preguntale a los candidatos
28
+ """)
29
+
30
+ inp = gr.Textbox(placeholder="Haz tu pregunta aquΓ­")
31
+ search_button = gr.Button("Buscar")
32
+ with gr.Row():
33
+ response = gr.Label(value="Petro")
34
+ context = gr.Label(value="El viejo")
35
+ with gr.Row():
36
+ with gr.Column():
37
+ # resp_1 = gr.Markdown("<b>Respuesta</b>")
38
+ # context_1 = gr.Markdown("<b>Contexto</b>")
39
+ resp_1 = gr.Textbox(lines=1, label="respuesta")
40
+ context_1 = gr.Textbox(lines=5, label="contexto")
41
+ with gr.Column():
42
+ resp_2 = gr.Textbox(lines=1, label="respuesta")
43
+ context_2 = gr.Textbox(lines=5, label="contexto")
44
+
45
+ search_button.click(search, inputs = inp, outputs=[resp_1, context_1, resp_2, context_2])
46
+ demo.launch(debug = True)