import gradio as gr query = ExtractiveProposalQueries(es_host = Config.es_host, es_index = Config.proposals_index, es_user = Config.es_user, es_password = Config.es_password, reader_name_or_path = Config.reader_model_name_or_path, use_gpu = Config.use_gpu) def update(query): return f"{query}", f"{query}", f"{query}", f"{query}" def search(question): p1_result = query.search_by_query(query = question, retriever_top_k = 5, reader_top_k = 3, es_index = "petro") p2_result = query.search_by_query(query = question, retriever_top_k = 5, reader_top_k = 3, es_index = "rodolfo") return [p1_result[0].answer, p1_result[0].context, p2_result[0].answer, p2_result[0].context] demo = gr.Blocks() with demo: gr.Markdown( """ # Ask2Democracy Preguntale a los candidatos """) inp = gr.Textbox(placeholder="Haz tu pregunta aquĆ­") search_button = gr.Button("Buscar") with gr.Row(): response = gr.Label(value="Petro") context = gr.Label(value="El viejo") with gr.Row(): with gr.Column(): # resp_1 = gr.Markdown("Respuesta") # context_1 = gr.Markdown("Contexto") resp_1 = gr.Textbox(lines=1, label="respuesta") context_1 = gr.Textbox(lines=5, label="contexto") with gr.Column(): resp_2 = gr.Textbox(lines=1, label="respuesta") context_2 = gr.Textbox(lines=5, label="contexto") search_button.click(search, inputs = inp, outputs=[resp_1, context_1, resp_2, context_2]) demo.launch(debug = True)