Download app.py from LeeKinXUn/CHatGLM: direct link, hf CLI and curl.
- Browser
- Download file 790 Bytes
-
https://huggingface.co/spaces/LeeKinXUn/CHatGLM/resolve/main/app.py
- Command line
-
hf download hf://spaces/LeeKinXUn/CHatGLM/app.py
-
curl -L -o app.py https://huggingface.co/spaces/LeeKinXUn/CHatGLM/resolve/main/app.py
790 Bytes
| from transformers import AutoTokenizer,AutoModel | |
| import gradio as gr | |
| from gradio.components import Textbox | |
| tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True) | |
| model = AutoModel.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True).float() | |
| model.eval() | |
| history=[] | |
| def ChatGLM_bot(input,history=history): | |
| if input: | |
| response,history = model.chat(tokenizer,input,history=history) | |
| return response | |
| inputs = Textbox(line=7,labels='่ฏท่พๅ ฅไฝ ็้ฎ้ข') | |
| outputs = Textbox(line=7,labels='ไธ่ฝAI็ๅ็ญ') | |
| gr.Interface(fn=ChatGLM_bot,inputs=inputs,outputs=outputs,title='ไธ่ฝ็AIๅฉๆ', | |
| description='ๆๆฏไธ่ฝ็AIๅฉๆ,ๆจๅฏไปฅ้ฎๆไปปไฝ้ฎ้ข', | |
| theme=gr.themes.Default()).launch(share=True) |