'commit'
This commit is contained in:
@@ -52,8 +52,8 @@ class LLMClient:
|
||||
yield f"处理请求时发生异常: {str(e)}"
|
||||
|
||||
|
||||
async def save_lesson_plan(content_chunks, output_file):
|
||||
"""异步保存导学案内容到文件"""
|
||||
async def save_lesson_plan(content_chunks, output_file, stream_print=False):
|
||||
"""异步保存教案内容到文件,支持实时打印"""
|
||||
try:
|
||||
output_dir = os.path.dirname(output_file)
|
||||
if output_dir and not os.path.exists(output_dir):
|
||||
@@ -66,12 +66,15 @@ async def save_lesson_plan(content_chunks, output_file):
|
||||
full_content.append(chunk)
|
||||
await f.write(chunk)
|
||||
await f.flush()
|
||||
# 实时打印输出内容
|
||||
if stream_print:
|
||||
print(chunk, end='', flush=True)
|
||||
|
||||
logger.info(f"导学案已保存到: {os.path.abspath(output_file)}")
|
||||
logger.info(f"教案已保存到: {os.path.abspath(output_file)}")
|
||||
return ''.join(full_content), True
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"保存导学案失败: {str(e)}")
|
||||
logger.error(f"保存教案失败: {str(e)}")
|
||||
return None, False
|
||||
|
||||
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user