diff --git a/AI/Text2Sql/app.py b/AI/Text2Sql/app.py index 568b9a3a..fba6225f 100644 --- a/AI/Text2Sql/app.py +++ b/AI/Text2Sql/app.py @@ -1,3 +1,4 @@ +import asyncio import json import uuid from datetime import date, datetime @@ -187,7 +188,9 @@ async def get_docx_stream( # 记录到数据库 await db.execute("UPDATE t_bi_question SET docx_file_name = $1 WHERE id = $2", filename, question_id) - + except asyncio.CancelledError: + # 客户端提前断开连接,无需处理 + print("客户端断开连接") except Exception as e: # 如果发生异常,返回错误信息 error_response = json.dumps({ @@ -200,7 +203,7 @@ async def get_docx_stream( finally: # 确保资源释放 if "response" in locals(): - await response.aclose() + await response.close() # 使用 StreamingResponse 返回流式结果 return StreamingResponse( diff --git a/AI/Text2Sql/static/607c45d2-0472-43b5-8d5d-d899400bf60d.docx b/AI/Text2Sql/static/607c45d2-0472-43b5-8d5d-d899400bf60d.docx new file mode 100644 index 00000000..ff26648c Binary files /dev/null and b/AI/Text2Sql/static/607c45d2-0472-43b5-8d5d-d899400bf60d.docx differ diff --git a/AI/Text2Sql/static/93304d26-716b-4712-b0a3-07f4e0c4bb18.docx b/AI/Text2Sql/static/93304d26-716b-4712-b0a3-07f4e0c4bb18.docx new file mode 100644 index 00000000..1ab47133 Binary files /dev/null and b/AI/Text2Sql/static/93304d26-716b-4712-b0a3-07f4e0c4bb18.docx differ