| import gradio as gr |
|
|
| history = {} |
| |
| prompt = '请你扮演儿童心理专家,你的任务是设计适合青少年心理成长的活动方案,要求设计的活动运用心理学原理,选择的材料来源日常生活' |
|
|
| |
| |
| |
| |
| |
| |
| def chat(p, qid, uid): |
| global history |
| if uid in history: |
| count = history[uid] |
| else: |
| count = 0 |
| count = count+1 |
| history[uid] = count |
| return ["text", response] |
|
|
| iface = gr.Interface(fn=chat, |
| inputs=["text", "text", "text"], |
| outputs=["text", "text"], |
| description="""这是一个极其简单的示范程序,只会重复你的话。 |
| 已添加多轮对话的极简示范。能分别统计不同的 uid 的对话轮数。但本实现是内存中的,一旦重启即被清空。如需可持久的多轮对话,需要改用数据库等方式。 |
| 你只需要 duplicate 本项目,修改 chat 函数,就能造一个能到瀛海威广场注册的机器人了。 |
| [对话测试](https://huggingface.co/spaces/BaixingAI/hackathon_test) [参考文档](https://huggingface.co/spaces/baixing/hackathon_test/blob/main/bot-api.md) [Q & A](https://huggingface.co/spaces/baixing/hackathon_test/blob/main/qna.md) |
| """) |
| iface.launch() |