Emeritus-21 commited on
Commit
977d71c
·
verified ·
1 Parent(s): befd148

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -30
app.py CHANGED
@@ -575,36 +575,55 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
575
  download_csv_file = gr.File(label="CSV File")
576
  download_csv_btn.click(fn=get_csv_file, outputs=download_csv_file)
577
 
578
- with gr.Tab("🧪 GRPO / Dataset"):
579
- gr.Markdown("""
580
- **GRPO Fine-tuning** (run offline or in a training Space):
581
- - Click **Export GRPO Preferences** to produce `data/grpo_prefs.jsonl` of (prompt, chosen, rejected).
582
- - Click **Write Trainer Script** to create `train/grpo_train.py`.
583
- - Then run:
584
- ```bash
585
- pip install trl accelerate peft transformers datasets
586
- python train/grpo_train.py
587
-
588
- Set BASE_MODEL/OUTPUT_DIR env vars if you like.
589
- ```""")
590
-
591
- # These lines need to be indented to be inside the Tab's context
592
- grpo_btn = gr.Button("📦 Export GRPO Preferences")
593
- grpo_status = gr.Markdown()
594
- grpo_btn.click(fn=export_grpo_preferences, outputs=[grpo_status])
595
-
596
- write_script_btn = gr.Button("📝 Write grpo_train.py")
597
- write_script_status = gr.Markdown()
598
- write_script_btn.click(fn=lambda: f"✅ Trainer script written to {_write_trainer_script()}", outputs=[write_script_status])
599
-
600
- gr.Markdown("---")
601
- gr.Markdown("### ⬇️ Download GRPO Dataset")
602
-
603
- with gr.Row():
604
- download_grpo_btn = gr.Button("⬇️ Download GRPO Data (grpo_prefs.jsonl)")
605
- download_grpo_file = gr.File(label="GRPO Dataset File")
606
- download_grpo_btn.click(fn=get_grpo_file, outputs=[download_grpo_file])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
 
608
  # The `if __name__ == "__main__":` block should be at the top level
609
  if __name__ == "__main__":
610
- demo.queue(max_size=50).launch(share=True)
 
575
  download_csv_file = gr.File(label="CSV File")
576
  download_csv_btn.click(fn=get_csv_file, outputs=download_csv_file)
577
 
578
+ # ... code for previous tabs ...
579
+
580
+ with gr.Tab("✏️ Feedback & Memory"):
581
+ gr.Markdown(...)
582
+ build_mem_btn = gr.Button("🧠 Build/Refresh Memory from Feedback")
583
+ mem_status = gr.Markdown()
584
+ build_mem_btn.click(fn=compile_memory_rules, outputs=[mem_status])
585
+
586
+ csv_status = gr.Markdown()
587
+
588
+ gr.Markdown("---")
589
+ gr.Markdown("### ⬇️ Download Feedback Data")
590
+ with gr.Row():
591
+ download_csv_btn = gr.Button("⬇️ Download Feedback as CSV")
592
+ download_csv_file = gr.File(label="CSV File")
593
+ download_csv_btn.click(fn=get_csv_file, outputs=download_csv_file)
594
+
595
+ # Make sure this line is indented correctly, aligning with the other `with gr.Tab` blocks.
596
+ # It should have the same indentation as the "📊 Model Evaluation" and "✏️ Feedback & Memory" tabs.
597
+ with gr.Tab("🧪 GRPO / Dataset"):
598
+ gr.Markdown("""
599
+ **GRPO Fine-tuning** (run offline or in a training Space):
600
+ - Click **Export GRPO Preferences** to produce `data/grpo_prefs.jsonl` of (prompt, chosen, rejected).
601
+ - Click **Write Trainer Script** to create `train/grpo_train.py`.
602
+ - Then run:
603
+ ```bash
604
+ pip install trl accelerate peft transformers datasets
605
+ python train/grpo_train.py
606
+
607
+ Set BASE_MODEL/OUTPUT_DIR env vars if you like.
608
+ ```""")
609
+
610
+ # All of these components must also be indented correctly under this `with` block.
611
+ grpo_btn = gr.Button("📦 Export GRPO Preferences")
612
+ grpo_status = gr.Markdown()
613
+ grpo_btn.click(fn=export_grpo_preferences, outputs=[grpo_status])
614
+
615
+ write_script_btn = gr.Button("📝 Write grpo_train.py")
616
+ write_script_status = gr.Markdown()
617
+ write_script_btn.click(fn=lambda: f"✅ Trainer script written to {_write_trainer_script()}", outputs=[write_script_status])
618
+
619
+ gr.Markdown("---")
620
+ gr.Markdown("### ⬇️ Download GRPO Dataset")
621
+
622
+ with gr.Row():
623
+ download_grpo_btn = gr.Button("⬇️ Download GRPO Data (grpo_prefs.jsonl)")
624
+ download_grpo_file = gr.File(label="GRPO Dataset File")
625
+ download_grpo_btn.click(fn=get_grpo_file, outputs=[download_grpo_file])
626
 
627
  # The `if __name__ == "__main__":` block should be at the top level
628
  if __name__ == "__main__":
629
+ demo.queue(max_size=50).launch(share=True)