优化多可选答案时的处理逻辑

This commit is contained in:
2026-05-22 13:14:29 +08:00
parent 48e9d0d4b2
commit c446bb6fd3
+8 -1
View File
@@ -162,7 +162,14 @@ def build_response_gapfill(task: TaskInfo) -> dict:
"""gapfill: 填空题 — 优先使用expectedResponse中的正确答案""" """gapfill: 填空题 — 优先使用expectedResponse中的正确答案"""
expected = task.expected_response.get("contents", {}).get("gapfill", {}) expected = task.expected_response.get("contents", {}).get("gapfill", {})
if expected: if expected:
return {"gapfill": expected} result = {}
for gid, gdata in expected.items():
user_input = gdata.get("userInput", "")
# 处理 "friendlier | more friendly" 多答案格式,取第一个
if " | " in user_input:
user_input = user_input.split(" | ")[0].strip()
result[gid] = {"id": gid, "userInput": user_input}
return {"gapfill": result}
# 回退:从task.detail获取gap列表, 填入空字符串 # 回退:从task.detail获取gap列表, 填入空字符串
gf = task.task_detail.get("gapfill", {}) gf = task.task_detail.get("gapfill", {})