Commit 78ed5c19 by 潘诗林

fix:大模型解析优化

1 parent 87abdb57
......@@ -286,7 +286,7 @@ public class PreLearnBigModelService {
public void pollTaskResults() {
log.info("pollTaskResults: 开始轮询大模型任务结果");
List<PreLearnProductScript> pendingList = preLearnProductScriptMapper
.selectPendingPolling(AiStatusEnum.GENERATING.getValue(), 20);
.selectPendingPolling(AiStatusEnum.GENERATING.getValue(), 50);
if (CollectionUtils.isEmpty(pendingList)) {
log.info("pollTaskResults: 无待轮询的记录");
......@@ -308,21 +308,47 @@ public class PreLearnBigModelService {
TaskQueryResult result = queryTaskResult(script.getModelTaskId());
if (result.isCompleted()) {
// 成功: 写入response_content,更新状态为READY
preLearnProductScriptMapper.updateScriptReady(
script.getId(),
result.getScriptJson(),
"READY");
log.info("pollTaskResults: 剧本生成成功, scriptId={}, taskId={}",
script.getId(), script.getModelTaskId());
readyCount++;
// 检查 scriptJson 外层的 is_legal 字段
boolean isLegal = false;
String legalMsg = null;
if (StringUtils.hasText(result.getScriptJson())) {
try {
JSONObject outerJson = JSONObject.parseObject(result.getScriptJson());
if (outerJson.containsKey("is_legal") && outerJson.getBooleanValue("is_legal")) {
isLegal = true;
legalMsg = outerJson.getString("msg");
}
} catch (Exception e) {
log.warn("pollTaskResults: 解析is_legal失败, scriptId={}", script.getId(), e);
}
}
if (isLegal) {
// 合法: 写入response_content,更新状态为READY
preLearnProductScriptMapper.updateScriptReady(
script.getId(),
result.getScriptJson(),
AiStatusEnum.READY.getValue());
log.info("pollTaskResults: 剧本生成成功, scriptId={}, taskId={}",
script.getId(), script.getModelTaskId());
readyCount++;
} else {
// is_legal=false: 标记为FAILED,记录msg
preLearnProductScriptMapper.updateScriptFailed(
script.getId(),
legalMsg,
AiStatusEnum.FAILED.getValue());
log.warn("pollTaskResults: 剧本不合法, scriptId={}, taskId={}, msg={}",
script.getId(), script.getModelTaskId(), legalMsg);
failedCount++;
}
} else if (result.isFailed()) {
// 失败: 写入error_msg,更新状态为FAILED
// 大模型调用失败: 写入error_msg,更新状态为FAILED
preLearnProductScriptMapper.updateScriptFailed(
script.getId(),
result.getErrorMsg(),
"FAILED");
AiStatusEnum.FAILED.getValue());
log.warn("pollTaskResults: 剧本生成失败, scriptId={}, taskId={}, error={}",
script.getId(), script.getModelTaskId(), result.getErrorMsg());
failedCount++;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!