Spaces:
Running
on
Zero
Running
on
Zero
bugfix
Browse files
app.py
CHANGED
@@ -47,11 +47,9 @@ def suggest_next(text, model_name, k, m):
|
|
47 |
do_sample=False,
|
48 |
early_stopping=True
|
49 |
)
|
50 |
-
# 提取、過濾並轉繁體
|
51 |
suggestions = [out["generated_text"][len(text):].strip() for out in outs]
|
52 |
suggestions = [s for s in suggestions if s]
|
53 |
suggestions = [cc.convert(s) for s in suggestions]
|
54 |
-
# 編號候選
|
55 |
numbered = [f"{i+1}. {s}" for i, s in enumerate(suggestions)]
|
56 |
return update(choices=numbered, value=None)
|
57 |
|
@@ -62,10 +60,10 @@ def append_suggestion(current, choice):
|
|
62 |
text = choice.split(". ", 1)[1] if ". " in choice else choice
|
63 |
return current + text
|
64 |
|
65 |
-
# 自訂 CSS
|
66 |
custom_css = """
|
67 |
#suggestions-bar {
|
68 |
-
margin-
|
69 |
}
|
70 |
#suggestions-bar .candidate-list {
|
71 |
display: flex;
|
@@ -93,10 +91,12 @@ custom_css = """
|
|
93 |
background: #e6f7ff;
|
94 |
border: 1px solid #1890ff;
|
95 |
}
|
|
|
|
|
|
|
96 |
"""
|
97 |
|
98 |
with gr.Blocks(css=custom_css) as demo:
|
99 |
-
# 標題與說明
|
100 |
gr.Markdown(
|
101 |
"## 🇹🇼 繁體中文 IME 加速器 \
|
102 |
"
|
@@ -111,7 +111,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
111 |
)
|
112 |
input_text = gr.Textbox(
|
113 |
label="", placeholder="請輸入拼音或文字…",
|
114 |
-
lines=1, max_lines=1, elem_id="input-box"
|
115 |
)
|
116 |
|
117 |
# 預測按鈕(置於下方)
|
|
|
47 |
do_sample=False,
|
48 |
early_stopping=True
|
49 |
)
|
|
|
50 |
suggestions = [out["generated_text"][len(text):].strip() for out in outs]
|
51 |
suggestions = [s for s in suggestions if s]
|
52 |
suggestions = [cc.convert(s) for s in suggestions]
|
|
|
53 |
numbered = [f"{i+1}. {s}" for i, s in enumerate(suggestions)]
|
54 |
return update(choices=numbered, value=None)
|
55 |
|
|
|
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-right: 8px;
|
67 |
}
|
68 |
#suggestions-bar .candidate-list {
|
69 |
display: flex;
|
|
|
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:
|
|
|
100 |
gr.Markdown(
|
101 |
"## 🇹🇼 繁體中文 IME 加速器 \
|
102 |
"
|
|
|
111 |
)
|
112 |
input_text = gr.Textbox(
|
113 |
label="", placeholder="請輸入拼音或文字…",
|
114 |
+
lines=1, max_lines=1, elem_id="input-box"
|
115 |
)
|
116 |
|
117 |
# 預測按鈕(置於下方)
|