ysharma HF staff commited on
Commit
df2fe5f
1 Parent(s): cee8055

update streaming code for using chunks

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -79,7 +79,7 @@ def predict(inputs, top_p, temperature, openai_api_key, chat_counter, chatbot=[]
79
  if len(chunk) > 12 and "delta" in json.loads(chunk[6:])['choices'][0]:
80
  #if len(json.loads(chunk.decode()[6:])['choices'][0]["delta"]) == 0:
81
  # break
82
- partial_words = partial_words + json.loads(chunk.decode()[6:])['choices'][0]["delta"]["content"]
83
  if token_counter == 0:
84
  history.append(" " + partial_words)
85
  else:
 
79
  if len(chunk) > 12 and "delta" in json.loads(chunk[6:])['choices'][0]:
80
  #if len(json.loads(chunk.decode()[6:])['choices'][0]["delta"]) == 0:
81
  # break
82
+ partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
83
  if token_counter == 0:
84
  history.append(" " + partial_words)
85
  else: