Upload app.py
Browse files
app.py
CHANGED
|
@@ -698,58 +698,68 @@ with gr.Blocks(title="OpenEvolve Prompt Optimizer", theme=gr.themes.Soft()) as d
|
|
| 698 |
info="Use {input} as placeholder for dataset inputs"
|
| 699 |
)
|
| 700 |
|
|
|
|
|
|
|
|
|
|
| 701 |
optimize_btn = gr.Button("๐ Validate & Optimize Prompt", variant="primary", size="lg")
|
| 702 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 703 |
with gr.Row():
|
| 704 |
with gr.Column():
|
| 705 |
-
summary = gr.Markdown(
|
| 706 |
|
| 707 |
with gr.Row():
|
| 708 |
with gr.Column():
|
| 709 |
-
initial_results = gr.Markdown(
|
| 710 |
with gr.Column():
|
| 711 |
-
final_results = gr.Markdown(
|
| 712 |
|
| 713 |
with gr.Row():
|
| 714 |
with gr.Column():
|
| 715 |
-
evolution_progress = gr.Markdown(
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
|
|
|
|
|
|
|
|
|
| 753 |
|
| 754 |
optimize_btn.click(
|
| 755 |
fn=optimize_prompt,
|
|
|
|
| 698 |
info="Use {input} as placeholder for dataset inputs"
|
| 699 |
)
|
| 700 |
|
| 701 |
+
# Button outside the column for better visibility
|
| 702 |
+
with gr.Row():
|
| 703 |
+
with gr.Column():
|
| 704 |
optimize_btn = gr.Button("๐ Validate & Optimize Prompt", variant="primary", size="lg")
|
| 705 |
|
| 706 |
+
# Results section - clearly separated
|
| 707 |
+
gr.Markdown("---")
|
| 708 |
+
gr.Markdown("## ๐ Results")
|
| 709 |
+
|
| 710 |
with gr.Row():
|
| 711 |
with gr.Column():
|
| 712 |
+
summary = gr.Markdown("Click 'Validate & Optimize Prompt' to start optimization...", visible=True)
|
| 713 |
|
| 714 |
with gr.Row():
|
| 715 |
with gr.Column():
|
| 716 |
+
initial_results = gr.Markdown("### Initial Results\nWill appear here after validation...", visible=True)
|
| 717 |
with gr.Column():
|
| 718 |
+
final_results = gr.Markdown("### Final Results\nWill appear here after optimization...", visible=True)
|
| 719 |
|
| 720 |
with gr.Row():
|
| 721 |
with gr.Column():
|
| 722 |
+
evolution_progress = gr.Markdown("### Evolution Progress\nEvolution progress will appear here during optimization...", visible=True)
|
| 723 |
+
|
| 724 |
+
# Documentation section - in collapsible accordion
|
| 725 |
+
gr.Markdown("---")
|
| 726 |
+
with gr.Accordion("๐ Documentation & Examples", open=False):
|
| 727 |
+
gr.Markdown("""
|
| 728 |
+
### Example Datasets & Fields:
|
| 729 |
+
|
| 730 |
+
| Dataset | Split | Input Field | Target Field | Task |
|
| 731 |
+
|---------|-------|-------------|--------------|------|
|
| 732 |
+
| stanfordnlp/imdb | test | text | label | Sentiment Analysis |
|
| 733 |
+
| rajpurkar/squad | validation | question | answers | Question Answering |
|
| 734 |
+
| dair-ai/emotion | test | text | label | Emotion Classification |
|
| 735 |
+
| openai/gsm8k | test | question | answer | Math Reasoning |
|
| 736 |
+
| fancyzhx/ag_news | test | text | label | News Classification |
|
| 737 |
+
|
| 738 |
+
### About This Demo Space:
|
| 739 |
+
|
| 740 |
+
**This is a demonstration space** showcasing OpenEvolve's prompt optimization capabilities.
|
| 741 |
+
The interface shows you how the system works, but **you'll need to set up your own instance to run optimizations**.
|
| 742 |
+
|
| 743 |
+
### How to Run This Yourself:
|
| 744 |
+
|
| 745 |
+
1. **Clone this Space**: Click "โฎ" (three dots) at top-right โ "Duplicate this Space"
|
| 746 |
+
2. **Set Environment Variables** in your cloned Space's settings:
|
| 747 |
+
- `OPENAI_API_KEY`: Your OpenRouter API key (get free key at [openrouter.ai/keys](https://openrouter.ai/keys))
|
| 748 |
+
- `HF_TOKEN`: (Optional) HuggingFace token for private datasets
|
| 749 |
+
3. **Configure Your Optimization**:
|
| 750 |
+
- Dataset: Use full name format (e.g., `stanfordnlp/imdb` or `openai/gsm8k`)
|
| 751 |
+
- Fields: Specify exact field names from the dataset schema
|
| 752 |
+
- Model: Choose from 30+ free models (larger models = better results but slower/rate-limited)
|
| 753 |
+
4. **Run & Monitor**:
|
| 754 |
+
- All inputs are validated before starting
|
| 755 |
+
- Evolution takes 5-15 minutes (10 iterations, 100 samples per evaluation)
|
| 756 |
+
- Watch evolution progress visualization in real-time
|
| 757 |
+
|
| 758 |
+
### About OpenEvolve:
|
| 759 |
+
OpenEvolve is an open-source evolutionary optimization framework. Learn more at:
|
| 760 |
+
- [GitHub Repository](https://github.com/algorithmicsuperintelligence/openevolve)
|
| 761 |
+
- [Documentation](https://github.com/algorithmicsuperintelligence/openevolve#readme)
|
| 762 |
+
""")
|
| 763 |
|
| 764 |
optimize_btn.click(
|
| 765 |
fn=optimize_prompt,
|