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)