Update networks/message_streamer.py
Browse files
networks/message_streamer.py
CHANGED
|
@@ -147,21 +147,22 @@ class MessageStreamer:
|
|
| 147 |
for line in stream_response.iter_lines():
|
| 148 |
if not line:
|
| 149 |
continue
|
| 150 |
-
|
| 151 |
content = self.parse_line(line)
|
| 152 |
-
|
| 153 |
-
if content.strip() == self.stop_sequences:
|
| 154 |
content_type = "Finished"
|
| 155 |
logger.success("\n[Finished]")
|
| 156 |
is_finished = True
|
| 157 |
else:
|
| 158 |
content_type = "Completions"
|
| 159 |
logger.back(content, end="")
|
| 160 |
-
|
| 161 |
output = self.message_outputer.output(
|
| 162 |
content=content, content_type=content_type
|
| 163 |
)
|
| 164 |
yield output
|
| 165 |
-
|
| 166 |
if not is_finished:
|
| 167 |
yield self.message_outputer.output(content="", content_type="Finished")
|
|
|
|
|
|
| 147 |
for line in stream_response.iter_lines():
|
| 148 |
if not line:
|
| 149 |
continue
|
| 150 |
+
|
| 151 |
content = self.parse_line(line)
|
| 152 |
+
|
| 153 |
+
if content is not None and content.strip() == self.stop_sequences:
|
| 154 |
content_type = "Finished"
|
| 155 |
logger.success("\n[Finished]")
|
| 156 |
is_finished = True
|
| 157 |
else:
|
| 158 |
content_type = "Completions"
|
| 159 |
logger.back(content, end="")
|
| 160 |
+
|
| 161 |
output = self.message_outputer.output(
|
| 162 |
content=content, content_type=content_type
|
| 163 |
)
|
| 164 |
yield output
|
| 165 |
+
|
| 166 |
if not is_finished:
|
| 167 |
yield self.message_outputer.output(content="", content_type="Finished")
|
| 168 |
+
|