ArmelR commited on
Commit
a233551
·
1 Parent(s): cda134b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -116,23 +116,30 @@ def generate(
116
 
117
  output = ""
118
  previous_token = ""
119
- #t = 0
120
  for response in stream:
121
- #print(f"IN_{t}")
122
  if (
123
  (response.token.text in ["Human", "-----", "Question:"] and previous_token in ["\n", "-----"])
124
  or response.token.text in ["<|endoftext|>", "<|end|>"]
125
  ):
126
- print("OUT = "+str(output))
127
  return wrap_html_code(output.strip())
128
  else:
129
  output += response.token.text
130
- #print(f"Out_{t} : {output}")
131
- #t += 1
132
  previous_token = response.token.text
133
- print("Output = "+str(output))
134
  return wrap_html_code(output.strip())
135
-
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
  # chatbot mode
138
  def user(user_message, history):
 
116
 
117
  output = ""
118
  previous_token = ""
119
+ """
120
  for response in stream:
 
121
  if (
122
  (response.token.text in ["Human", "-----", "Question:"] and previous_token in ["\n", "-----"])
123
  or response.token.text in ["<|endoftext|>", "<|end|>"]
124
  ):
 
125
  return wrap_html_code(output.strip())
126
  else:
127
  output += response.token.text
 
 
128
  previous_token = response.token.text
 
129
  return wrap_html_code(output.strip())
130
+ """
131
+ for idx, response in enumerate(stream) :
132
+ if response.token.special :
133
+ continue
134
+ if (
135
+ (response.token.text in ["Human", "-----", "Question:"] and previous_token in ["\n", "-----"])
136
+ or response.token.text in ["<|endoftext|>", "<|end|>"]
137
+ ):
138
+ break
139
+ else :
140
+ output += response.token.text
141
+ previous_token = response.token.text
142
+ yield wrap_html_code(output.strip())
143
 
144
  # chatbot mode
145
  def user(user_message, history):