File size: 790 Bytes
79afb7d e997932 79afb7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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) |