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 b966be5417
commit a31ee4bba0
8 changed files with 475 additions and 75 deletions

View File

@@ -154,7 +154,8 @@ def generate_questions_from_file(
def analyze_file_for_exam(
file_path: str,
collection: str,
top_k: int = 50
top_k: int = 50,
max_total: int = None
) -> Dict[str, Any]:
"""
分析文件内容,返回 AI 推荐的题型和数量
@@ -193,7 +194,7 @@ def analyze_file_for_exam(
}
# 2. 调用 AI 分析
return analyze_document_for_exam(chunks)
return analyze_document_for_exam(chunks, max_total=max_total)
def retrieve_file_chunks_for_analysis(
@@ -311,6 +312,7 @@ def retrieve_file_chunks(
engine = get_engine()
# 按优先级遍历 collections找到文件即停止
results = None
for coll in collections:
# 尝试两种格式:文件名和完整路径
for source_filter in [filename, file_path]:
@@ -330,7 +332,7 @@ def retrieve_file_chunks(
break # 外层循环跳出
chunks = []
if results.get('documents') and results['documents'][0]:
if results and results.get('documents') and results['documents'][0]:
for i, (doc, meta, score) in enumerate(zip(
results['documents'][0],
results['metadatas'][0],