Spaces:
Sleeping
Sleeping
removed preview from table, simplified custom edit
Browse files
app.py
CHANGED
|
@@ -25,25 +25,10 @@ def update_token_visibility(api):
|
|
| 25 |
|
| 26 |
def update_prompt_template(prompt_format):
|
| 27 |
"""Update the template content when a preset is selected"""
|
| 28 |
-
if prompt_format == "custom": # Don't update content when switching to custom
|
| 29 |
-
return gr.update() # Skip update
|
| 30 |
if prompt_format in PROMPT_TEMPLATES:
|
| 31 |
return PROMPT_TEMPLATES[prompt_format]
|
| 32 |
return ""
|
| 33 |
|
| 34 |
-
def handle_template_edit(prompt_format, new_template):
|
| 35 |
-
"""Handle when user edits the template"""
|
| 36 |
-
# If we're already in custom mode, don't trigger another format change
|
| 37 |
-
if prompt_format == "custom":
|
| 38 |
-
return gr.update()
|
| 39 |
-
|
| 40 |
-
# If the template matches a preset exactly, keep the preset name
|
| 41 |
-
for format_name, template in PROMPT_TEMPLATES.items():
|
| 42 |
-
if template.strip() == new_template.strip():
|
| 43 |
-
return format_name
|
| 44 |
-
# Otherwise switch to custom
|
| 45 |
-
return "custom"
|
| 46 |
-
|
| 47 |
with gr.Blocks(gr.themes.Soft()) as demo:
|
| 48 |
gr.Markdown("# DuckDB SQL Evaluation App")
|
| 49 |
|
|
@@ -70,7 +55,6 @@ with gr.Blocks(gr.themes.Soft()) as demo:
|
|
| 70 |
|
| 71 |
with gr.Row():
|
| 72 |
with gr.Column():
|
| 73 |
-
# Add 'custom' to the choices
|
| 74 |
prompt_format = gr.Dropdown(
|
| 75 |
label="Prompt Format",
|
| 76 |
choices=['duckdbinst', 'duckdbinstgraniteshort', 'custom'],
|
|
@@ -81,16 +65,16 @@ with gr.Blocks(gr.themes.Soft()) as demo:
|
|
| 81 |
label="Prompt Template Content",
|
| 82 |
placeholder="Enter your custom prompt template here or select a preset format above.",
|
| 83 |
lines=10,
|
| 84 |
-
value=PROMPT_TEMPLATES['duckdbinstgraniteshort']
|
| 85 |
)
|
| 86 |
|
| 87 |
gr.Examples(
|
| 88 |
examples=[
|
| 89 |
-
["openrouter", "qwen/qwen-2.5-72b-instruct", "duckdbinst"
|
| 90 |
-
["openrouter", "meta-llama/llama-3.2-3b-instruct:free", "duckdbinstgraniteshort"
|
| 91 |
-
["openrouter", "mistralai/mistral-nemo", "duckdbinst"
|
| 92 |
],
|
| 93 |
-
inputs=[inference_api, model_name, prompt_format
|
| 94 |
)
|
| 95 |
|
| 96 |
start_btn = gr.Button("Start Evaluation")
|
|
@@ -110,11 +94,11 @@ with gr.Blocks(gr.themes.Soft()) as demo:
|
|
| 110 |
outputs=[custom_prompt]
|
| 111 |
)
|
| 112 |
|
| 113 |
-
#
|
| 114 |
custom_prompt.change(
|
| 115 |
-
fn=
|
| 116 |
-
inputs=
|
| 117 |
-
outputs=
|
| 118 |
)
|
| 119 |
|
| 120 |
start_btn.click(
|
|
|
|
| 25 |
|
| 26 |
def update_prompt_template(prompt_format):
|
| 27 |
"""Update the template content when a preset is selected"""
|
|
|
|
|
|
|
| 28 |
if prompt_format in PROMPT_TEMPLATES:
|
| 29 |
return PROMPT_TEMPLATES[prompt_format]
|
| 30 |
return ""
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
with gr.Blocks(gr.themes.Soft()) as demo:
|
| 33 |
gr.Markdown("# DuckDB SQL Evaluation App")
|
| 34 |
|
|
|
|
| 55 |
|
| 56 |
with gr.Row():
|
| 57 |
with gr.Column():
|
|
|
|
| 58 |
prompt_format = gr.Dropdown(
|
| 59 |
label="Prompt Format",
|
| 60 |
choices=['duckdbinst', 'duckdbinstgraniteshort', 'custom'],
|
|
|
|
| 65 |
label="Prompt Template Content",
|
| 66 |
placeholder="Enter your custom prompt template here or select a preset format above.",
|
| 67 |
lines=10,
|
| 68 |
+
value=PROMPT_TEMPLATES['duckdbinstgraniteshort']
|
| 69 |
)
|
| 70 |
|
| 71 |
gr.Examples(
|
| 72 |
examples=[
|
| 73 |
+
["openrouter", "qwen/qwen-2.5-72b-instruct", "duckdbinst"],
|
| 74 |
+
["openrouter", "meta-llama/llama-3.2-3b-instruct:free", "duckdbinstgraniteshort"],
|
| 75 |
+
["openrouter", "mistralai/mistral-nemo", "duckdbinst"],
|
| 76 |
],
|
| 77 |
+
inputs=[inference_api, model_name, prompt_format],
|
| 78 |
)
|
| 79 |
|
| 80 |
start_btn = gr.Button("Start Evaluation")
|
|
|
|
| 94 |
outputs=[custom_prompt]
|
| 95 |
)
|
| 96 |
|
| 97 |
+
# Just switch to custom mode when editing starts
|
| 98 |
custom_prompt.change(
|
| 99 |
+
fn=lambda _: "custom",
|
| 100 |
+
inputs=None,
|
| 101 |
+
outputs=prompt_format
|
| 102 |
)
|
| 103 |
|
| 104 |
start_btn.click(
|