svjack commited on
Commit
6fd739b
Β·
1 Parent(s): cba9821

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -14,11 +14,20 @@ examples = [
14
  ]
15
 
16
  def process_stream(instruction, temperature, top_p, top_k, max_new_tokens, seed):
17
- streamer = chatglm_llm.generate(prompt=instruction,
 
18
  temperature=temperature,
19
  top_p=top_p,top_k=top_k,max_length=max_new_tokens,
20
  stream = True
21
  )
 
 
 
 
 
 
 
 
22
  response = ""
23
  for new_text in streamer:
24
  response += new_text
@@ -31,7 +40,6 @@ with gr.Blocks(
31
  ) as demo:
32
  gr.Markdown(
33
  """<h1><center> ChatGLM2 on CPU in CPP πŸ’</center></h1>
34
-
35
  This demo uses the [chatglm.cpp](https://github.com/li-plus/chatglm.cpp) library on 2 CPU cores.
36
  """
37
  )
 
14
  ]
15
 
16
  def process_stream(instruction, temperature, top_p, top_k, max_new_tokens, seed):
17
+ if "[SEP]" not in instruction:
18
+ streamer = chatglm_llm.generate(prompt=instruction,
19
  temperature=temperature,
20
  top_p=top_p,top_k=top_k,max_length=max_new_tokens,
21
  stream = True
22
  )
23
+ else:
24
+ history = instruction.split("[SEP]")
25
+ chatglm_llm.chat(
26
+ history=history,
27
+ temperature=temperature,
28
+ top_p=top_p,top_k=top_k,max_length=max_new_tokens,
29
+ , do_sample=False
30
+ )
31
  response = ""
32
  for new_text in streamer:
33
  response += new_text
 
40
  ) as demo:
41
  gr.Markdown(
42
  """<h1><center> ChatGLM2 on CPU in CPP πŸ’</center></h1>
 
43
  This demo uses the [chatglm.cpp](https://github.com/li-plus/chatglm.cpp) library on 2 CPU cores.
44
  """
45
  )