Spaces:
Running
on
Zero
Running
on
Zero
bugfix
Browse files
app.py
CHANGED
@@ -38,12 +38,12 @@ def suggest_next(text, model_name, k, m):
|
|
38 |
early_stopping=True
|
39 |
)
|
40 |
suggestions = [out["generated_text"][len(text):] for out in outs]
|
41 |
-
#
|
42 |
-
return update(choices=suggestions, value=
|
43 |
|
44 |
def append_suggestion(current, choice):
|
45 |
-
#
|
46 |
-
if
|
47 |
return current
|
48 |
return current + choice
|
49 |
|
@@ -53,7 +53,7 @@ with gr.Blocks() as demo:
|
|
53 |
"結合小型語言模型與 ZeroGPU,即時 IME 風格建議條。"
|
54 |
)
|
55 |
|
56 |
-
#
|
57 |
suggestions = gr.Radio(
|
58 |
[], label="建議清單", interactive=True, type="value", elem_id="suggestions-bar"
|
59 |
)
|
|
|
38 |
early_stopping=True
|
39 |
)
|
40 |
suggestions = [out["generated_text"][len(text):] for out in outs]
|
41 |
+
# 使用 None 重置選值,避免預設 value 不在 choices 列表中
|
42 |
+
return update(choices=suggestions, value=None)
|
43 |
|
44 |
def append_suggestion(current, choice):
|
45 |
+
# 如果沒有選擇,直接返回原文字
|
46 |
+
if choice is None:
|
47 |
return current
|
48 |
return current + choice
|
49 |
|
|
|
53 |
"結合小型語言模型與 ZeroGPU,即時 IME 風格建議條。"
|
54 |
)
|
55 |
|
56 |
+
# 建議清單置頂,使用 Radio 類型一次展開
|
57 |
suggestions = gr.Radio(
|
58 |
[], label="建議清單", interactive=True, type="value", elem_id="suggestions-bar"
|
59 |
)
|