Spaces:
Sleeping
Sleeping
ganchengguang
commited on
Commit
•
959c7e5
1
Parent(s):
f6f833c
Update app.py
Browse files
app.py
CHANGED
@@ -36,35 +36,25 @@ def respond(message, language, task, system_message, max_tokens, temperature, to
|
|
36 |
)
|
37 |
# 解码回复
|
38 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
39 |
-
|
40 |
|
41 |
# 更新任务选项的函数
|
42 |
def update_tasks(language):
|
43 |
return gr.update(choices=list(options[language].keys()))
|
44 |
|
45 |
# 创建Gradio接口
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
value=0.95,
|
59 |
-
step=0.05,
|
60 |
-
label="Top-p (nucleus sampling)"
|
61 |
-
),
|
62 |
-
],
|
63 |
-
live=True
|
64 |
-
)
|
65 |
-
|
66 |
-
# 设置语言选择框的动态更新
|
67 |
-
demo.components[1].change(update_tasks, inputs=demo.components[1], outputs=demo.components[2])
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
demo.launch()
|
|
|
36 |
)
|
37 |
# 解码回复
|
38 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
39 |
+
return response
|
40 |
|
41 |
# 更新任务选项的函数
|
42 |
def update_tasks(language):
|
43 |
return gr.update(choices=list(options[language].keys()))
|
44 |
|
45 |
# 创建Gradio接口
|
46 |
+
with gr.Blocks() as demo:
|
47 |
+
system_message = gr.Textbox(value="You are a friendly Chatbot.", label="System message")
|
48 |
+
language = gr.Dropdown(label="Language", choices=list(options.keys()), value="English")
|
49 |
+
task = gr.Dropdown(label="Task", choices=list(options['English'].keys()))
|
50 |
+
message = gr.Textbox(label="Input Text")
|
51 |
+
max_tokens = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
|
52 |
+
temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
|
53 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
54 |
+
output = gr.Textbox(label="Output")
|
55 |
+
|
56 |
+
language.change(update_tasks, inputs=language, outputs=task)
|
57 |
+
message.submit(respond, inputs=[message, language, task, system_message, max_tokens, temperature, top_p], outputs=output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
if __name__ == "__main__":
|
60 |
demo.launch()
|