wannaphong commited on
Commit
0cbbcf0
1 Parent(s): 92b1747

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -102,9 +102,14 @@ def respond(
102
  stream = llm.create_chat_completion(messages=messages,temperature = temperature,top_k = top_k,top_p = top_p,min_p = min_p,max_tokens = max_tokens,repeat_penalty = repeat_penalty,stream = True)
103
 
104
  outputs = ""
105
- for output in stream:
106
- outputs += output
107
- yield outputs.replace("<|assistant|>","").replace("<|user|>","")
 
 
 
 
 
108
 
109
  description = """
110
  """
 
102
  stream = llm.create_chat_completion(messages=messages,temperature = temperature,top_k = top_k,top_p = top_p,min_p = min_p,max_tokens = max_tokens,repeat_penalty = repeat_penalty,stream = True)
103
 
104
  outputs = ""
105
+ for chunk in stream:
106
+ delta = chunk['choices'][0]['delta']
107
+ if 'content' in delta:
108
+ tokens = delta['content'].split()
109
+ for token in tokens:
110
+ yield token
111
+
112
+ #yield outputs.replace("<|assistant|>","").replace("<|user|>","")
113
 
114
  description = """
115
  """