Spaces:
Running
Running
Commit
·
4a5bb08
1
Parent(s):
c05b50f
Add Reset button to clear all inputs and outputs
Browse files
app.py
CHANGED
|
@@ -297,6 +297,31 @@ def add_category_field(current_count):
|
|
| 297 |
return updates
|
| 298 |
|
| 299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
def generate_code(spreadsheet_file, spreadsheet_column,
|
| 301 |
cat1, cat2, cat3, cat4, cat5, cat6, cat7, cat8, cat9, cat10,
|
| 302 |
model_tier, model, model_source_input):
|
|
@@ -450,6 +475,7 @@ https://github.com/chrissoria/cat-llm
|
|
| 450 |
with gr.Row():
|
| 451 |
classify_btn = gr.Button("Classify", variant="primary")
|
| 452 |
see_code_btn = gr.Button("See the Code", variant="secondary")
|
|
|
|
| 453 |
|
| 454 |
with gr.Column():
|
| 455 |
status = gr.Markdown("Ready to classify")
|
|
@@ -507,6 +533,12 @@ https://github.com/chrissoria/cat-llm
|
|
| 507 |
outputs=[code_output]
|
| 508 |
)
|
| 509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
|
| 511 |
if __name__ == "__main__":
|
| 512 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 297 |
return updates
|
| 298 |
|
| 299 |
|
| 300 |
+
def reset_all():
|
| 301 |
+
"""Reset all inputs and outputs to initial state."""
|
| 302 |
+
updates = [
|
| 303 |
+
None, # spreadsheet_file
|
| 304 |
+
gr.update(choices=[], value=None), # spreadsheet_column
|
| 305 |
+
]
|
| 306 |
+
# Reset category inputs (first 3 visible, rest hidden, all empty)
|
| 307 |
+
for i in range(MAX_CATEGORIES):
|
| 308 |
+
updates.append(gr.update(value="", visible=(i < INITIAL_CATEGORIES)))
|
| 309 |
+
updates.extend([
|
| 310 |
+
gr.update(visible=True), # add_category_btn
|
| 311 |
+
INITIAL_CATEGORIES, # category_count
|
| 312 |
+
"Free Models", # model_tier
|
| 313 |
+
FREE_MODEL_CHOICES[0], # model
|
| 314 |
+
"auto", # model_source
|
| 315 |
+
"", # api_key
|
| 316 |
+
"**Free tier** - no API key required! We cover the cost while CatLLM is in review.", # api_key_status
|
| 317 |
+
"Ready to classify", # status
|
| 318 |
+
None, # results
|
| 319 |
+
None, # download_file
|
| 320 |
+
gr.update(value="", visible=False), # code_output
|
| 321 |
+
])
|
| 322 |
+
return updates
|
| 323 |
+
|
| 324 |
+
|
| 325 |
def generate_code(spreadsheet_file, spreadsheet_column,
|
| 326 |
cat1, cat2, cat3, cat4, cat5, cat6, cat7, cat8, cat9, cat10,
|
| 327 |
model_tier, model, model_source_input):
|
|
|
|
| 475 |
with gr.Row():
|
| 476 |
classify_btn = gr.Button("Classify", variant="primary")
|
| 477 |
see_code_btn = gr.Button("See the Code", variant="secondary")
|
| 478 |
+
reset_btn = gr.Button("Reset", variant="stop")
|
| 479 |
|
| 480 |
with gr.Column():
|
| 481 |
status = gr.Markdown("Ready to classify")
|
|
|
|
| 533 |
outputs=[code_output]
|
| 534 |
)
|
| 535 |
|
| 536 |
+
reset_btn.click(
|
| 537 |
+
fn=reset_all,
|
| 538 |
+
inputs=[],
|
| 539 |
+
outputs=[spreadsheet_file, spreadsheet_column] + category_inputs + [add_category_btn, category_count, model_tier, model, model_source, api_key, api_key_status, status, results, download_file, code_output]
|
| 540 |
+
)
|
| 541 |
+
|
| 542 |
|
| 543 |
if __name__ == "__main__":
|
| 544 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|