Spaces:
Sleeping
Sleeping
import gradio as gr | |
# 预测函数 | |
def predict(input_text, language): | |
if language == "Chinese": | |
# 中文处理逻辑 | |
response = "这是中文回答:{}".format(input_text) | |
else: | |
# 英文处理逻辑 | |
response = "This is the English response: {}".format(input_text) | |
return response | |
# 创建Gradio界面,并设置默认语言为中文 | |
iface = gr.Interface(fn=predict, | |
inputs=[gr.Textbox(label="Enter Text"), | |
gr.Dropdown(["English", "Chinese"], label="Select Language", value="Chinese")], # 设置默认值为中文 | |
outputs="text") | |
iface.launch() | |