Spaces:
Runtime error
Runtime error
update chunk extraction code
Browse files
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) >
|
| 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"]
|
|
|
|
| 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.decode()[6:])['choices'][0]["delta"]["content"]
|