THUDM / ChatGLM2-6B

ChatGLM2-6B: An Open Bilingual Chat LLM | 开源双语对话语言模型
Other
15.68k stars 1.85k forks source link

如何在web_demo中修改代码增加systemprompt呢? #569

Open BryanMurkyChan opened 11 months ago

BryanMurkyChan commented 11 months ago

Is there an existing issue for this?

Current Behavior

描述:我希望能在web_demo中添加systemprompt,让模型拥有内置的角色设定,类似chatgpt的customize

我在cli_demo.py中能顺利添加systemprompt,在第45行处修改成query = systemprompt+input("\n用户:")即可 image 但是我在web_demo.py中不知道怎么添加,我尝试过 (1)在72行修改为chatbot.append((systemprompt + parse_text(input), "")) (2)98行user_input = systemprompt+gr.Textbox(show_label=False, placeholder="Input...", lines=10).style(container=False) 第一种方法没有效果,第二种方法报错了 报错为 File "web_demo.py", line 97, in user_input = systemprompt+gr.Textbox(show_label=False, placeholder="Input...", lines=10).style( TypeError: can only concatenate str (not "Textbox") to str 有没有大神指点一下该怎么修改呢?

Expected Behavior

No response

Steps To Reproduce

我在cli_demo.py中能顺利添加systemprompt,在第45行处修改成query = systemprompt+input("\n用户:")即可 image 但是我在web_demo.py中不知道怎么添加,我尝试过 (1)在72行修改为chatbot.append((systemprompt + parse_text(input), "")) (2)98行user_input = systemprompt+gr.Textbox(show_label=False, placeholder="Input...", lines=10).style(container=False) 第一种方法没有效果,第二种方法报错了 报错为 File "web_demo.py", line 97, in user_input = systemprompt+gr.Textbox(show_label=False, placeholder="Input...", lines=10).style( TypeError: can only concatenate str (not "Textbox") to str 有没有大神指点一下该怎么修改呢?

Environment

- OS:Ubuntu 20.04
- Python:3.8
- Transformers:4.26.1
- PyTorch:1.12
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :True

Anything else?

No response

jyyang26 commented 2 months ago

m