LeeKinXUn commited on
Commit
79afb7d
ยท
1 Parent(s): a1975fd

Add application file

Browse files
Files changed (2) hide show
  1. app.py +24 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoTokenizer,AutoModel
2
+ import gradio as gr
3
+ from gradio.components import Textbox
4
+
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True)
7
+ model = AutoModel.from_pretrained("THUDM/chatglm-6b-int4", trust_remote_code=True).half().cuda()
8
+ model.eval()
9
+
10
+ history=[]
11
+
12
+ def ChatGLM_bot(input,history=history):
13
+ if input:
14
+ response,history = model.chat(tokenizer,input,history=history)
15
+ return response
16
+
17
+
18
+ inputs = Textbox(line=7,labels='่ฏท่พ“ๅ…ฅไฝ ็š„้—ฎ้ข˜')
19
+ outputs = Textbox(line=7,labels='ไธ‡่ƒฝAI็š„ๅ›ž็ญ”')
20
+
21
+
22
+ gr.Interface(fn=ChatGLM_bot,inputs=inputs,outputs=outputs,title='ไธ‡่ƒฝ็š„AIๅŠฉๆ‰‹',
23
+ description='ๆˆ‘ๆ˜ฏไธ‡่ƒฝ็š„AIๅŠฉๆ‰‹,ๆ‚จๅฏไปฅ้—ฎๆˆ‘ไปปไฝ•้—ฎ้ข˜',
24
+ theme=gr.themes.Default()).launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ protobuf transformers==4.27.1 cpm_kernels
2
+ sentencepiece