This commit is contained in:
2025-09-05 07:05:22 +08:00
parent e5fbdcc76b
commit 4dc5554c0c
6 changed files with 7 additions and 4 deletions

View File

@@ -70,18 +70,17 @@ async def generate_dao_xue_an(request: Request):
try:
yield "data: 正在转换为Word文档...\n\n"
# 执行Pandoc命令
# 恢复Pandoc转换执行代码
result = subprocess.run(
["pandoc", temp_md_path, "-o", docx_path],
capture_output=True,
text=True,
check=True
)
# 清理临时文件
os.unlink(temp_md_path)
logger.info(f"导学案已转换为Word文档: {docx_path}")
# 添加转换完成状态提示
yield "data: Word文档转换完成准备下载...\n\n"
# 修改下载链接为静态文件路径
yield f"data: [下载链接] /static/teacherHelpergenerated_files/{docx_filename}\n\n"
except subprocess.CalledProcessError as e:

View File

@@ -40,11 +40,15 @@ class LLMClient:
if chunk and chunk.choices and len(chunk.choices) > 0:
delta = chunk.choices[0].delta
if delta and delta.content and delta.content.strip():
# 添加控制台打印输出
print(f"[LLM Stream] 接收到内容片段: {delta.content.strip()}")
yield delta.content
else:
if completion and completion.choices and len(completion.choices) > 0:
message = completion.choices[0].message
if message and message.content and message.content.strip():
# 添加控制台打印输出
print(f"[LLM Response] 接收到完整内容: {message.content.strip()[:100]}...") # 仅打印前100字符
yield message.content
except Exception as e: