Update networks/openai_streamer.py
Browse files
networks/openai_streamer.py
CHANGED
@@ -65,6 +65,7 @@ class OpenaiRequester:
|
|
65 |
logger.success("\n[Finished]")
|
66 |
break
|
67 |
line = line.strip()
|
|
|
68 |
if line:
|
69 |
try:
|
70 |
data = json.loads(line, strict=False)
|
@@ -205,6 +206,7 @@ class OpenaiStreamer:
|
|
205 |
line = line.decode("utf-8")
|
206 |
line = re.sub(r"^data:\s*", "", line)
|
207 |
line = line.strip()
|
|
|
208 |
|
209 |
if not line:
|
210 |
continue
|
@@ -215,6 +217,7 @@ class OpenaiStreamer:
|
|
215 |
logger.success("\n[Finished]")
|
216 |
is_finished = True
|
217 |
else:
|
|
|
218 |
content_type = "Completions"
|
219 |
delta_content = ""
|
220 |
try:
|
@@ -253,6 +256,7 @@ class OpenaiStreamer:
|
|
253 |
]
|
254 |
final_content = ""
|
255 |
for item in self.chat_return_generator(stream_response):
|
|
|
256 |
try:
|
257 |
data = json.loads(item)
|
258 |
delta = data["choices"][0]["delta"]
|
|
|
65 |
logger.success("\n[Finished]")
|
66 |
break
|
67 |
line = line.strip()
|
68 |
+
print(line)
|
69 |
if line:
|
70 |
try:
|
71 |
data = json.loads(line, strict=False)
|
|
|
206 |
line = line.decode("utf-8")
|
207 |
line = re.sub(r"^data:\s*", "", line)
|
208 |
line = line.strip()
|
209 |
+
print(line)
|
210 |
|
211 |
if not line:
|
212 |
continue
|
|
|
217 |
logger.success("\n[Finished]")
|
218 |
is_finished = True
|
219 |
else:
|
220 |
+
print(line)
|
221 |
content_type = "Completions"
|
222 |
delta_content = ""
|
223 |
try:
|
|
|
256 |
]
|
257 |
final_content = ""
|
258 |
for item in self.chat_return_generator(stream_response):
|
259 |
+
print(item)
|
260 |
try:
|
261 |
data = json.loads(item)
|
262 |
delta = data["choices"][0]["delta"]
|