Update app.py
Browse files
app.py
CHANGED
|
@@ -81,10 +81,10 @@ with gr.Blocks() as demo:
|
|
| 81 |
|
| 82 |
# Define output components with tabs
|
| 83 |
with gr.Tabs() as tabs:
|
| 84 |
-
|
|
|
|
| 85 |
for model in MODEL_OPTIONS:
|
| 86 |
-
|
| 87 |
-
output_comparisons.append(gr.JSON(label=model, elem_id=f"output-{model}"))
|
| 88 |
|
| 89 |
output_history = gr.JSON(label="History", elem_id="output-history")
|
| 90 |
clear_history_button = gr.Button("Clear History")
|
|
@@ -94,7 +94,9 @@ with gr.Blocks() as demo:
|
|
| 94 |
|
| 95 |
# Define the button to trigger generating comparisons
|
| 96 |
generate_button = gr.Button("Generate Comparisons")
|
| 97 |
-
|
|
|
|
|
|
|
| 98 |
|
| 99 |
# Insert custom CSS using gr.HTML()
|
| 100 |
gr.HTML("""
|
|
|
|
| 81 |
|
| 82 |
# Define output components with tabs
|
| 83 |
with gr.Tabs() as tabs:
|
| 84 |
+
# Dynamically create one gr.JSON component for each model
|
| 85 |
+
output_comparisons = {}
|
| 86 |
for model in MODEL_OPTIONS:
|
| 87 |
+
output_comparisons[model] = gr.JSON(label=model)
|
|
|
|
| 88 |
|
| 89 |
output_history = gr.JSON(label="History", elem_id="output-history")
|
| 90 |
clear_history_button = gr.Button("Clear History")
|
|
|
|
| 94 |
|
| 95 |
# Define the button to trigger generating comparisons
|
| 96 |
generate_button = gr.Button("Generate Comparisons")
|
| 97 |
+
|
| 98 |
+
# Ensure output_comparisons is defined before use
|
| 99 |
+
generate_button.click(generate_comparisons_with_history, inputs=[input_text, selected_models, gr.State()], outputs=[*output_comparisons.values(), output_history])
|
| 100 |
|
| 101 |
# Insert custom CSS using gr.HTML()
|
| 102 |
gr.HTML("""
|