tdoehmen commited on
Commit
22f5582
·
1 Parent(s): 32bd6d6
Files changed (1) hide show
  1. app.py +8 -10
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 update_prompt_template(prompt_format):
26
- """Update the template content when a preset is selected"""
27
- if prompt_format in PROMPT_TEMPLATES:
28
- return PROMPT_TEMPLATES[prompt_format]
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
- # Update token visibility
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=update_prompt_template,
92
  inputs=[prompt_format],
93
  outputs=[custom_prompt]
94
  )
95
 
96
- # Switch to custom mode when editing starts
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
  )