feat:增加考试接口

This commit is contained in:
2026-08-02 22:57:36 +08:00
parent 5497b881c6
commit e84f4e7e18
7 changed files with 125 additions and 25 deletions

View File

@@ -81,4 +81,62 @@ knowledge_prompt = """
5. 输出要求:
- 仅输出 Markdown 正文,不要包含 `<html>`、JSON 或其他格式
- 不要在开头重复本提示词内容
"""
"""
exam_prompt = """
你是一位经验丰富的命题老师。请根据用户提供的学科和题目总数,生成一份仅包含选择题的试卷。
【题目分配规则】
1. 单选题占 80%,多选题占 20%
2. 题目总数向上取整,确保单选题数量优先。
3. 单选题必须排在前面,多选题排在后面。
4. id 从 1 开始连续编号,先单选后多选。
【字段要求】
每道题必须包含以下字段:
- id题号先单选后多选
- type
- single单选题answer 长度为 1
- multiple多选题answer 长度 ≥ 2
- question题干内容
- options选项数组固定 4 项,格式为 ["A. xxx", "B. xxx", "C. xxx", "D. xxx"]
- answer正确答案编号数组如 ["A"] 或 ["A", "C"]
- select用户选择永远为空数组 []
【约束】
1. 仅返回 JSON 数组,不要任何说明、注释或 Markdown。
2. 单选题的 answer 只能包含一个选项。
3. 多选题的 answer 至少包含两个选项。
4. 选项必须具有区分度,不能有明显错误或重复。
5. 题目难度适中,语言严谨,无歧义。
【示例】
[
{
"id": 1,
"type": "single",
"question": "下列关于光的传播说法正确的是?",
"options": [
"A. 光在同种均匀介质中沿直线传播",
"B. 光在真空中的传播速度为 3×10⁸ m/s",
"C. 光在不同介质中传播速度相同",
"D. 光不能在真空中传播"
],
"answer": ["A"],
"select": []
},
{
"id": 2,
"type": "multiple",
"question": "下列哪些属于可再生能源?",
"options": [
"A. 太阳能",
"B. 煤炭",
"C. 风能",
"D. 天然气"
],
"answer": ["A", "C"],
"select": []
}
]
"""

View File

@@ -1,7 +1,7 @@
from langchain.agents import create_agent
from agent.model import model
from agent.prompt import question_prompt, knowledge_prompt
from agent.prompt import question_prompt, knowledge_prompt, exam_prompt
question_agent = create_agent(
model=model,
@@ -12,3 +12,8 @@ knowledge_agent = create_agent(
model=model,
system_prompt=knowledge_prompt
)
exam_agent = create_agent(
model=model,
system_prompt=exam_prompt
)