XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

fix(api): prevent emitting false DONE frame after mid-stream streaming exceptions

a51fc0b4
Anand Mall <anand@example.com>
提交于

代码差异

1 个文件 +6 -0
Modified g4f/api/__init__.py +6 -0
@@ -961,9 +961,11 @@ class Api:
961 961 except RateLimitError as e:
962 962 debug.error(e)
963 963 yield f"data: {format_exception(e, config)}\n\n"
964 return
964 965 except Exception as e:
965 966 logger.exception(e)
966 967 yield f"data: {format_exception(e, config)}\n\n"
968 return
967 969 finally:
968 970 if hasattr(response, "aclose"):
969 971 try:
@@ -1111,9 +1113,11 @@ class Api:
1111 1113 except RateLimitError as e:
1112 1114 debug.error(e)
1113 1115 yield f"data: {format_exception(e, config)}\n\n"
1116 return
1114 1117 except Exception as e:
1115 1118 logger.exception(e)
1116 1119 yield f"data: {format_exception(e, config)}\n\n"
1120 return
1117 1121 finally:
1118 1122 if hasattr(response, "aclose"):
1119 1123 try:
@@ -1265,9 +1269,11 @@ class Api:
1265 1269 except RateLimitError as e:
1266 1270 debug.error(e)
1267 1271 yield f"data: {format_exception(e, config)}\n\n"
1272 return
1268 1273 except Exception as e:
1269 1274 logger.exception(e)
1270 1275 yield f"data: {format_exception(e, config)}\n\n"
1276 return
1271 1277 finally:
1272 1278 if hasattr(response, "aclose"):
1273 1279 try: