duxb commited on
Commit
b1d56c1
1 Parent(s): 020bf57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import json
4
  model_path = 'THUDM/chatglm-6b'
5
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
6
- model = AutoModel.from_pretrained(model_path, trust_remote_code=True).half().float()
7
  model = model.eval()
8
 
9
  MAX_TURNS = 20
@@ -34,9 +34,9 @@ with gr.Blocks() as demo:
34
  text_boxes = []
35
  for i in range(MAX_BOXES):
36
  if i % 2 == 0:
37
- text_boxes.append(gr.Text(visible=False, label="提问:"))
38
  else:
39
- text_boxes.append(gr.Text(visible=False, label="回复:"))
40
 
41
  with gr.Row():
42
  with gr.Column(scale=4):
@@ -46,7 +46,6 @@ with gr.Blocks() as demo:
46
  max_length = gr.Slider(0, 4096, value=2048, step=1.0, label="Maximum length", interactive=True)
47
  top_p = gr.Slider(0, 1, value=0.7, step=0.01, label="Top P", interactive=True)
48
  temperature = gr.Slider(0, 1, value=0.95, step=0.01, label="Temperature", interactive=True)
49
- history = gr.TextArea(visible=False)
50
  button = gr.Button("Generate")
51
- button.click(predict, [txt, max_length, top_p, temperature, history, state], [state] + text_boxes, queue=True)
52
- demo.queue(concurrency_count=10).launch(enable_queue=True, max_threads=2)
 
3
  import json
4
  model_path = 'THUDM/chatglm-6b'
5
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
6
+ model = AutoModel.from_pretrained(model_path, trust_remote_code=True).bfloat16()
7
  model = model.eval()
8
 
9
  MAX_TURNS = 20
 
34
  text_boxes = []
35
  for i in range(MAX_BOXES):
36
  if i % 2 == 0:
37
+ text_boxes.append(gr.Markdown(visible=False, label="提问:"))
38
  else:
39
+ text_boxes.append(gr.Markdown(visible=False, label="回复:"))
40
 
41
  with gr.Row():
42
  with gr.Column(scale=4):
 
46
  max_length = gr.Slider(0, 4096, value=2048, step=1.0, label="Maximum length", interactive=True)
47
  top_p = gr.Slider(0, 1, value=0.7, step=0.01, label="Top P", interactive=True)
48
  temperature = gr.Slider(0, 1, value=0.95, step=0.01, label="Temperature", interactive=True)
 
49
  button = gr.Button("Generate")
50
+ button.click(predict, [txt, max_length, top_p, temperature, state], [state] + text_boxes)
51
+ demo.queue().launch(share=True, inbrowser=True)