fix: 重试成功后清空执行记录中的旧报错信息

This commit is contained in:
2026-08-21 10:56:31 +08:00
parent cef837a35c
commit 9bc388018b
5 changed files with 62 additions and 1 deletions
+15
View File
@@ -35,6 +35,21 @@ func (d *execChatDao) Update(ctx context.Context, req *sessionDto.UpdateExecChat
return r.RowsAffected()
}
// ClearError 清空对话执行记录的报错信息(重新执行成功后调用,OmitEmpty 的 Update 会跳过空串,需显式写空)
func (d *execChatDao) ClearError(ctx context.Context, id int64) (rows int64, err error) {
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameExecChat).
Where(entity.ExecChatCol.Id, id).
Data(map[string]any{
entity.ExecChatCol.ErrorMessage: "",
entity.ExecChatCol.Error: "",
}).
Update()
if err != nil {
return
}
return r.RowsAffected()
}
func (d *execChatDao) Delete(ctx context.Context, req *sessionDto.DeleteExecChatReq) (rows int64, err error) {
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameExecChat).Where(entity.ExecChatCol.Id, req.Id).Delete()
if err != nil {
+15
View File
@@ -43,6 +43,21 @@ func (d *execWorkflowDao) Update(ctx context.Context, req *sessionDto.UpdateWork
return r.RowsAffected()
}
// ClearError 清空执行记录的报错信息(重新执行成功后调用,OmitEmpty 的 Update 会跳过空串,需显式写空)
func (d *execWorkflowDao) ClearError(ctx context.Context, id int64) (rows int64, err error) {
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameExecWorkflow).
Where(entity.ExecWorkflowCol.Id, id).
Data(map[string]any{
entity.ExecWorkflowCol.ErrorMessage: "",
entity.ExecWorkflowCol.Error: "",
}).
Update()
if err != nil {
return
}
return r.RowsAffected()
}
func (d *execWorkflowDao) GetById(ctx context.Context, id int64) (res *entity.ExecWorkflow, err error) {
r, err := gfdb.DB(ctx, public.DbNameBlackDeacon).Model(ctx, public.TableNameExecWorkflow).
Where(entity.ExecWorkflowCol.Id, id).
+7
View File
@@ -190,6 +190,13 @@ func recordWorkflow(ctx context.Context, id int64, duration time.Duration, runEr
glog.Errorf(ctx, "exec_workflow 落库失败: %v", err)
return
}
// 执行成功:重新执行复用了同一条记录,OmitEmpty 的 Update 会跳过空 error_message/error
// 需显式清空,避免上一次失败的报错残留
if runErr == nil {
if _, err := sessionDao.ExecWorkflowDao.ClearError(ctx, id); err != nil {
glog.Errorf(ctx, "exec_workflow 报错信息清空失败: %v", err)
}
}
}
// workflowResultFileUrls 查询指定工作流执行保存的结果文件路径(带文件前缀,与 session/get 返回一致)
@@ -51,8 +51,14 @@ func ScriptTranscribeLambda(ctx context.Context, input any) (any, error) {
}
var totalDuration int
var modelId int64
// 静音模式:清空镜头台词/旁白,生成视频不含口播、旁白、字幕与人物开口动作,默认开启
noSpeech := true
for _, item := range *n {
switch item.Field {
case "noSpeech":
if !g.IsEmpty(item.Value) {
noSpeech = gconv.Bool(item.Value)
}
case "totalDuration":
if !g.IsEmpty(item.Value) {
totalDuration = gconv.Int(item.Value)
@@ -136,6 +142,14 @@ func ScriptTranscribeLambda(ctx context.Context, input any) (any, error) {
if err != nil {
return nil, err
}
// 静音模式:清空台词与旁白,保证写进视频 prompt 的只有事件/环境音/运镜/景别,
// 视频模型不会产生口播、旁白配音、字幕烧录,也不会把角色标记为开口优先做口型动画
if noSpeech {
for i := range shots {
shots[i].Dialogue = ""
shots[i].Narration = ""
}
}
// 5. 产出固定结构 {"shots": [...]}
var arr []any
+11 -1
View File
@@ -165,7 +165,17 @@ func recordChat(ctx context.Context, id int64, answer string, msg string, runErr
ErrorMessage: msg,
Error: errorDetail,
})
return err
if err != nil {
return err
}
// 执行成功:重新执行复用了同一条记录,OmitEmpty 的 Update 会跳过空 error_message/error
// 需显式清空,避免上一次失败的报错残留
if runErr == nil {
if _, err := sessionDao.ExecChatDao.ClearError(ctx, id); err != nil {
glog.Errorf(ctx, "exec_chat 报错信息清空失败: %v", err)
}
}
return nil
}
// pushAgentEvent 把 ReAct 过程事件转为 WS 推送消息