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

update chunk decode logic

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -76,7 +76,7 @@ def predict(inputs, top_p, temperature, openai_api_key, chat_counter, chatbot=[]
76
  if chunk.decode() :
77
  chunk = chunk.decode()
78
  # decode each line as response data is in bytes
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"]
 
76
  if chunk.decode() :
77
  chunk = chunk.decode()
78
  # decode each line as response data is in bytes
79
+ if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
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"]