feat(exam_pkg): 优化出题系统稳定性与推理模型适配

- core/llm_utils: MiMo模型自动注入thinking=disabled参数,全局生效
- config: 新增LLM_DISABLE_THINKING配置项(默认true)
- generator: 推理模型自适应max_tokens(1.5x)、429限流重试+指数退避、v2管线补题机制
- generator: analyze_document_for_exam新增max_total参数控制AI出题上限
- generator: validate_questions_schema兼容type和question_type字段
- grader: 主观题max_tokens从1000提升至2000、fuzzy_match增加编辑距离容错
- manager: results变量初始化防NameError、透传max_total参数
- api: /exam/generate-smart支持max_total请求参数
This commit is contained in:
lacerate551
2026-06-22 18:51:11 +08:00
parent d589c27bce
commit 5ccfdaf9d1
6 changed files with 462 additions and 66 deletions

View File

@@ -210,6 +210,7 @@ def api_generate_smart():
"file_path": "public/产品手册.pdf",
"collection": "public_kb",
"difficulty": 3, // 可选,默认 3
"max_total": 20, // 可选AI出题总数上限。不传则不限制
"options": {} // 可选
}
@@ -231,6 +232,16 @@ def api_generate_smart():
if diff_error:
return error_response("INVALID_PARAMS", BAD_REQUEST, diff_error, http_status=400)
# 可选AI出题总数上限不传则不限制
max_total = data.get('max_total')
if max_total is not None:
try:
max_total = int(max_total)
if max_total <= 0:
return error_response("INVALID_PARAMS", BAD_REQUEST, "max_total 必须为正整数", http_status=400)
except (ValueError, TypeError):
return error_response("INVALID_PARAMS", BAD_REQUEST, "max_total 必须为整数", http_status=400)
# 校验排除题干列表(可选)
exclude_stems = data.get('exclude_stems')
stems_error = validate_exclude_stems(exclude_stems)
@@ -255,7 +266,8 @@ def api_generate_smart():
from exam_pkg.manager import analyze_file_for_exam
ai_analysis = analyze_file_for_exam(
file_path=file_path,
collection=collection
collection=collection,
max_total=max_total
)
question_types = ai_analysis.get('question_types', {})