diff --git a/AI/Text2Sql/__pycache__/app.cpython-310.pyc b/AI/Text2Sql/__pycache__/app.cpython-310.pyc index 2e2b081c..3b103c15 100644 Binary files a/AI/Text2Sql/__pycache__/app.cpython-310.pyc and b/AI/Text2Sql/__pycache__/app.cpython-310.pyc differ diff --git a/AI/Text2Sql/app.py b/AI/Text2Sql/app.py index c09ac32a..77e3e1b0 100644 --- a/AI/Text2Sql/app.py +++ b/AI/Text2Sql/app.py @@ -127,7 +127,6 @@ async def get_docx_stream( chunk_content = chunk.choices[0].delta.content # 逐字拆分并返回 for char in chunk_content: - # print(char, end="", flush=True) # 逐字输出到控制台 yield char.encode("utf-8") # 将字符编码为 UTF-8 字节 summary += char # 将内容拼接到 summary 中 @@ -136,14 +135,15 @@ async def get_docx_stream( # 记录到数据库 update_question_by_id(db, question_id, docx_file_name=filename) + except Exception as e: # 如果发生异常,返回错误信息 error_response = json.dumps({ "success": False, "message": f"生成Word文件失败: {str(e)}" }) - # print(error_response) # 输出错误信息到控制台 yield error_response.encode("utf-8") # 将错误信息编码为 UTF-8 字节 + finally: # 确保资源释放 if "response" in locals(): @@ -156,6 +156,7 @@ async def get_docx_stream( headers={ "Cache-Control": "no-cache", # 禁用缓存 "Content-Type": "text/plain; charset=utf-8", # 设置内容类型和字符编码 + "X-Accel-Buffering": "no", # 禁用 Nginx 缓冲(如果使用 Nginx) } ) diff --git a/AI/Text2Sql/static/56248468-d0b4-4d9e-b1fe-d70f97b035ab.docx b/AI/Text2Sql/static/56248468-d0b4-4d9e-b1fe-d70f97b035ab.docx new file mode 100644 index 00000000..90b12641 Binary files /dev/null and b/AI/Text2Sql/static/56248468-d0b4-4d9e-b1fe-d70f97b035ab.docx differ diff --git a/AI/Text2Sql/static/7407dc92-bf0d-414b-92e2-ec5f94fe1245.docx b/AI/Text2Sql/static/7407dc92-bf0d-414b-92e2-ec5f94fe1245.docx new file mode 100644 index 00000000..6685308c Binary files /dev/null and b/AI/Text2Sql/static/7407dc92-bf0d-414b-92e2-ec5f94fe1245.docx differ diff --git a/AI/Text2Sql/static/d400befe-fc40-46d9-87ef-6c683fd1d3de.docx b/AI/Text2Sql/static/d400befe-fc40-46d9-87ef-6c683fd1d3de.docx new file mode 100644 index 00000000..7b8e1c43 Binary files /dev/null and b/AI/Text2Sql/static/d400befe-fc40-46d9-87ef-6c683fd1d3de.docx differ diff --git a/AI/Text2Sql/static/e49095c7-518f-41e2-b820-a87732f4f6b1.docx b/AI/Text2Sql/static/e49095c7-518f-41e2-b820-a87732f4f6b1.docx new file mode 100644 index 00000000..de6b82cf Binary files /dev/null and b/AI/Text2Sql/static/e49095c7-518f-41e2-b820-a87732f4f6b1.docx differ diff --git a/AI/Text2Sql/static/e9761842-cffd-458f-b78d-cb4a25e99a8c.docx b/AI/Text2Sql/static/e9761842-cffd-458f-b78d-cb4a25e99a8c.docx new file mode 100644 index 00000000..7312b638 Binary files /dev/null and b/AI/Text2Sql/static/e9761842-cffd-458f-b78d-cb4a25e99a8c.docx differ diff --git a/AI/Text2Sql/static/ec7ae951-1e3b-4481-bbeb-538979232140.docx b/AI/Text2Sql/static/ec7ae951-1e3b-4481-bbeb-538979232140.docx new file mode 100644 index 00000000..5a6c9c0a Binary files /dev/null and b/AI/Text2Sql/static/ec7ae951-1e3b-4481-bbeb-538979232140.docx differ