None1145 commited on
Commit
b221f27
·
verified ·
1 Parent(s): b3068c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -26,7 +26,7 @@ model = f"./Models/{repo_id}/{filename}"
26
  max_length = 8192
27
  pipeline = chatglm_cpp.Pipeline(model, max_length=max_length)
28
 
29
- # messages = []
30
 
31
  def respond(
32
  message,
@@ -36,9 +36,9 @@ def respond(
36
  temperature,
37
  top_p,
38
  ):
39
- # global messages
40
 
41
- # print(messages)
42
 
43
  generation_kwargs = dict(
44
  max_length=max_length,
@@ -51,8 +51,8 @@ def respond(
51
  stream=True,
52
  )
53
 
54
- # if messages == []:
55
- messages = [chatglm_cpp.ChatMessage(role="system", content=system_message)]
56
 
57
  print(messages)
58
 
@@ -64,15 +64,18 @@ def respond(
64
 
65
  messages.append(chatglm_cpp.ChatMessage(role="user", content=message))
66
 
 
 
67
  response = ""
68
  yield response
69
  chunks = []
 
70
 
71
  for chunk in pipeline.chat(messages, **generation_kwargs):
72
  response += chunk.content
73
  chunks.append(chunk)
74
  yield response
75
-
76
  messages.append(chatglm_cpp.ChatMessage(role="assistant", content=response))
77
 
78
  print(messages)
 
26
  max_length = 8192
27
  pipeline = chatglm_cpp.Pipeline(model, max_length=max_length)
28
 
29
+ messages = []
30
 
31
  def respond(
32
  message,
 
36
  temperature,
37
  top_p,
38
  ):
39
+ global messages
40
 
41
+ print(messages)
42
 
43
  generation_kwargs = dict(
44
  max_length=max_length,
 
51
  stream=True,
52
  )
53
 
54
+ if messages == []:
55
+ messages = [chatglm_cpp.ChatMessage(role="system", content=system_message)]
56
 
57
  print(messages)
58
 
 
64
 
65
  messages.append(chatglm_cpp.ChatMessage(role="user", content=message))
66
 
67
+ print(messages)
68
+
69
  response = ""
70
  yield response
71
  chunks = []
72
+ yield response
73
 
74
  for chunk in pipeline.chat(messages, **generation_kwargs):
75
  response += chunk.content
76
  chunks.append(chunk)
77
  yield response
78
+ yield response
79
  messages.append(chatglm_cpp.ChatMessage(role="assistant", content=response))
80
 
81
  print(messages)