Spaces:
Sleeping
Sleeping
Update _app.py
Browse files
_app.py
CHANGED
|
@@ -134,12 +134,17 @@ def add_query(to_add, history):
|
|
| 134 |
|
| 135 |
# return q_a_df, answers_df, summary
|
| 136 |
|
| 137 |
-
def qa_summarise(selected_queries, qa_llm_model, text_field, data_df):
|
| 138 |
|
| 139 |
qa_input_df = data_df[data_df["model_label"] != "none"].reset_index()
|
| 140 |
texts = qa_input_df[text_field].to_list()
|
| 141 |
|
| 142 |
-
summary = generate_answer(qa_llm_model,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
doc_df = pd.DataFrame()
|
| 145 |
doc_df["number"] = [i+1 for i in range(len(texts))]
|
|
@@ -228,7 +233,7 @@ with gr.Blocks() as demo:
|
|
| 228 |
outputs=[incorrect, correct, accuracy, data_eval, download_csv])
|
| 229 |
|
| 230 |
qa_tab = gr.Tab("Question Answering")
|
| 231 |
-
|
| 232 |
|
| 233 |
with qa_tab:
|
| 234 |
# XXX Add some button disabling here, if the classification process is not completed first XXX
|
|
@@ -251,6 +256,8 @@ with gr.Blocks() as demo:
|
|
| 251 |
with gr.Column():
|
| 252 |
batch_size = gr.Slider(50, 500, value=150, step=1, label="Batch size", info="Choose between 50 and 500", interactive=True)
|
| 253 |
topk = gr.Slider(1, 10, value=5, step=1, label="Number of results to retrieve", info="Choose between 1 and 10", interactive=True)
|
|
|
|
|
|
|
| 254 |
|
| 255 |
selected_queries = gr.CheckboxGroup(label="Select at least one query using the checkboxes", interactive=True)
|
| 256 |
queries_state = gr.State()
|
|
@@ -269,7 +276,7 @@ with gr.Blocks() as demo:
|
|
| 269 |
# inputs=[selected_queries, qa_llm_model, aggregator, batch_size, topk, text_field, data],
|
| 270 |
# outputs=[qa_df, answers_df, hsummary])
|
| 271 |
qa_button.click(qa_summarise,
|
| 272 |
-
inputs=[selected_queries, qa_llm_model, text_field, data],
|
| 273 |
outputs=[hsummary, qa_df])
|
| 274 |
|
| 275 |
|
|
|
|
| 134 |
|
| 135 |
# return q_a_df, answers_df, summary
|
| 136 |
|
| 137 |
+
def qa_summarise(selected_queries, qa_llm_model, text_field, response_lang, data_df):
|
| 138 |
|
| 139 |
qa_input_df = data_df[data_df["model_label"] != "none"].reset_index()
|
| 140 |
texts = qa_input_df[text_field].to_list()
|
| 141 |
|
| 142 |
+
summary = generate_answer(qa_llm_model,
|
| 143 |
+
texts,
|
| 144 |
+
selected_queries[0],
|
| 145 |
+
selected_queries,
|
| 146 |
+
response_lang,
|
| 147 |
+
mode="multi_summarize")
|
| 148 |
|
| 149 |
doc_df = pd.DataFrame()
|
| 150 |
doc_df["number"] = [i+1 for i in range(len(texts))]
|
|
|
|
| 233 |
outputs=[incorrect, correct, accuracy, data_eval, download_csv])
|
| 234 |
|
| 235 |
qa_tab = gr.Tab("Question Answering")
|
| 236 |
+
|
| 237 |
|
| 238 |
with qa_tab:
|
| 239 |
# XXX Add some button disabling here, if the classification process is not completed first XXX
|
|
|
|
| 256 |
with gr.Column():
|
| 257 |
batch_size = gr.Slider(50, 500, value=150, step=1, label="Batch size", info="Choose between 50 and 500", interactive=True)
|
| 258 |
topk = gr.Slider(1, 10, value=5, step=1, label="Number of results to retrieve", info="Choose between 1 and 10", interactive=True)
|
| 259 |
+
|
| 260 |
+
response_lang = gr.Dropdown(["english", "german", "catalan", "spanish"], label="Response language", value="english", interactive=True)
|
| 261 |
|
| 262 |
selected_queries = gr.CheckboxGroup(label="Select at least one query using the checkboxes", interactive=True)
|
| 263 |
queries_state = gr.State()
|
|
|
|
| 276 |
# inputs=[selected_queries, qa_llm_model, aggregator, batch_size, topk, text_field, data],
|
| 277 |
# outputs=[qa_df, answers_df, hsummary])
|
| 278 |
qa_button.click(qa_summarise,
|
| 279 |
+
inputs=[selected_queries, qa_llm_model, text_field, response_lang, data],
|
| 280 |
outputs=[hsummary, qa_df])
|
| 281 |
|
| 282 |
|