Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -99,26 +99,29 @@ def handle_magic_click(current_text, current_button_text):
|
|
| 99 |
result = magic_function(current_text)
|
| 100 |
category_fix = result.get("category_fix", "")
|
| 101 |
suggestion = result.get("suggestion", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
if category_fix == "COMPLIANT":
|
| 104 |
# COMPLIANT case - no changes to input, green background, lock, add checklist, change button to Reset
|
| 105 |
return (
|
| 106 |
-
gr.update(value=current_text, elem_classes="success-text", interactive=False), # text_area - keep original, green, lock
|
| 107 |
current_text, # previous_text_area - store current
|
| 108 |
gr.update(visible=False), # previous_text_area visibility - hide
|
| 109 |
gr.update(value=f"**{category_fix}**", visible=True), # category_label - show category in bold
|
| 110 |
gr.update(value="Reset"), # button text - change to Reset
|
| 111 |
-
"Your Text ✓" # text_area label - add checklist symbol
|
| 112 |
)
|
| 113 |
else:
|
| 114 |
# Non-compliant case - show suggestion, show previous text, show category
|
| 115 |
return (
|
| 116 |
-
gr.update(value=suggestion, elem_classes="", interactive=True), # text_area - show suggestion, normal style, unlocked
|
| 117 |
current_text, # previous_text_area - store current
|
| 118 |
gr.update(visible=True), # previous_text_area visibility - show
|
| 119 |
gr.update(value=f"**{category_fix}**", visible=True), # category_label - show category in bold
|
| 120 |
gr.update(value="Magic Button"), # button text - keep as Magic Button
|
| 121 |
-
"Your Text" # text_area label - normal
|
| 122 |
)
|
| 123 |
|
| 124 |
|
|
@@ -135,7 +138,7 @@ with gr.Blocks(css=".success-text { background-color: #d4edda !important; }") as
|
|
| 135 |
magic_button.click(
|
| 136 |
fn=handle_magic_click,
|
| 137 |
inputs=[text_area, magic_button],
|
| 138 |
-
outputs=[text_area, previous_text_area, previous_text_area, category_label, magic_button
|
| 139 |
)
|
| 140 |
|
| 141 |
if __name__ == "__main__":
|
|
|
|
| 99 |
result = magic_function(current_text)
|
| 100 |
category_fix = result.get("category_fix", "")
|
| 101 |
suggestion = result.get("suggestion", "")
|
| 102 |
+
|
| 103 |
+
print(current_text)
|
| 104 |
+
print(category_fix)
|
| 105 |
+
print(suggestion)
|
| 106 |
+
print()
|
| 107 |
|
| 108 |
if category_fix == "COMPLIANT":
|
| 109 |
# COMPLIANT case - no changes to input, green background, lock, add checklist, change button to Reset
|
| 110 |
return (
|
| 111 |
+
gr.update(label="Your Text ✓", "value=current_text, elem_classes="success-text", interactive=False), # text_area - keep original, green, lock
|
| 112 |
current_text, # previous_text_area - store current
|
| 113 |
gr.update(visible=False), # previous_text_area visibility - hide
|
| 114 |
gr.update(value=f"**{category_fix}**", visible=True), # category_label - show category in bold
|
| 115 |
gr.update(value="Reset"), # button text - change to Reset
|
|
|
|
| 116 |
)
|
| 117 |
else:
|
| 118 |
# Non-compliant case - show suggestion, show previous text, show category
|
| 119 |
return (
|
| 120 |
+
gr.update(label="Your Text", value=suggestion, elem_classes="", interactive=True), # text_area - show suggestion, normal style, unlocked
|
| 121 |
current_text, # previous_text_area - store current
|
| 122 |
gr.update(visible=True), # previous_text_area visibility - show
|
| 123 |
gr.update(value=f"**{category_fix}**", visible=True), # category_label - show category in bold
|
| 124 |
gr.update(value="Magic Button"), # button text - keep as Magic Button
|
|
|
|
| 125 |
)
|
| 126 |
|
| 127 |
|
|
|
|
| 138 |
magic_button.click(
|
| 139 |
fn=handle_magic_click,
|
| 140 |
inputs=[text_area, magic_button],
|
| 141 |
+
outputs=[text_area, previous_text_area, previous_text_area, category_label, magic_button]
|
| 142 |
)
|
| 143 |
|
| 144 |
if __name__ == "__main__":
|