Spaces:
Sleeping
Sleeping
last try
Browse files
app.py
CHANGED
|
@@ -22,11 +22,11 @@ def update_token_visibility(api):
|
|
| 22 |
"""Update visibility of the OpenRouter token input"""
|
| 23 |
return gr.update(visible=api == "openrouter")
|
| 24 |
|
| 25 |
-
def
|
| 26 |
-
"""
|
| 27 |
-
if
|
| 28 |
-
return PROMPT_TEMPLATES[
|
| 29 |
-
return
|
| 30 |
|
| 31 |
with gr.Blocks(gr.themes.Soft()) as demo:
|
| 32 |
gr.Markdown("# DuckDB SQL Evaluation App")
|
|
@@ -79,22 +79,20 @@ with gr.Blocks(gr.themes.Soft()) as demo:
|
|
| 79 |
start_btn = gr.Button("Start Evaluation")
|
| 80 |
output = gr.Textbox(label="Output", lines=20)
|
| 81 |
|
| 82 |
-
#
|
| 83 |
inference_api.change(
|
| 84 |
fn=update_token_visibility,
|
| 85 |
inputs=[inference_api],
|
| 86 |
outputs=[openrouter_token]
|
| 87 |
)
|
| 88 |
|
| 89 |
-
# Update template content when preset is selected
|
| 90 |
prompt_format.change(
|
| 91 |
-
fn=
|
| 92 |
inputs=[prompt_format],
|
| 93 |
outputs=[custom_prompt]
|
| 94 |
)
|
| 95 |
|
| 96 |
-
|
| 97 |
-
custom_prompt.input( # Using input instead of change
|
| 98 |
fn=lambda: "custom",
|
| 99 |
outputs=prompt_format
|
| 100 |
)
|
|
|
|
| 22 |
"""Update visibility of the OpenRouter token input"""
|
| 23 |
return gr.update(visible=api == "openrouter")
|
| 24 |
|
| 25 |
+
def on_prompt_format_change(choice):
|
| 26 |
+
"""Only update content when selecting a preset"""
|
| 27 |
+
if choice in PROMPT_TEMPLATES:
|
| 28 |
+
return PROMPT_TEMPLATES[choice]
|
| 29 |
+
return gr.update()
|
| 30 |
|
| 31 |
with gr.Blocks(gr.themes.Soft()) as demo:
|
| 32 |
gr.Markdown("# DuckDB SQL Evaluation App")
|
|
|
|
| 79 |
start_btn = gr.Button("Start Evaluation")
|
| 80 |
output = gr.Textbox(label="Output", lines=20)
|
| 81 |
|
| 82 |
+
# Event handlers
|
| 83 |
inference_api.change(
|
| 84 |
fn=update_token_visibility,
|
| 85 |
inputs=[inference_api],
|
| 86 |
outputs=[openrouter_token]
|
| 87 |
)
|
| 88 |
|
|
|
|
| 89 |
prompt_format.change(
|
| 90 |
+
fn=on_prompt_format_change,
|
| 91 |
inputs=[prompt_format],
|
| 92 |
outputs=[custom_prompt]
|
| 93 |
)
|
| 94 |
|
| 95 |
+
custom_prompt.input(
|
|
|
|
| 96 |
fn=lambda: "custom",
|
| 97 |
outputs=prompt_format
|
| 98 |
)
|