Files
ai-agent/workflow/service/flow/flow_checkpoint_store.go
T
19904408334 cef837a35c feat: 支持工作流断点续跑并拆分错误信息存储
- 新增同会话+同工作流最近执行失败且参数一致时断点续跑逻辑
- exec_workflow/exec_chat 新增 error 字段存储原始错误,error_message 仅存友好提示
- 新增 UpdateExecChatReq 与 exec_chat_dao Update 方法
- 新增 GetLatestBySessionAndFlow 查询最近执行记录
- 修正 ListDates 分组与排序 SQL 表达式
- 新增 pipeline 配置结构,删除旧设计文档
2026-08-21 09:54:06 +08:00

65 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package flow
import (
"ai-agent/workflow/consts/node"
flowDto "ai-agent/workflow/model/dto/flow"
"ai-agent/workflow/model/entity"
"context"
"encoding/json"
"time"
flowDao "ai-agent/workflow/dao/flow"
"github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema"
)
// 注册 checkpoint 序列化类型
func init() {
// ========== 1. Eino 断点核心状态(根类型) ==========
schema.RegisterName[*flowDto.NodeExecutionState]("flow.NodeExecutionState")
schema.RegisterName[*flowDto.NodeExecutionInput]("flow.NodeExecutionInput")
schema.RegisterName[*flowDto.FlowExecutionInput]("flow.FlowExecutionInput")
// ========== 2. 原有第三方类型 ==========
schema.RegisterName[json.Number]("json.Number")
schema.RegisterName[time.Time]("time.Time")
schema.RegisterName[time.Duration]("time.Duration")
// ========== 3. flowDto 内部嵌套类型 ==========
schema.RegisterName[flowDto.ExecutedNode]("flow.ExecutedNode")
// ========== 4. entity 核心链路类型(递归自 *entity.FlowNode ==========
schema.RegisterName[*entity.FlowNode]("entity.FlowNode")
schema.RegisterName[node.NodeType]("node.NodeType")
schema.RegisterName[*entity.SubFlowConfig]("entity.SubFlowConfig")
//schema.RegisterName[node.NodeFormField]("node.NodeFormField")
schema.RegisterName[entity.ModelItem]("node.ModelItem")
// ========== 5. FlowInfo 相关(流程拓扑结构) ==========
schema.RegisterName[entity.FlowInfo]("entity.FlowInfo")
schema.RegisterName[entity.FlowEdge]("entity.FlowEdge")
}
// DbCheckPointStore 数据库存储实现
type DbCheckPointStore struct{}
func NewDbCheckPointStore() compose.CheckPointStore {
return &DbCheckPointStore{}
}
func (d *DbCheckPointStore) Get(ctx context.Context, id string) ([]byte, bool, error) {
record, err := flowDao.FlowCheckpointDao.Get(ctx, id)
if err != nil {
return nil, false, err
}
if record == nil || record.Data == "" {
return nil, false, nil
}
return []byte(record.Data), true, nil
}
func (d *DbCheckPointStore) Set(ctx context.Context, id string, val []byte) error {
return flowDao.FlowCheckpointDao.SaveOrUpdate(ctx, id, string(val))
}