Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,14 +114,24 @@ def qa_process(selected_queries, qa_llm_model, aggregator,
|
|
| 114 |
genra.retrieval(batch_number, queries_df, topk, summarize_batch)
|
| 115 |
|
| 116 |
gr.Info("Processed all batches!")
|
| 117 |
-
|
| 118 |
-
|
| 119 |
summary = genra.summarize_history(queries_df)
|
| 120 |
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
-
|
| 124 |
-
return result_df, summary
|
| 125 |
|
| 126 |
|
| 127 |
with gr.Blocks() as demo:
|
|
@@ -234,13 +244,13 @@ with gr.Blocks() as demo:
|
|
| 234 |
qa_button = gr.Button("Start QA")
|
| 235 |
hsummary = gr.Textbox(label="Historical Summary")
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 239 |
|
| 240 |
addqry_button.click(add_query, inputs=[query_inp, queries_state], outputs=[selected_queries, queries_state])
|
| 241 |
qa_button.click(qa_process,
|
| 242 |
inputs=[selected_queries, qa_llm_model, aggregator, batch_size, topk, text_field, data],
|
| 243 |
-
outputs=[
|
| 244 |
|
| 245 |
|
| 246 |
demo.launch()
|
|
|
|
| 114 |
genra.retrieval(batch_number, queries_df, topk, summarize_batch)
|
| 115 |
|
| 116 |
gr.Info("Processed all batches!")
|
| 117 |
+
|
| 118 |
+
gr.Info("Getting summary...")
|
| 119 |
summary = genra.summarize_history(queries_df)
|
| 120 |
|
| 121 |
+
gr.Info("Preparing results...")
|
| 122 |
+
results = genra.answers_store
|
| 123 |
+
final_answers, q_a = [], []
|
| 124 |
+
for q, g_answers in results.items():
|
| 125 |
+
for answer in g_answers:
|
| 126 |
+
final_answers.append({'question':q, "tweets":answer['tweets'], "batch":answer['batch_number'], "summary":answer['summary'] })
|
| 127 |
+
for t in answer['tweets']:
|
| 128 |
+
q_a.append((q,t))
|
| 129 |
+
answers_df = pd.DataFrame.from_dict(final_answers)
|
| 130 |
+
q_a = list(set(q_a))
|
| 131 |
+
q_a_df = pd.DataFrame(q_a, columns =['question', 'tweet'])
|
| 132 |
+
q_a_df = q_a_df.sort_values(by=["question"], ascending=False)
|
| 133 |
|
| 134 |
+
return q_a_df, answers_df, summary
|
|
|
|
| 135 |
|
| 136 |
|
| 137 |
with gr.Blocks() as demo:
|
|
|
|
| 244 |
qa_button = gr.Button("Start QA")
|
| 245 |
hsummary = gr.Textbox(label="Historical Summary")
|
| 246 |
|
| 247 |
+
qa_df = gr.DataFrame()
|
| 248 |
+
answers_df = gr.DataFrame()
|
| 249 |
|
| 250 |
addqry_button.click(add_query, inputs=[query_inp, queries_state], outputs=[selected_queries, queries_state])
|
| 251 |
qa_button.click(qa_process,
|
| 252 |
inputs=[selected_queries, qa_llm_model, aggregator, batch_size, topk, text_field, data],
|
| 253 |
+
outputs=[qa_df, answers_df, hsummary])
|
| 254 |
|
| 255 |
|
| 256 |
demo.launch()
|