From 15efa4cb1eb23ca1920cefaca26ea6c25f6f3599 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Sun, 29 Jun 2025 10:49:07 +0800 Subject: [PATCH] 'commit' --- dsRag/Start.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dsRag/Start.py b/dsRag/Start.py index ce4a4ea6..71540369 100644 --- a/dsRag/Start.py +++ b/dsRag/Start.py @@ -87,14 +87,14 @@ async def save_to_word(request: Request): logger.error(f"Request parsing failed: {str(e)}") raise HTTPException(status_code=400, detail=f"Invalid request: {str(e)}") - # 创建临时HTML文件 - temp_html = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex + ".html") - with open(temp_html, "w", encoding="utf-8") as f: + # 创建临时Markdown文件 + temp_md = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex + ".md") + with open(temp_md, "w", encoding="utf-8") as f: f.write(html_content) # 使用pandoc转换 output_file = os.path.join(tempfile.gettempdir(), "【理想大模型】问答.docx") - subprocess.run(['pandoc', temp_html, '-o', output_file,'--resource-path=static'], check=True) + subprocess.run(['pandoc', temp_md, '-o', output_file,'--resource-path=static'], check=True) # 读取生成的Word文件 with open(output_file, "rb") as f: @@ -115,8 +115,8 @@ async def save_to_word(request: Request): finally: # 清理临时文件 try: - if temp_html and os.path.exists(temp_html): - os.remove(temp_html) + if temp_md and os.path.exists(temp_md): + os.remove(temp_md) if output_file and os.path.exists(output_file): os.remove(output_file) except Exception as e: