Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|