Update app.py
Browse files
app.py
CHANGED
|
@@ -387,6 +387,7 @@ def get_theme_styles(theme_choice: str) -> Tuple[str, str, str, str]:
|
|
| 387 |
theme = themes.get(theme_choice, themes["Light"])
|
| 388 |
return (theme["explanation"], theme["code"], theme["explanation"], theme["code"])
|
| 389 |
|
|
|
|
| 390 |
def trigger_correction_wrapper(model, code):
|
| 391 |
"""Wrapper for trigger correction with proper error handling."""
|
| 392 |
try:
|
|
@@ -446,36 +447,6 @@ def validate_and_chart_object(model, original, converted):
|
|
| 446 |
logger.error(f"Object validation error: {str(e)}")
|
| 447 |
return f"Validation error: {str(e)}", None
|
| 448 |
|
| 449 |
-
# In the Apex Trigger tab section:
|
| 450 |
-
trigger_button.click(
|
| 451 |
-
fn=trigger_correction_wrapper,
|
| 452 |
-
inputs=[primary_model_dropdown, trigger_input],
|
| 453 |
-
outputs=[trigger_full_response, trigger_code_output, trigger_explanation],
|
| 454 |
-
show_progress=True
|
| 455 |
-
)
|
| 456 |
-
|
| 457 |
-
validate_trigger_button.click(
|
| 458 |
-
fn=validate_and_chart_trigger,
|
| 459 |
-
inputs=[validation_model_dropdown, trigger_input, trigger_code_output],
|
| 460 |
-
outputs=[trigger_validation_output, trigger_chart],
|
| 461 |
-
show_progress=True
|
| 462 |
-
)
|
| 463 |
-
|
| 464 |
-
# In the CloudCraze Object tab section:
|
| 465 |
-
object_button.click(
|
| 466 |
-
fn=object_conversion_wrapper,
|
| 467 |
-
inputs=[primary_model_dropdown, object_input],
|
| 468 |
-
outputs=[object_full_response, object_code_output, object_explanation],
|
| 469 |
-
show_progress=True
|
| 470 |
-
)
|
| 471 |
-
|
| 472 |
-
validate_object_button.click(
|
| 473 |
-
fn=validate_and_chart_object,
|
| 474 |
-
inputs=[validation_model_dropdown, object_input, object_code_output],
|
| 475 |
-
outputs=[object_validation_output, object_chart],
|
| 476 |
-
show_progress=True
|
| 477 |
-
)
|
| 478 |
-
|
| 479 |
def main():
|
| 480 |
"""Main application entry point."""
|
| 481 |
with gr.Blocks(
|
|
@@ -578,15 +549,9 @@ def main():
|
|
| 578 |
|
| 579 |
validate_trigger_button = gr.Button("π Validate Correction", variant="secondary", size="lg")
|
| 580 |
|
| 581 |
-
# Wire up functionality
|
| 582 |
-
def validate_and_chart_trigger(model, original, corrected):
|
| 583 |
-
validation_text = validate_apex_trigger(model, original, corrected)
|
| 584 |
-
metrics = extract_validation_metrics(validation_text)
|
| 585 |
-
chart = create_enhanced_radar_chart(metrics) if metrics else None
|
| 586 |
-
return validation_text, chart
|
| 587 |
-
|
| 588 |
trigger_button.click(
|
| 589 |
-
fn=
|
| 590 |
inputs=[primary_model_dropdown, trigger_input],
|
| 591 |
outputs=[trigger_full_response, trigger_code_output, trigger_explanation],
|
| 592 |
show_progress=True
|
|
@@ -674,14 +639,9 @@ def main():
|
|
| 674 |
|
| 675 |
validate_object_button = gr.Button("π Validate Conversion", variant="secondary", size="lg")
|
| 676 |
|
| 677 |
-
|
| 678 |
-
validation_text = validate_cc_object_conversion(model, original, converted)
|
| 679 |
-
metrics = extract_validation_metrics(validation_text)
|
| 680 |
-
chart = create_enhanced_radar_chart(metrics) if metrics else None
|
| 681 |
-
return validation_text, chart
|
| 682 |
-
|
| 683 |
object_button.click(
|
| 684 |
-
fn=
|
| 685 |
inputs=[primary_model_dropdown, object_input],
|
| 686 |
outputs=[object_full_response, object_code_output, object_explanation],
|
| 687 |
show_progress=True
|
|
@@ -719,7 +679,17 @@ def main():
|
|
| 719 |
value="Light"
|
| 720 |
)
|
| 721 |
|
| 722 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
|
| 724 |
gr.Markdown("### π About This Tool")
|
| 725 |
gr.Markdown(
|
|
|
|
| 387 |
theme = themes.get(theme_choice, themes["Light"])
|
| 388 |
return (theme["explanation"], theme["code"], theme["explanation"], theme["code"])
|
| 389 |
|
| 390 |
+
# Wrapper functions with proper error handling
|
| 391 |
def trigger_correction_wrapper(model, code):
|
| 392 |
"""Wrapper for trigger correction with proper error handling."""
|
| 393 |
try:
|
|
|
|
| 447 |
logger.error(f"Object validation error: {str(e)}")
|
| 448 |
return f"Validation error: {str(e)}", None
|
| 449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 450 |
def main():
|
| 451 |
"""Main application entry point."""
|
| 452 |
with gr.Blocks(
|
|
|
|
| 549 |
|
| 550 |
validate_trigger_button = gr.Button("π Validate Correction", variant="secondary", size="lg")
|
| 551 |
|
| 552 |
+
# Wire up functionality - INSIDE the main function where UI elements are defined
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
trigger_button.click(
|
| 554 |
+
fn=trigger_correction_wrapper,
|
| 555 |
inputs=[primary_model_dropdown, trigger_input],
|
| 556 |
outputs=[trigger_full_response, trigger_code_output, trigger_explanation],
|
| 557 |
show_progress=True
|
|
|
|
| 639 |
|
| 640 |
validate_object_button = gr.Button("π Validate Conversion", variant="secondary", size="lg")
|
| 641 |
|
| 642 |
+
# Wire up functionality - INSIDE the main function where UI elements are defined
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 643 |
object_button.click(
|
| 644 |
+
fn=object_conversion_wrapper,
|
| 645 |
inputs=[primary_model_dropdown, object_input],
|
| 646 |
outputs=[object_full_response, object_code_output, object_explanation],
|
| 647 |
show_progress=True
|
|
|
|
| 679 |
value="Light"
|
| 680 |
)
|
| 681 |
|
| 682 |
+
# Comment out theme functionality for now to avoid conflicts
|
| 683 |
+
# theme_radio.change(
|
| 684 |
+
# fn=get_theme_styles,
|
| 685 |
+
# inputs=[theme_radio],
|
| 686 |
+
# outputs=[
|
| 687 |
+
# trigger_explanation,
|
| 688 |
+
# trigger_code_output,
|
| 689 |
+
# object_explanation,
|
| 690 |
+
# object_code_output
|
| 691 |
+
# ]
|
| 692 |
+
# )
|
| 693 |
|
| 694 |
gr.Markdown("### π About This Tool")
|
| 695 |
gr.Markdown(
|