Files
dsProject/dsLightRag/TeacherHelper/T1_DaoXueAn.py

56 lines
1.6 KiB
Python
Raw Normal View History

2025-09-04 15:24:38 +08:00
import asyncio
import logging
import os
import sys
# 导入教学辅助工具
from TeacherHelper.Kit.TeacherHelper import (
generate_gravitation_lesson_plan,
save_lesson_plan
)
# 配置日志
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# 测试生成导学案的函数
async def test_generate_lesson_plan():
print("\n===== 测试生成万有引力导学案 =====")
try:
# 调用教学辅助工具生成导学案
lesson_plan_chunks = await generate_gravitation_lesson_plan()
output_file = "./markdown/万有引力导学案.md"
# 调用教学辅助工具保存文件
print("\n生成的导学案:")
2025-09-04 15:30:56 +08:00
full_content, success = await save_lesson_plan(lesson_plan_chunks, output_file, stream_print=True)
2025-09-04 15:24:38 +08:00
if success:
print(full_content)
print(f"\n导学案已保存到:{os.path.abspath(output_file)}")
else:
print("\n导学案保存失败")
except Exception as e:
print(f"生成导学案时发生异常: {str(e)}", file=sys.stderr)
# 主函数
async def main():
try:
# 直接生成导学案,不进行交互式测试
await test_generate_lesson_plan()
except KeyboardInterrupt:
print("\n程序被用户中断")
except Exception as e:
print(f"测试过程中发生异常: {str(e)}", file=sys.stderr)
finally:
print("\n测试程序结束")
if __name__ == '__main__':
# 运行异步主函数
asyncio.run(main())