| import gradio as gr | |
| from transformers import pipeline | |
| pipe = pipeline("text-generation", model="X-D-Lab/MindChat-Qwen2-0_5B") | |
| def respond(message): | |
| result = pipe(message, max_new_tokens=100) | |
| return result[0]["generated_text"] | |
| # 创建界面 | |
| gr.Interface( | |
| fn=respond, | |
| inputs="text", | |
| outputs="text", | |
| title="MindChat对话演示", | |
| description="基于 X-D-Lab/MindChat-Qwen2-0_5B 构建的中文聊天机器人", | |
| allow_flagging="never", | |
| live=False | |
| ).launch(share=True) |