Mel Seto
commited on
Commit
·
51a8ded
1
Parent(s):
a6cd490
default to traditional, remove checkbox
Browse files- src/app.py +5 -7
src/app.py
CHANGED
|
@@ -20,6 +20,8 @@ USE_MOCK = False # ✅ Toggle between mock and real API
|
|
| 20 |
|
| 21 |
# simplified to traditional Chinese character converter
|
| 22 |
char_converter = OpenCC('s2t')
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# ======================
|
| 25 |
# Instantiate client (if not mocking)
|
|
@@ -126,7 +128,7 @@ def find_idiom(situation: str, max_attempts: int = 3):
|
|
| 126 |
# ======================
|
| 127 |
# UI Wrapper
|
| 128 |
# ======================
|
| 129 |
-
def update_ui(situation
|
| 130 |
if USE_MOCK:
|
| 131 |
idiom, explanation = find_idiom_mock()
|
| 132 |
else:
|
|
@@ -138,7 +140,7 @@ def update_ui(situation, char_mode: bool):
|
|
| 138 |
|
| 139 |
idiom, explanation = find_idiom(situation)
|
| 140 |
|
| 141 |
-
idiom_output = char_converter.convert(idiom.split("<br>")[0]) if
|
| 142 |
|
| 143 |
return (
|
| 144 |
f"<div class='idiom-output'>{idiom_output}</div>",
|
|
@@ -176,10 +178,6 @@ def launch_app():
|
|
| 176 |
|
| 177 |
|
| 178 |
with gr.Column():
|
| 179 |
-
char_mode = gr.Checkbox(
|
| 180 |
-
label="Show Traditional",
|
| 181 |
-
value = True,
|
| 182 |
-
)
|
| 183 |
idiom_output = gr.HTML(label="Idiom")
|
| 184 |
explanation_output = gr.HTML(label="Explanation")
|
| 185 |
|
|
@@ -187,7 +185,7 @@ def launch_app():
|
|
| 187 |
# pylint: disable=no-member
|
| 188 |
generate_btn.click(
|
| 189 |
fn=update_ui,
|
| 190 |
-
inputs=[situation
|
| 191 |
outputs=[idiom_output, explanation_output],
|
| 192 |
)
|
| 193 |
|
|
|
|
| 20 |
|
| 21 |
# simplified to traditional Chinese character converter
|
| 22 |
char_converter = OpenCC('s2t')
|
| 23 |
+
# Set default to Traditional characters due to user base
|
| 24 |
+
IS_TRADITIONAL = True
|
| 25 |
|
| 26 |
# ======================
|
| 27 |
# Instantiate client (if not mocking)
|
|
|
|
| 128 |
# ======================
|
| 129 |
# UI Wrapper
|
| 130 |
# ======================
|
| 131 |
+
def update_ui(situation):
|
| 132 |
if USE_MOCK:
|
| 133 |
idiom, explanation = find_idiom_mock()
|
| 134 |
else:
|
|
|
|
| 140 |
|
| 141 |
idiom, explanation = find_idiom(situation)
|
| 142 |
|
| 143 |
+
idiom_output = char_converter.convert(idiom.split("<br>")[0]) if IS_TRADITIONAL else idiom
|
| 144 |
|
| 145 |
return (
|
| 146 |
f"<div class='idiom-output'>{idiom_output}</div>",
|
|
|
|
| 178 |
|
| 179 |
|
| 180 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
idiom_output = gr.HTML(label="Idiom")
|
| 182 |
explanation_output = gr.HTML(label="Explanation")
|
| 183 |
|
|
|
|
| 185 |
# pylint: disable=no-member
|
| 186 |
generate_btn.click(
|
| 187 |
fn=update_ui,
|
| 188 |
+
inputs=[situation],
|
| 189 |
outputs=[idiom_output, explanation_output],
|
| 190 |
)
|
| 191 |
|