Ajaykanth Maddi commited on
Commit ·
e8bb07c
1
Parent(s): 124750e
Export Button UI Changes
Browse files
app.py
CHANGED
|
@@ -179,19 +179,48 @@ initial_subset = available_subsets[0] if available_subsets else None
|
|
| 179 |
# initial_summary = update_summary(initial_subset) if initial_subset else "No data available"
|
| 180 |
initial_plot = plot_subset_metrics(initial_subset) if initial_subset else "No data available"
|
| 181 |
|
| 182 |
-
def generate_file(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
"""Generate a file with the given text and return the file path."""
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
# Step 2: Convert to JSON string for display
|
| 192 |
-
json_str = json.dumps(
|
| 193 |
|
| 194 |
-
fileName = "
|
| 195 |
# Save to file inside Space
|
| 196 |
with open(fileName, "w") as f:
|
| 197 |
f.write(json_str)
|
|
@@ -418,7 +447,15 @@ with gr.Blocks(
|
|
| 418 |
download_file = gr.File(label="Download Link")
|
| 419 |
generate_btn.click(
|
| 420 |
fn=generate_file,
|
| 421 |
-
inputs=[subset_dropdown,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
outputs=[json_output, download_file]
|
| 423 |
)
|
| 424 |
|
|
|
|
| 179 |
# initial_summary = update_summary(initial_subset) if initial_subset else "No data available"
|
| 180 |
initial_plot = plot_subset_metrics(initial_subset) if initial_subset else "No data available"
|
| 181 |
|
| 182 |
+
def generate_file(subset_dropdown, dataset_type_dropdown,
|
| 183 |
+
chunking_dropdown, embed_dropdown, retriever_dropdown,
|
| 184 |
+
chunk_count, retriever_type,
|
| 185 |
+
reranking_checkbox, evaluator_dropdown,
|
| 186 |
+
orig_ans_display, y_metrics_display,
|
| 187 |
+
gen_ans_display, y_pred_metrics_display,
|
| 188 |
+
chunks_retrieved_display,
|
| 189 |
+
evaluator_json_output):
|
| 190 |
"""Generate a file with the given text and return the file path."""
|
| 191 |
|
| 192 |
+
export_data = {
|
| 193 |
+
"metadata": {
|
| 194 |
+
"timestamp": datetime.datetime.now().isoformat(),
|
| 195 |
+
"format_version": "1.0"
|
| 196 |
+
},
|
| 197 |
+
"subset": {
|
| 198 |
+
"subset": subset_dropdown,
|
| 199 |
+
"dataset_type": dataset_type_dropdown,
|
| 200 |
+
},
|
| 201 |
+
"model_details": {
|
| 202 |
+
"strategy": chunking_dropdown,
|
| 203 |
+
"embed_model": embed_dropdown,
|
| 204 |
+
"generator_model": retriever_dropdown,
|
| 205 |
+
"chunk_count": chunk_count,
|
| 206 |
+
"retriever_type": retriever_type,
|
| 207 |
+
"reranking": reranking_checkbox,
|
| 208 |
+
"evaluator_model": evaluator_dropdown
|
| 209 |
+
},
|
| 210 |
+
"results": {
|
| 211 |
+
"original_answer": orig_ans_display,
|
| 212 |
+
"y_metrics": y_metrics_display,
|
| 213 |
+
"generated_answer": gen_ans_display,
|
| 214 |
+
"y_pred_metrics": y_pred_metrics_display,
|
| 215 |
+
"retrieved_chunks": chunks_retrieved_display,
|
| 216 |
+
"evaluator_json_output": evaluator_json_output
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
|
| 220 |
# Step 2: Convert to JSON string for display
|
| 221 |
+
json_str = json.dumps(export_data, indent=2)
|
| 222 |
|
| 223 |
+
fileName = f"{subset_dropdown}_output_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
|
| 224 |
# Save to file inside Space
|
| 225 |
with open(fileName, "w") as f:
|
| 226 |
f.write(json_str)
|
|
|
|
| 447 |
download_file = gr.File(label="Download Link")
|
| 448 |
generate_btn.click(
|
| 449 |
fn=generate_file,
|
| 450 |
+
inputs=[subset_dropdown, dataset_type_dropdown,
|
| 451 |
+
chunking_dropdown, embed_dropdown, retriever_dropdown,
|
| 452 |
+
chunk_count, retriever_type,
|
| 453 |
+
reranking_checkbox, evaluator_dropdown,
|
| 454 |
+
orig_ans_display, y_metrics_display,
|
| 455 |
+
gen_ans_display, y_pred_metrics_display,
|
| 456 |
+
chunks_retrieved_display,
|
| 457 |
+
evaluator_json_output
|
| 458 |
+
],
|
| 459 |
outputs=[json_output, download_file]
|
| 460 |
)
|
| 461 |
|