olcapone commited on
Commit
74dcbb3
·
verified ·
1 Parent(s): 4f44249

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -825,7 +825,19 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
825
  results_df = pd.DataFrame(results_log)
826
  return status_message, results_df
827
 
828
-
 
 
 
 
 
 
 
 
 
 
 
 
829
  # --- Build Gradio Interface using Blocks ---
830
  with gr.Blocks() as demo:
831
  gr.Markdown("# Basic Agent Evaluation Runner")
@@ -849,14 +861,22 @@ with gr.Blocks() as demo:
849
  run_button = gr.Button("Run Evaluation & Submit All Answers")
850
 
851
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
852
- # Removed max_rows=10 from DataFrame constructor
853
  results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
854
-
 
 
855
  run_button.click(
856
  fn=run_and_submit_all,
857
- outputs=[status_output, results_table]
858
  )
859
 
 
 
 
 
 
 
 
860
  if __name__ == "__main__":
861
  print("\n" + "-"*30 + " App Starting " + "-"*30)
862
  # Check for SPACE_HOST and SPACE_ID at startup for information
 
825
  results_df = pd.DataFrame(results_log)
826
  return status_message, results_df
827
 
828
+ answers_state = gr.State([])
829
+
830
+ def build_jsonl(answers):
831
+ import json, os
832
+ path = "/tmp/submission.jsonl"
833
+ with open(path, "w", encoding="utf-8") as f:
834
+ for a in answers:
835
+ f.write(json.dumps(
836
+ {"task_id": a["task_id"], "model_answer": a["submitted_answer"]},
837
+ ensure_ascii=False
838
+ ) + "\n")
839
+ return path # gr.File/DownloadButton will serve this file
840
+
841
  # --- Build Gradio Interface using Blocks ---
842
  with gr.Blocks() as demo:
843
  gr.Markdown("# Basic Agent Evaluation Runner")
 
861
  run_button = gr.Button("Run Evaluation & Submit All Answers")
862
 
863
  status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
 
864
  results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
865
+ jsonl_file = gr.File(label="submission.jsonl", interactive=False)
866
+ save_btn = gr.Button("Build JSONL for Leaderboard")
867
+
868
  run_button.click(
869
  fn=run_and_submit_all,
870
+ outputs=[status_output, results_table, answers_state]
871
  )
872
 
873
+ save_btn.click(
874
+ fn=build_jsonl,
875
+ inputs=[answers_state],
876
+ outputs=[jsonl_file]
877
+ )
878
+
879
+
880
  if __name__ == "__main__":
881
  print("\n" + "-"*30 + " App Starting " + "-"*30)
882
  # Check for SPACE_HOST and SPACE_ID at startup for information