robert commited on
Commit
c88df11
1 Parent(s): c42ac02

Refactoring the model to be a function not a generator

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -77,10 +77,14 @@ def spaces_model_predict(message: str, history: list[tuple[str, str]]):
77
  t = Thread(target=model.generate, kwargs=generate_kwargs)
78
  t.start()
79
 
80
- partial_message = ""
81
  for new_token in streamer:
82
- partial_message += new_token
83
- yield partial_message
 
 
 
 
84
 
85
 
86
  def predict(
 
77
  t = Thread(target=model.generate, kwargs=generate_kwargs)
78
  t.start()
79
 
80
+ generated_text = ""
81
  for new_token in streamer:
82
+ generated_text += new_token
83
+ if "<|user|>" in generated_text:
84
+ generated_text = generated_text.split("<|user|>")[0].strip()
85
+ break
86
+
87
+ return generated_text
88
 
89
 
90
  def predict(