Spaces:
Running
Running
jonathanjordan21
commited on
Commit
•
357c5ed
1
Parent(s):
1fcd6c7
Update networks/huggingface_streamer.py
Browse files
networks/huggingface_streamer.py
CHANGED
@@ -203,7 +203,19 @@ class HuggingfaceStreamer:
|
|
203 |
output = self.message_outputer.output(
|
204 |
content=content, content_type=content_type
|
205 |
)
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
if not is_finished:
|
209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
output = self.message_outputer.output(
|
204 |
content=content, content_type=content_type
|
205 |
)
|
206 |
+
|
207 |
+
output = json.loads(output.split('data: ')[1])
|
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 json.dumps(output)
|
213 |
|
214 |
if not is_finished:
|
215 |
+
final_output = self.message_outputer.output(content="", content_type="Finished").split('data: ')[1]
|
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 json.dumps(final_output)
|
221 |
+
# yield self.message_outputer.output(content="", content_type="Finished").split('data: ')[1]
|