This commit is contained in:
2025-09-04 16:01:49 +08:00
parent 7c091a12d0
commit 8996b508a3
2 changed files with 69 additions and 16 deletions

View File

@@ -21,14 +21,23 @@ async def generate_gravitation_homework():
异步生成器: 流式返回作业内容
"""
# 系统指令 - 符合布鲁姆认知分类和双减政策
system_prompt = "你是命题专家,熟悉布鲁姆认知分类和'双减'政策。客观题采用'四选一'单选,难度比例易:中:难=6:3:1主观题设置2小问第1问'解释现象'对应'理解'第2问'方案设计'对应'创新'。题量控制为20分钟完成。"
system_prompt = "你是命题专家,熟悉布鲁姆认知分类和'双减'政策。你需要根据用户提供的题目材料来生成作业,而不是自己创造题目。客观题采用'四选一'单选,难度比例易:中:难=6:3:1主观题设置2小问第1问'解释现象'对应'理解'第2问'方案设计'对应'创新'。题量控制为20分钟完成。"
# 创建LLM客户端实例使用现有类
llm_client = LLMClient(system_prompt=system_prompt) # 修改为与T3_KeJian.py一致
# 读取题目材料 - 使用绝对路径
current_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(current_dir)
yunxiao_path = os.path.join(project_root, "static", "YunXiao.txt")
with open(yunxiao_path, "r", encoding="utf-8") as f:
question_material = f.read()
# 作业生成提示词
prompt = """输出'万有引力'课后作业满分100分
prompt = f"""根据以下'万有引力'相关题目材料,输出课后作业满分100分
A. 客观题8题×5分=40分
- 从提供的材料中选择题目,并按要求重新组织
- 前3题考'史实&概念'识记
- 中间3题考'公式变形&比例'理解
- 后2题考'情境估算'应用
@@ -38,6 +47,9 @@ B. 主观题2题30+30分
C. 评分标准主观题分点给分每点10分
D. 参考答案与解析(客观题给出选项+一句话解析;主观题给出关键公式与评分关键词)
以下是题目材料:
{question_material}
【格式要求】
### A. 客观题
<ul>
@@ -47,7 +59,7 @@ D. 参考答案与解析(客观题给出选项+一句话解析;主观题给
### B. 主观题
#### 1. ……
#### 2. ……
#### 2. ……
### C. 评分标准
……
@@ -70,7 +82,10 @@ async def test_generate_homework():
try:
# 修复添加await关键字获取生成器
homework_generator = await generate_gravitation_homework()
output_path = "./markdown/万有引力作业.md"
# 使用绝对路径保存文件
current_dir = os.path.dirname(os.path.abspath(__file__))
output_path = os.path.join(current_dir, "markdown", "万有引力作业.md")
# 修复正确调用save_lesson_plan函数使用位置参数而非关键字参数
full_content, success = await save_lesson_plan(