update layout
Browse files
app.py
CHANGED
|
@@ -60,10 +60,10 @@ def append_suggestion(current, choice):
|
|
| 60 |
text = choice.split(". ", 1)[1] if ". " in choice else choice
|
| 61 |
return current + text
|
| 62 |
|
| 63 |
-
# 自訂 CSS
|
| 64 |
custom_css = """
|
| 65 |
#suggestions-bar {
|
| 66 |
-
margin-
|
| 67 |
}
|
| 68 |
#suggestions-bar .candidate-list {
|
| 69 |
display: flex;
|
|
@@ -91,9 +91,6 @@ custom_css = """
|
|
| 91 |
background: #e6f7ff;
|
| 92 |
border: 1px solid #1890ff;
|
| 93 |
}
|
| 94 |
-
#input-box {
|
| 95 |
-
flex: 1;
|
| 96 |
-
}
|
| 97 |
"""
|
| 98 |
|
| 99 |
with gr.Blocks(css=custom_css) as demo:
|
|
@@ -103,18 +100,19 @@ with gr.Blocks(css=custom_css) as demo:
|
|
| 103 |
"結合小型語言模型與 ZeroGPU,提供即時輸入法風格候選欄。"
|
| 104 |
)
|
| 105 |
|
| 106 |
-
#
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
|
|
|
| 116 |
|
| 117 |
-
#
|
| 118 |
predict_button = gr.Button("預測", elem_id="predict-button")
|
| 119 |
|
| 120 |
# 進階參數設定(可摺疊)
|
|
|
|
| 60 |
text = choice.split(". ", 1)[1] if ". " in choice else choice
|
| 61 |
return current + text
|
| 62 |
|
| 63 |
+
# 自訂 CSS:模擬經典中文輸入法候選欄樣式
|
| 64 |
custom_css = """
|
| 65 |
#suggestions-bar {
|
| 66 |
+
margin-bottom: 8px;
|
| 67 |
}
|
| 68 |
#suggestions-bar .candidate-list {
|
| 69 |
display: flex;
|
|
|
|
| 91 |
background: #e6f7ff;
|
| 92 |
border: 1px solid #1890ff;
|
| 93 |
}
|
|
|
|
|
|
|
|
|
|
| 94 |
"""
|
| 95 |
|
| 96 |
with gr.Blocks(css=custom_css) as demo:
|
|
|
|
| 100 |
"結合小型語言模型與 ZeroGPU,提供即時輸入法風格候選欄。"
|
| 101 |
)
|
| 102 |
|
| 103 |
+
# 候選條(置於上方)
|
| 104 |
+
suggestions = gr.Radio(
|
| 105 |
+
[], label="", interactive=True, type="value",
|
| 106 |
+
elem_id="suggestions-bar", elem_classes="candidate-list"
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
# 輸入框(置於候選條下方)
|
| 110 |
+
input_text = gr.Textbox(
|
| 111 |
+
label="", placeholder="請輸入拼音或文字…",
|
| 112 |
+
lines=1, max_lines=1, elem_id="input-box"
|
| 113 |
+
)
|
| 114 |
|
| 115 |
+
# 預測按鈕(置於文字框下方)
|
| 116 |
predict_button = gr.Button("預測", elem_id="predict-button")
|
| 117 |
|
| 118 |
# 進階參數設定(可摺疊)
|