Spaces:
Runtime error
Runtime error
Update networks/huggingface_streamer.py
Browse files
networks/huggingface_streamer.py
CHANGED
|
@@ -204,18 +204,18 @@ class HuggingfaceStreamer:
|
|
| 204 |
content=content, content_type=content_type
|
| 205 |
)
|
| 206 |
|
| 207 |
-
output = json.loads(output
|
| 208 |
print("OUTPUT OLLAMA STREAMER", output)
|
| 209 |
output['repsonse'] = output['choices'][-1]['delta'].get('content')
|
| 210 |
output['done'] = output['choices'][-1].get('finish_reason')
|
| 211 |
output['created_at'] = output.get('created')
|
| 212 |
-
yield
|
| 213 |
|
| 214 |
if not is_finished:
|
| 215 |
-
final_output = self.message_outputer.output(content="", content_type="Finished")
|
| 216 |
final_output = json.loads(final_output)
|
| 217 |
final_output = final_output['choices'][-1]['delta'].get('content')
|
| 218 |
final_output['done'] = output['choices'][-1].get('finish_reason')
|
| 219 |
final_output['created_at'] = final_output.get('created')
|
| 220 |
-
yield
|
| 221 |
# yield self.message_outputer.output(content="", content_type="Finished").split('data: ')[1]
|
|
|
|
| 204 |
content=content, content_type=content_type
|
| 205 |
)
|
| 206 |
|
| 207 |
+
output = json.loads(output)
|
| 208 |
print("OUTPUT OLLAMA STREAMER", output)
|
| 209 |
output['repsonse'] = output['choices'][-1]['delta'].get('content')
|
| 210 |
output['done'] = output['choices'][-1].get('finish_reason')
|
| 211 |
output['created_at'] = output.get('created')
|
| 212 |
+
yield output
|
| 213 |
|
| 214 |
if not is_finished:
|
| 215 |
+
final_output = self.message_outputer.output(content="", content_type="Finished")
|
| 216 |
final_output = json.loads(final_output)
|
| 217 |
final_output = final_output['choices'][-1]['delta'].get('content')
|
| 218 |
final_output['done'] = output['choices'][-1].get('finish_reason')
|
| 219 |
final_output['created_at'] = final_output.get('created')
|
| 220 |
+
yield final_output
|
| 221 |
# yield self.message_outputer.output(content="", content_type="Finished").split('data: ')[1]
|