Skip to content

Commit 660ea0a

Browse files
committed
fix the format issue
1 parent 9cc572f commit 660ea0a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fastchat/serve/api_provider.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,21 +1326,25 @@ def bailing_api_stream_iter(
13261326
curr_buf += new_buf
13271327
while True:
13281328
x_part = curr_buf.split("\n\n", 1)
1329-
if len(x_part) > 1: # part can be sent
1330-
y_part = x_part[0][len("data:"):].strip()
1329+
if len(x_part) > 1: # part can be sent
1330+
y_part = x_part[0][len("data:") :].strip()
13311331
try:
13321332
y = json.loads(y_part)
13331333
output_text = y["choices"][0]["delta"]["content"]
13341334
except Exception as e:
1335-
curr_buf = x_part[1] # finish one response
1336-
logger.error(f"Read the error content. Content: {y_part}, Info:{e}")
1335+
curr_buf = x_part[1] # finish one response
1336+
logger.error(
1337+
f"Read the error content. Content: {y_part}, Info:{e}"
1338+
)
13371339
continue # skip current part
13381340
total_text += output_text
1339-
curr_buf = x_part[1] # finish one response and look to leftover
1341+
curr_buf = x_part[
1342+
1
1343+
] # finish one response and look to leftover
13401344
yield {"text": total_text, "error_code": 0}
1341-
else: # no part can be sent and continue to read
1345+
else: # no part can be sent and continue to read
13421346
break
1343-
return # finish the total
1347+
return # finish the total
13441348
else:
13451349
logger.error(
13461350
f"Error occurs and retry if possible. status_code={resp.status_code}"

0 commit comments

Comments
 (0)