feat(backend):workflow support conversation manager & add conversation/message nodes

This commit is contained in:
zhuangjie.1125
2025-07-30 12:26:46 +08:00
parent e3930873c6
commit 03b8d8e17a
82 changed files with 11676 additions and 563 deletions

View File

@ -555,7 +555,11 @@ func CreateProjectConversationDef(ctx context.Context, c *app.RequestContext) {
return
}
resp := new(workflow.CreateProjectConversationDefResponse)
resp, err := appworkflow.SVC.CreateApplicationConversationDef(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}
@ -570,8 +574,11 @@ func UpdateProjectConversationDef(ctx context.Context, c *app.RequestContext) {
invalidParamRequestResponse(c, err.Error())
return
}
resp := new(workflow.UpdateProjectConversationDefResponse)
resp, err := appworkflow.SVC.UpdateApplicationConversationDef(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}
@ -587,7 +594,11 @@ func DeleteProjectConversationDef(ctx context.Context, c *app.RequestContext) {
return
}
resp := new(workflow.DeleteProjectConversationDefResponse)
resp, err := appworkflow.SVC.DeleteApplicationConversationDef(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}
@ -603,7 +614,11 @@ func ListProjectConversationDef(ctx context.Context, c *app.RequestContext) {
return
}
resp := new(workflow.ListProjectConversationResponse)
resp, err := appworkflow.SVC.ListApplicationConversationDef(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}
@ -723,7 +738,11 @@ func GetChatFlowRole(ctx context.Context, c *app.RequestContext) {
return
}
resp := new(workflow.GetChatFlowRoleResponse)
resp, err := appworkflow.SVC.GetChatFlowRole(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}
@ -738,8 +757,11 @@ func CreateChatFlowRole(ctx context.Context, c *app.RequestContext) {
invalidParamRequestResponse(c, err.Error())
return
}
resp := new(workflow.CreateChatFlowRoleResponse)
resp, err := appworkflow.SVC.CreateChatFlowRole(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}
@ -755,7 +777,11 @@ func DeleteChatFlowRole(ctx context.Context, c *app.RequestContext) {
return
}
resp := new(workflow.DeleteChatFlowRoleResponse)
resp, err := appworkflow.SVC.DeleteChatFlowRole(ctx, &req)
if err != nil {
internalServerErrorResponse(ctx, c, err)
return
}
c.JSON(consts.StatusOK, resp)
}

View File

@ -26,6 +26,8 @@ const (
Scene_GenerateAgentInfo Scene = 8
//openapi
Scene_SceneOpenApi Scene = 9
// 工作流
Scene_SceneWorkflow Scene = 50
)
func (p Scene) String() string {

View File

@ -473,7 +473,10 @@ const (
NodeType_Input NodeType = 30
NodeType_Batch NodeType = 28
NodeType_Continue NodeType = 29
NodeType_MessageList NodeType = 37
NodeType_AssignVariable NodeType = 40
NodeType_ConversationList NodeType = 53
NodeType_CreateMessage NodeType = 55
NodeType_JsonSerialization NodeType = 58
NodeType_JsonDeserialization NodeType = 59
NodeType_DatasetDelete NodeType = 60
@ -533,8 +536,14 @@ func (p NodeType) String() string {
return "Batch"
case NodeType_Continue:
return "Continue"
case NodeType_MessageList:
return "MessageList"
case NodeType_AssignVariable:
return "AssignVariable"
case NodeType_ConversationList:
return "ConversationList"
case NodeType_CreateMessage:
return "CreateMessage"
case NodeType_JsonSerialization:
return "JsonSerialization"
case NodeType_JsonDeserialization:
@ -599,8 +608,14 @@ func NodeTypeFromString(s string) (NodeType, error) {
return NodeType_Batch, nil
case "Continue":
return NodeType_Continue, nil
case "MessageList":
return NodeType_MessageList, nil
case "AssignVariable":
return NodeType_AssignVariable, nil
case "ConversationList":
return NodeType_ConversationList, nil
case "CreateMessage":
return NodeType_CreateMessage, nil
case "JsonSerialization":
return NodeType_JsonSerialization, nil
case "JsonDeserialization":
@ -657,11 +672,14 @@ const (
NodeTemplateType_Input NodeTemplateType = 30
NodeTemplateType_Batch NodeTemplateType = 28
NodeTemplateType_Continue NodeTemplateType = 29
NodeTemplateType_MessageList NodeTemplateType = 37
NodeTemplateType_AssignVariable NodeTemplateType = 40
NodeTemplateType_DatabaseInsert NodeTemplateType = 41
NodeTemplateType_DatabaseUpdate NodeTemplateType = 42
NodeTemplateType_DatabasesELECT NodeTemplateType = 43
NodeTemplateType_DatabaseDelete NodeTemplateType = 44
NodeTemplateType_ConversationList NodeTemplateType = 53
NodeTemplateType_CreateMessage NodeTemplateType = 55
NodeTemplateType_JsonSerialization NodeTemplateType = 58
NodeTemplateType_JsonDeserialization NodeTemplateType = 59
NodeTemplateType_DatasetDelete NodeTemplateType = 60
@ -723,6 +741,8 @@ func (p NodeTemplateType) String() string {
return "Batch"
case NodeTemplateType_Continue:
return "Continue"
case NodeTemplateType_MessageList:
return "MessageList"
case NodeTemplateType_AssignVariable:
return "AssignVariable"
case NodeTemplateType_DatabaseInsert:
@ -733,6 +753,10 @@ func (p NodeTemplateType) String() string {
return "DatabasesELECT"
case NodeTemplateType_DatabaseDelete:
return "DatabaseDelete"
case NodeTemplateType_ConversationList:
return "ConversationList"
case NodeTemplateType_CreateMessage:
return "CreateMessage"
case NodeTemplateType_JsonSerialization:
return "JsonSerialization"
case NodeTemplateType_JsonDeserialization:
@ -799,6 +823,8 @@ func NodeTemplateTypeFromString(s string) (NodeTemplateType, error) {
return NodeTemplateType_Batch, nil
case "Continue":
return NodeTemplateType_Continue, nil
case "MessageList":
return NodeTemplateType_MessageList, nil
case "AssignVariable":
return NodeTemplateType_AssignVariable, nil
case "DatabaseInsert":
@ -809,6 +835,10 @@ func NodeTemplateTypeFromString(s string) (NodeTemplateType, error) {
return NodeTemplateType_DatabasesELECT, nil
case "DatabaseDelete":
return NodeTemplateType_DatabaseDelete, nil
case "ConversationList":
return NodeTemplateType_ConversationList, nil
case "CreateMessage":
return NodeTemplateType_CreateMessage, nil
case "JsonSerialization":
return NodeTemplateType_JsonSerialization, nil
case "JsonDeserialization":
@ -64103,7 +64133,7 @@ func (p *ChatFlowRole) String() string {
}
type CreateChatFlowRoleRequest struct {
ChatFlowRole *ChatFlowRole `thrift:"ChatFlowRole,1" json:"chat_flow_role" form:"ChatFlowRole" query:"ChatFlowRole"`
ChatFlowRole *ChatFlowRole `thrift:"ChatFlowRole,1" json:"chat_flow_role" query:"chat_flow_role" `
Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"`
}
@ -64302,7 +64332,9 @@ func (p *CreateChatFlowRoleRequest) String() string {
type CreateChatFlowRoleResponse struct {
// 数据库中ID
ID string `thrift:"ID,1" form:"ID" json:"ID" query:"ID"`
ID string `thrift:"ID,1" json:"id" query:"id" `
Code int64 `thrift:"code,253,required" form:"code,required" json:"code,required" query:"code,required"`
Msg string `thrift:"msg,254,required" form:"msg,required" json:"msg,required" query:"msg,required"`
BaseResp *base.BaseResp `thrift:"BaseResp,255,required" form:"BaseResp,required" json:"BaseResp,required" query:"BaseResp,required"`
}
@ -64317,6 +64349,14 @@ func (p *CreateChatFlowRoleResponse) GetID() (v string) {
return p.ID
}
func (p *CreateChatFlowRoleResponse) GetCode() (v int64) {
return p.Code
}
func (p *CreateChatFlowRoleResponse) GetMsg() (v string) {
return p.Msg
}
var CreateChatFlowRoleResponse_BaseResp_DEFAULT *base.BaseResp
func (p *CreateChatFlowRoleResponse) GetBaseResp() (v *base.BaseResp) {
@ -64328,6 +64368,8 @@ func (p *CreateChatFlowRoleResponse) GetBaseResp() (v *base.BaseResp) {
var fieldIDToName_CreateChatFlowRoleResponse = map[int16]string{
1: "ID",
253: "code",
254: "msg",
255: "BaseResp",
}
@ -64338,6 +64380,8 @@ func (p *CreateChatFlowRoleResponse) IsSetBaseResp() bool {
func (p *CreateChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
var fieldTypeId thrift.TType
var fieldId int16
var issetCode bool = false
var issetMsg bool = false
var issetBaseResp bool = false
if _, err = iprot.ReadStructBegin(); err != nil {
@ -64362,6 +64406,24 @@ func (p *CreateChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 253:
if fieldTypeId == thrift.I64 {
if err = p.ReadField253(iprot); err != nil {
goto ReadFieldError
}
issetCode = true
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 254:
if fieldTypeId == thrift.STRING {
if err = p.ReadField254(iprot); err != nil {
goto ReadFieldError
}
issetMsg = true
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 255:
if fieldTypeId == thrift.STRUCT {
if err = p.ReadField255(iprot); err != nil {
@ -64384,6 +64446,16 @@ func (p *CreateChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
goto ReadStructEndError
}
if !issetCode {
fieldId = 253
goto RequiredFieldNotSetError
}
if !issetMsg {
fieldId = 254
goto RequiredFieldNotSetError
}
if !issetBaseResp {
fieldId = 255
goto RequiredFieldNotSetError
@ -64417,6 +64489,28 @@ func (p *CreateChatFlowRoleResponse) ReadField1(iprot thrift.TProtocol) error {
p.ID = _field
return nil
}
func (p *CreateChatFlowRoleResponse) ReadField253(iprot thrift.TProtocol) error {
var _field int64
if v, err := iprot.ReadI64(); err != nil {
return err
} else {
_field = v
}
p.Code = _field
return nil
}
func (p *CreateChatFlowRoleResponse) ReadField254(iprot thrift.TProtocol) error {
var _field string
if v, err := iprot.ReadString(); err != nil {
return err
} else {
_field = v
}
p.Msg = _field
return nil
}
func (p *CreateChatFlowRoleResponse) ReadField255(iprot thrift.TProtocol) error {
_field := base.NewBaseResp()
if err := _field.Read(iprot); err != nil {
@ -64436,6 +64530,14 @@ func (p *CreateChatFlowRoleResponse) Write(oprot thrift.TProtocol) (err error) {
fieldId = 1
goto WriteFieldError
}
if err = p.writeField253(oprot); err != nil {
fieldId = 253
goto WriteFieldError
}
if err = p.writeField254(oprot); err != nil {
fieldId = 254
goto WriteFieldError
}
if err = p.writeField255(oprot); err != nil {
fieldId = 255
goto WriteFieldError
@ -64474,6 +64576,38 @@ WriteFieldBeginError:
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
}
func (p *CreateChatFlowRoleResponse) writeField253(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("code", thrift.I64, 253); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteI64(p.Code); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 253 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 253 end error: ", p), err)
}
func (p *CreateChatFlowRoleResponse) writeField254(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("msg", thrift.STRING, 254); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteString(p.Msg); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 254 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 254 end error: ", p), err)
}
func (p *CreateChatFlowRoleResponse) writeField255(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil {
goto WriteFieldBeginError
@ -64500,10 +64634,10 @@ func (p *CreateChatFlowRoleResponse) String() string {
}
type DeleteChatFlowRoleRequest struct {
WorkflowID string `thrift:"WorkflowID,1" form:"WorkflowID" json:"WorkflowID" query:"WorkflowID"`
ConnectorID string `thrift:"ConnectorID,2" form:"ConnectorID" json:"ConnectorID" query:"ConnectorID"`
WorkflowID string `thrift:"WorkflowID,1" json:"workflow_id" query:"workflow_id" `
ConnectorID string `thrift:"ConnectorID,2" json:"connector_id" query:"connector_id" `
// 数据库中ID
ID string `thrift:"ID,4" form:"ID" json:"ID" query:"ID"`
ID string `thrift:"ID,4" json:"id" query:"id" `
Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"`
}
@ -64936,12 +65070,12 @@ func (p *DeleteChatFlowRoleResponse) String() string {
}
type GetChatFlowRoleRequest struct {
WorkflowID string `thrift:"WorkflowID,1" form:"WorkflowID" json:"WorkflowID" query:"WorkflowID"`
ConnectorID string `thrift:"ConnectorID,2" form:"ConnectorID" json:"ConnectorID" query:"ConnectorID"`
IsDebug bool `thrift:"IsDebug,3" form:"IsDebug" json:"IsDebug" query:"IsDebug"`
WorkflowID string `thrift:"WorkflowID,1" json:"workflow_id" query:"workflow_id" `
ConnectorID string `thrift:"ConnectorID,2" json:"connector_id" query:"connector_id" `
IsDebug bool `thrift:"IsDebug,3" json:"is_debug" query:"is_debug" `
// 4: optional string AppID (api.query = "app_id")
Ext map[string]string `thrift:"Ext,5,optional" json:"Ext,omitempty" query:"ext"`
Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"`
Base *base.Base `thrift:"Base,255,optional" json:"base" query:"base" `
}
func NewGetChatFlowRoleRequest() *GetChatFlowRoleRequest {
@ -65304,8 +65438,10 @@ func (p *GetChatFlowRoleRequest) String() string {
}
type GetChatFlowRoleResponse struct {
Role *ChatFlowRole `thrift:"Role,1,optional" form:"Role" json:"Role,omitempty" query:"Role"`
BaseResp *base.BaseResp `thrift:"BaseResp,255,required" form:"BaseResp,required" json:"BaseResp,required" query:"BaseResp,required"`
Code int64 `thrift:"code,1,required" form:"code,required" json:"code,required" query:"code,required"`
Msg string `thrift:"msg,2,required" form:"msg,required" json:"msg,required" query:"msg,required"`
Role *ChatFlowRole `thrift:"Role,3,optional" json:"role" query:"role" `
BaseResp *base.BaseResp `thrift:"BaseResp,255,required" json:"base_resp" query:"base_resp,required" `
}
func NewGetChatFlowRoleResponse() *GetChatFlowRoleResponse {
@ -65315,6 +65451,14 @@ func NewGetChatFlowRoleResponse() *GetChatFlowRoleResponse {
func (p *GetChatFlowRoleResponse) InitDefault() {
}
func (p *GetChatFlowRoleResponse) GetCode() (v int64) {
return p.Code
}
func (p *GetChatFlowRoleResponse) GetMsg() (v string) {
return p.Msg
}
var GetChatFlowRoleResponse_Role_DEFAULT *ChatFlowRole
func (p *GetChatFlowRoleResponse) GetRole() (v *ChatFlowRole) {
@ -65334,7 +65478,9 @@ func (p *GetChatFlowRoleResponse) GetBaseResp() (v *base.BaseResp) {
}
var fieldIDToName_GetChatFlowRoleResponse = map[int16]string{
1: "Role",
1: "code",
2: "msg",
3: "Role",
255: "BaseResp",
}
@ -65349,6 +65495,8 @@ func (p *GetChatFlowRoleResponse) IsSetBaseResp() bool {
func (p *GetChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
var fieldTypeId thrift.TType
var fieldId int16
var issetCode bool = false
var issetMsg bool = false
var issetBaseResp bool = false
if _, err = iprot.ReadStructBegin(); err != nil {
@ -65366,10 +65514,28 @@ func (p *GetChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
switch fieldId {
case 1:
if fieldTypeId == thrift.STRUCT {
if fieldTypeId == thrift.I64 {
if err = p.ReadField1(iprot); err != nil {
goto ReadFieldError
}
issetCode = true
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 2:
if fieldTypeId == thrift.STRING {
if err = p.ReadField2(iprot); err != nil {
goto ReadFieldError
}
issetMsg = true
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
case 3:
if fieldTypeId == thrift.STRUCT {
if err = p.ReadField3(iprot); err != nil {
goto ReadFieldError
}
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
@ -65395,6 +65561,16 @@ func (p *GetChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
goto ReadStructEndError
}
if !issetCode {
fieldId = 1
goto RequiredFieldNotSetError
}
if !issetMsg {
fieldId = 2
goto RequiredFieldNotSetError
}
if !issetBaseResp {
fieldId = 255
goto RequiredFieldNotSetError
@ -65418,6 +65594,28 @@ RequiredFieldNotSetError:
}
func (p *GetChatFlowRoleResponse) ReadField1(iprot thrift.TProtocol) error {
var _field int64
if v, err := iprot.ReadI64(); err != nil {
return err
} else {
_field = v
}
p.Code = _field
return nil
}
func (p *GetChatFlowRoleResponse) ReadField2(iprot thrift.TProtocol) error {
var _field string
if v, err := iprot.ReadString(); err != nil {
return err
} else {
_field = v
}
p.Msg = _field
return nil
}
func (p *GetChatFlowRoleResponse) ReadField3(iprot thrift.TProtocol) error {
_field := NewChatFlowRole()
if err := _field.Read(iprot); err != nil {
return err
@ -65444,6 +65642,14 @@ func (p *GetChatFlowRoleResponse) Write(oprot thrift.TProtocol) (err error) {
fieldId = 1
goto WriteFieldError
}
if err = p.writeField2(oprot); err != nil {
fieldId = 2
goto WriteFieldError
}
if err = p.writeField3(oprot); err != nil {
fieldId = 3
goto WriteFieldError
}
if err = p.writeField255(oprot); err != nil {
fieldId = 255
goto WriteFieldError
@ -65467,8 +65673,40 @@ WriteStructEndError:
}
func (p *GetChatFlowRoleResponse) writeField1(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("code", thrift.I64, 1); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteI64(p.Code); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
}
func (p *GetChatFlowRoleResponse) writeField2(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("msg", thrift.STRING, 2); err != nil {
goto WriteFieldBeginError
}
if err := oprot.WriteString(p.Msg); err != nil {
return err
}
if err = oprot.WriteFieldEnd(); err != nil {
goto WriteFieldEndError
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
}
func (p *GetChatFlowRoleResponse) writeField3(oprot thrift.TProtocol) (err error) {
if p.IsSetRole() {
if err = oprot.WriteFieldBegin("Role", thrift.STRUCT, 1); err != nil {
if err = oprot.WriteFieldBegin("Role", thrift.STRUCT, 3); err != nil {
goto WriteFieldBeginError
}
if err := p.Role.Write(oprot); err != nil {
@ -65480,9 +65718,9 @@ func (p *GetChatFlowRoleResponse) writeField1(oprot thrift.TProtocol) (err error
}
return nil
WriteFieldBeginError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
WriteFieldEndError:
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
}
func (p *GetChatFlowRoleResponse) writeField255(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil {

View File

@ -0,0 +1,264 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package workflow
import (
"context"
"fmt"
"github.com/coze-dev/coze-studio/backend/types/consts"
"runtime/debug"
"strconv"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/lang/maps"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/pkg/safego"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
func (w *ApplicationService) CreateApplicationConversationDef(ctx context.Context, req *workflow.CreateProjectConversationDefRequest) (resp *workflow.CreateProjectConversationDefResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrConversationOfAppOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
var (
spaceID = mustParseInt64(req.GetSpaceID())
appID = mustParseInt64(req.GetProjectID())
userID = ctxutil.MustGetUIDFromCtx(ctx)
)
if err := checkUserSpace(ctx, userID, spaceID); err != nil {
return nil, err
}
uniqueID, err := GetWorkflowDomainSVC().CreateDraftConversationTemplate(ctx, &vo.CreateConversationTemplateMeta{
AppID: appID,
SpaceID: spaceID,
Name: req.GetConversationName(),
UserID: userID,
})
if err != nil {
return nil, err
}
return &workflow.CreateProjectConversationDefResponse{
UniqueID: strconv.FormatInt(uniqueID, 10),
SpaceID: req.GetSpaceID(),
}, err
}
func (w *ApplicationService) UpdateApplicationConversationDef(ctx context.Context, req *workflow.UpdateProjectConversationDefRequest) (resp *workflow.UpdateProjectConversationDefResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrConversationOfAppOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
var (
spaceID = mustParseInt64(req.GetSpaceID())
templateID = mustParseInt64(req.GetUniqueID())
appID = mustParseInt64(req.GetProjectID())
userID = ctxutil.MustGetUIDFromCtx(ctx)
)
if err := checkUserSpace(ctx, userID, spaceID); err != nil {
return nil, err
}
err = GetWorkflowDomainSVC().UpdateDraftConversationTemplateName(ctx, appID, userID, templateID, req.GetConversationName())
if err != nil {
return nil, err
}
return &workflow.UpdateProjectConversationDefResponse{}, err
}
func (w *ApplicationService) DeleteApplicationConversationDef(ctx context.Context, req *workflow.DeleteProjectConversationDefRequest) (resp *workflow.DeleteProjectConversationDefResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrConversationOfAppOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
var (
appID = mustParseInt64(req.GetProjectID())
templateID = mustParseInt64(req.GetUniqueID())
)
if err := checkUserSpace(ctx, ctxutil.MustGetUIDFromCtx(ctx), mustParseInt64(req.GetSpaceID())); err != nil {
return nil, err
}
if req.GetCheckOnly() {
wfs, err := GetWorkflowDomainSVC().CheckWorkflowsToReplace(ctx, appID, templateID)
if err != nil {
return nil, err
}
resp = &workflow.DeleteProjectConversationDefResponse{NeedReplace: make([]*workflow.Workflow, 0)}
for _, wf := range wfs {
resp.NeedReplace = append(resp.NeedReplace, &workflow.Workflow{
Name: wf.Name,
URL: wf.IconURL,
WorkflowID: strconv.FormatInt(wf.ID, 10),
})
}
return resp, nil
}
wfID2ConversationName, err := maps.TransformKeyWithErrorCheck(req.GetReplace(), func(k1 string) (int64, error) {
return strconv.ParseInt(k1, 10, 64)
})
rowsAffected, err := GetWorkflowDomainSVC().DeleteDraftConversationTemplate(ctx, templateID, wfID2ConversationName)
if err != nil {
return nil, err
}
if rowsAffected > 0 {
return &workflow.DeleteProjectConversationDefResponse{
Success: true,
}, err
}
rowsAffected, err = GetWorkflowDomainSVC().DeleteDynamicConversation(ctx, vo.Draft, templateID)
if err != nil {
return nil, err
}
if rowsAffected == 0 {
return nil, fmt.Errorf("delete conversation failed")
}
return &workflow.DeleteProjectConversationDefResponse{
Success: true,
}, nil
}
func (w *ApplicationService) ListApplicationConversationDef(ctx context.Context, req *workflow.ListProjectConversationRequest) (resp *workflow.ListProjectConversationResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrConversationOfAppOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
var connectorID int64
if len(req.GetConnectorID()) != 0 {
connectorID = mustParseInt64(req.GetConnectorID())
} else {
connectorID = consts.CozeConnectorID
}
var (
page = mustParseInt64(ternary.IFElse(req.GetCursor() == "", "0", req.GetCursor()))
size = req.GetLimit()
userID = ctxutil.MustGetUIDFromCtx(ctx)
spaceID = mustParseInt64(req.GetSpaceID())
appID = mustParseInt64(req.GetProjectID())
version = req.ProjectVersion
listConversationMeta = vo.ListConversationMeta{
APPID: appID,
UserID: userID,
ConnectorID: connectorID,
}
)
if err := checkUserSpace(ctx, userID, spaceID); err != nil {
return nil, err
}
env := ternary.IFElse(req.GetCreateEnv() == workflow.CreateEnv_Draft, vo.Draft, vo.Online)
if req.GetCreateMethod() == workflow.CreateMethod_ManualCreate {
templates, err := GetWorkflowDomainSVC().ListConversationTemplate(ctx, env, &vo.ListConversationTemplatePolicy{
AppID: appID,
Page: &vo.Page{
Page: int32(page),
Size: int32(size),
},
NameLike: ternary.IFElse(len(req.GetNameLike()) == 0, nil, ptr.Of(req.GetNameLike())),
Version: version,
})
if err != nil {
return nil, err
}
stsConversations, err := GetWorkflowDomainSVC().MGetStaticConversation(ctx, env, userID, connectorID, slices.Transform(templates, func(a *entity.ConversationTemplate) int64 {
return a.TemplateID
}))
if err != nil {
return nil, err
}
stsConversationMap := slices.ToMap(stsConversations, func(e *entity.StaticConversation) (int64, *entity.StaticConversation) {
return e.TemplateID, e
})
resp = &workflow.ListProjectConversationResponse{Data: make([]*workflow.ProjectConversation, 0)}
for _, tmpl := range templates {
conversationID := ""
if c, ok := stsConversationMap[tmpl.TemplateID]; ok {
conversationID = strconv.FormatInt(c.ConversationID, 10)
}
resp.Data = append(resp.Data, &workflow.ProjectConversation{
UniqueID: strconv.FormatInt(tmpl.TemplateID, 10),
ConversationName: tmpl.Name,
ConversationID: conversationID,
})
}
}
if req.GetCreateMethod() == workflow.CreateMethod_NodeCreate {
dyConversations, err := GetWorkflowDomainSVC().ListDynamicConversation(ctx, env, &vo.ListConversationPolicy{
ListConversationMeta: listConversationMeta,
Page: &vo.Page{
Page: int32(page),
Size: int32(size),
},
NameLike: ternary.IFElse(len(req.GetNameLike()) == 0, nil, ptr.Of(req.GetNameLike())),
})
if err != nil {
return nil, err
}
resp = &workflow.ListProjectConversationResponse{Data: make([]*workflow.ProjectConversation, 0, len(dyConversations))}
resp.Data = append(resp.Data, slices.Transform(dyConversations, func(a *entity.DynamicConversation) *workflow.ProjectConversation {
return &workflow.ProjectConversation{
UniqueID: strconv.FormatInt(a.ID, 10),
ConversationName: a.Name,
ConversationID: strconv.FormatInt(a.ConversationID, 10),
}
})...)
}
return resp, nil
}

View File

@ -21,6 +21,7 @@ import (
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
wfconversation "github.com/coze-dev/coze-studio/backend/crossdomain/workflow/conversation"
wfdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/workflow/database"
wfknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/workflow/knowledge"
wfmodel "github.com/coze-dev/coze-studio/backend/crossdomain/workflow/model"
@ -34,6 +35,7 @@ import (
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
crosscode "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/code"
crossconversation "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
crossdatabase "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/database"
crossknowledge "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/knowledge"
crossmodel "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/model"
@ -78,6 +80,7 @@ func InitService(components *ServiceComponents) *ApplicationService {
crossmodel.SetManager(wfmodel.NewModelManager(components.ModelManager, nil))
crosscode.SetCodeRunner(components.CodeRunner)
crosssearch.SetNotifier(wfsearch.NewNotify(components.DomainNotifier))
crossconversation.SetConversationManager(wfconversation.NewConversationRepository())
SVC.DomainSVC = workflowDomainSVC
SVC.ImageX = components.ImageX

View File

@ -93,7 +93,7 @@ func (w *ApplicationService) GetNodeTemplateList(ctx context.Context, req *workf
toQueryTypes := make(map[entity.NodeType]bool)
for _, t := range req.NodeTypes {
entityType, err := nodeType2EntityNodeType(t)
entityType, err := entity.BlockType2EntityNodeType(t)
if err != nil {
logs.Warnf("get node type %v failed, err:=%v", t, err)
continue
@ -116,7 +116,7 @@ func (w *ApplicationService) GetNodeTemplateList(ctx context.Context, req *workf
Name: category,
}
for _, nodeMeta := range nodeMetaList {
tplType, err := entityNodeTypeToAPINodeTemplateType(nodeMeta.Type)
tplType, err := entity.NodeTypeToAPINodeTemplateType(nodeMeta.Type)
if err != nil {
return nil, err
}
@ -169,6 +169,21 @@ func (w *ApplicationService) CreateWorkflow(ctx context.Context, req *workflow.C
if err := checkUserSpace(ctx, uID, spaceID); err != nil {
return nil, err
}
var createConversation bool
if req.ProjectID != nil && req.IsSetFlowMode() && req.GetFlowMode() == workflow.WorkflowMode_ChatFlow && req.IsSetCreateConversation() && req.GetCreateConversation() {
createConversation = true
_, err := GetWorkflowDomainSVC().CreateDraftConversationTemplate(ctx, &vo.CreateConversationTemplateMeta{
AppID: mustParseInt64(req.GetProjectID()),
UserID: uID,
SpaceID: spaceID,
Name: req.Name,
})
if err != nil {
return nil, err
}
}
wf := &vo.MetaCreate{
CreatorID: uID,
SpaceID: spaceID,
@ -180,6 +195,13 @@ func (w *ApplicationService) CreateWorkflow(ctx context.Context, req *workflow.C
Mode: ternary.IFElse(req.IsSetFlowMode(), req.GetFlowMode(), workflow.WorkflowMode_Workflow),
InitCanvasSchema: entity.GetDefaultInitCanvasJsonSchema(i18n.GetLocale(ctx)),
}
if req.IsSetFlowMode() && req.GetFlowMode() == workflow.WorkflowMode_ChatFlow {
conversationName := req.Name
if !req.IsSetProjectID() || mustParseInt64(req.GetProjectID()) == 0 || !createConversation {
conversationName = "Default"
}
wf.InitCanvasSchema = entity.GetDefaultInitCanvasJsonSchemaChat(i18n.GetLocale(ctx), conversationName)
}
id, err := GetWorkflowDomainSVC().Create(ctx, wf)
if err != nil {
@ -1034,6 +1056,18 @@ func (w *ApplicationService) CopyWorkflowFromLibraryToApp(ctx context.Context, w
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, vo.CopyWorkflowPolicy{
TargetAppID: &appID,
})
if wf.Mode == workflow.WorkflowMode_ChatFlow {
err = GetWorkflowDomainSVC().CopyChatFlowRole(ctx, &vo.CopyRolePolicy{
SourceID: workflowID,
TargetID: wf.ID,
CreatorID: wf.CreatorID,
})
if err != nil {
return 0, err
}
}
if err != nil {
return 0, err
}
@ -1127,7 +1161,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
}
func convertNodeExecution(nodeExe *entity.NodeExecution) (*workflow.NodeResult, error) {
nType, err := entityNodeTypeToAPINodeTemplateType(nodeExe.NodeType)
nType, err := entity.NodeTypeToAPINodeTemplateType(nodeExe.NodeType)
if err != nil {
return nil, err
}
@ -1317,7 +1351,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
}
var nodeType workflow.NodeTemplateType
nodeType, err = entityNodeTypeToAPINodeTemplateType(msg.NodeType)
nodeType, err = entity.NodeTypeToAPINodeTemplateType(msg.NodeType)
if err != nil {
logs.Errorf("convert node type %v failed, err:=%v", msg.NodeType, err)
nodeType = workflow.NodeTemplateType(0)
@ -3338,178 +3372,6 @@ func toWorkflowParameter(nType *vo.NamedTypeInfo) (*workflow.Parameter, error) {
return wp, nil
}
func nodeType2EntityNodeType(t string) (entity.NodeType, error) {
i, err := strconv.Atoi(t)
if err != nil {
return "", fmt.Errorf("invalid node type string '%s': %w", t, err)
}
switch i {
case 1:
return entity.NodeTypeEntry, nil
case 2:
return entity.NodeTypeExit, nil
case 3:
return entity.NodeTypeLLM, nil
case 4:
return entity.NodeTypePlugin, nil
case 5:
return entity.NodeTypeCodeRunner, nil
case 6:
return entity.NodeTypeKnowledgeRetriever, nil
case 8:
return entity.NodeTypeSelector, nil
case 9:
return entity.NodeTypeSubWorkflow, nil
case 12:
return entity.NodeTypeDatabaseCustomSQL, nil
case 13:
return entity.NodeTypeOutputEmitter, nil
case 15:
return entity.NodeTypeTextProcessor, nil
case 18:
return entity.NodeTypeQuestionAnswer, nil
case 19:
return entity.NodeTypeBreak, nil
case 20:
return entity.NodeTypeVariableAssignerWithinLoop, nil
case 21:
return entity.NodeTypeLoop, nil
case 22:
return entity.NodeTypeIntentDetector, nil
case 27:
return entity.NodeTypeKnowledgeIndexer, nil
case 28:
return entity.NodeTypeBatch, nil
case 29:
return entity.NodeTypeContinue, nil
case 30:
return entity.NodeTypeInputReceiver, nil
case 32:
return entity.NodeTypeVariableAggregator, nil
case 37:
return entity.NodeTypeMessageList, nil
case 38:
return entity.NodeTypeClearMessage, nil
case 39:
return entity.NodeTypeCreateConversation, nil
case 40:
return entity.NodeTypeVariableAssigner, nil
case 42:
return entity.NodeTypeDatabaseUpdate, nil
case 43:
return entity.NodeTypeDatabaseQuery, nil
case 44:
return entity.NodeTypeDatabaseDelete, nil
case 45:
return entity.NodeTypeHTTPRequester, nil
case 46:
return entity.NodeTypeDatabaseInsert, nil
case 58:
return entity.NodeTypeJsonSerialization, nil
case 59:
return entity.NodeTypeJsonDeserialization, nil
case 60:
return entity.NodeTypeKnowledgeDeleter, nil
default:
// Handle all unknown or unsupported types here
return "", fmt.Errorf("unsupported or unknown node type ID: %d", i)
}
}
// entityNodeTypeToAPINodeTemplateType converts an entity.NodeType to the corresponding workflow.NodeTemplateType.
func entityNodeTypeToAPINodeTemplateType(nodeType entity.NodeType) (workflow.NodeTemplateType, error) {
switch nodeType {
case entity.NodeTypeEntry:
return workflow.NodeTemplateType_Start, nil
case entity.NodeTypeExit:
return workflow.NodeTemplateType_End, nil
case entity.NodeTypeLLM:
return workflow.NodeTemplateType_LLM, nil
case entity.NodeTypePlugin:
// Maps to Api type in the API model
return workflow.NodeTemplateType_Api, nil
case entity.NodeTypeCodeRunner:
return workflow.NodeTemplateType_Code, nil
case entity.NodeTypeKnowledgeRetriever:
// Maps to Dataset type in the API model
return workflow.NodeTemplateType_Dataset, nil
case entity.NodeTypeSelector:
// Maps to If type in the API model
return workflow.NodeTemplateType_If, nil
case entity.NodeTypeSubWorkflow:
return workflow.NodeTemplateType_SubWorkflow, nil
case entity.NodeTypeDatabaseCustomSQL:
// Maps to the generic Database type in the API model
return workflow.NodeTemplateType_Database, nil
case entity.NodeTypeOutputEmitter:
// Maps to Message type in the API model
return workflow.NodeTemplateType_Message, nil
case entity.NodeTypeTextProcessor:
return workflow.NodeTemplateType_Text, nil
case entity.NodeTypeQuestionAnswer:
return workflow.NodeTemplateType_Question, nil
case entity.NodeTypeBreak:
return workflow.NodeTemplateType_Break, nil
case entity.NodeTypeVariableAssigner:
return workflow.NodeTemplateType_AssignVariable, nil
case entity.NodeTypeVariableAssignerWithinLoop:
return workflow.NodeTemplateType_LoopSetVariable, nil
case entity.NodeTypeLoop:
return workflow.NodeTemplateType_Loop, nil
case entity.NodeTypeIntentDetector:
return workflow.NodeTemplateType_Intent, nil
case entity.NodeTypeKnowledgeIndexer:
// Maps to DatasetWrite type in the API model
return workflow.NodeTemplateType_DatasetWrite, nil
case entity.NodeTypeBatch:
return workflow.NodeTemplateType_Batch, nil
case entity.NodeTypeContinue:
return workflow.NodeTemplateType_Continue, nil
case entity.NodeTypeInputReceiver:
return workflow.NodeTemplateType_Input, nil
case entity.NodeTypeMessageList:
return workflow.NodeTemplateType(37), nil
case entity.NodeTypeVariableAggregator:
return workflow.NodeTemplateType(32), nil
case entity.NodeTypeClearMessage:
return workflow.NodeTemplateType(38), nil
case entity.NodeTypeCreateConversation:
return workflow.NodeTemplateType(39), nil
// Note: entity.NodeTypeVariableAggregator (ID 32) has no direct mapping in NodeTemplateType
// Note: entity.NodeTypeMessageList (ID 37) has no direct mapping in NodeTemplateType
// Note: entity.NodeTypeClearMessage (ID 38) has no direct mapping in NodeTemplateType
// Note: entity.NodeTypeCreateConversation (ID 39) has no direct mapping in NodeTemplateType
case entity.NodeTypeDatabaseUpdate:
return workflow.NodeTemplateType_DatabaseUpdate, nil
case entity.NodeTypeDatabaseQuery:
// Maps to DatabasesELECT (ID 43) in the API model (note potential typo)
return workflow.NodeTemplateType_DatabasesELECT, nil
case entity.NodeTypeDatabaseDelete:
return workflow.NodeTemplateType_DatabaseDelete, nil
// Note: entity.NodeTypeHTTPRequester (ID 45) has no direct mapping in NodeTemplateType
case entity.NodeTypeHTTPRequester:
return workflow.NodeTemplateType(45), nil
case entity.NodeTypeDatabaseInsert:
// Maps to DatabaseInsert (ID 41) in the API model, despite entity ID being 46.
// return workflow.NodeTemplateType_DatabaseInsert, nil
return workflow.NodeTemplateType(46), nil
case entity.NodeTypeJsonSerialization:
return workflow.NodeTemplateType(58), nil
case entity.NodeTypeJsonDeserialization:
return workflow.NodeTemplateType_JsonDeserialization, nil
case entity.NodeTypeKnowledgeDeleter:
return workflow.NodeTemplateType_DatasetDelete, nil
case entity.NodeTypeLambda:
return 0, nil
default:
// Handle entity types that don't have a corresponding NodeTemplateType
return workflow.NodeTemplateType(0), fmt.Errorf("cannot map entity node type '%s' to a workflow.NodeTemplateType", nodeType)
}
}
func i64PtrToStringPtr(i *int64) *string {
if i == nil {
return nil
@ -3813,3 +3675,351 @@ func checkUserSpace(ctx context.Context, uid int64, spaceID int64) error {
return nil
}
func (w *ApplicationService) populateChatFlowRoleFields(role *workflow.ChatFlowRole, targetRole interface{}) error {
var avatarUri, audioStr, bgStr, obStr, srStr, uiStr string
var err error
if role.Avatar != nil {
avatarUri = role.Avatar.ImageUri
}
if role.AudioConfig != nil {
audioStr, err = sonic.MarshalString(*role.AudioConfig)
if err != nil {
return vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.BackgroundImageInfo != nil {
bgStr, err = sonic.MarshalString(*role.BackgroundImageInfo)
if err != nil {
return vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.OnboardingInfo != nil {
obStr, err = sonic.MarshalString(*role.OnboardingInfo)
if err != nil {
return vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.SuggestReplyInfo != nil {
srStr, err = sonic.MarshalString(*role.SuggestReplyInfo)
if err != nil {
return vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.UserInputConfig != nil {
uiStr, err = sonic.MarshalString(*role.UserInputConfig)
if err != nil {
return vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
switch r := targetRole.(type) {
case *vo.ChatFlowRoleCreate:
if role.Name != nil {
r.Name = *role.Name
}
if role.Description != nil {
r.Description = *role.Description
}
if avatarUri != "" {
r.AvatarUri = avatarUri
}
if audioStr != "" {
r.AudioConfig = audioStr
}
if bgStr != "" {
r.BackgroundImageInfo = bgStr
}
if obStr != "" {
r.OnboardingInfo = obStr
}
if srStr != "" {
r.SuggestReplyInfo = srStr
}
if uiStr != "" {
r.UserInputConfig = uiStr
}
case *vo.ChatFlowRoleUpdate:
r.Name = role.Name
r.Description = role.Description
if avatarUri != "" {
r.AvatarUri = ptr.Of(avatarUri)
}
if audioStr != "" {
r.AudioConfig = ptr.Of(audioStr)
}
if bgStr != "" {
r.BackgroundImageInfo = ptr.Of(bgStr)
}
if obStr != "" {
r.OnboardingInfo = ptr.Of(obStr)
}
if srStr != "" {
r.SuggestReplyInfo = ptr.Of(srStr)
}
if uiStr != "" {
r.UserInputConfig = ptr.Of(uiStr)
}
default:
return vo.WrapError(errno.ErrInvalidParameter, fmt.Errorf("invalid type for targetRole: %T", targetRole))
}
return nil
}
func IsChatFlow(wf *entity.Workflow) bool {
if wf == nil || wf.ID == 0 {
return false
}
return wf.Meta.Mode == workflow.WorkflowMode_ChatFlow
}
func (w *ApplicationService) CreateChatFlowRole(ctx context.Context, req *workflow.CreateChatFlowRoleRequest) (
_ *workflow.CreateChatFlowRoleResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrChatFlowRoleOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
uID := ctxutil.MustGetUIDFromCtx(ctx)
wf, err := GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
ID: mustParseInt64(req.GetChatFlowRole().GetWorkflowID()),
MetaOnly: true,
})
if err != nil {
return nil, err
}
if err = checkUserSpace(ctx, uID, wf.Meta.SpaceID); err != nil {
return nil, err
}
role := req.GetChatFlowRole()
if !IsChatFlow(wf) {
logs.CtxWarnf(ctx, "CreateChatFlowRole not chat flow, workflowID: %d", wf.ID)
return nil, vo.WrapError(errno.ErrChatFlowRoleOperationFail, fmt.Errorf("workflow %d is not a chat flow", wf.ID))
}
oldRole, err := GetWorkflowDomainSVC().GetChatFlowRole(ctx, mustParseInt64(role.WorkflowID), "")
if err != nil {
return nil, err
}
var roleID int64
if oldRole != nil {
role.ID = strconv.FormatInt(oldRole.ID, 10)
roleID = oldRole.ID
}
if role.GetID() == "" || role.GetID() == "0" {
chatFlowRole := &vo.ChatFlowRoleCreate{
WorkflowID: mustParseInt64(role.WorkflowID),
CreatorID: uID,
}
if err = w.populateChatFlowRoleFields(role, chatFlowRole); err != nil {
return nil, err
}
roleID, err = GetWorkflowDomainSVC().CreateChatFlowRole(ctx, chatFlowRole)
if err != nil {
return nil, err
}
} else {
chatFlowRole := &vo.ChatFlowRoleUpdate{
WorkflowID: mustParseInt64(role.WorkflowID),
}
if err = w.populateChatFlowRoleFields(role, chatFlowRole); err != nil {
return nil, err
}
err = GetWorkflowDomainSVC().UpdateChatFlowRole(ctx, chatFlowRole.WorkflowID, chatFlowRole)
if err != nil {
return nil, err
}
}
return &workflow.CreateChatFlowRoleResponse{
ID: strconv.FormatInt(roleID, 10),
}, nil
}
func (w *ApplicationService) DeleteChatFlowRole(ctx context.Context, req *workflow.DeleteChatFlowRoleRequest) (
_ *workflow.DeleteChatFlowRoleResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrChatFlowRoleOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
uID := ctxutil.MustGetUIDFromCtx(ctx)
wf, err := GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
ID: mustParseInt64(req.GetWorkflowID()),
MetaOnly: true,
})
if err != nil {
return nil, err
}
if err = checkUserSpace(ctx, uID, wf.Meta.SpaceID); err != nil {
return nil, err
}
err = GetWorkflowDomainSVC().DeleteChatFlowRole(ctx, mustParseInt64(req.ID), mustParseInt64(req.WorkflowID))
if err != nil {
return nil, err
}
return &workflow.DeleteChatFlowRoleResponse{}, nil
}
func (w *ApplicationService) GetChatFlowRole(ctx context.Context, req *workflow.GetChatFlowRoleRequest) (
_ *workflow.GetChatFlowRoleResponse, err error) {
defer func() {
if panicErr := recover(); panicErr != nil {
err = safego.NewPanicErr(panicErr, debug.Stack())
}
if err != nil {
err = vo.WrapIfNeeded(errno.ErrChatFlowRoleOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
}
}()
uID := ctxutil.MustGetUIDFromCtx(ctx)
wf, err := GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
ID: mustParseInt64(req.GetWorkflowID()),
MetaOnly: true,
})
if err != nil {
return nil, err
}
if err = checkUserSpace(ctx, uID, wf.Meta.SpaceID); err != nil {
return nil, err
}
if !IsChatFlow(wf) {
logs.CtxWarnf(ctx, "GetChatFlowRole not chat flow, workflowID: %d", wf.ID)
return nil, vo.WrapError(errno.ErrChatFlowRoleOperationFail, fmt.Errorf("workflow %d is not a chat flow", wf.ID))
}
var version string
if wf.Meta.AppID != nil {
version = "" // TODO : search version from DB using AppID
}
role, err := GetWorkflowDomainSVC().GetChatFlowRole(ctx, mustParseInt64(req.WorkflowID), version)
if err != nil {
return nil, err
}
if role == nil {
logs.CtxWarnf(ctx, "GetChatFlowRole role nil, workflowID: %d", wf.ID)
// Return nil for the error to align with the production behavior,
// where the GET API may be called before the CREATE API during chatflow creation.
return &workflow.GetChatFlowRoleResponse{}, nil
}
wfRole, err := w.convertChatFlowRole(ctx, role)
if err != nil {
return nil, fmt.Errorf("failed to get chat flow role config, internal data processing error: %+v", err)
}
return &workflow.GetChatFlowRoleResponse{
Role: wfRole,
}, nil
}
func (w *ApplicationService) convertChatFlowRole(ctx context.Context, role *entity.ChatFlowRole) (*workflow.ChatFlowRole, error) {
var err error
res := &workflow.ChatFlowRole{
ID: strconv.FormatInt(role.ID, 10),
WorkflowID: strconv.FormatInt(role.WorkflowID, 10),
Name: ptr.Of(role.Name),
Description: ptr.Of(role.Description),
}
if role.AvatarUri != "" {
url, err := w.ImageX.GetResourceURL(ctx, role.AvatarUri)
if err != nil {
return nil, err
}
res.Avatar = &workflow.AvatarConfig{
ImageUri: role.AvatarUri,
ImageUrl: url.URL,
}
}
if role.AudioConfig != "" {
err = sonic.UnmarshalString(role.AudioConfig, &res.AudioConfig)
if err != nil {
logs.CtxErrorf(ctx, "GetChatFlowRole AudioConfig UnmarshalString err: %+v", err)
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.OnboardingInfo != "" {
err = sonic.UnmarshalString(role.OnboardingInfo, &res.OnboardingInfo)
if err != nil {
logs.CtxErrorf(ctx, "GetChatFlowRole OnboardingInfo UnmarshalString err: %+v", err)
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.SuggestReplyInfo != "" {
err = sonic.UnmarshalString(role.SuggestReplyInfo, &res.SuggestReplyInfo)
if err != nil {
logs.CtxErrorf(ctx, "GetChatFlowRole SuggestReplyInfo UnmarshalString err: %+v", err)
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.UserInputConfig != "" {
err = sonic.UnmarshalString(role.UserInputConfig, &res.UserInputConfig)
if err != nil {
logs.CtxErrorf(ctx, "GetChatFlowRole UserInputConfig UnmarshalString err: %+v", err)
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
}
if role.BackgroundImageInfo != "" {
res.BackgroundImageInfo = &workflow.BackgroundImageInfo{}
err = sonic.UnmarshalString(role.BackgroundImageInfo, res.BackgroundImageInfo)
if err != nil {
logs.CtxErrorf(ctx, "GetChatFlowRole BackgroundImageInfo UnmarshalString err: %+v", err)
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
}
if res.BackgroundImageInfo != nil {
if res.BackgroundImageInfo.WebBackgroundImage != nil && res.BackgroundImageInfo.WebBackgroundImage.OriginImageUri != nil {
url, err := w.ImageX.GetResourceURL(ctx, res.BackgroundImageInfo.WebBackgroundImage.GetOriginImageUri())
if err != nil {
logs.CtxErrorf(ctx, "get url by uri err, err:%s", err.Error())
return nil, err
}
res.BackgroundImageInfo.WebBackgroundImage.ImageUrl = &url.URL
}
if res.BackgroundImageInfo.MobileBackgroundImage != nil && res.BackgroundImageInfo.MobileBackgroundImage.OriginImageUri != nil {
url, err := w.ImageX.GetResourceURL(ctx, res.BackgroundImageInfo.MobileBackgroundImage.GetOriginImageUri())
if err != nil {
logs.CtxErrorf(ctx, "get url by uri err, err:%s", err.Error())
return nil, err
}
res.BackgroundImageInfo.MobileBackgroundImage.ImageUrl = &url.URL
}
}
}
return res, nil
}

View File

@ -20,10 +20,13 @@ import (
"context"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
)
type Conversation interface {
GetCurrentConversation(ctx context.Context, req *conversation.GetCurrent) (*conversation.Conversation, error)
Create(ctx context.Context, req *entity.CreateMeta) (*entity.Conversation, error)
NewConversationCtx(ctx context.Context, req *entity.NewConversationCtxRequest) (*entity.NewConversationCtxResponse, error)
}
var defaultSVC Conversation

View File

@ -20,13 +20,16 @@ import (
"context"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
)
type Message interface {
GetByRunIDs(ctx context.Context, conversationID int64, runIDs []int64) ([]*message.Message, error)
PreCreate(ctx context.Context, msg *message.Message) (*message.Message, error)
Create(ctx context.Context, msg *message.Message) (*message.Message, error)
List(ctx context.Context, meta *entity.ListMeta) (*entity.ListResult, error)
Edit(ctx context.Context, msg *message.Message) (*message.Message, error)
Delete(ctx context.Context, req *entity.DeleteMeta) error
}
var defaultSVC Message

View File

@ -20,8 +20,10 @@ import (
"context"
einoCompose "github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
workflowEntity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
)
@ -37,10 +39,13 @@ type Workflow interface {
GetWorkflowIDsByAppID(ctx context.Context, appID int64) ([]int64, error)
SyncExecuteWorkflow(ctx context.Context, config vo.ExecuteConfig, input map[string]any) (*workflowEntity.WorkflowExecution, vo.TerminatePlan, error)
WithExecuteConfig(cfg vo.ExecuteConfig) einoCompose.Option
StreamExecute(ctx context.Context, config vo.ExecuteConfig, input map[string]any) (*schema.StreamReader[*workflowEntity.Message], error)
InitApplicationDefaultConversationTemplate(ctx context.Context, spaceID int64, appID int64, userID int64) error
}
type ExecuteConfig = vo.ExecuteConfig
type ExecuteMode = vo.ExecuteMode
type WorkflowMessage = workflowEntity.Message
const (
ExecuteModeDebug ExecuteMode = "debug"

View File

@ -21,6 +21,7 @@ import (
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossconversation"
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
conversation "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/service"
)
@ -40,3 +41,11 @@ func InitDomainService(c conversation.Conversation) crossconversation.Conversati
func (s *impl) GetCurrentConversation(ctx context.Context, req *model.GetCurrent) (*model.Conversation, error) {
return s.DomainSVC.GetCurrentConversation(ctx, req)
}
func (s *impl) Create(ctx context.Context, req *entity.CreateMeta) (*entity.Conversation, error) {
return s.DomainSVC.Create(ctx, req)
}
func (s *impl) NewConversationCtx(ctx context.Context, req *entity.NewConversationCtxRequest) (*entity.NewConversationCtxResponse, error) {
return s.DomainSVC.NewConversationCtx(ctx, req)
}

View File

@ -21,6 +21,7 @@ import (
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossmessage"
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
message "github.com/coze-dev/coze-studio/backend/domain/conversation/message/service"
)
@ -53,3 +54,11 @@ func (c *impl) Edit(ctx context.Context, msg *model.Message) (*model.Message, er
func (c *impl) PreCreate(ctx context.Context, msg *model.Message) (*model.Message, error) {
return c.DomainSVC.PreCreate(ctx, msg)
}
func (c *impl) List(ctx context.Context, lm *entity.ListMeta) (*entity.ListResult, error) {
return c.DomainSVC.List(ctx, lm)
}
func (c *impl) Delete(ctx context.Context, req *entity.DeleteMeta) error {
return c.DomainSVC.Delete(ctx, req)
}

View File

@ -20,6 +20,7 @@ import (
"context"
einoCompose "github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossworkflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
@ -72,6 +73,14 @@ func (i *impl) WithExecuteConfig(cfg vo.ExecuteConfig) einoCompose.Option {
return i.DomainSVC.WithExecuteConfig(cfg)
}
func (i *impl) StreamExecute(ctx context.Context, config vo.ExecuteConfig, input map[string]any) (*schema.StreamReader[*workflowEntity.Message], error) {
return i.DomainSVC.StreamExecute(ctx, config, input)
}
func (i *impl) InitApplicationDefaultConversationTemplate(ctx context.Context, spaceID int64, appID int64, userID int64) error {
return i.DomainSVC.InitApplicationDefaultConversationTemplate(ctx, spaceID, appID, userID)
}
func (i *impl) GetWorkflowIDsByAppID(ctx context.Context, appID int64) ([]int64, error) {
metas, _, err := i.DomainSVC.MGet(ctx, &vo.MGetPolicy{
MetaQuery: vo.MetaQuery{

View File

@ -0,0 +1,185 @@
package conversation
import (
"context"
"strconv"
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossconversation"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossmessage"
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
msgentity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
)
type ConversationRepository struct {
}
func NewConversationRepository() *ConversationRepository {
return &ConversationRepository{}
}
func (c *ConversationRepository) CreateConversation(ctx context.Context, req *conversation.CreateConversationRequest) (int64, error) {
ret, err := crossconversation.DefaultSVC().Create(ctx, &entity.CreateMeta{
AgentID: req.AppID,
UserID: req.UserID,
ConnectorID: req.ConnectorID,
Scene: common.Scene_SceneWorkflow,
})
if err != nil {
return 0, err
}
return ret.ID, nil
}
func (c *ConversationRepository) CreateMessage(ctx context.Context, req *conversation.CreateMessageRequest) (int64, error) {
msg := &message.Message{
ConversationID: req.ConversationID,
Role: schema.RoleType(req.Role),
Content: req.Content,
ContentType: message.ContentType(req.ContentType),
UserID: strconv.FormatInt(req.UserID, 10),
AgentID: req.AppID,
RunID: req.RunID,
}
if msg.Role == "user" {
msg.MessageType = message.MessageTypeQuestion
} else {
msg.MessageType = message.MessageTypeAnswer
}
ret, err := crossmessage.DefaultSVC().Create(ctx, msg)
if err != nil {
return 0, err
}
return ret.ID, nil
}
func (c *ConversationRepository) MessageList(ctx context.Context, req *conversation.MessageListRequest) (*conversation.MessageListResponse, error) {
lm := &msgentity.ListMeta{
ConversationID: req.ConversationID,
Limit: int(req.Limit), // Since the value of limit is checked inside the node, the type cast here is safe
UserID: strconv.FormatInt(req.UserID, 10),
AgentID: req.AppID,
OrderBy: req.OrderBy,
}
if req.BeforeID != nil {
lm.Cursor, _ = strconv.ParseInt(*req.BeforeID, 10, 64)
lm.Direction = msgentity.ScrollPageDirectionPrev
}
if req.AfterID != nil {
lm.Cursor, _ = strconv.ParseInt(*req.AfterID, 10, 64)
lm.Direction = msgentity.ScrollPageDirectionNext
}
lm.Direction = msgentity.ScrollPageDirectionNext
lr, err := crossmessage.DefaultSVC().List(ctx, lm)
if err != nil {
return nil, err
}
response := &conversation.MessageListResponse{}
if lr.PrevCursor > 0 {
response.FirstID = strconv.FormatInt(lr.PrevCursor, 10)
}
if lr.NextCursor > 0 {
response.LastID = strconv.FormatInt(lr.NextCursor, 10)
}
if len(lr.Messages) == 0 {
return response, nil
}
messages, err := convertMessage(lr.Messages)
if err != nil {
return nil, err
}
response.Messages = messages
return response, nil
}
func (c *ConversationRepository) ClearConversationHistory(ctx context.Context, req *conversation.ClearConversationHistoryReq) error {
_, err := crossconversation.DefaultSVC().NewConversationCtx(ctx, &entity.NewConversationCtxRequest{
ID: req.ConversationID,
})
if err != nil {
return err
}
return nil
}
func (c *ConversationRepository) DeleteMessage(ctx context.Context, req *conversation.DeleteMessageRequest) error {
return crossmessage.DefaultSVC().Delete(ctx, &msgentity.DeleteMeta{
MessageIDs: []int64{req.MessageID},
})
}
func (c *ConversationRepository) EditMessage(ctx context.Context, req *conversation.EditMessageRequest) error {
_, err := crossmessage.DefaultSVC().Edit(ctx, &msgentity.Message{
ID: req.MessageID,
ConversationID: req.ConversationID,
Content: req.Content,
})
if err != nil {
return err
}
return nil
}
func (c *ConversationRepository) GetLatestRunIDs(ctx context.Context, req *conversation.GetLatestRunIDsRequest) ([]int64, error) {
return []int64{0}, nil
}
func (c *ConversationRepository) GetMessagesByRunIDs(ctx context.Context, req *conversation.GetMessagesByRunIDsRequest) (*conversation.GetMessagesByRunIDsResponse, error) {
messages, err := crossmessage.DefaultSVC().GetByRunIDs(ctx, req.ConversationID, req.RunIDs)
if err != nil {
return nil, err
}
msgs, err := convertMessage(messages)
if err != nil {
return nil, err
}
return &conversation.GetMessagesByRunIDsResponse{
Messages: msgs,
}, nil
}
func convertMessage(msgs []*msgentity.Message) ([]*conversation.Message, error) {
messages := make([]*conversation.Message, 0, len(msgs))
for _, m := range msgs {
msg := &conversation.Message{
ID: m.ID,
Role: string(m.Role),
ContentType: string(m.ContentType)}
if m.MultiContent != nil {
var mcs []*conversation.Content
for _, c := range m.MultiContent {
if c.FileData != nil {
for _, fd := range c.FileData {
mcs = append(mcs, &conversation.Content{
Type: string(c.Type),
Uri: ptr.Of(fd.Url),
})
}
} else {
mcs = append(mcs, &conversation.Content{
Type: string(c.Type),
Text: ptr.Of(c.Text),
})
}
}
msg.MultiContent = mcs
} else {
msg.Text = ptr.Of(m.Content)
}
messages = append(messages, msg)
}
return messages, nil
}

View File

@ -0,0 +1,364 @@
package conversation
import (
"testing"
apimessage "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/stretchr/testify/assert"
)
func Test_convertMessage(t *testing.T) {
type args struct {
lr *entity.ListResult
}
tests := []struct {
name string
args args
want *conversation.MessageListResponse
wantErr bool
}{
{
name: "pure text",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 1,
Role: "user",
ContentType: "text",
MultiContent: []*apimessage.InputMetaData{
{
Type: "text",
Text: "hello",
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 1,
Role: "user",
ContentType: "text",
MultiContent: []*conversation.Content{
{Type: "text", Text: ptr.Of("hello")},
},
},
},
},
},
{
name: "pure file",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 2,
Role: "user",
ContentType: "file",
MultiContent: []*apimessage.InputMetaData{
{
Type: "file",
FileData: []*apimessage.FileData{
{
Url: "f_uri_1",
},
},
},
{
Type: "text",
Text: "",
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 2,
Role: "user",
ContentType: "file",
MultiContent: []*conversation.Content{
{Type: "file", Uri: ptr.Of("f_uri_1")},
{Type: "text", Text: ptr.Of("")},
},
},
},
},
},
{
name: "text and file",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 3,
Role: "user",
ContentType: "text_file",
MultiContent: []*apimessage.InputMetaData{
{
Type: "text",
Text: "hello",
},
{
Type: "file",
FileData: []*apimessage.FileData{
{
Url: "f_uri_2",
},
},
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 3,
Role: "user",
ContentType: "text_file",
MultiContent: []*conversation.Content{
{Type: "text", Text: ptr.Of("hello")},
{Type: "file", Uri: ptr.Of("f_uri_2")},
},
},
},
},
},
{
name: "multiple files",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 4,
Role: "user",
ContentType: "file",
MultiContent: []*apimessage.InputMetaData{
{
Type: "file",
FileData: []*apimessage.FileData{
{
Url: "f_uri_3",
},
{
Url: "f_uri_4",
},
},
},
{
Type: "text",
Text: "",
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 4,
Role: "user",
ContentType: "file",
MultiContent: []*conversation.Content{
{Type: "file", Uri: ptr.Of("f_uri_3")},
{Type: "file", Uri: ptr.Of("f_uri_4")},
{Type: "text", Text: ptr.Of("")},
},
},
},
},
},
{
name: "empty text",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 5,
Role: "user",
ContentType: "text",
MultiContent: []*apimessage.InputMetaData{
{
Type: "text",
Text: "",
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 5,
Role: "user",
ContentType: "text",
MultiContent: []*conversation.Content{
{Type: "text", Text: ptr.Of("")},
},
},
},
},
},
{
name: "pure image",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 6,
Role: "user",
ContentType: "image",
MultiContent: []*apimessage.InputMetaData{
{
Type: "image",
FileData: []*apimessage.FileData{
{
Url: "image_uri_5",
},
},
},
{
Type: "text",
Text: "",
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 6,
Role: "user",
ContentType: "image",
MultiContent: []*conversation.Content{
{Type: "image", Uri: ptr.Of("image_uri_5")},
{Type: "text", Text: ptr.Of("")},
},
},
},
},
},
{
name: "multiple images",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 7,
Role: "user",
ContentType: "image",
MultiContent: []*apimessage.InputMetaData{
{
Type: "image",
FileData: []*apimessage.FileData{
{
Url: "file_id_6",
},
{
Url: "file_id_7",
},
},
},
{
Type: "text",
Text: "",
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 7,
Role: "user",
ContentType: "image",
MultiContent: []*conversation.Content{
{Type: "image", Uri: ptr.Of("file_id_6")},
{Type: "image", Uri: ptr.Of("file_id_7")},
{Type: "text", Text: ptr.Of("")},
},
},
},
},
},
{
name: "mixed content",
args: args{
lr: &entity.ListResult{
Messages: []*entity.Message{
{
ID: 8,
Role: "user",
ContentType: "mix",
MultiContent: []*apimessage.InputMetaData{
{
Type: "text",
Text: "hello",
},
{
Type: "image",
FileData: []*apimessage.FileData{
{
Url: "file_id_8",
},
},
},
{
Type: "file",
FileData: []*apimessage.FileData{
{
Url: "file_id_9",
},
},
},
},
},
},
},
},
want: &conversation.MessageListResponse{
Messages: []*conversation.Message{
{
ID: 8,
Role: "user",
ContentType: "mix",
MultiContent: []*conversation.Content{
{Type: "text", Text: ptr.Of("hello")},
{Type: "image", Uri: ptr.Of("file_id_8")},
{Type: "file", Uri: ptr.Of("file_id_9")},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
msgs, err := convertMessage(tt.args.lr.Messages)
if (err != nil) != tt.wantErr {
t.Errorf("convertMessage() error = %v, wantErr %v", err, tt.wantErr)
return
}
for i, msg := range msgs {
assert.Equal(t, msg.MultiContent, tt.want.Messages[i].MultiContent)
}
})
}
}

View File

@ -29,6 +29,7 @@ import (
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossdatabase"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossknowledge"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossplugin"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossworkflow"
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
"github.com/coze-dev/coze-studio/backend/domain/app/repository"
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
@ -67,6 +68,11 @@ func (a *appServiceImpl) CreateDraftAPP(ctx context.Context, req *CreateDraftAPP
return 0, errorx.Wrapf(err, "CreateDraftAPP failed, spaceID=%d", req.SpaceID)
}
err = crossworkflow.DefaultSVC().InitApplicationDefaultConversationTemplate(ctx, req.SpaceID, appID, req.OwnerID)
if err != nil {
return 0, err
}
return appID, nil
}

View File

@ -53,6 +53,20 @@ type AsTool interface {
allInterruptEvents map[string]*entity.ToolInterruptEvent) compose.Option
}
type ConversationService interface {
CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error)
UpdateDraftConversationTemplateName(ctx context.Context, appID int64, userID int64, templateID int64, name string) error
DeleteDraftConversationTemplate(ctx context.Context, templateID int64, wfID2ConversationName map[int64]string) (int64, error)
CheckWorkflowsToReplace(ctx context.Context, appID int64, templateID int64) ([]*entity.Workflow, error)
DeleteDynamicConversation(ctx context.Context, env vo.Env, templateID int64) (int64, error)
ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error)
MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error)
ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error)
ReleaseConversationTemplate(ctx context.Context, appID int64, version string) error
InitApplicationDefaultConversationTemplate(ctx context.Context, spaceID int64, appID int64, userID int64) error
}
type InterruptEventStore interface {
SaveInterruptEvents(ctx context.Context, wfExeID int64, events []*entity.InterruptEvent) error
GetFirstInterruptEvent(ctx context.Context, wfExeID int64) (*entity.InterruptEvent, bool, error)
@ -90,3 +104,22 @@ type ToolFromWorkflow interface {
TerminatePlan() vo.TerminatePlan
GetWorkflow() *entity.Workflow
}
type ConversationIDGenerator func(ctx context.Context, appID int64, userID, connectorID int64) (int64, error)
type ConversationRepository interface {
CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error)
UpdateDraftConversationTemplateName(ctx context.Context, templateID int64, name string) error
DeleteDraftConversationTemplate(ctx context.Context, templateID int64) (int64, error)
GetConversationTemplate(ctx context.Context, env vo.Env, policy vo.GetConversationTemplatePolicy) (*entity.ConversationTemplate, bool, error)
DeleteDynamicConversation(ctx context.Context, env vo.Env, id int64) (int64, error)
ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error)
MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error)
GetOrCreateStaticConversation(ctx context.Context, env vo.Env, idGen ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, bool, error)
GetOrCreateDynamicConversation(ctx context.Context, env vo.Env, idGen ConversationIDGenerator, meta *vo.CreateDynamicConversation) (int64, bool, error)
GetDynamicConversationByName(ctx context.Context, env vo.Env, appID, connectorID, userID int64, name string) (*entity.DynamicConversation, bool, error)
GetStaticConversationByTemplateID(ctx context.Context, env vo.Env, userID, connectorID, templateID int64) (*entity.StaticConversation, bool, error)
ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error)
BatchCreateOnlineConversationTemplate(ctx context.Context, templates []*entity.ConversationTemplate, version string) error
UpdateDynamicConversationNameByID(ctx context.Context, env vo.Env, templateID int64, name string) error
}

View File

@ -16,46 +16,116 @@
package conversation
import "context"
import (
"context"
)
type ClearMessageRequest struct {
Name string
}
type ClearMessageResponse struct {
IsSuccess bool
}
type CreateConversationRequest struct {
Name string
AppID int64
UserID int64
ConnectorID int64
}
type CreateConversationResponse struct {
Result map[string]any
type CreateMessageRequest struct {
ConversationID int64
Role string
Content string
ContentType string
UserID int64
AppID int64
RunID int64
}
type ListMessageRequest struct {
ConversationName string
Limit *int
BeforeID *string
AfterID *string
}
type Message struct {
ID string `json:"id"`
Role string `json:"role"`
ContentType string `json:"contentType"`
Content string `json:"content"`
type MessageListRequest struct {
ConversationID int64
Limit int64
BeforeID *string
AfterID *string
UserID int64
AppID int64
OrderBy *string
}
type ListMessageResponse struct {
type MessageListResponse struct {
Messages []*Message
FirstID string
LastID string
HasMore bool
}
var ConversationManagerImpl ConversationManager
var conversationManagerImpl ConversationManager
type ConversationManager interface {
ClearMessage(context.Context, *ClearMessageRequest) (*ClearMessageResponse, error)
CreateConversation(ctx context.Context, c *CreateConversationRequest) (*CreateConversationResponse, error)
MessageList(ctx context.Context, req *ListMessageRequest) (*ListMessageResponse, error)
func GetConversationManager() ConversationManager {
return conversationManagerImpl
}
func SetConversationManager(c ConversationManager) {
conversationManagerImpl = c
}
type ConversationHistoryRequest struct {
ConversationID int64
AppID int64
UserID int64
Rounds int64
}
type Content struct {
Type string `json:"type"`
Text *string `json:"text,omitempty"`
Uri *string `json:"uri,omitempty"`
}
type Message struct {
ID int64
Role string `json:"role"` // user or assistant
MultiContent []*Content `json:"multi_content"`
Text *string `json:"text,omitempty"`
ContentType string `json:"content_type"`
}
type ConversationHistoryResponse struct {
Messages []*Message
}
type GetLatestRunIDsRequest struct {
ConversationID int64
UserID int64
AppID int64
Rounds int64
}
type ClearConversationHistoryReq struct {
ConversationID int64
}
type DeleteMessageRequest struct {
ConversationID int64
MessageID int64
}
type EditMessageRequest struct {
ConversationID int64
MessageID int64
Content string
}
type GetMessagesByRunIDsRequest struct {
ConversationID int64
RunIDs []int64
}
type GetMessagesByRunIDsResponse struct {
Messages []*Message
}
//go:generate mockgen -destination conversationmock/conversation_mock.go --package conversationmock -source conversation.go
type ConversationManager interface {
CreateConversation(ctx context.Context, req *CreateConversationRequest) (int64, error)
CreateMessage(ctx context.Context, req *CreateMessageRequest) (int64, error)
MessageList(ctx context.Context, req *MessageListRequest) (*MessageListResponse, error)
GetLatestRunIDs(ctx context.Context, req *GetLatestRunIDsRequest) ([]int64, error)
GetMessagesByRunIDs(ctx context.Context, req *GetMessagesByRunIDsRequest) (*GetMessagesByRunIDsResponse, error)
ClearConversationHistory(ctx context.Context, req *ClearConversationHistoryReq) error
DeleteMessage(ctx context.Context, req *DeleteMessageRequest) error
EditMessage(ctx context.Context, req *EditMessageRequest) error
}

View File

@ -0,0 +1,159 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: conversation.go
//
// Generated by this command:
//
// mockgen -destination conversationmock/conversation_mock.go --package conversationmock -source conversation.go
//
// Package conversationmock is a generated GoMock package.
package conversationmock
import (
context "context"
reflect "reflect"
conversation "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
gomock "go.uber.org/mock/gomock"
)
// MockConversationManager is a mock of ConversationManager interface.
type MockConversationManager struct {
ctrl *gomock.Controller
recorder *MockConversationManagerMockRecorder
isgomock struct{}
}
// MockConversationManagerMockRecorder is the mock recorder for MockConversationManager.
type MockConversationManagerMockRecorder struct {
mock *MockConversationManager
}
// NewMockConversationManager creates a new mock instance.
func NewMockConversationManager(ctrl *gomock.Controller) *MockConversationManager {
mock := &MockConversationManager{ctrl: ctrl}
mock.recorder = &MockConversationManagerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockConversationManager) EXPECT() *MockConversationManagerMockRecorder {
return m.recorder
}
// ClearConversationHistory mocks base method.
func (m *MockConversationManager) ClearConversationHistory(ctx context.Context, req *conversation.ClearConversationHistoryReq) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ClearConversationHistory", ctx, req)
ret0, _ := ret[0].(error)
return ret0
}
// ClearConversationHistory indicates an expected call of ClearConversationHistory.
func (mr *MockConversationManagerMockRecorder) ClearConversationHistory(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClearConversationHistory", reflect.TypeOf((*MockConversationManager)(nil).ClearConversationHistory), ctx, req)
}
// CreateConversation mocks base method.
func (m *MockConversationManager) CreateConversation(ctx context.Context, req *conversation.CreateConversationRequest) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateConversation", ctx, req)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateConversation indicates an expected call of CreateConversation.
func (mr *MockConversationManagerMockRecorder) CreateConversation(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateConversation", reflect.TypeOf((*MockConversationManager)(nil).CreateConversation), ctx, req)
}
// CreateMessage mocks base method.
func (m *MockConversationManager) CreateMessage(ctx context.Context, req *conversation.CreateMessageRequest) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateMessage", ctx, req)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateMessage indicates an expected call of CreateMessage.
func (mr *MockConversationManagerMockRecorder) CreateMessage(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateMessage", reflect.TypeOf((*MockConversationManager)(nil).CreateMessage), ctx, req)
}
// DeleteMessage mocks base method.
func (m *MockConversationManager) DeleteMessage(ctx context.Context, req *conversation.DeleteMessageRequest) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteMessage", ctx, req)
ret0, _ := ret[0].(error)
return ret0
}
// DeleteMessage indicates an expected call of DeleteMessage.
func (mr *MockConversationManagerMockRecorder) DeleteMessage(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteMessage", reflect.TypeOf((*MockConversationManager)(nil).DeleteMessage), ctx, req)
}
// EditMessage mocks base method.
func (m *MockConversationManager) EditMessage(ctx context.Context, req *conversation.EditMessageRequest) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EditMessage", ctx, req)
ret0, _ := ret[0].(error)
return ret0
}
// EditMessage indicates an expected call of EditMessage.
func (mr *MockConversationManagerMockRecorder) EditMessage(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EditMessage", reflect.TypeOf((*MockConversationManager)(nil).EditMessage), ctx, req)
}
// GetLatestRunIDs mocks base method.
func (m *MockConversationManager) GetLatestRunIDs(ctx context.Context, req *conversation.GetLatestRunIDsRequest) ([]int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetLatestRunIDs", ctx, req)
ret0, _ := ret[0].([]int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetLatestRunIDs indicates an expected call of GetLatestRunIDs.
func (mr *MockConversationManagerMockRecorder) GetLatestRunIDs(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLatestRunIDs", reflect.TypeOf((*MockConversationManager)(nil).GetLatestRunIDs), ctx, req)
}
// GetMessagesByRunIDs mocks base method.
func (m *MockConversationManager) GetMessagesByRunIDs(ctx context.Context, req *conversation.GetMessagesByRunIDsRequest) (*conversation.GetMessagesByRunIDsResponse, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetMessagesByRunIDs", ctx, req)
ret0, _ := ret[0].(*conversation.GetMessagesByRunIDsResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetMessagesByRunIDs indicates an expected call of GetMessagesByRunIDs.
func (mr *MockConversationManagerMockRecorder) GetMessagesByRunIDs(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMessagesByRunIDs", reflect.TypeOf((*MockConversationManager)(nil).GetMessagesByRunIDs), ctx, req)
}
// MessageList mocks base method.
func (m *MockConversationManager) MessageList(ctx context.Context, req *conversation.MessageListRequest) (*conversation.MessageListResponse, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MessageList", ctx, req)
ret0, _ := ret[0].(*conversation.MessageListResponse)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// MessageList indicates an expected call of MessageList.
func (mr *MockConversationManagerMockRecorder) MessageList(ctx, req any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MessageList", reflect.TypeOf((*MockConversationManager)(nil).MessageList), ctx, req)
}

View File

@ -0,0 +1,37 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package entity
import "time"
type ChatFlowRole struct {
ID int64
WorkflowID int64
ConnectorID int64
Name string
Description string
Version string
AvatarUri string
BackgroundImageInfo string
OnboardingInfo string
SuggestReplyInfo string
AudioConfig string
UserInputConfig string
CreatorID int64
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@ -0,0 +1,23 @@
package entity
type ConversationTemplate struct {
SpaceID int64
AppID int64
Name string
TemplateID int64
}
type StaticConversation struct {
UserID int64
ConnectorID int64
TemplateID int64
ConversationID int64
}
type DynamicConversation struct {
ID int64
UserID int64
ConnectorID int64
ConversationID int64
Name string
}

View File

@ -16,6 +16,15 @@
package entity
import (
"fmt"
"strconv"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type NodeType string
type NodeTypeMeta struct {
@ -116,8 +125,11 @@ const (
NodeTypeCodeRunner NodeType = "CodeRunner"
NodeTypePlugin NodeType = "Plugin"
NodeTypeCreateConversation NodeType = "CreateConversation"
NodeTypeConversationList NodeType = "ConversationList"
NodeTypeMessageList NodeType = "MessageList"
NodeTypeClearMessage NodeType = "ClearMessage"
NodeTypeCreateMessage NodeType = "CreateMessage"
NodeTypeEditMessage NodeType = "EditMessage"
NodeTypeDeleteMessage NodeType = "DeleteMessage"
NodeTypeLambda NodeType = "Lambda"
NodeTypeLLM NodeType = "LLM"
NodeTypeSelector NodeType = "Selector"
@ -125,9 +137,93 @@ const (
NodeTypeSubWorkflow NodeType = "SubWorkflow"
NodeTypeJsonSerialization NodeType = "JsonSerialization"
NodeTypeJsonDeserialization NodeType = "JsonDeserialization"
NodeTypeConversationUpdate NodeType = "ConversationUpdate"
NodeTypeConversationDelete NodeType = "ConversationDelete"
NodeTypeClearConversationHistory NodeType = "ClearConversationHistory"
NodeTypeConversationHistory NodeType = "ConversationHistory"
NodeTypeComment NodeType = "Comment"
)
const (
EntryNodeKey = "100001"
ExitNodeKey = "900001"
)
var blockType2NodeType = map[vo.BlockType]NodeType{
vo.BlockTypeBotStart: NodeTypeEntry,
vo.BlockTypeBotEnd: NodeTypeExit,
vo.BlockTypeBotLLM: NodeTypeLLM,
vo.BlockTypeBotAPI: NodeTypePlugin,
vo.BlockTypeBotCode: NodeTypeCodeRunner,
vo.BlockTypeBotDataset: NodeTypeKnowledgeRetriever,
vo.BlockTypeCondition: NodeTypeSelector,
vo.BlockTypeBotSubWorkflow: NodeTypeSubWorkflow,
vo.BlockTypeDatabase: NodeTypeDatabaseCustomSQL,
vo.BlockTypeBotMessage: NodeTypeOutputEmitter,
vo.BlockTypeBotText: NodeTypeTextProcessor,
vo.BlockTypeQuestion: NodeTypeQuestionAnswer,
vo.BlockTypeBotBreak: NodeTypeBreak,
vo.BlockTypeBotLoopSetVariable: NodeTypeVariableAssignerWithinLoop,
vo.BlockTypeBotLoop: NodeTypeLoop,
vo.BlockTypeBotIntent: NodeTypeIntentDetector,
vo.BlockTypeBotDatasetWrite: NodeTypeKnowledgeIndexer,
vo.BlockTypeBotInput: NodeTypeInputReceiver,
vo.BlockTypeBotBatch: NodeTypeBatch,
vo.BlockTypeBotContinue: NodeTypeContinue,
vo.BlockTypeBotComment: NodeTypeComment,
vo.BlockTypeBotVariableMerge: NodeTypeVariableAggregator,
vo.BlockTypeCreateConversation: NodeTypeCreateConversation,
vo.BlockTypeBotAssignVariable: NodeTypeVariableAssigner,
vo.BlockTypeDatabaseUpdate: NodeTypeDatabaseUpdate,
vo.BlockTypeDatabaseSelect: NodeTypeDatabaseQuery,
vo.BlockTypeDatabaseDelete: NodeTypeDatabaseDelete,
vo.BlockTypeDatabaseInsert: NodeTypeDatabaseInsert,
vo.BlockTypeBotHttp: NodeTypeHTTPRequester,
vo.BlockTypeConversationUpdate: NodeTypeConversationUpdate,
vo.BlockTypeConversationDelete: NodeTypeConversationDelete,
vo.BlockTypeJsonSerialization: NodeTypeJsonSerialization,
vo.BlockTypeJsonDeserialization: NodeTypeJsonDeserialization,
vo.BlockTypeBotDatasetDelete: NodeTypeKnowledgeDeleter,
vo.BlockTypeConversationList: NodeTypeConversationList,
vo.BlockTypeClearConversationHistory: NodeTypeClearConversationHistory,
vo.BlockTypeConversationHistory: NodeTypeConversationHistory,
vo.BlockTypeBotMessageList: NodeTypeMessageList,
vo.BlockTypeCreateMessage: NodeTypeCreateMessage,
vo.BlockTypeEditeMessage: NodeTypeEditMessage,
vo.BlockTypeDeleteMessage: NodeTypeDeleteMessage,
}
var nodeType2BlockType = func() map[NodeType]vo.BlockType {
nodeType2BlockType := make(map[NodeType]vo.BlockType, len(blockType2NodeType))
for k, v := range blockType2NodeType {
nodeType2BlockType[v] = k
}
return nodeType2BlockType
}()
func BlockType2EntityNodeType(t string) (NodeType, error) {
blockType := vo.BlockType(t)
if nodeType, ok := blockType2NodeType[blockType]; ok {
return nodeType, nil
}
return "", fmt.Errorf("cannot map block type'%s' to a node type", t)
}
func NodeTypeToAPINodeTemplateType(nodeType NodeType) (workflow.NodeTemplateType, error) {
if blockType, ok := nodeType2BlockType[nodeType]; ok {
blockTypeInt, err := strconv.ParseInt(string(blockType), 10, 64)
if err != nil {
return 0, err
}
return workflow.NodeTemplateType(blockTypeInt), nil
}
return workflow.NodeTemplateType(0), fmt.Errorf("cannot map entity node type '%s' to a workflow.NodeTemplateType", nodeType)
}
func NodeTypeToBlockType(nodeType NodeType) (vo.BlockType, error) {
if t, ok := nodeType2BlockType[nodeType]; ok {
return t, nil
}
return "", vo.WrapError(errno.ErrSchemaConversionFail,
fmt.Errorf("cannot map entity node type '%s' to a block type", nodeType))
}

View File

@ -17,6 +17,8 @@
package entity
import (
"fmt"
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
)
@ -481,7 +483,6 @@ var NodeTypeMetas = []*NodeTypeMeta{
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-List.jpeg",
SupportBatch: false, // supportBatch: 1
Disabled: true,
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
@ -492,14 +493,13 @@ var NodeTypeMetas = []*NodeTypeMeta{
},
{
ID: 38,
Name: "清除上下文",
Type: NodeTypeClearMessage,
Name: "清空会话历史",
Type: NodeTypeClearConversationHistory,
Category: "conversation_history", // Mapped from cate_list
Desc: "用于清空会话历史清空后LLM看到的会话历史为空",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Delete.jpeg",
SupportBatch: false, // supportBatch: 1
Disabled: true,
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
@ -508,6 +508,25 @@ var NodeTypeMetas = []*NodeTypeMeta{
EnUSName: "Clear conversation history",
EnUSDescription: "Used to clear conversation history. After clearing, the conversation history visible to the LLM node will be empty.",
},
{
ID: 54,
Name: "查询会话历史",
Type: NodeTypeConversationHistory,
Category: "conversation_history", // Mapped from cate_list
Desc: "用于查询会话历史返回LLM可见的会话消息",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-查询会话历史.jpg",
SupportBatch: false,
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Query Conversation History",
EnUSDescription: "Used to query conversation history, returns conversation messages visible to the LLM",
},
{
ID: 39,
Name: "创建会话",
@ -517,15 +536,51 @@ var NodeTypeMetas = []*NodeTypeMeta{
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Create.jpeg",
SupportBatch: false, // supportBatch: 1
Disabled: true,
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Create conversation",
EnUSName: "Create Conversation",
EnUSDescription: "This node is used to create a conversation.",
},
{
ID: 51,
Name: "修改会话",
Type: NodeTypeConversationUpdate,
Category: "conversation_management", // Mapped from cate_list
Desc: "用于修改会话的名字",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-编辑会话.jpg",
SupportBatch: false,
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Edit Conversation",
EnUSDescription: "Used to modify the name of a conversation.",
},
{
ID: 52,
Name: "删除会话",
Type: NodeTypeConversationDelete,
Category: "conversation_management", // Mapped from cate_list
Desc: "用于删除会话",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-删除会话.jpg",
SupportBatch: false,
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Delete Conversation",
EnUSDescription: "Used to delete a conversation.",
},
{
ID: 40,
Name: "变量赋值",
@ -632,13 +687,83 @@ var NodeTypeMetas = []*NodeTypeMeta{
EnUSName: "Add Data",
EnUSDescription: "Add new data records to the table, and insert them into the database after the user enters the data content",
},
{
ID: 53,
Name: "查询会话列表",
Type: NodeTypeConversationList,
Category: "conversation_management",
Desc: "用于查询所有会话,包含静态会话、动态会话",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-查询会话.jpg",
SupportBatch: false,
ExecutableMeta: ExecutableMeta{
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Query Conversation List",
EnUSDescription: "Used to query all conversations, including static conversations and dynamic conversations",
},
{
ID: 55,
Name: "创建消息",
Type: NodeTypeCreateMessage,
Category: "message",
Desc: "用于创建消息",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-创建消息.jpg",
SupportBatch: false, // supportBatch: 1
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Create message",
EnUSDescription: "Used to create messages",
},
{
ID: 56,
Name: "修改消息",
Type: NodeTypeEditMessage,
Category: "message",
Desc: "用于修改消息",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-修改消息.jpg",
SupportBatch: false, // supportBatch: 1
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Edit message",
EnUSDescription: "Used to edit messages",
},
{
ID: 57,
Name: "删除消息",
Type: NodeTypeDeleteMessage,
Category: "message",
Desc: "用于删除消息",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-删除消息.jpg",
SupportBatch: false, // supportBatch: 1
ExecutableMeta: ExecutableMeta{
PreFillZero: true,
PostFillNil: true,
StreamingParadigms: map[StreamingParadigm]bool{Invoke: true},
},
EnUSName: "Delete message",
EnUSDescription: "Used to delete messages",
},
{
ID: 58,
Name: "JSON 序列化",
Type: NodeTypeJsonSerialization,
Category: "utilities",
Desc: "用于把变量转化为JSON字符串",
Color: "F2B600",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-to_json.png",
SupportBatch: false,
ExecutableMeta: ExecutableMeta{
@ -656,7 +781,7 @@ var NodeTypeMetas = []*NodeTypeMeta{
Type: NodeTypeJsonDeserialization,
Category: "utilities",
Desc: "用于将JSON字符串解析为变量",
Color: "F2B600",
Color: "#F2B600",
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-from_json.png",
SupportBatch: false,
ExecutableMeta: ExecutableMeta{
@ -862,6 +987,133 @@ const defaultEnUSInitCanvasJsonSchema = `{
}
}`
const defaultZhCNInitCanvasJsonSchemaChat = `{
"nodes": [{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": 0,
"y": 0
}
},
"data": {
"outputs": [{
"type": "string",
"name": "USER_INPUT",
"required": true
}, {
"type": "string",
"name": "CONVERSATION_NAME",
"required": false,
"description": "本次请求绑定的会话,会自动写入消息、会从该会话读对话历史。",
"defaultValue": "%s"
}],
"nodeMeta": {
"title": "开始",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start.png",
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"subTitle": ""
}
}
}, {
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 1000,
"y": 0
}
},
"data": {
"nodeMeta": {
"title": "结束",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End.png",
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"subTitle": ""
},
"inputs": {
"terminatePlan": "useAnswerContent",
"streamingOutput": true,
"inputParameters": [{
"name": "output",
"input": {
"type": "string",
"value": {
"type": "ref"
}
}
}]
}
}
}]
}`
const defaultEnUSInitCanvasJsonSchemaChat = `{
"nodes": [{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": 0,
"y": 0
}
},
"data": {
"outputs": [{
"type": "string",
"name": "USER_INPUT",
"required": true
}, {
"type": "string",
"name": "CONVERSATION_NAME",
"required": false,
"description": "The conversation bound to this request will automatically write messages and read conversation history from that conversation.",
"defaultValue": "%s"
}],
"nodeMeta": {
"title": "Start",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start.png",
"description": "The starting node of the workflow, used to set the information needed to initiate the workflow.",
"subTitle": ""
}
}
}, {
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 1000,
"y": 0
}
},
"data": {
"nodeMeta": {
"title": "End",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End.png",
"description": "The final node of the workflow, used to return the result information after the workflow runs.",
"subTitle": ""
},
"inputs": {
"terminatePlan": "useAnswerContent",
"streamingOutput": true,
"inputParameters": [{
"name": "output",
"input": {
"type": "string",
"value": {
"type": "ref"
}
}
}]
}
}
}]
}`
func GetDefaultInitCanvasJsonSchema(locale i18n.Locale) string {
return ternary.IFElse(locale == i18n.LocaleEN, defaultEnUSInitCanvasJsonSchema, defaultZhCNInitCanvasJsonSchema)
}
func GetDefaultInitCanvasJsonSchemaChat(locale i18n.Locale, name string) string {
return ternary.IFElse(locale == i18n.LocaleEN, fmt.Sprintf(defaultEnUSInitCanvasJsonSchemaChat, name), fmt.Sprintf(defaultZhCNInitCanvasJsonSchemaChat, name))
}

View File

@ -445,37 +445,47 @@ func (b BlockType) String() string {
}
const (
BlockTypeBotStart BlockType = "1"
BlockTypeBotEnd BlockType = "2"
BlockTypeBotLLM BlockType = "3"
BlockTypeBotAPI BlockType = "4"
BlockTypeBotCode BlockType = "5"
BlockTypeBotDataset BlockType = "6"
BlockTypeCondition BlockType = "8"
BlockTypeBotSubWorkflow BlockType = "9"
BlockTypeDatabase BlockType = "12"
BlockTypeBotMessage BlockType = "13"
BlockTypeBotText BlockType = "15"
BlockTypeQuestion BlockType = "18"
BlockTypeBotBreak BlockType = "19"
BlockTypeBotLoopSetVariable BlockType = "20"
BlockTypeBotLoop BlockType = "21"
BlockTypeBotIntent BlockType = "22"
BlockTypeBotDatasetWrite BlockType = "27"
BlockTypeBotInput BlockType = "30"
BlockTypeBotBatch BlockType = "28"
BlockTypeBotContinue BlockType = "29"
BlockTypeBotComment BlockType = "31"
BlockTypeBotVariableMerge BlockType = "32"
BlockTypeBotAssignVariable BlockType = "40"
BlockTypeDatabaseUpdate BlockType = "42"
BlockTypeDatabaseSelect BlockType = "43"
BlockTypeDatabaseDelete BlockType = "44"
BlockTypeBotHttp BlockType = "45"
BlockTypeDatabaseInsert BlockType = "46"
BlockTypeJsonSerialization BlockType = "58"
BlockTypeJsonDeserialization BlockType = "59"
BlockTypeBotDatasetDelete BlockType = "60"
BlockTypeBotStart BlockType = "1"
BlockTypeBotEnd BlockType = "2"
BlockTypeBotLLM BlockType = "3"
BlockTypeBotAPI BlockType = "4"
BlockTypeBotCode BlockType = "5"
BlockTypeBotDataset BlockType = "6"
BlockTypeCondition BlockType = "8"
BlockTypeBotSubWorkflow BlockType = "9"
BlockTypeDatabase BlockType = "12"
BlockTypeBotMessage BlockType = "13"
BlockTypeBotText BlockType = "15"
BlockTypeQuestion BlockType = "18"
BlockTypeBotBreak BlockType = "19"
BlockTypeBotLoopSetVariable BlockType = "20"
BlockTypeBotLoop BlockType = "21"
BlockTypeBotIntent BlockType = "22"
BlockTypeBotDatasetWrite BlockType = "27"
BlockTypeBotInput BlockType = "30"
BlockTypeBotBatch BlockType = "28"
BlockTypeBotContinue BlockType = "29"
BlockTypeBotComment BlockType = "31"
BlockTypeBotVariableMerge BlockType = "32"
BlockTypeBotMessageList BlockType = "37"
BlockTypeClearConversationHistory BlockType = "38"
BlockTypeCreateConversation BlockType = "39"
BlockTypeBotAssignVariable BlockType = "40"
BlockTypeDatabaseUpdate BlockType = "42"
BlockTypeDatabaseSelect BlockType = "43"
BlockTypeDatabaseDelete BlockType = "44"
BlockTypeBotHttp BlockType = "45"
BlockTypeDatabaseInsert BlockType = "46"
BlockTypeConversationList BlockType = "53"
BlockTypeConversationUpdate BlockType = "51"
BlockTypeConversationDelete BlockType = "52"
BlockTypeConversationHistory BlockType = "54"
BlockTypeCreateMessage BlockType = "55"
BlockTypeEditeMessage BlockType = "56"
BlockTypeDeleteMessage BlockType = "57"
BlockTypeJsonSerialization BlockType = "58"
BlockTypeJsonDeserialization BlockType = "59"
BlockTypeBotDatasetDelete BlockType = "60"
)
type VariableType string

View File

@ -0,0 +1,54 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package vo
type ChatFlowRoleCreate struct {
WorkflowID int64
CreatorID int64
Name string
Description string
AvatarUri string
BackgroundImageInfo string
OnboardingInfo string
SuggestReplyInfo string
AudioConfig string
UserInputConfig string
}
type ChatFlowRoleUpdate struct {
WorkflowID int64
Name *string
Description *string
AvatarUri *string
BackgroundImageInfo *string
OnboardingInfo *string
SuggestReplyInfo *string
AudioConfig *string
UserInputConfig *string
}
type PublishRolePolicy struct {
WorkflowID int64
CreatorID int64
Version string
}
type CopyRolePolicy struct {
SourceID int64
TargetID int64
CreatorID int64
}

View File

@ -0,0 +1,58 @@
package vo
type Env string
const (
Draft Env = "draft"
Online Env = "online"
)
type CreateConversationTemplateMeta struct {
UserID int64
AppID int64
SpaceID int64
Name string
}
type GetConversationTemplatePolicy struct {
AppID *int64
Name *string
Version *string
TemplateID *int64
}
type ListConversationTemplatePolicy struct {
AppID int64
Page *Page
NameLike *string
Version *string
}
type ListConversationMeta struct {
APPID int64
UserID int64
ConnectorID int64
}
type ListConversationPolicy struct {
ListConversationMeta
Page *Page
NameLike *string
Version *string
}
type CreateStaticConversation struct {
AppID int64
UserID int64
ConnectorID int64
TemplateID int64
}
type CreateDynamicConversation struct {
AppID int64
UserID int64
ConnectorID int64
Name string
}

View File

@ -16,22 +16,27 @@
package vo
import "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
type ExecuteConfig struct {
ID int64
From Locator
Version string
CommitID string
Operator int64
Mode ExecuteMode
AppID *int64
AgentID *int64
ConnectorID int64
ConnectorUID string
TaskType TaskType
SyncPattern SyncPattern
InputFailFast bool // whether to fail fast if input conversion has warnings
BizType BizType
Cancellable bool
ID int64
From Locator
Version string
CommitID string
Operator int64
Mode ExecuteMode
AppID *int64
AgentID *int64
ConnectorID int64
ConnectorUID string
TaskType TaskType
SyncPattern SyncPattern
InputFailFast bool // whether to fail fast if input conversion has warnings
BizType BizType
Cancellable bool
WorkflowMode WorkflowMode
RoundID *int64 // if workflow is chat flow, conversation round id is required
ConversationID *int64 // if workflow is chat flow, conversation id is required
}
type ExecuteMode string
@ -42,6 +47,8 @@ const (
ExecuteModeNodeDebug ExecuteMode = "node_debug"
)
type WorkflowMode = workflow.WorkflowMode
type TaskType string
const (

View File

@ -80,4 +80,5 @@ type MetaQuery struct {
LibOnly bool
NeedTotalNumber bool
DescByUpdate bool
Mode *workflow.WorkflowMode
}

View File

@ -20,11 +20,11 @@ import (
"context"
"github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
)
//go:generate mockgen -destination ../../internal/mock/domain/workflow/interface.go --package mockWorkflow -source interface.go
@ -44,6 +44,13 @@ type Service interface {
GetWorkflowReference(ctx context.Context, id int64) (map[int64]*vo.Meta, error)
CreateChatFlowRole(ctx context.Context, role *vo.ChatFlowRoleCreate) (int64, error)
UpdateChatFlowRole(ctx context.Context, workflowID int64, role *vo.ChatFlowRoleUpdate) error
GetChatFlowRole(ctx context.Context, workflowID int64, version string) (*entity.ChatFlowRole, error)
DeleteChatFlowRole(ctx context.Context, id int64, workflowID int64) error
PublishChatFlowRole(ctx context.Context, policy *vo.PublishRolePolicy) error
CopyChatFlowRole(ctx context.Context, policy *vo.CopyRolePolicy) error
Executable
AsTool
@ -52,12 +59,18 @@ type Service interface {
DuplicateWorkflowsByAppID(ctx context.Context, sourceAPPID, targetAppID int64, related vo.ExternalResourceRelated) error
GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*vo.DependenceResource, error)
SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related vo.ExternalResourceRelated) error
ConversationService
}
type Repository interface {
CreateMeta(ctx context.Context, meta *vo.Meta) (int64, error)
CreateVersion(ctx context.Context, id int64, info *vo.VersionInfo, newRefs map[entity.WorkflowReferenceKey]struct{}) (err error)
CreateOrUpdateDraft(ctx context.Context, id int64, draft *vo.DraftInfo) error
CreateChatFlowRoleConfig(ctx context.Context, chatFlowRole *entity.ChatFlowRole) (int64, error)
UpdateChatFlowRoleConfig(ctx context.Context, workflowID int64, chatFlowRole *vo.ChatFlowRoleUpdate) error
GetChatFlowRoleConfig(ctx context.Context, workflowID int64, version string) (*entity.ChatFlowRole, error, bool)
DeleteChatFlowRoleConfig(ctx context.Context, id int64, workflowID int64) error
Delete(ctx context.Context, id int64) error
MDelete(ctx context.Context, ids []int64) error
GetMeta(ctx context.Context, id int64) (*vo.Meta, error)
@ -94,8 +107,11 @@ type Repository interface {
IsApplicationConnectorWorkflowVersion(ctx context.Context, connectorID, workflowID int64, version string) (b bool, err error)
GetObjectUrl(ctx context.Context, objectKey string, opts ...storage.GetOptFn) (string, error)
compose.CheckPointStore
idgen.IDGenerator
ConversationRepository
}
var repositorySingleton Repository

View File

@ -210,33 +210,43 @@ func normalizePorts(connections []*compose.Connection, nodeMap map[string]*vo.No
}
var blockTypeToNodeSchema = map[vo.BlockType]func(*vo.Node, ...OptionFn) (*compose.NodeSchema, error){
vo.BlockTypeBotStart: toEntryNodeSchema,
vo.BlockTypeBotEnd: toExitNodeSchema,
vo.BlockTypeBotLLM: toLLMNodeSchema,
vo.BlockTypeBotLoopSetVariable: toLoopSetVariableNodeSchema,
vo.BlockTypeBotBreak: toBreakNodeSchema,
vo.BlockTypeBotContinue: toContinueNodeSchema,
vo.BlockTypeCondition: toSelectorNodeSchema,
vo.BlockTypeBotText: toTextProcessorNodeSchema,
vo.BlockTypeBotIntent: toIntentDetectorSchema,
vo.BlockTypeDatabase: toDatabaseCustomSQLSchema,
vo.BlockTypeDatabaseSelect: toDatabaseQuerySchema,
vo.BlockTypeDatabaseInsert: toDatabaseInsertSchema,
vo.BlockTypeDatabaseDelete: toDatabaseDeleteSchema,
vo.BlockTypeDatabaseUpdate: toDatabaseUpdateSchema,
vo.BlockTypeBotHttp: toHttpRequesterSchema,
vo.BlockTypeBotDatasetWrite: toKnowledgeIndexerSchema,
vo.BlockTypeBotDatasetDelete: toKnowledgeDeleterSchema,
vo.BlockTypeBotDataset: toKnowledgeRetrieverSchema,
vo.BlockTypeBotAssignVariable: toVariableAssignerSchema,
vo.BlockTypeBotCode: toCodeRunnerSchema,
vo.BlockTypeBotAPI: toPluginSchema,
vo.BlockTypeBotVariableMerge: toVariableAggregatorSchema,
vo.BlockTypeBotInput: toInputReceiverSchema,
vo.BlockTypeBotMessage: toOutputEmitterNodeSchema,
vo.BlockTypeQuestion: toQASchema,
vo.BlockTypeJsonSerialization: toJSONSerializeSchema,
vo.BlockTypeJsonDeserialization: toJSONDeserializeSchema,
vo.BlockTypeBotStart: toEntryNodeSchema,
vo.BlockTypeBotEnd: toExitNodeSchema,
vo.BlockTypeBotLLM: toLLMNodeSchema,
vo.BlockTypeBotLoopSetVariable: toLoopSetVariableNodeSchema,
vo.BlockTypeBotBreak: toBreakNodeSchema,
vo.BlockTypeBotContinue: toContinueNodeSchema,
vo.BlockTypeCondition: toSelectorNodeSchema,
vo.BlockTypeBotText: toTextProcessorNodeSchema,
vo.BlockTypeBotIntent: toIntentDetectorSchema,
vo.BlockTypeDatabase: toDatabaseCustomSQLSchema,
vo.BlockTypeDatabaseSelect: toDatabaseQuerySchema,
vo.BlockTypeDatabaseInsert: toDatabaseInsertSchema,
vo.BlockTypeDatabaseDelete: toDatabaseDeleteSchema,
vo.BlockTypeDatabaseUpdate: toDatabaseUpdateSchema,
vo.BlockTypeBotHttp: toHttpRequesterSchema,
vo.BlockTypeBotDatasetWrite: toKnowledgeIndexerSchema,
vo.BlockTypeBotDatasetDelete: toKnowledgeDeleterSchema,
vo.BlockTypeBotDataset: toKnowledgeRetrieverSchema,
vo.BlockTypeBotAssignVariable: toVariableAssignerSchema,
vo.BlockTypeBotCode: toCodeRunnerSchema,
vo.BlockTypeBotAPI: toPluginSchema,
vo.BlockTypeBotVariableMerge: toVariableAggregatorSchema,
vo.BlockTypeBotInput: toInputReceiverSchema,
vo.BlockTypeBotMessage: toOutputEmitterNodeSchema,
vo.BlockTypeQuestion: toQASchema,
vo.BlockTypeJsonSerialization: toJSONSerializeSchema,
vo.BlockTypeJsonDeserialization: toJSONDeserializeSchema,
vo.BlockTypeCreateConversation: toCreateConversationSchema,
vo.BlockTypeConversationUpdate: toConversationUpdateSchema,
vo.BlockTypeConversationDelete: toConversationDeleteSchema,
vo.BlockTypeConversationList: toConversationListSchema,
vo.BlockTypeClearConversationHistory: toClearConversationHistorySchema,
vo.BlockTypeConversationHistory: toConversationHistorySchema,
vo.BlockTypeCreateMessage: toCreateMessageSchema,
vo.BlockTypeBotMessageList: toMessageListSchema,
vo.BlockTypeDeleteMessage: toDeleteMessageSchema,
vo.BlockTypeEditeMessage: toEditMessageSchema,
}
var blockTypeToSkip = map[vo.BlockType]bool{
@ -1394,11 +1404,10 @@ func toHttpRequesterSchema(n *vo.Node, opts ...OptionFn) (*compose.NodeSchema, e
formDataVars := make([]string, 0)
for i := range inputs.Body.BodyData.FormData.Data {
p := inputs.Body.BodyData.FormData.Data[i]
formDataVars = append(formDataVars, p.Name)
if p.Input.Type == vo.VariableTypeString && p.Input.AssistType > vo.AssistTypeNotSet && p.Input.AssistType < vo.AssistTypeTime {
bodyConfig.FormDataConfig.FileTypeMapping[p.Name] = true
formDataVars = append(formDataVars, p.Name)
}
}
md5FieldMapping.SetBodyFields(formDataVars...)
case httprequester.BodyTypeRawText:
@ -1944,6 +1953,180 @@ func toJSONDeserializeSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, er
return ns, nil
}
func toCreateConversationSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeCreateConversation,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toConversationUpdateSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeConversationUpdate,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toConversationListSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeConversationList,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toCreateMessageSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeCreateMessage,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toMessageListSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeMessageList,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toDeleteMessageSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeDeleteMessage,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toEditMessageSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeEditMessage,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toConversationHistorySchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeConversationHistory,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toClearConversationHistorySchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeClearConversationHistory,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func toConversationDeleteSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, error) {
ns := &compose.NodeSchema{
Key: vo.NodeKey(n.ID),
Type: entity.NodeTypeConversationDelete,
Name: n.Data.Meta.Title,
}
if err := SetInputsForNodeSchema(n, ns); err != nil {
return nil, err
}
if err := SetOutputTypesForNodeSchema(n, ns); err != nil {
return nil, err
}
return ns, nil
}
func buildClauseGroupFromCondition(condition *vo.DBCondition) (*database.ClauseGroup, error) {
clauseGroup := &database.ClauseGroup{}
if len(condition.ConditionList) == 1 {

View File

@ -0,0 +1,93 @@
{
"nodes": [
{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": 13.818572856225469,
"y": -37.20384999753011
}
},
"data": {
"nodeMeta": {
"title": "开始",
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": ""
},
"settings": null,
"version": "",
"outputs": [
{
"type": "string",
"name": "USER_INPUT",
"required": false
},
{
"type": "string",
"name": "CONVERSATION_NAME",
"required": false,
"description": "本次请求绑定的会话,会自动写入消息、会从该会话读对话历史。",
"defaultValue": "Default"
},
{
"type": "string",
"name": "input",
"required": false
}
],
"trigger_parameters": []
}
},
{
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 642.9671427865745,
"y": -37.20384999753011
}
},
"data": {
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
},
"inputs": {
"terminatePlan": "returnVariables",
"inputParameters": [
{
"name": "output",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "100001",
"name": "input"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
}
],
"edges": [
{
"sourceNodeID": "100001",
"targetNodeID": "900001"
}
],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,89 @@
{
"nodes": [{
"blocks": [],
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [{
"name": "USER_INPUT",
"required": false,
"type": "string"
}, {
"defaultValue": "Default",
"description": "本次请求绑定的会话,会自动写入消息、会从该会话读对话历史。",
"name": "CONVERSATION_NAME",
"required": false,
"type": "string"
}],
"trigger_parameters": []
},
"edges": null,
"id": "100001",
"meta": {
"position": {
"x": 0,
"y": 0
}
},
"type": "1"
}, {
"blocks": [],
"data": {
"inputs": {
"content": {
"type": "string",
"value": {
"content": "{{output}}",
"type": "literal"
}
},
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "USER_INPUT",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "output"
}],
"streamingOutput": true,
"terminatePlan": "useAnswerContent"
},
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
}
},
"edges": null,
"id": "900001",
"meta": {
"position": {
"x": 1000,
"y": 0
}
},
"type": "2"
}],
"edges": [{
"sourceNodeID": "100001",
"targetNodeID": "900001",
"sourcePortID": ""
}],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,193 @@
{
"nodes": [{
"blocks": [],
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [{
"name": "USER_INPUT",
"required": false,
"type": "string"
}, {
"defaultValue": "Default",
"description": "本次请求绑定的会话,会自动写入消息、会从该会话读对话历史。",
"name": "CONVERSATION_NAME",
"required": false,
"type": "string"
}],
"trigger_parameters": []
},
"edges": null,
"id": "100001",
"meta": {
"position": {
"x": 0,
"y": 0
}
},
"type": "1"
}, {
"blocks": [],
"data": {
"inputs": {
"content": {
"type": "string",
"value": {
"content": "{{output}}",
"type": "literal"
}
},
"inputParameters": [{
"input": {
"schema": {
"schema": [{
"name": "conversationName",
"type": "string"
}, {
"name": "conversationId",
"type": "string"
}],
"type": "object"
},
"type": "list",
"value": {
"content": {
"blockID": "107363",
"name": "conversationList",
"source": "block-output"
},
"rawMeta": {
"type": 103
},
"type": "ref"
}
},
"name": "output"
}],
"streamingOutput": true,
"terminatePlan": "useAnswerContent"
},
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
}
},
"edges": null,
"id": "900001",
"meta": {
"position": {
"x": 1058,
"y": -13
}
},
"type": "2"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": []
},
"nodeMeta": {
"description": "用于查询所有会话,包含静态会话、动态会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-查询会话.jpg",
"mainColor": "#F2B600",
"subTitle": "查询会话列表",
"title": "查询会话列表"
},
"outputs": [{
"name": "conversationList",
"schema": {
"schema": [{
"name": "conversationName",
"type": "string"
}, {
"name": "conversationId",
"type": "string"
}],
"type": "object"
},
"type": "list"
}]
},
"edges": null,
"id": "107363",
"meta": {
"position": {
"x": 561,
"y": 186
}
},
"type": "53"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "CONVERSATION_NAME",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "conversationName"
}]
},
"nodeMeta": {
"description": "用于创建会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Create.jpeg",
"mainColor": "#F2B600",
"subTitle": "创建会话",
"title": "创建会话"
},
"outputs": [{
"name": "isSuccess",
"type": "boolean"
}, {
"name": "isExisted",
"type": "boolean"
}, {
"name": "conversationId",
"type": "string"
}]
},
"edges": null,
"id": "110245",
"meta": {
"position": {
"x": 487,
"y": -196
}
},
"type": "39"
}],
"edges": [{
"sourceNodeID": "100001",
"targetNodeID": "110245",
"sourcePortID": ""
}, {
"sourceNodeID": "107363",
"targetNodeID": "900001",
"sourcePortID": ""
}, {
"sourceNodeID": "110245",
"targetNodeID": "107363",
"sourcePortID": ""
}],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,137 @@
{
"nodes": [
{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": 180,
"y": 13.700000000000003
}
},
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [
{
"type": "string",
"name": "input",
"required": false
}
],
"trigger_parameters": []
}
},
{
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 1100,
"y": 0.7000000000000028
}
},
"data": {
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
},
"inputs": {
"terminatePlan": "returnVariables",
"inputParameters": [
{
"name": "output",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "163698",
"name": "conversationId"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
},
{
"id": "163698",
"type": "39",
"meta": {
"position": {
"x": 640,
"y": 0
}
},
"data": {
"outputs": [
{
"type": "boolean",
"name": "isSuccess"
},
{
"type": "boolean",
"name": "isExisted"
},
{
"type": "string",
"name": "conversationId"
}
],
"nodeMeta": {
"title": "创建会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Create.jpeg",
"description": "用于创建会话",
"mainColor": "#F2B600",
"subTitle": "创建会话"
},
"inputs": {
"inputParameters": [
{
"name": "conversationName",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "100001",
"name": "input"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
}
],
"edges": [
{
"sourceNodeID": "100001",
"targetNodeID": "163698"
},
{
"sourceNodeID": "163698",
"targetNodeID": "900001"
}
],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,129 @@
{
"nodes": [
{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": -13.523809523809522,
"y": -25.294372294372295
}
},
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [
{
"type": "string",
"name": "input",
"required": false
}
],
"trigger_parameters": []
}
},
{
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 890.3549783549786,
"y": -71.48917748917748
}
},
"data": {
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
},
"inputs": {
"terminatePlan": "returnVariables",
"inputParameters": [
{
"name": "output",
"input": {
"type": "boolean",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "118024",
"name": "isSuccess"
},
"rawMeta": {
"type": 3
}
}
}
}
]
}
}
},
{
"id": "118024",
"type": "52",
"meta": {
"position": {
"x": 423.6623376623378,
"y": -126.39999999999999
}
},
"data": {
"outputs": [
{
"type": "boolean",
"name": "isSuccess"
}
],
"nodeMeta": {
"title": "删除会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-删除会话.jpg",
"description": "用于删除会话",
"mainColor": "#F2B600",
"subTitle": "删除会话"
},
"inputs": {
"inputParameters": [
{
"name": "conversationName",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "100001",
"name": "input"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
}
],
"edges": [
{
"sourceNodeID": "100001",
"targetNodeID": "118024"
},
{
"sourceNodeID": "118024",
"targetNodeID": "900001"
}
],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,191 @@
{
"nodes": [
{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": -243.67931247880136,
"y": -233.598184501318
}
},
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [
{
"type": "string",
"name": "input",
"required": false
}
],
"trigger_parameters": []
}
},
{
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 911.2952705396514,
"y": -331.2250749763467
}
},
"data": {
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
},
"inputs": {
"terminatePlan": "returnVariables",
"inputParameters": [
{
"name": "output",
"input": {
"value": {
"type": "object_ref"
},
"type": "object",
"schema": [
{
"name": "isSuccess",
"input": {
"type": "boolean",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "122336",
"name": "isSuccess"
},
"rawMeta": {
"type": 3
}
}
}
},
{
"name": "isExisted",
"input": {
"type": "boolean",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "122336",
"name": "isExisted"
},
"rawMeta": {
"type": 3
}
}
}
},
{
"name": "conversationId",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "122336",
"name": "conversationId"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
]
}
}
},
{
"id": "122336",
"type": "51",
"meta": {
"position": {
"x": 343.08704991877585,
"y": -462.38794621339696
}
},
"data": {
"outputs": [
{
"type": "boolean",
"name": "isSuccess"
},
{
"type": "boolean",
"name": "isExisted"
},
{
"type": "string",
"name": "conversationId"
}
],
"nodeMeta": {
"title": "修改会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-编辑会话.jpg",
"description": "用于修改会话的名字",
"mainColor": "#F2B600",
"subTitle": "修改会话"
},
"inputs": {
"inputParameters": [
{
"name": "conversationName",
"input": {
"type": "string",
"value": {
"type": "literal",
"content": "template_v1",
"rawMeta": {
"type": 1
}
}
}
},
{
"name": "newConversationName",
"input": {
"type": "string",
"value": {
"type": "literal",
"content": "new",
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
}
],
"edges": [
{
"sourceNodeID": "100001",
"targetNodeID": "122336"
},
{
"sourceNodeID": "122336",
"targetNodeID": "900001"
}
],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,262 @@
{
"nodes": [
{
"id": "100001",
"type": "1",
"meta": {
"position": {
"x": 180,
"y": 13.700000000000003
}
},
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [
{
"type": "string",
"name": "input",
"required": true
},
{
"type": "string",
"name": "new_name",
"required": true
}
],
"trigger_parameters": []
}
},
{
"id": "900001",
"type": "2",
"meta": {
"position": {
"x": 1560,
"y": 0.7000000000000028
}
},
"data": {
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
},
"inputs": {
"terminatePlan": "returnVariables",
"inputParameters": [
{
"name": "obj",
"input": {
"value": {
"type": "object_ref"
},
"type": "object",
"schema": [
{
"name": "isSuccess",
"input": {
"type": "boolean",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "193175",
"name": "isSuccess"
},
"rawMeta": {
"type": 3
}
}
}
},
{
"name": "isExisted",
"input": {
"type": "boolean",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "193175",
"name": "isExisted"
},
"rawMeta": {
"type": 3
}
}
}
},
{
"name": "conversationId",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "193175",
"name": "conversationId"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
]
}
}
},
{
"id": "139551",
"type": "39",
"meta": {
"position": {
"x": 627.929589270746,
"y": -36.21123218776195
}
},
"data": {
"outputs": [
{
"type": "boolean",
"name": "isSuccess"
},
{
"type": "boolean",
"name": "isExisted"
},
{
"type": "string",
"name": "conversationId"
}
],
"nodeMeta": {
"title": "创建会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Create.jpeg",
"description": "用于创建会话",
"mainColor": "#F2B600",
"subTitle": "创建会话"
},
"inputs": {
"inputParameters": [
{
"name": "conversationName",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "100001",
"name": "input"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
},
{
"id": "193175",
"type": "51",
"meta": {
"position": {
"x": 1100,
"y": 0
}
},
"data": {
"outputs": [
{
"type": "boolean",
"name": "isSuccess"
},
{
"type": "boolean",
"name": "isExisted"
},
{
"type": "string",
"name": "conversationId"
}
],
"nodeMeta": {
"title": "修改会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-编辑会话.jpg",
"description": "用于修改会话的名字",
"mainColor": "#F2B600",
"subTitle": "修改会话"
},
"inputs": {
"inputParameters": [
{
"name": "conversationName",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "100001",
"name": "input"
},
"rawMeta": {
"type": 1
}
}
}
},
{
"name": "newConversationName",
"input": {
"type": "string",
"value": {
"type": "ref",
"content": {
"source": "block-output",
"blockID": "100001",
"name": "new_name"
},
"rawMeta": {
"type": 1
}
}
}
}
]
}
}
}
],
"edges": [
{
"sourceNodeID": "100001",
"targetNodeID": "139551"
},
{
"sourceNodeID": "193175",
"targetNodeID": "900001"
},
{
"sourceNodeID": "139551",
"targetNodeID": "193175"
}
],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,234 @@
{
"nodes": [{
"blocks": [],
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [{
"name": "USER_INPUT",
"required": false,
"type": "string"
}, {
"defaultValue": "Default",
"description": "本次请求绑定的会话,会自动写入消息、会从该会话读对话历史。",
"name": "CONVERSATION_NAME",
"required": false,
"type": "string"
}],
"trigger_parameters": []
},
"edges": null,
"id": "100001",
"meta": {
"position": {
"x": 0,
"y": 0
}
},
"type": "1"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "boolean",
"value": {
"content": {
"blockID": "195185",
"name": "isSuccess",
"source": "block-output"
},
"rawMeta": {
"type": 3
},
"type": "ref"
}
},
"name": "output"
}, {
"input": {
"type": "string",
"value": {
"content": {
"blockID": "195185",
"name": "message.messageId",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "mID"
}],
"terminatePlan": "returnVariables"
},
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
}
},
"edges": null,
"id": "900001",
"meta": {
"position": {
"x": 1000,
"y": 0
}
},
"type": "2"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "CONVERSATION_NAME",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "conversationName"
}, {
"input": {
"type": "string",
"value": {
"content": "user",
"type": "literal"
}
},
"name": "role"
}, {
"input": {
"type": "string",
"value": {
"content": "1",
"rawMeta": {
"type": 1
},
"type": "literal"
}
},
"name": "content"
}]
},
"nodeMeta": {
"description": "用于创建消息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-创建消息.jpg",
"mainColor": "#F2B600",
"subTitle": "创建消息",
"title": "创建消息"
},
"outputs": [{
"name": "isSuccess",
"type": "boolean"
}, {
"name": "message",
"schema": [{
"name": "messageId",
"type": "string"
}, {
"name": "role",
"type": "string"
}, {
"name": "contentType",
"type": "string"
}, {
"name": "content",
"type": "string"
}],
"type": "object"
}]
},
"edges": null,
"id": "195185",
"meta": {
"position": {
"x": 482,
"y": -13
}
},
"type": "55"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "CONVERSATION_NAME",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "conversationName"
}]
},
"nodeMeta": {
"description": "用于创建会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Create.jpeg",
"mainColor": "#F2B600",
"subTitle": "创建会话",
"title": "创建会话"
},
"outputs": [{
"name": "isSuccess",
"type": "boolean"
}, {
"name": "isExisted",
"type": "boolean"
}, {
"name": "conversationId",
"type": "string"
}]
},
"edges": null,
"id": "121849",
"meta": {
"position": {
"x": 302,
"y": -236
}
},
"type": "39"
}],
"edges": [{
"sourceNodeID": "100001",
"targetNodeID": "121849",
"sourcePortID": ""
}, {
"sourceNodeID": "195185",
"targetNodeID": "900001",
"sourcePortID": ""
}, {
"sourceNodeID": "121849",
"targetNodeID": "195185",
"sourcePortID": ""
}],
"versions": {
"loop": "v2"
}
}

View File

@ -0,0 +1,310 @@
{
"nodes": [{
"blocks": [],
"data": {
"nodeMeta": {
"description": "工作流的起始节点,用于设定启动工作流需要的信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Start-v2.jpg",
"subTitle": "",
"title": "开始"
},
"outputs": [{
"name": "USER_INPUT",
"required": false,
"type": "string"
}, {
"defaultValue": "Default",
"description": "本次请求绑定的会话,会自动写入消息、会从该会话读对话历史。",
"name": "CONVERSATION_NAME",
"required": false,
"type": "string"
}],
"trigger_parameters": []
},
"edges": null,
"id": "100001",
"meta": {
"position": {
"x": 0,
"y": 0
}
},
"type": "1"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"schema": {
"schema": [{
"name": "messageId",
"type": "string"
}, {
"name": "role",
"type": "string"
}, {
"name": "contentType",
"type": "string"
}, {
"name": "content",
"type": "string"
}],
"type": "object"
},
"type": "list",
"value": {
"content": {
"blockID": "132703",
"name": "messageList",
"source": "block-output"
},
"rawMeta": {
"type": 103
},
"type": "ref"
}
},
"name": "output"
}],
"terminatePlan": "returnVariables"
},
"nodeMeta": {
"description": "工作流的最终节点,用于返回工作流运行后的结果信息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-End-v2.jpg",
"subTitle": "",
"title": "结束"
}
},
"edges": null,
"id": "900001",
"meta": {
"position": {
"x": 1000,
"y": 0
}
},
"type": "2"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "CONVERSATION_NAME",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "conversationName"
}]
},
"nodeMeta": {
"description": "用于查询消息列表",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-List.jpeg",
"mainColor": "#F2B600",
"subTitle": "查询消息列表",
"title": "查询消息列表"
},
"outputs": [{
"name": "messageList",
"schema": {
"schema": [{
"name": "messageId",
"type": "string"
}, {
"name": "role",
"type": "string"
}, {
"name": "contentType",
"type": "string"
}, {
"name": "content",
"type": "string"
}],
"type": "object"
},
"type": "list"
}, {
"name": "firstId",
"type": "string"
}, {
"name": "lastId",
"type": "string"
}, {
"name": "hasMore",
"type": "boolean"
}]
},
"edges": null,
"id": "132703",
"meta": {
"position": {
"x": 514,
"y": 96
}
},
"type": "37"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "CONVERSATION_NAME",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "conversationName"
}]
},
"nodeMeta": {
"description": "用于创建会话",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Conversation-Create.jpeg",
"mainColor": "#F2B600",
"subTitle": "创建会话",
"title": "创建会话"
},
"outputs": [{
"name": "isSuccess",
"type": "boolean"
}, {
"name": "isExisted",
"type": "boolean"
}, {
"name": "conversationId",
"type": "string"
}]
},
"edges": null,
"id": "166724",
"meta": {
"position": {
"x": 323,
"y": -332
}
},
"type": "39"
}, {
"blocks": [],
"data": {
"inputs": {
"inputParameters": [{
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "CONVERSATION_NAME",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "conversationName"
}, {
"input": {
"type": "string",
"value": {
"content": "user",
"type": "literal"
}
},
"name": "role"
}, {
"input": {
"type": "string",
"value": {
"content": {
"blockID": "100001",
"name": "USER_INPUT",
"source": "block-output"
},
"rawMeta": {
"type": 1
},
"type": "ref"
}
},
"name": "content"
}]
},
"nodeMeta": {
"description": "用于创建消息",
"icon": "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-创建消息.jpg",
"mainColor": "#F2B600",
"subTitle": "创建消息",
"title": "创建消息"
},
"outputs": [{
"name": "isSuccess",
"type": "boolean"
}, {
"name": "message",
"schema": [{
"name": "messageId",
"type": "string"
}, {
"name": "role",
"type": "string"
}, {
"name": "contentType",
"type": "string"
}, {
"name": "content",
"type": "string"
}],
"type": "object"
}]
},
"edges": null,
"id": "157061",
"meta": {
"position": {
"x": 479,
"y": -127
}
},
"type": "55"
}],
"edges": [{
"sourceNodeID": "100001",
"targetNodeID": "166724",
"sourcePortID": ""
}, {
"sourceNodeID": "132703",
"targetNodeID": "900001",
"sourcePortID": ""
}, {
"sourceNodeID": "157061",
"targetNodeID": "132703",
"sourcePortID": ""
}, {
"sourceNodeID": "166724",
"targetNodeID": "157061",
"sourcePortID": ""
}],
"versions": {
"loop": "v2"
}
}

View File

@ -19,6 +19,7 @@ package compose
import (
"context"
"fmt"
"runtime/debug"
"github.com/cloudwego/eino/compose"
@ -432,6 +433,61 @@ func (s *NodeSchema) New(ctx context.Context, inner compose.Runnable[map[string]
return nil, err
}
return invokableNode(s, r.Create), nil
case entity.NodeTypeConversationUpdate:
r := conversation.NewUpdateConversation(ctx)
if err != nil {
return nil, err
}
return invokableNode(s, r.Update), nil
case entity.NodeTypeConversationList:
r, err := conversation.NewConversationList(ctx)
if err != nil {
return nil, err
}
return invokableNode(s, r.List), nil
case entity.NodeTypeConversationDelete:
r := conversation.NewDeleteConversation(ctx)
if err != nil {
return nil, err
}
return invokableNode(s, r.Delete), nil
case entity.NodeTypeCreateMessage:
conf, err := s.ToCreateMessageConfig()
if err != nil {
return nil, err
}
r, err := conversation.NewCreateMessage(ctx, conf)
if err != nil {
return nil, err
}
return invokableNode(s, r.Create), nil
case entity.NodeTypeClearConversationHistory:
cfg, err := s.ToClearConversationHistoryConfig()
if err != nil {
return nil, err
}
r, err := conversation.NewClearConversationHistory(ctx, cfg)
if err != nil {
return nil, err
}
return invokableNode(s, r.Clear), nil
case entity.NodeTypeConversationHistory:
cfg, err := s.ToConversationHistoryConfig()
if err != nil {
return nil, err
}
r, err := conversation.NewConversationHistory(ctx, cfg)
if err != nil {
return nil, err
}
return invokableNode(s, r.HistoryMessages), nil
case entity.NodeTypeMessageList:
conf, err := s.ToMessageListConfig()
if err != nil {
@ -442,16 +498,26 @@ func (s *NodeSchema) New(ctx context.Context, inner compose.Runnable[map[string]
return nil, err
}
return invokableNode(s, r.List), nil
case entity.NodeTypeClearMessage:
conf, err := s.ToClearMessageConfig()
case entity.NodeTypeDeleteMessage:
conf, err := s.ToDeleteMessageConfig()
if err != nil {
return nil, err
}
r, err := conversation.NewClearMessage(ctx, conf)
r, err := conversation.NewDeleteMessage(ctx, conf)
if err != nil {
return nil, err
}
return invokableNode(s, r.Clear), nil
return invokableNode(s, r.Delete), nil
case entity.NodeTypeEditMessage:
conf, err := s.ToEditMessageConfig()
if err != nil {
return nil, err
}
r, err := conversation.NewEditMessage(ctx, conf)
if err != nil {
return nil, err
}
return invokableNode(s, r.Edit), nil
case entity.NodeTypeIntentDetector:
conf, err := s.ToIntentDetectorConfig(ctx)
if err != nil {

View File

@ -86,6 +86,8 @@ func init() {
_ = compose.RegisterSerializableType[vo.Locator]("wf_locator")
_ = compose.RegisterSerializableType[vo.BizType]("biz_type")
_ = compose.RegisterSerializableType[*variableassigner.AppVariables]("app_variables")
_ = compose.RegisterSerializableType[workflow2.WorkflowMode]("workflow_mode")
}
func (s *State) SetAppVariableValue(key string, value any) {

View File

@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"runtime/debug"
"strconv"
"time"
@ -502,6 +503,7 @@ func (s *NodeSchema) ToDatabaseCustomSQLConfig() (*database.CustomSQLConfig, err
OutputConfig: s.OutputTypes,
CustomSQLExecutor: crossdatabase.GetDatabaseOperator(),
}, nil
}
func (s *NodeSchema) ToDatabaseQueryConfig() (*database.QueryConfig, error) {
@ -517,6 +519,7 @@ func (s *NodeSchema) ToDatabaseQueryConfig() (*database.QueryConfig, error) {
}
func (s *NodeSchema) ToDatabaseInsertConfig() (*database.InsertConfig, error) {
return &database.InsertConfig{
DatabaseInfoID: mustGetKey[int64]("DatabaseInfoID", s.Configs),
OutputConfig: s.OutputTypes,
@ -534,6 +537,7 @@ func (s *NodeSchema) ToDatabaseDeleteConfig() (*database.DeleteConfig, error) {
}
func (s *NodeSchema) ToDatabaseUpdateConfig() (*database.UpdateConfig, error) {
return &database.UpdateConfig{
DatabaseInfoID: mustGetKey[int64]("DatabaseInfoID", s.Configs),
ClauseGroup: mustGetKey[*crossdatabase.ClauseGroup]("ClauseGroup", s.Configs),
@ -573,6 +577,7 @@ func (s *NodeSchema) ToPluginConfig() (*plugin.Config, error) {
PluginVersion: mustGetKey[string]("PluginVersion", s.Configs),
PluginService: crossplugin.GetPluginService(),
}, nil
}
func (s *NodeSchema) ToCodeRunnerConfig() (*code.Config, error) {
@ -586,19 +591,42 @@ func (s *NodeSchema) ToCodeRunnerConfig() (*code.Config, error) {
func (s *NodeSchema) ToCreateConversationConfig() (*conversation.CreateConversationConfig, error) {
return &conversation.CreateConversationConfig{
Creator: crossconversation.ConversationManagerImpl,
Manager: crossconversation.GetConversationManager(),
}, nil
}
func (s *NodeSchema) ToClearMessageConfig() (*conversation.ClearMessageConfig, error) {
return &conversation.ClearMessageConfig{
Clearer: crossconversation.ConversationManagerImpl,
func (s *NodeSchema) ToDeleteMessageConfig() (*conversation.DeleteMessageConfig, error) {
return &conversation.DeleteMessageConfig{
Manager: crossconversation.GetConversationManager(),
}, nil
}
func (s *NodeSchema) ToEditMessageConfig() (*conversation.EditMessageConfig, error) {
return &conversation.EditMessageConfig{
Manager: crossconversation.GetConversationManager(),
}, nil
}
func (s *NodeSchema) ToCreateMessageConfig() (*conversation.CreateMessageConfig, error) {
return &conversation.CreateMessageConfig{
Creator: crossconversation.GetConversationManager(),
}, nil
}
func (s *NodeSchema) ToMessageListConfig() (*conversation.MessageListConfig, error) {
return &conversation.MessageListConfig{
Lister: crossconversation.ConversationManagerImpl,
Lister: crossconversation.GetConversationManager(),
}, nil
}
func (s *NodeSchema) ToClearConversationHistoryConfig() (*conversation.ClearConversationHistoryConfig, error) {
return &conversation.ClearConversationHistoryConfig{
Manager: crossconversation.GetConversationManager(),
}, nil
}
func (s *NodeSchema) ToConversationHistoryConfig() (*conversation.ConversationHistoryConfig, error) {
return &conversation.ConversationHistoryConfig{
Manager: crossconversation.GetConversationManager(),
}, nil
}

View File

@ -0,0 +1,106 @@
package conversation
import (
"context"
"errors"
"fmt"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type ClearConversationHistoryConfig struct {
Manager conversation.ConversationManager
}
type ClearConversationHistory struct {
cfg *ClearConversationHistoryConfig
}
func NewClearConversationHistory(_ context.Context, cfg *ClearConversationHistoryConfig) (*ClearConversationHistory, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Manager == nil {
return nil, errors.New("manager is required")
}
return &ClearConversationHistory{
cfg: cfg,
}, nil
}
func (c *ClearConversationHistory) Clear(ctx context.Context, in map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
version = execCtx.ExeCfg.Version
)
if agentID != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, query conversation list is not available"))
}
if appID == nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("query conversation list node, app id is required"))
}
conversationName, ok := in["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversation name is required"))
}
t, existed, err := wf.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
var conversationID int64
if existed {
ret, existed, err := wf.GetRepository().GetStaticConversationByTemplateID(ctx, env, userID, connectorID, t.TemplateID)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if existed {
conversationID = ret.ConversationID
}
} else {
ret, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if existed {
conversationID = ret.ConversationID
}
}
if !existed {
return map[string]any{
"isSuccess": false,
}, nil
}
err = c.cfg.Manager.ClearConversationHistory(ctx, &conversation.ClearConversationHistoryReq{
ConversationID: conversationID,
})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return map[string]any{
"isSuccess": true,
}, nil
}

View File

@ -1,64 +0,0 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package conversation
import (
"context"
"errors"
"github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
)
type ClearMessageConfig struct {
Clearer conversation.ConversationManager
}
type MessageClear struct {
config *ClearMessageConfig
}
func NewClearMessage(ctx context.Context, cfg *ClearMessageConfig) (*MessageClear, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Clearer == nil {
return nil, errors.New("clearer is required")
}
return &MessageClear{
config: cfg,
}, nil
}
func (c *MessageClear) Clear(ctx context.Context, input map[string]any) (map[string]any, error) {
name, ok := nodes.TakeMapValue(input, compose.FieldPath{"ConversationName"})
if !ok {
return nil, errors.New("input map should contains 'ConversationName' key ")
}
response, err := c.config.Clearer.ClearMessage(ctx, &conversation.ClearMessageRequest{
Name: name.(string),
})
if err != nil {
return nil, err
}
return map[string]any{
"isSuccess": response.IsSuccess,
}, nil
}

View File

@ -0,0 +1,128 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package conversation
import (
"context"
"fmt"
"strconv"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type ConversationList struct {
}
func NewConversationList(_ context.Context) (*ConversationList, error) {
return &ConversationList{}, nil
}
type conversationInfo struct {
conversationName string
conversationId string
}
func (c *ConversationList) List(ctx context.Context, _ map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
version = execCtx.ExeCfg.Version
)
if agentID != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, query conversation list is not available"))
}
if appID == nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("query conversation list node, app id is required"))
}
templates, err := workflow.GetRepository().ListConversationTemplate(ctx, env, &vo.ListConversationTemplatePolicy{
AppID: *appID,
Version: ptr.Of(version),
})
if err != nil {
return nil, err
}
templateIds := make([]int64, 0, len(templates))
for _, template := range templates {
templateIds = append(templateIds, template.TemplateID)
}
staticConversations, err := workflow.GetRepository().MGetStaticConversation(ctx, env, userID, connectorID, templateIds)
if err != nil {
return nil, err
}
templateIDToConvID := slices.ToMap(staticConversations, func(conv *entity.StaticConversation) (int64, int64) {
return conv.TemplateID, conv.ConversationID
})
var conversationList []conversationInfo
for _, template := range templates {
convID, ok := templateIDToConvID[template.TemplateID]
if !ok {
convID = 0
}
conversationList = append(conversationList, conversationInfo{
conversationName: template.Name,
conversationId: strconv.FormatInt(convID, 10),
})
}
dynamicConversations, err := workflow.GetRepository().ListDynamicConversation(ctx, env, &vo.ListConversationPolicy{
ListConversationMeta: vo.ListConversationMeta{
APPID: *appID,
UserID: userID,
ConnectorID: connectorID,
},
})
if err != nil {
return nil, err
}
for _, conv := range dynamicConversations {
conversationList = append(conversationList, conversationInfo{
conversationName: conv.Name,
conversationId: strconv.FormatInt(conv.ConversationID, 10),
})
}
resultList := make([]any, len(conversationList))
for i, v := range conversationList {
resultList[i] = map[string]any{
"conversationName": v.conversationName,
"conversationId": v.conversationId,
}
}
return map[string]any{
"conversationList": resultList,
}, nil
}

View File

@ -0,0 +1,153 @@
package conversation
import (
"context"
"errors"
"fmt"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type ConversationHistoryConfig struct {
Manager conversation.ConversationManager
}
type ConversationHistory struct {
cfg *ConversationHistoryConfig
}
func NewConversationHistory(_ context.Context, cfg *ConversationHistoryConfig) (*ConversationHistory, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Manager == nil {
return nil, errors.New("manager is required")
}
return &ConversationHistory{
cfg: cfg,
}, nil
}
func (ch *ConversationHistory) HistoryMessages(ctx context.Context, input map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
version = execCtx.ExeCfg.Version
)
if agentID != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, query conversation list is not available"))
}
if appID == nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("query conversation list node, app id is required"))
}
conversationName, ok := input["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversation name is required"))
}
rounds, ok := input["rounds"].(int64)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("rounds is required"))
}
template, existed, err := wf.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
var conversationID int64
if existed {
sts, existed, err := wf.GetRepository().GetStaticConversationByTemplateID(ctx, env, userID, connectorID, template.TemplateID)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if existed {
conversationID = sts.ConversationID
}
} else {
dyConversation, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if existed {
conversationID = dyConversation.ConversationID
}
}
if !existed {
return nil, vo.WrapError(errno.ErrConversationOfAppNotFound, fmt.Errorf("the conversation name does not exist: '%v'", conversationName))
}
isChatFlow := execCtx.ExeCfg.WorkflowMode == workflow.WorkflowMode_ChatFlow
if isChatFlow {
rounds += 1
}
runIDs, err := ch.cfg.Manager.GetLatestRunIDs(ctx, &conversation.GetLatestRunIDsRequest{
ConversationID: conversationID,
UserID: userID,
AppID: *appID,
Rounds: rounds,
})
var messageList []any
if len(runIDs) == 0 {
return map[string]any{
"messageList": messageList,
}, nil
}
if isChatFlow {
if len(runIDs) == 1 {
return map[string]any{
"messageList": messageList,
}, nil
}
runIDs = runIDs[1:] // chatflow needs to filter out this session
}
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
response, err := ch.cfg.Manager.GetMessagesByRunIDs(ctx, &conversation.GetMessagesByRunIDsRequest{
ConversationID: conversationID,
RunIDs: runIDs,
})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
for _, msg := range response.Messages {
content, err := convertMessageToString(ctx, msg)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
messageList = append(messageList, map[string]any{
"role": msg.Role,
"content": content,
})
}
return map[string]any{
"messageList": messageList,
}, nil
}

View File

@ -19,27 +19,31 @@ package conversation
import (
"context"
"errors"
"fmt"
"github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type CreateConversationConfig struct {
Creator conversation.ConversationManager
Manager conversation.ConversationManager
}
type CreateConversation struct {
config *CreateConversationConfig
}
func NewCreateConversation(ctx context.Context, cfg *CreateConversationConfig) (*CreateConversation, error) {
func NewCreateConversation(_ context.Context, cfg *CreateConversationConfig) (*CreateConversation, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Creator == nil {
return nil, errors.New("creator is required")
if cfg.Manager == nil {
return nil, errors.New("manager is required")
}
return &CreateConversation{
config: cfg,
@ -47,16 +51,76 @@ func NewCreateConversation(ctx context.Context, cfg *CreateConversationConfig) (
}
func (c *CreateConversation) Create(ctx context.Context, input map[string]any) (map[string]any, error) {
name, ok := nodes.TakeMapValue(input, compose.FieldPath{"ConversationName"})
if !ok {
return nil, errors.New("input map should contains 'ConversationName' key ")
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
conversationIDGenerator = workflow.ConversationIDGenerator(func(ctx context.Context, appID int64, userID, connectorID int64) (int64, error) {
return c.config.Manager.CreateConversation(ctx, &conversation.CreateConversationRequest{
AppID: appID,
UserID: userID,
ConnectorID: connectorID,
})
})
)
if agentID != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, create conversation is not available"))
}
response, err := c.config.Creator.CreateConversation(ctx, &conversation.CreateConversationRequest{
Name: name.(string),
if appID == nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, errors.New("create conversation node, app id is required"))
}
conversationName, ok := input["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversation name is required"))
}
template, existed, err := workflow.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, err
}
return response.Result, nil
if existed {
cID, existed, err := workflow.GetRepository().GetOrCreateStaticConversation(ctx, env, conversationIDGenerator, &vo.CreateStaticConversation{
AppID: ptr.From(appID),
TemplateID: template.TemplateID,
UserID: userID,
ConnectorID: connectorID,
})
if err != nil {
return nil, err
}
return map[string]any{
"isSuccess": true,
"conversationId": cID,
"isExisted": existed,
}, nil
}
cID, existed, err := workflow.GetRepository().GetOrCreateDynamicConversation(ctx, env, conversationIDGenerator, &vo.CreateDynamicConversation{
AppID: ptr.From(appID),
UserID: userID,
ConnectorID: connectorID,
Name: conversationName,
})
if err != nil {
return nil, err
}
return map[string]any{
"isSuccess": true,
"conversationId": cID,
"isExisted": existed,
}, nil
}

View File

@ -0,0 +1,240 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package conversation
import (
"context"
"errors"
"fmt"
"sync/atomic"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type CreateMessageConfig struct {
Creator conversation.ConversationManager
}
type CreateMessage struct {
config *CreateMessageConfig
}
func NewCreateMessage(_ context.Context, cfg *CreateMessageConfig) (*CreateMessage, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Creator == nil {
return nil, errors.New("creator is required")
}
return &CreateMessage{
config: cfg,
}, nil
}
func (c *CreateMessage) getConversationIDByName(ctx context.Context, env vo.Env, appID *int64, version, conversationName string, userID, connectorID int64) (int64, error) {
template, isExist, err := workflow.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return 0, vo.WrapError(errno.ErrConversationNodeInvalidOperation, err)
}
conversationIDGenerator := workflow.ConversationIDGenerator(func(ctx context.Context, appID int64, userID, connectorID int64) (int64, error) {
return c.config.Creator.CreateConversation(ctx, &conversation.CreateConversationRequest{
AppID: appID,
UserID: userID,
ConnectorID: connectorID,
})
})
var conversationID int64
if isExist {
cID, _, err := workflow.GetRepository().GetOrCreateStaticConversation(ctx, env, conversationIDGenerator, &vo.CreateStaticConversation{
AppID: ptr.From(appID),
TemplateID: template.TemplateID,
UserID: userID,
ConnectorID: connectorID,
})
if err != nil {
return 0, err
}
conversationID = cID
} else {
dc, _, err := workflow.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return 0, err
}
if dc != nil {
conversationID = dc.ConversationID
}
}
return conversationID, nil
}
func (c *CreateMessage) Create(ctx context.Context, input map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
)
conversationName, ok := input["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversationName is required"))
}
role, ok := input["role"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("role is required"))
}
if role != "user" && role != "assistant" {
return nil, vo.WrapError(errno.ErrInvalidParameter, fmt.Errorf("role must be user or assistant"))
}
content, ok := input["content"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrConversationNodeInvalidOperation, errors.New("content is required"))
}
var conversationID int64
var err error
var resolvedAppID int64
if appID == nil {
if conversationName != "Default" {
return nil, vo.WrapError(errno.ErrOnlyDefaultConversationAllowInAgentScenario, errors.New("conversation node only allow in application"))
}
if agentID == nil || execCtx.ExeCfg.ConversationID == nil {
return map[string]any{
"isSuccess": false,
"message": map[string]any{
"messageId": "0",
"role": role,
"contentType": "text",
"content": content,
},
}, nil
}
conversationID = *execCtx.ExeCfg.ConversationID
resolvedAppID = *agentID
} else {
conversationID, err = c.getConversationIDByName(ctx, env, appID, version, conversationName, userID, connectorID)
if err != nil {
return nil, err
}
resolvedAppID = *appID
}
if conversationID == 0 {
return map[string]any{
"isSuccess": false,
"message": map[string]any{
"messageId": "0",
"role": role,
"contentType": "text",
"content": content,
},
}, nil
}
currentConversationID := execCtx.ExeCfg.ConversationID
isCurrentConversation := currentConversationID != nil && *currentConversationID == conversationID
var runID int64
if role == "user" {
// For user messages, always create a new run and store the ID in the context.
newRunID, err := workflow.GetRepository().GenID(ctx)
if err != nil {
return nil, err
}
if execCtx.ExeCfg.RoundID != nil {
atomic.StoreInt64(execCtx.ExeCfg.RoundID, newRunID)
}
runID = newRunID
} else if isCurrentConversation {
// For assistant messages in the same conversation, reuse the runID from the context.
if execCtx.ExeCfg.RoundID == nil {
// This indicates an inconsistent state, as a user message should have set this.
return map[string]any{
"isSuccess": false,
"message": map[string]any{
"messageId": "0",
"role": role,
"contentType": "text",
"content": content,
},
}, nil
}
runID = *execCtx.ExeCfg.RoundID
} else {
// For assistant messages in a different conversation or a new workflow run,
// find the latest runID or create a new one as a fallback.
runIDs, err := c.config.Creator.GetLatestRunIDs(ctx, &conversation.GetLatestRunIDsRequest{
ConversationID: conversationID,
UserID: userID,
AppID: resolvedAppID,
Rounds: 1,
})
if err != nil {
return nil, err
}
if len(runIDs) > 0 && runIDs[0] != 0 {
runID = runIDs[0]
} else {
newRunID, err := workflow.GetRepository().GenID(ctx)
if err != nil {
return nil, err
}
runID = newRunID
}
}
mID, err := c.config.Creator.CreateMessage(ctx, &conversation.CreateMessageRequest{
ConversationID: conversationID,
Role: role,
Content: content,
ContentType: "text",
UserID: userID,
AppID: resolvedAppID,
RunID: runID,
})
if err != nil {
return nil, fmt.Errorf("failed to create message: %w", err)
}
messageOutput := map[string]any{
"messageId": mID,
"role": role,
"contentType": "text",
"content": content,
}
return map[string]any{
"isSuccess": true,
"message": messageOutput,
}, nil
}

View File

@ -0,0 +1,80 @@
package conversation
import (
"context"
"errors"
"fmt"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type DeleteConversation struct {
}
func NewDeleteConversation(_ context.Context) *DeleteConversation {
return &DeleteConversation{}
}
func (c *DeleteConversation) Delete(ctx context.Context, in map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
)
if agentID != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, delete conversation is not available"))
}
if appID == nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, errors.New("delete conversation node, app id is required"))
}
cName, ok := in["conversationName"]
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversation name is required"))
}
conversationName := cName.(string)
_, existed, err := wf.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, err
}
if existed {
return nil, vo.WrapError(errno.ErrConversationNodeInvalidOperation, fmt.Errorf("only conversation created through nodes are allowed to be modified or deleted"))
}
dyConversation, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return nil, err
}
if !existed {
return nil, vo.WrapError(errno.ErrConversationOfAppNotFound, fmt.Errorf("the conversation name does not exist: '%v'", conversationName))
}
_, err = wf.GetRepository().DeleteDynamicConversation(ctx, env, dyConversation.ID)
if err != nil {
return nil, err
}
return map[string]any{
"isSuccess": true,
}, nil
}

View File

@ -0,0 +1,148 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package conversation
import (
"context"
"errors"
"fmt"
"strconv"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type DeleteMessageConfig struct {
Manager conversation.ConversationManager
}
type DeleteMessage struct {
config *DeleteMessageConfig
}
func NewDeleteMessage(_ context.Context, cfg *DeleteMessageConfig) (*DeleteMessage, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Manager == nil {
return nil, errors.New("manager is required")
}
return &DeleteMessage{
config: cfg,
}, nil
}
func (c *DeleteMessage) Delete(ctx context.Context, input map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
successMap = map[string]any{
"isSuccess": true,
}
failedMap = map[string]any{
"isSuccess": false,
}
)
conversationName, ok := input["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversationName is required"))
}
messageStr, ok := input["messageId"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("messageId is required"))
}
messageID, err := strconv.ParseInt(messageStr, 10, 64)
if err != nil {
return nil, vo.WrapError(errno.ErrInvalidParameter, err)
}
if appID == nil {
if conversationName != "Default" {
return nil, vo.WrapError(errno.ErrOnlyDefaultConversationAllowInAgentScenario, fmt.Errorf("only default conversation allow in agent scenario"))
}
if agentID == nil || execCtx.ExeCfg.ConversationID == nil {
return failedMap, nil
}
err = c.config.Manager.DeleteMessage(ctx, &conversation.DeleteMessageRequest{ConversationID: *execCtx.ExeCfg.ConversationID, MessageID: messageID})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return successMap, nil
}
t, existed, err := wf.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if existed {
sts, existed, err := wf.GetRepository().GetStaticConversationByTemplateID(ctx, env, userID, connectorID, t.TemplateID)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if !existed {
return failedMap, nil
}
err = c.config.Manager.DeleteMessage(ctx, &conversation.DeleteMessageRequest{ConversationID: sts.ConversationID, MessageID: messageID})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return successMap, nil
} else {
dyConversation, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if !existed {
return failedMap, nil
}
err = c.config.Manager.DeleteMessage(ctx, &conversation.DeleteMessageRequest{ConversationID: dyConversation.ConversationID, MessageID: messageID})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return successMap, nil
}
}

View File

@ -0,0 +1,154 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package conversation
import (
"context"
"errors"
"fmt"
"strconv"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type EditMessageConfig struct {
Manager conversation.ConversationManager
}
type EditMessage struct {
config *EditMessageConfig
}
func NewEditMessage(_ context.Context, cfg *EditMessageConfig) (*EditMessage, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
if cfg.Manager == nil {
return nil, errors.New("clearer is required")
}
return &EditMessage{
config: cfg,
}, nil
}
func (e *EditMessage) Edit(ctx context.Context, input map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
successMap = map[string]any{
"isSuccess": true,
}
failedMap = map[string]any{
"isSuccess": false,
}
)
conversationName, ok := input["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversationName is required"))
}
messageStr, ok := input["messageId"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("messageId is required"))
}
messageID, err := strconv.ParseInt(messageStr, 10, 64)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
newContent, ok := input["newContent"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("newContent is required"))
}
if appID == nil {
if conversationName != "Default" {
return nil, vo.WrapError(errno.ErrOnlyDefaultConversationAllowInAgentScenario, fmt.Errorf("only default conversation allow in agent scenario"))
}
if agentID == nil || execCtx.ExeCfg.ConversationID == nil {
return failedMap, nil
}
err = e.config.Manager.EditMessage(ctx, &conversation.EditMessageRequest{ConversationID: *execCtx.ExeCfg.ConversationID, MessageID: messageID, Content: newContent})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return successMap, err
}
t, existed, err := wf.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if existed {
sts, existed, err := wf.GetRepository().GetStaticConversationByTemplateID(ctx, env, userID, connectorID, t.TemplateID)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if !existed {
return failedMap, nil
}
err = e.config.Manager.DeleteMessage(ctx, &conversation.DeleteMessageRequest{ConversationID: sts.ConversationID, MessageID: messageID})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return successMap, nil
} else {
dyConversation, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
if !existed {
return failedMap, nil
}
err = e.config.Manager.EditMessage(ctx, &conversation.EditMessageRequest{ConversationID: dyConversation.ConversationID, MessageID: messageID, Content: newContent})
if err != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
}
return successMap, nil
}
}

View File

@ -18,13 +18,18 @@ package conversation
import (
"context"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type MessageListConfig struct {
@ -34,14 +39,7 @@ type MessageList struct {
config *MessageListConfig
}
type Param struct {
ConversationName string
Limit *int
BeforeID *string
AfterID *string
}
func NewMessageList(ctx context.Context, cfg *MessageListConfig) (*MessageList, error) {
func NewMessageList(_ context.Context, cfg *MessageListConfig) (*MessageList, error) {
if cfg == nil {
return nil, errors.New("config is required")
}
@ -56,53 +54,182 @@ func NewMessageList(ctx context.Context, cfg *MessageListConfig) (*MessageList,
}
func (m *MessageList) List(ctx context.Context, input map[string]any) (map[string]any, error) {
param := &Param{}
name, ok := nodes.TakeMapValue(input, compose.FieldPath{"ConversationName"})
if !ok {
return nil, errors.New("ConversationName is required")
}
param.ConversationName = name.(string)
limit, ok := nodes.TakeMapValue(input, compose.FieldPath{"Limit"})
if ok {
limit := limit.(int)
param.Limit = &limit
}
beforeID, ok := nodes.TakeMapValue(input, compose.FieldPath{"BeforeID"})
if ok {
beforeID := beforeID.(string)
param.BeforeID = &beforeID
}
afterID, ok := nodes.TakeMapValue(input, compose.FieldPath{"AfterID"})
if ok {
afterID := afterID.(string)
param.BeforeID = &afterID
}
r, err := m.config.Lister.MessageList(ctx, &conversation.ListMessageRequest{
ConversationName: param.ConversationName,
Limit: param.Limit,
BeforeID: param.BeforeID,
AfterID: param.AfterID,
func (m *MessageList) getConversationIDByName(ctx context.Context, env vo.Env, appID *int64, version, conversationName string, userID, connectorID int64) (int64, error) {
template, isExist, err := workflow.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return 0, vo.WrapError(errno.ErrConversationNodeInvalidOperation, err)
}
var conversationID int64
if isExist {
sc, _, err := workflow.GetRepository().GetStaticConversationByTemplateID(ctx, env, userID, connectorID, template.TemplateID)
if err != nil {
return 0, vo.WrapError(errno.ErrConversationNodeInvalidOperation, err)
}
if sc != nil {
conversationID = sc.ConversationID
}
} else {
dc, _, err := workflow.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return 0, vo.WrapError(errno.ErrConversationNodeInvalidOperation, err)
}
if dc != nil {
conversationID = dc.ConversationID
}
}
return conversationID, nil
}
func (m *MessageList) List(ctx context.Context, input map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
)
conversationName, ok := input["conversationName"].(string)
if !ok {
return nil, vo.WrapError(errno.ErrConversationNodeInvalidOperation, errors.New("ConversationName is required"))
}
var conversationID int64
var err error
var resolvedAppID int64
if appID == nil {
if conversationName != "Default" {
return nil, vo.WrapError(errno.ErrOnlyDefaultConversationAllowInAgentScenario, errors.New("conversation node only allow in application"))
}
if agentID == nil || execCtx.ExeCfg.ConversationID == nil {
return map[string]any{
"messageList": []any{},
"firstId": "0",
"lastId": "0",
"hasMore": false,
}, nil
}
conversationID = *execCtx.ExeCfg.ConversationID
resolvedAppID = *agentID
} else {
conversationID, err = m.getConversationIDByName(ctx, env, appID, version, conversationName, userID, connectorID)
if err != nil {
return nil, err
}
resolvedAppID = *appID
}
req := &conversation.MessageListRequest{
UserID: userID,
AppID: resolvedAppID,
ConversationID: conversationID,
}
if req.ConversationID == 0 {
return map[string]any{
"messageList": []any{},
"firstId": "0",
"lastId": "0",
"hasMore": false,
}, nil
}
limit, ok := input["Limit"].(int64)
if ok {
if limit > 0 && limit <= 50 {
req.Limit = limit
} else {
req.Limit = 50
}
} else {
req.Limit = 50
}
beforeID, ok := input["beforeId"].(string)
if ok {
req.BeforeID = &beforeID
}
afterID, ok := input["afterId"].(string)
if ok {
req.AfterID = &afterID
}
if beforeID != "" && afterID != "" {
return nil, vo.WrapError(errno.ErrInvalidParameter, fmt.Errorf("BeforeID and AfterID cannot be set at the same time"))
}
ml, err := m.config.Lister.MessageList(ctx, req)
if err != nil {
return nil, err
}
result := make(map[string]any)
objects := make([]any, 0, len(r.Messages))
for _, msg := range r.Messages {
object := make(map[string]any)
bs, _ := json.Marshal(msg)
err := json.Unmarshal(bs, &object)
var messageList []any
for _, msg := range ml.Messages {
content, err := convertMessageToString(ctx, msg)
if err != nil {
return nil, err
}
objects = append(objects, object)
messageList = append(messageList, map[string]any{
"messageId": strconv.FormatInt(msg.ID, 10),
"role": msg.Role,
"contentType": msg.ContentType,
"content": content,
})
}
result["messageList"] = objects
result["firstId"] = r.FirstID
result["hasMore"] = r.HasMore
return result, nil
// TODO: After the List interface is updated, the firstId and lastId from the response can be returned directly without extra processing
var firstId, lastId any = "0", "0"
if len(messageList) > 0 {
if firstMsg, ok := messageList[0].(map[string]any); ok {
firstId = firstMsg["messageId"]
}
if lastMsg, ok := messageList[len(messageList)-1].(map[string]any); ok {
lastId = lastMsg["messageId"]
}
}
return map[string]any{
"messageList": messageList,
"firstId": firstId,
"lastId": lastId,
"hasMore": ml.HasMore,
}, nil
}
func convertMessageToString(ctx context.Context, msg *conversation.Message) (string, error) {
if msg.MultiContent != nil {
sb := strings.Builder{}
for idx, m := range msg.MultiContent {
if m.Uri != nil {
url, err := workflow.GetRepository().GetObjectUrl(ctx, ptr.From(m.Uri))
if err != nil {
return "", err
}
sb.WriteString(url)
} else if m.Text != nil {
sb.WriteString(ptr.From(m.Text))
}
if idx < len(msg.MultiContent)-1 {
sb.WriteString(",")
}
}
return sb.String(), nil
} else if msg.Text != nil {
return ptr.From(msg.Text), nil
} else {
return "", vo.WrapError(errno.ErrInvalidParameter, errors.New("message is invalid"))
}
}

View File

@ -0,0 +1,107 @@
package conversation
import (
"context"
"errors"
"fmt"
"strconv"
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type UpdateConversation struct {
}
func NewUpdateConversation(_ context.Context) *UpdateConversation {
return &UpdateConversation{}
}
func (c *UpdateConversation) Update(ctx context.Context, in map[string]any) (map[string]any, error) {
var (
execCtx = execute.GetExeCtx(ctx)
env = ternary.IFElse(execCtx.ExeCfg.Mode == vo.ExecuteModeRelease, vo.Online, vo.Draft)
appID = execCtx.ExeCfg.AppID
agentID = execCtx.ExeCfg.AgentID
version = execCtx.ExeCfg.Version
connectorID = execCtx.ExeCfg.ConnectorID
userID = execCtx.ExeCfg.Operator
)
cName, ok := in["conversationName"]
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversation name is required"))
}
conversationName := cName.(string)
ncName, ok := in["newConversationName"]
if !ok {
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("new conversationName name is required"))
}
newConversationName := ncName.(string)
if agentID != nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, update conversation is not available"))
}
if appID == nil {
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, errors.New("conversation update node, app id is required"))
}
_, existed, err := wf.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
AppID: appID,
Name: ptr.Of(conversationName),
Version: ptr.Of(version),
})
if err != nil {
return nil, err
}
if existed {
return nil, vo.WrapError(errno.ErrConversationNodeInvalidOperation, fmt.Errorf("only conversation created through nodes are allowed to be modified or deleted"))
}
conversation, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, conversationName)
if err != nil {
return nil, err
}
if !existed {
return map[string]any{
"conversationId": "0",
"isSuccess": false,
"isExisted": false,
}, nil
}
ncConversation, existed, err := wf.GetRepository().GetDynamicConversationByName(ctx, env, *appID, connectorID, userID, newConversationName)
if err != nil {
return nil, err
}
if existed {
return map[string]any{
"conversationId": strconv.FormatInt(ncConversation.ConversationID, 10),
"isSuccess": false,
"isExisted": true,
}, nil
}
err = wf.GetRepository().UpdateDynamicConversationNameByID(ctx, env, conversation.ID, newConversationName)
if err != nil {
return nil, err
}
return map[string]any{
"conversationId": strconv.FormatInt(conversation.ConversationID, 10),
"isSuccess": true,
"isExisted": false,
}, nil
}

View File

@ -0,0 +1,710 @@
package repo
import (
"context"
"errors"
"fmt"
"gorm.io/gen"
"gorm.io/gorm"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
const batchSize = 10
func (r *RepositoryImpl) CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error) {
id, err := r.GenID(ctx)
if err != nil {
return 0, vo.WrapError(errno.ErrIDGenError, err)
}
m := &model.AppConversationTemplateDraft{
ID: id,
AppID: template.AppID,
SpaceID: template.SpaceID,
Name: template.Name,
CreatorID: template.UserID,
TemplateID: id,
}
err = r.query.AppConversationTemplateDraft.WithContext(ctx).Create(m)
if err != nil {
return 0, vo.WrapError(errno.ErrDatabaseError, err)
}
return id, nil
}
func (r *RepositoryImpl) GetConversationTemplate(ctx context.Context, env vo.Env, policy vo.GetConversationTemplatePolicy) (*entity.ConversationTemplate, bool, error) {
var (
appID = policy.AppID
name = policy.Name
version = policy.Version
templateID = policy.TemplateID
)
conditions := make([]gen.Condition, 0)
if env == vo.Draft {
if appID != nil {
conditions = append(conditions, r.query.AppConversationTemplateDraft.AppID.Eq(*appID))
}
if name != nil {
conditions = append(conditions, r.query.AppConversationTemplateDraft.Name.Eq(*name))
}
if templateID != nil {
conditions = append(conditions, r.query.AppConversationTemplateDraft.TemplateID.Eq(*templateID))
}
template, err := r.query.AppConversationTemplateDraft.WithContext(ctx).Where(conditions...).First()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
return nil, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return &entity.ConversationTemplate{
AppID: template.AppID,
Name: template.Name,
TemplateID: template.TemplateID,
}, true, nil
} else if env == vo.Online {
if policy.Version == nil {
return nil, false, fmt.Errorf("need to set the version to query the online environment template")
}
conditions = append(conditions, r.query.AppConversationTemplateOnline.Version.Eq(*version))
if appID != nil {
conditions = append(conditions, r.query.AppConversationTemplateOnline.AppID.Eq(*appID))
}
if name != nil {
conditions = append(conditions, r.query.AppConversationTemplateOnline.Name.Eq(*name))
}
if templateID != nil {
conditions = append(conditions, r.query.AppConversationTemplateOnline.TemplateID.Eq(*templateID))
}
template, err := r.query.AppConversationTemplateOnline.WithContext(ctx).Where(conditions...).First()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
return nil, false, err
}
return &entity.ConversationTemplate{
AppID: template.AppID,
Name: template.Name,
TemplateID: template.TemplateID,
}, true, nil
}
return nil, false, fmt.Errorf("unknown env %v", env)
}
func (r *RepositoryImpl) UpdateDraftConversationTemplateName(ctx context.Context, templateID int64, name string) error {
_, err := r.query.AppConversationTemplateDraft.WithContext(ctx).Where(
r.query.AppConversationTemplateDraft.TemplateID.Eq(templateID),
).UpdateColumnSimple(r.query.AppConversationTemplateDraft.Name.Value(name))
if err != nil {
return vo.WrapError(errno.ErrDatabaseError, err)
}
return nil
}
func (r *RepositoryImpl) DeleteDraftConversationTemplate(ctx context.Context, templateID int64) (int64, error) {
resultInfo, err := r.query.AppConversationTemplateDraft.WithContext(ctx).Where(
r.query.AppConversationTemplateDraft.TemplateID.Eq(templateID),
).Delete()
if err != nil {
return 0, vo.WrapError(errno.ErrDatabaseError, err)
}
return resultInfo.RowsAffected, nil
}
func (r *RepositoryImpl) DeleteDynamicConversation(ctx context.Context, env vo.Env, id int64) (int64, error) {
if env == vo.Draft {
info, err := r.query.AppDynamicConversationDraft.WithContext(ctx).Where(r.query.AppDynamicConversationDraft.ID.Eq(id)).Delete()
if err != nil {
return 0, vo.WrapError(errno.ErrDatabaseError, err)
}
return info.RowsAffected, nil
} else if env == vo.Online {
info, err := r.query.AppDynamicConversationOnline.WithContext(ctx).Where(r.query.AppDynamicConversationOnline.ID.Eq(id)).Delete()
if err != nil {
return 0, vo.WrapError(errno.ErrDatabaseError, err)
}
return info.RowsAffected, nil
} else {
return 0, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
if env == vo.Draft {
return r.listDraftConversationTemplate(ctx, policy)
} else if env == vo.Online {
return r.listOnlineConversationTemplate(ctx, policy)
} else {
return nil, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) listDraftConversationTemplate(ctx context.Context, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
conditions := make([]gen.Condition, 0)
conditions = append(conditions, r.query.AppConversationTemplateDraft.AppID.Eq(policy.AppID))
if policy.NameLike != nil {
conditions = append(conditions, r.query.AppConversationTemplateDraft.Name.Like("%%"+*policy.NameLike+"%%"))
}
appConversationTemplateDraftDao := r.query.AppConversationTemplateDraft.WithContext(ctx)
var (
templates []*model.AppConversationTemplateDraft
err error
)
if policy.Page != nil {
templates, err = appConversationTemplateDraftDao.Where(conditions...).Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
} else {
templates, err = appConversationTemplateDraftDao.Where(conditions...).Find()
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []*entity.ConversationTemplate{}, nil
}
return nil, vo.WrapError(errno.ErrDatabaseError, err)
}
return slices.Transform(templates, func(a *model.AppConversationTemplateDraft) *entity.ConversationTemplate {
return &entity.ConversationTemplate{
SpaceID: a.SpaceID,
AppID: a.AppID,
Name: a.Name,
TemplateID: a.TemplateID,
}
}), nil
}
func (r *RepositoryImpl) listOnlineConversationTemplate(ctx context.Context, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
conditions := make([]gen.Condition, 0)
conditions = append(conditions, r.query.AppConversationTemplateOnline.AppID.Eq(policy.AppID))
if policy.Version == nil {
return nil, fmt.Errorf("list online template fail, version is required")
}
conditions = append(conditions, r.query.AppConversationTemplateOnline.Version.Eq(*policy.Version))
if policy.NameLike != nil {
conditions = append(conditions, r.query.AppConversationTemplateOnline.Name.Like("%%"+*policy.NameLike+"%%"))
}
appConversationTemplateOnlineDao := r.query.AppConversationTemplateOnline.WithContext(ctx)
var (
templates []*model.AppConversationTemplateOnline
err error
)
if policy.Page != nil {
templates, err = appConversationTemplateOnlineDao.Where(conditions...).Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
} else {
templates, err = appConversationTemplateOnlineDao.Where(conditions...).Find()
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []*entity.ConversationTemplate{}, nil
}
return nil, vo.WrapError(errno.ErrDatabaseError, err)
}
return slices.Transform(templates, func(a *model.AppConversationTemplateOnline) *entity.ConversationTemplate {
return &entity.ConversationTemplate{
SpaceID: a.SpaceID,
AppID: a.AppID,
Name: a.Name,
TemplateID: a.TemplateID,
}
}), nil
}
func (r *RepositoryImpl) MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
if env == vo.Draft {
return r.mGetDraftStaticConversation(ctx, userID, connectorID, templateIDs)
} else if env == vo.Online {
return r.mGetOnlineStaticConversation(ctx, userID, connectorID, templateIDs)
} else {
return nil, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) mGetDraftStaticConversation(ctx context.Context, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
conditions := make([]gen.Condition, 0, 3)
conditions = append(conditions, r.query.AppStaticConversationDraft.UserID.Eq(userID))
conditions = append(conditions, r.query.AppStaticConversationDraft.ConnectorID.Eq(connectorID))
if len(templateIDs) == 1 {
conditions = append(conditions, r.query.AppStaticConversationDraft.TemplateID.Eq(templateIDs[0]))
} else {
conditions = append(conditions, r.query.AppStaticConversationDraft.TemplateID.In(templateIDs...))
}
cs, err := r.query.AppStaticConversationDraft.WithContext(ctx).Where(conditions...).Find()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []*entity.StaticConversation{}, nil
}
return nil, vo.WrapError(errno.ErrDatabaseError, err)
}
return slices.Transform(cs, func(a *model.AppStaticConversationDraft) *entity.StaticConversation {
return &entity.StaticConversation{
TemplateID: a.TemplateID,
ConversationID: a.ConversationID,
UserID: a.UserID,
ConnectorID: a.ConnectorID,
}
}), nil
}
func (r *RepositoryImpl) mGetOnlineStaticConversation(ctx context.Context, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
conditions := make([]gen.Condition, 0, 3)
conditions = append(conditions, r.query.AppStaticConversationOnline.UserID.Eq(userID))
conditions = append(conditions, r.query.AppStaticConversationOnline.ConnectorID.Eq(connectorID))
if len(templateIDs) == 1 {
conditions = append(conditions, r.query.AppStaticConversationOnline.TemplateID.Eq(templateIDs[0]))
} else {
conditions = append(conditions, r.query.AppStaticConversationOnline.TemplateID.In(templateIDs...))
}
cs, err := r.query.AppStaticConversationOnline.WithContext(ctx).Where(conditions...).Find()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []*entity.StaticConversation{}, nil
}
return nil, vo.WrapError(errno.ErrDatabaseError, err)
}
return slices.Transform(cs, func(a *model.AppStaticConversationOnline) *entity.StaticConversation {
return &entity.StaticConversation{
TemplateID: a.TemplateID,
ConversationID: a.ConversationID,
}
}), nil
}
func (r *RepositoryImpl) ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
if env == vo.Draft {
return r.listDraftDynamicConversation(ctx, policy)
} else if env == vo.Online {
return r.listOnlineDynamicConversation(ctx, policy)
} else {
return nil, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) listDraftDynamicConversation(ctx context.Context, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
var (
appID = policy.APPID
userID = policy.UserID
connectorID = policy.ConnectorID
)
conditions := make([]gen.Condition, 0)
conditions = append(conditions, r.query.AppDynamicConversationDraft.AppID.Eq(appID))
conditions = append(conditions, r.query.AppDynamicConversationDraft.UserID.Eq(userID))
conditions = append(conditions, r.query.AppDynamicConversationDraft.ConnectorID.Eq(connectorID))
if policy.NameLike != nil {
conditions = append(conditions, r.query.AppDynamicConversationDraft.Name.Like("%%"+*policy.NameLike+"%%"))
}
appDynamicConversationDraftDao := r.query.AppDynamicConversationDraft.WithContext(ctx).Where(conditions...)
var (
dynamicConversations = make([]*model.AppDynamicConversationDraft, 0)
err error
)
if policy.Page != nil {
dynamicConversations, err = appDynamicConversationDraftDao.Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
} else {
dynamicConversations, err = appDynamicConversationDraftDao.Where(conditions...).Find()
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []*entity.DynamicConversation{}, nil
}
return nil, vo.WrapError(errno.ErrDatabaseError, err)
}
return slices.Transform(dynamicConversations, func(a *model.AppDynamicConversationDraft) *entity.DynamicConversation {
return &entity.DynamicConversation{
ID: a.ID,
Name: a.Name,
UserID: a.UserID,
ConnectorID: a.ConnectorID,
ConversationID: a.ConversationID,
}
}), nil
}
func (r *RepositoryImpl) listOnlineDynamicConversation(ctx context.Context, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
var (
appID = policy.APPID
userID = policy.UserID
connectorID = policy.ConnectorID
)
conditions := make([]gen.Condition, 0)
conditions = append(conditions, r.query.AppDynamicConversationOnline.AppID.Eq(appID))
conditions = append(conditions, r.query.AppDynamicConversationOnline.UserID.Eq(userID))
conditions = append(conditions, r.query.AppDynamicConversationOnline.AppID.Eq(appID))
conditions = append(conditions, r.query.AppDynamicConversationOnline.ConnectorID.Eq(connectorID))
if policy.NameLike != nil {
conditions = append(conditions, r.query.AppDynamicConversationOnline.Name.Like("%%"+*policy.NameLike+"%%"))
}
appDynamicConversationOnlineDao := r.query.AppDynamicConversationOnline.WithContext(ctx).Where(conditions...)
var (
dynamicConversations = make([]*model.AppDynamicConversationOnline, 0)
err error
)
if policy.Page != nil {
dynamicConversations, err = appDynamicConversationOnlineDao.Offset(policy.Page.Offset()).Limit(policy.Page.Limit()).Find()
} else {
dynamicConversations, err = appDynamicConversationOnlineDao.Where(conditions...).Find()
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return []*entity.DynamicConversation{}, nil
}
return nil, vo.WrapError(errno.ErrDatabaseError, err)
}
return slices.Transform(dynamicConversations, func(a *model.AppDynamicConversationOnline) *entity.DynamicConversation {
return &entity.DynamicConversation{
ID: a.ID,
Name: a.Name,
UserID: a.UserID,
ConnectorID: a.ConnectorID,
ConversationID: a.ConversationID,
}
}), nil
}
func (r *RepositoryImpl) GetOrCreateStaticConversation(ctx context.Context, env vo.Env, idGen workflow.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, bool, error) {
if env == vo.Draft {
return r.getOrCreateDraftStaticConversation(ctx, idGen, meta)
} else if env == vo.Online {
return r.getOrCreateOnlineStaticConversation(ctx, idGen, meta)
} else {
return 0, false, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) GetOrCreateDynamicConversation(ctx context.Context, env vo.Env, idGen workflow.ConversationIDGenerator, meta *vo.CreateDynamicConversation) (int64, bool, error) {
if env == vo.Draft {
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
ret, err := appDynamicConversationDraft.WithContext(ctx).Where(
appDynamicConversationDraft.AppID.Eq(meta.AppID),
appDynamicConversationDraft.ConnectorID.Eq(meta.ConnectorID),
appDynamicConversationDraft.UserID.Eq(meta.UserID),
appDynamicConversationDraft.Name.Eq(meta.Name),
).First()
if err == nil {
return ret.ConversationID, true, nil
}
if !errors.Is(err, gorm.ErrRecordNotFound) {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
cID, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
if err != nil {
return 0, false, err
}
id, err := r.GenID(ctx)
if err != nil {
return 0, false, vo.WrapError(errno.ErrIDGenError, err)
}
err = r.query.AppDynamicConversationDraft.WithContext(ctx).Create(&model.AppDynamicConversationDraft{
ID: id,
AppID: meta.AppID,
Name: meta.Name,
UserID: meta.UserID,
ConnectorID: meta.ConnectorID,
ConversationID: cID,
})
if err != nil {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return cID, false, nil
} else if env == vo.Online {
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
ret, err := appDynamicConversationOnline.WithContext(ctx).Where(
appDynamicConversationOnline.AppID.Eq(meta.AppID),
appDynamicConversationOnline.ConnectorID.Eq(meta.ConnectorID),
appDynamicConversationOnline.UserID.Eq(meta.UserID),
appDynamicConversationOnline.Name.Eq(meta.Name),
).First()
if err == nil {
return ret.ConversationID, true, nil
}
if !errors.Is(err, gorm.ErrRecordNotFound) {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
cID, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
if err != nil {
return 0, false, err
}
id, err := r.GenID(ctx)
if err != nil {
return 0, false, vo.WrapError(errno.ErrIDGenError, err)
}
err = r.query.AppDynamicConversationOnline.WithContext(ctx).Create(&model.AppDynamicConversationOnline{
ID: id,
AppID: meta.AppID,
Name: meta.Name,
UserID: meta.UserID,
ConnectorID: meta.ConnectorID,
ConversationID: cID,
})
if err != nil {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return cID, false, nil
} else {
return 0, false, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) GetStaticConversationByTemplateID(ctx context.Context, env vo.Env, userID, connectorID, templateID int64) (*entity.StaticConversation, bool, error) {
if env == vo.Draft {
conditions := make([]gen.Condition, 0, 3)
conditions = append(conditions, r.query.AppStaticConversationDraft.UserID.Eq(userID))
conditions = append(conditions, r.query.AppStaticConversationDraft.ConnectorID.Eq(connectorID))
conditions = append(conditions, r.query.AppStaticConversationDraft.TemplateID.Eq(templateID))
cs, err := r.query.AppStaticConversationDraft.WithContext(ctx).Where(conditions...).First()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
return nil, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return &entity.StaticConversation{
UserID: cs.UserID,
ConnectorID: cs.ConnectorID,
TemplateID: cs.TemplateID,
ConversationID: cs.ConversationID,
}, true, nil
} else if env == vo.Online {
conditions := make([]gen.Condition, 0, 3)
conditions = append(conditions, r.query.AppStaticConversationOnline.UserID.Eq(userID))
conditions = append(conditions, r.query.AppStaticConversationOnline.ConnectorID.Eq(connectorID))
conditions = append(conditions, r.query.AppStaticConversationOnline.TemplateID.Eq(templateID))
cs, err := r.query.AppStaticConversationOnline.WithContext(ctx).Where(conditions...).First()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
return nil, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return &entity.StaticConversation{
UserID: cs.UserID,
ConnectorID: cs.ConnectorID,
TemplateID: cs.TemplateID,
ConversationID: cs.ConversationID,
}, true, nil
} else {
return nil, false, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) getOrCreateDraftStaticConversation(ctx context.Context, idGen workflow.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, bool, error) {
cs, err := r.mGetDraftStaticConversation(ctx, meta.UserID, meta.ConnectorID, []int64{meta.TemplateID})
if err != nil {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
if len(cs) > 0 {
return cs[0].ConversationID, true, nil
}
conversationID, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
if err != nil {
return 0, false, err
}
id, err := r.GenID(ctx)
if err != nil {
return 0, false, vo.WrapError(errno.ErrIDGenError, err)
}
object := &model.AppStaticConversationDraft{
ID: id,
UserID: meta.UserID,
ConnectorID: meta.ConnectorID,
TemplateID: meta.TemplateID,
ConversationID: conversationID,
}
err = r.query.AppStaticConversationDraft.WithContext(ctx).Create(object)
if err != nil {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return conversationID, false, nil
}
func (r *RepositoryImpl) getOrCreateOnlineStaticConversation(ctx context.Context, idGen workflow.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, bool, error) {
cs, err := r.mGetOnlineStaticConversation(ctx, meta.UserID, meta.ConnectorID, []int64{meta.TemplateID})
if err != nil {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
if len(cs) > 0 {
return cs[0].ConversationID, true, nil
}
conversationID, err := idGen(ctx, meta.AppID, meta.UserID, meta.ConnectorID)
if err != nil {
return 0, false, err
}
id, err := r.GenID(ctx)
if err != nil {
return 0, false, vo.WrapError(errno.ErrIDGenError, err)
}
object := &model.AppStaticConversationOnline{
ID: id,
UserID: meta.UserID,
ConnectorID: meta.ConnectorID,
TemplateID: meta.TemplateID,
ConversationID: conversationID,
}
err = r.query.AppStaticConversationOnline.WithContext(ctx).Create(object)
if err != nil {
return 0, false, vo.WrapError(errno.ErrDatabaseError, err)
}
return conversationID, false, nil
}
func (r *RepositoryImpl) BatchCreateOnlineConversationTemplate(ctx context.Context, templates []*entity.ConversationTemplate, version string) error {
ids, err := r.GenMultiIDs(ctx, len(templates))
if err != nil {
return vo.WrapError(errno.ErrIDGenError, err)
}
objects := make([]*model.AppConversationTemplateOnline, 0, len(templates))
for idx := range templates {
template := templates[idx]
objects = append(objects, &model.AppConversationTemplateOnline{
ID: ids[idx],
SpaceID: template.SpaceID,
AppID: template.AppID,
TemplateID: template.TemplateID,
Name: template.Name,
Version: version,
})
}
err = r.query.AppConversationTemplateOnline.WithContext(ctx).CreateInBatches(objects, batchSize)
if err != nil {
return vo.WrapError(errno.ErrDatabaseError, err)
}
return nil
}
func (r *RepositoryImpl) GetDynamicConversationByName(ctx context.Context, env vo.Env, appID, connectorID, userID int64, name string) (*entity.DynamicConversation, bool, error) {
if env == vo.Draft {
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
ret, err := appDynamicConversationDraft.WithContext(ctx).Where(
appDynamicConversationDraft.AppID.Eq(appID),
appDynamicConversationDraft.ConnectorID.Eq(connectorID),
appDynamicConversationDraft.UserID.Eq(userID),
appDynamicConversationDraft.Name.Eq(name)).First()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
return nil, false, err
}
return &entity.DynamicConversation{
ID: ret.ID,
UserID: ret.UserID,
ConnectorID: ret.ConnectorID,
ConversationID: ret.ConversationID,
Name: ret.Name,
}, true, nil
} else if env == vo.Online {
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
ret, err := appDynamicConversationOnline.WithContext(ctx).Where(
appDynamicConversationOnline.AppID.Eq(appID),
appDynamicConversationOnline.ConnectorID.Eq(connectorID),
appDynamicConversationOnline.UserID.Eq(userID),
appDynamicConversationOnline.Name.Eq(name)).First()
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, false, nil
}
return nil, false, err
}
return &entity.DynamicConversation{
ID: ret.ID,
UserID: ret.UserID,
ConnectorID: ret.ConnectorID,
ConversationID: ret.ConversationID,
Name: ret.Name,
}, true, nil
} else {
return nil, false, fmt.Errorf("unknown env %v", env)
}
}
func (r *RepositoryImpl) UpdateDynamicConversationNameByID(ctx context.Context, env vo.Env, templateID int64, name string) error {
if env == vo.Draft {
appDynamicConversationDraft := r.query.AppDynamicConversationDraft
_, err := appDynamicConversationDraft.WithContext(ctx).Where(
appDynamicConversationDraft.ID.Eq(templateID),
).UpdateColumnSimple(appDynamicConversationDraft.Name.Value(name))
if err != nil {
return vo.WrapError(errno.ErrDatabaseError, err)
}
return nil
} else if env == vo.Online {
appDynamicConversationOnline := r.query.AppDynamicConversationOnline
_, err := appDynamicConversationOnline.WithContext(ctx).Where(
appDynamicConversationOnline.ID.Eq(templateID),
).UpdateColumnSimple(appDynamicConversationOnline.Name.Value(name))
if err != nil {
return vo.WrapError(errno.ErrDatabaseError, err)
}
return nil
} else {
return fmt.Errorf("unknown env %v", env)
}
}

View File

@ -0,0 +1,29 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"gorm.io/gorm"
)
const TableNameAppConversationTemplateDraft = "app_conversation_template_draft"
// AppConversationTemplateDraft mapped from table <app_conversation_template_draft>
type AppConversationTemplateDraft struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime:milli;comment:update time in millisecond" json:"updated_at"` // update time in millisecond
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
}
// TableName AppConversationTemplateDraft's table name
func (*AppConversationTemplateDraft) TableName() string {
return TableNameAppConversationTemplateDraft
}

View File

@ -0,0 +1,24 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
const TableNameAppConversationTemplateOnline = "app_conversation_template_online"
// AppConversationTemplateOnline mapped from table <app_conversation_template_online>
type AppConversationTemplateOnline struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
SpaceID int64 `gorm:"column:space_id;not null;comment:space id" json:"space_id"` // space id
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
Version string `gorm:"column:version;not null;comment:version name" json:"version"` // version name
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
}
// TableName AppConversationTemplateOnline's table name
func (*AppConversationTemplateOnline) TableName() string {
return TableNameAppConversationTemplateOnline
}

View File

@ -0,0 +1,28 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"gorm.io/gorm"
)
const TableNameAppDynamicConversationDraft = "app_dynamic_conversation_draft"
// AppDynamicConversationDraft mapped from table <app_dynamic_conversation_draft>
type AppDynamicConversationDraft struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
}
// TableName AppDynamicConversationDraft's table name
func (*AppDynamicConversationDraft) TableName() string {
return TableNameAppDynamicConversationDraft
}

View File

@ -0,0 +1,28 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"gorm.io/gorm"
)
const TableNameAppDynamicConversationOnline = "app_dynamic_conversation_online"
// AppDynamicConversationOnline mapped from table <app_dynamic_conversation_online>
type AppDynamicConversationOnline struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
AppID int64 `gorm:"column:app_id;not null;comment:app id" json:"app_id"` // app id
Name string `gorm:"column:name;not null;comment:conversion name" json:"name"` // conversion name
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
}
// TableName AppDynamicConversationOnline's table name
func (*AppDynamicConversationOnline) TableName() string {
return TableNameAppDynamicConversationOnline
}

View File

@ -0,0 +1,27 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"gorm.io/gorm"
)
const TableNameAppStaticConversationDraft = "app_static_conversation_draft"
// AppStaticConversationDraft mapped from table <app_static_conversation_draft>
type AppStaticConversationDraft struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
}
// TableName AppStaticConversationDraft's table name
func (*AppStaticConversationDraft) TableName() string {
return TableNameAppStaticConversationDraft
}

View File

@ -0,0 +1,22 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
const TableNameAppStaticConversationOnline = "app_static_conversation_online"
// AppStaticConversationOnline mapped from table <app_static_conversation_online>
type AppStaticConversationOnline struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
TemplateID int64 `gorm:"column:template_id;not null;comment:template id" json:"template_id"` // template id
UserID int64 `gorm:"column:user_id;not null;comment:user id" json:"user_id"` // user id
ConnectorID int64 `gorm:"column:connector_id;not null;comment:connector id" json:"connector_id"` // connector id
ConversationID int64 `gorm:"column:conversation_id;not null;comment:conversation id" json:"conversation_id"` // conversation id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
}
// TableName AppStaticConversationOnline's table name
func (*AppStaticConversationOnline) TableName() string {
return TableNameAppStaticConversationOnline
}

View File

@ -0,0 +1,36 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package model
import (
"gorm.io/gorm"
)
const TableNameChatFlowRoleConfig = "chat_flow_role_config"
// ChatFlowRoleConfig mapped from table <chat_flow_role_config>
type ChatFlowRoleConfig struct {
ID int64 `gorm:"column:id;primaryKey;comment:id" json:"id"` // id
WorkflowID int64 `gorm:"column:workflow_id;not null;comment:workflow id" json:"workflow_id"` // workflow id
Name string `gorm:"column:name;not null;comment:role name" json:"name"` // role name
Description string `gorm:"column:description;not null;comment:role description" json:"description"` // role description
Version string `gorm:"column:version;not null;comment:version" json:"version"` // version
Avatar string `gorm:"column:avatar;not null;comment:avatar uri" json:"avatar"` // avatar uri
BackgroundImageInfo string `gorm:"column:background_image_info;not null;comment:background image information, object structure" json:"background_image_info"` // background image information, object structure
OnboardingInfo string `gorm:"column:onboarding_info;not null;comment:intro information, object structure" json:"onboarding_info"` // intro information, object structure
SuggestReplyInfo string `gorm:"column:suggest_reply_info;not null;comment:user suggestions, object structure" json:"suggest_reply_info"` // user suggestions, object structure
AudioConfig string `gorm:"column:audio_config;not null;comment:agent audio config, object structure" json:"audio_config"` // agent audio config, object structure
UserInputConfig string `gorm:"column:user_input_config;not null;comment:user input config, object structure" json:"user_input_config"` // user input config, object structure
CreatorID int64 `gorm:"column:creator_id;not null;comment:creator id" json:"creator_id"` // creator id
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:create time in millisecond" json:"created_at"` // create time in millisecond
UpdatedAt int64 `gorm:"column:updated_at;autoUpdateTime:milli;comment:update time in millisecond" json:"updated_at"` // update time in millisecond
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:delete time in millisecond" json:"deleted_at"` // delete time in millisecond
ConnectorID int64 `gorm:"column:connector_id;comment:connector id" json:"connector_id"` // connector id
}
// TableName ChatFlowRoleConfig's table name
func (*ChatFlowRoleConfig) TableName() string {
return TableNameChatFlowRoleConfig
}

View File

@ -0,0 +1,412 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newAppConversationTemplateDraft(db *gorm.DB, opts ...gen.DOOption) appConversationTemplateDraft {
_appConversationTemplateDraft := appConversationTemplateDraft{}
_appConversationTemplateDraft.appConversationTemplateDraftDo.UseDB(db, opts...)
_appConversationTemplateDraft.appConversationTemplateDraftDo.UseModel(&model.AppConversationTemplateDraft{})
tableName := _appConversationTemplateDraft.appConversationTemplateDraftDo.TableName()
_appConversationTemplateDraft.ALL = field.NewAsterisk(tableName)
_appConversationTemplateDraft.ID = field.NewInt64(tableName, "id")
_appConversationTemplateDraft.AppID = field.NewInt64(tableName, "app_id")
_appConversationTemplateDraft.SpaceID = field.NewInt64(tableName, "space_id")
_appConversationTemplateDraft.Name = field.NewString(tableName, "name")
_appConversationTemplateDraft.TemplateID = field.NewInt64(tableName, "template_id")
_appConversationTemplateDraft.CreatorID = field.NewInt64(tableName, "creator_id")
_appConversationTemplateDraft.CreatedAt = field.NewInt64(tableName, "created_at")
_appConversationTemplateDraft.UpdatedAt = field.NewInt64(tableName, "updated_at")
_appConversationTemplateDraft.DeletedAt = field.NewField(tableName, "deleted_at")
_appConversationTemplateDraft.fillFieldMap()
return _appConversationTemplateDraft
}
type appConversationTemplateDraft struct {
appConversationTemplateDraftDo
ALL field.Asterisk
ID field.Int64 // id
AppID field.Int64 // app id
SpaceID field.Int64 // space id
Name field.String // conversion name
TemplateID field.Int64 // template id
CreatorID field.Int64 // creator id
CreatedAt field.Int64 // create time in millisecond
UpdatedAt field.Int64 // update time in millisecond
DeletedAt field.Field // delete time in millisecond
fieldMap map[string]field.Expr
}
func (a appConversationTemplateDraft) Table(newTableName string) *appConversationTemplateDraft {
a.appConversationTemplateDraftDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appConversationTemplateDraft) As(alias string) *appConversationTemplateDraft {
a.appConversationTemplateDraftDo.DO = *(a.appConversationTemplateDraftDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appConversationTemplateDraft) updateTableName(table string) *appConversationTemplateDraft {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.AppID = field.NewInt64(table, "app_id")
a.SpaceID = field.NewInt64(table, "space_id")
a.Name = field.NewString(table, "name")
a.TemplateID = field.NewInt64(table, "template_id")
a.CreatorID = field.NewInt64(table, "creator_id")
a.CreatedAt = field.NewInt64(table, "created_at")
a.UpdatedAt = field.NewInt64(table, "updated_at")
a.DeletedAt = field.NewField(table, "deleted_at")
a.fillFieldMap()
return a
}
func (a *appConversationTemplateDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appConversationTemplateDraft) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 9)
a.fieldMap["id"] = a.ID
a.fieldMap["app_id"] = a.AppID
a.fieldMap["space_id"] = a.SpaceID
a.fieldMap["name"] = a.Name
a.fieldMap["template_id"] = a.TemplateID
a.fieldMap["creator_id"] = a.CreatorID
a.fieldMap["created_at"] = a.CreatedAt
a.fieldMap["updated_at"] = a.UpdatedAt
a.fieldMap["deleted_at"] = a.DeletedAt
}
func (a appConversationTemplateDraft) clone(db *gorm.DB) appConversationTemplateDraft {
a.appConversationTemplateDraftDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appConversationTemplateDraft) replaceDB(db *gorm.DB) appConversationTemplateDraft {
a.appConversationTemplateDraftDo.ReplaceDB(db)
return a
}
type appConversationTemplateDraftDo struct{ gen.DO }
type IAppConversationTemplateDraftDo interface {
gen.SubQuery
Debug() IAppConversationTemplateDraftDo
WithContext(ctx context.Context) IAppConversationTemplateDraftDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppConversationTemplateDraftDo
WriteDB() IAppConversationTemplateDraftDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppConversationTemplateDraftDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppConversationTemplateDraftDo
Not(conds ...gen.Condition) IAppConversationTemplateDraftDo
Or(conds ...gen.Condition) IAppConversationTemplateDraftDo
Select(conds ...field.Expr) IAppConversationTemplateDraftDo
Where(conds ...gen.Condition) IAppConversationTemplateDraftDo
Order(conds ...field.Expr) IAppConversationTemplateDraftDo
Distinct(cols ...field.Expr) IAppConversationTemplateDraftDo
Omit(cols ...field.Expr) IAppConversationTemplateDraftDo
Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo
Group(cols ...field.Expr) IAppConversationTemplateDraftDo
Having(conds ...gen.Condition) IAppConversationTemplateDraftDo
Limit(limit int) IAppConversationTemplateDraftDo
Offset(offset int) IAppConversationTemplateDraftDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateDraftDo
Unscoped() IAppConversationTemplateDraftDo
Create(values ...*model.AppConversationTemplateDraft) error
CreateInBatches(values []*model.AppConversationTemplateDraft, batchSize int) error
Save(values ...*model.AppConversationTemplateDraft) error
First() (*model.AppConversationTemplateDraft, error)
Take() (*model.AppConversationTemplateDraft, error)
Last() (*model.AppConversationTemplateDraft, error)
Find() ([]*model.AppConversationTemplateDraft, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateDraft, err error)
FindInBatches(result *[]*model.AppConversationTemplateDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppConversationTemplateDraft) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo
Assign(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo
Joins(fields ...field.RelationField) IAppConversationTemplateDraftDo
Preload(fields ...field.RelationField) IAppConversationTemplateDraftDo
FirstOrInit() (*model.AppConversationTemplateDraft, error)
FirstOrCreate() (*model.AppConversationTemplateDraft, error)
FindByPage(offset int, limit int) (result []*model.AppConversationTemplateDraft, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAppConversationTemplateDraftDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a appConversationTemplateDraftDo) Debug() IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Debug())
}
func (a appConversationTemplateDraftDo) WithContext(ctx context.Context) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appConversationTemplateDraftDo) ReadDB() IAppConversationTemplateDraftDo {
return a.Clauses(dbresolver.Read)
}
func (a appConversationTemplateDraftDo) WriteDB() IAppConversationTemplateDraftDo {
return a.Clauses(dbresolver.Write)
}
func (a appConversationTemplateDraftDo) Session(config *gorm.Session) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Session(config))
}
func (a appConversationTemplateDraftDo) Clauses(conds ...clause.Expression) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appConversationTemplateDraftDo) Returning(value interface{}, columns ...string) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appConversationTemplateDraftDo) Not(conds ...gen.Condition) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appConversationTemplateDraftDo) Or(conds ...gen.Condition) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appConversationTemplateDraftDo) Select(conds ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appConversationTemplateDraftDo) Where(conds ...gen.Condition) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appConversationTemplateDraftDo) Order(conds ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appConversationTemplateDraftDo) Distinct(cols ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appConversationTemplateDraftDo) Omit(cols ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appConversationTemplateDraftDo) Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appConversationTemplateDraftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appConversationTemplateDraftDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appConversationTemplateDraftDo) Group(cols ...field.Expr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appConversationTemplateDraftDo) Having(conds ...gen.Condition) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appConversationTemplateDraftDo) Limit(limit int) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appConversationTemplateDraftDo) Offset(offset int) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appConversationTemplateDraftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appConversationTemplateDraftDo) Unscoped() IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Unscoped())
}
func (a appConversationTemplateDraftDo) Create(values ...*model.AppConversationTemplateDraft) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appConversationTemplateDraftDo) CreateInBatches(values []*model.AppConversationTemplateDraft, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appConversationTemplateDraftDo) Save(values ...*model.AppConversationTemplateDraft) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appConversationTemplateDraftDo) First() (*model.AppConversationTemplateDraft, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateDraft), nil
}
}
func (a appConversationTemplateDraftDo) Take() (*model.AppConversationTemplateDraft, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateDraft), nil
}
}
func (a appConversationTemplateDraftDo) Last() (*model.AppConversationTemplateDraft, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateDraft), nil
}
}
func (a appConversationTemplateDraftDo) Find() ([]*model.AppConversationTemplateDraft, error) {
result, err := a.DO.Find()
return result.([]*model.AppConversationTemplateDraft), err
}
func (a appConversationTemplateDraftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateDraft, err error) {
buf := make([]*model.AppConversationTemplateDraft, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appConversationTemplateDraftDo) FindInBatches(result *[]*model.AppConversationTemplateDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appConversationTemplateDraftDo) Attrs(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appConversationTemplateDraftDo) Assign(attrs ...field.AssignExpr) IAppConversationTemplateDraftDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appConversationTemplateDraftDo) Joins(fields ...field.RelationField) IAppConversationTemplateDraftDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appConversationTemplateDraftDo) Preload(fields ...field.RelationField) IAppConversationTemplateDraftDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appConversationTemplateDraftDo) FirstOrInit() (*model.AppConversationTemplateDraft, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateDraft), nil
}
}
func (a appConversationTemplateDraftDo) FirstOrCreate() (*model.AppConversationTemplateDraft, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateDraft), nil
}
}
func (a appConversationTemplateDraftDo) FindByPage(offset int, limit int) (result []*model.AppConversationTemplateDraft, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appConversationTemplateDraftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appConversationTemplateDraftDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appConversationTemplateDraftDo) Delete(models ...*model.AppConversationTemplateDraft) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appConversationTemplateDraftDo) withDO(do gen.Dao) *appConversationTemplateDraftDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,408 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newAppConversationTemplateOnline(db *gorm.DB, opts ...gen.DOOption) appConversationTemplateOnline {
_appConversationTemplateOnline := appConversationTemplateOnline{}
_appConversationTemplateOnline.appConversationTemplateOnlineDo.UseDB(db, opts...)
_appConversationTemplateOnline.appConversationTemplateOnlineDo.UseModel(&model.AppConversationTemplateOnline{})
tableName := _appConversationTemplateOnline.appConversationTemplateOnlineDo.TableName()
_appConversationTemplateOnline.ALL = field.NewAsterisk(tableName)
_appConversationTemplateOnline.ID = field.NewInt64(tableName, "id")
_appConversationTemplateOnline.AppID = field.NewInt64(tableName, "app_id")
_appConversationTemplateOnline.SpaceID = field.NewInt64(tableName, "space_id")
_appConversationTemplateOnline.Name = field.NewString(tableName, "name")
_appConversationTemplateOnline.TemplateID = field.NewInt64(tableName, "template_id")
_appConversationTemplateOnline.Version = field.NewString(tableName, "version")
_appConversationTemplateOnline.CreatorID = field.NewInt64(tableName, "creator_id")
_appConversationTemplateOnline.CreatedAt = field.NewInt64(tableName, "created_at")
_appConversationTemplateOnline.fillFieldMap()
return _appConversationTemplateOnline
}
type appConversationTemplateOnline struct {
appConversationTemplateOnlineDo
ALL field.Asterisk
ID field.Int64 // id
AppID field.Int64 // app id
SpaceID field.Int64 // space id
Name field.String // conversion name
TemplateID field.Int64 // template id
Version field.String // version name
CreatorID field.Int64 // creator id
CreatedAt field.Int64 // create time in millisecond
fieldMap map[string]field.Expr
}
func (a appConversationTemplateOnline) Table(newTableName string) *appConversationTemplateOnline {
a.appConversationTemplateOnlineDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appConversationTemplateOnline) As(alias string) *appConversationTemplateOnline {
a.appConversationTemplateOnlineDo.DO = *(a.appConversationTemplateOnlineDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appConversationTemplateOnline) updateTableName(table string) *appConversationTemplateOnline {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.AppID = field.NewInt64(table, "app_id")
a.SpaceID = field.NewInt64(table, "space_id")
a.Name = field.NewString(table, "name")
a.TemplateID = field.NewInt64(table, "template_id")
a.Version = field.NewString(table, "version")
a.CreatorID = field.NewInt64(table, "creator_id")
a.CreatedAt = field.NewInt64(table, "created_at")
a.fillFieldMap()
return a
}
func (a *appConversationTemplateOnline) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appConversationTemplateOnline) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 8)
a.fieldMap["id"] = a.ID
a.fieldMap["app_id"] = a.AppID
a.fieldMap["space_id"] = a.SpaceID
a.fieldMap["name"] = a.Name
a.fieldMap["template_id"] = a.TemplateID
a.fieldMap["version"] = a.Version
a.fieldMap["creator_id"] = a.CreatorID
a.fieldMap["created_at"] = a.CreatedAt
}
func (a appConversationTemplateOnline) clone(db *gorm.DB) appConversationTemplateOnline {
a.appConversationTemplateOnlineDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appConversationTemplateOnline) replaceDB(db *gorm.DB) appConversationTemplateOnline {
a.appConversationTemplateOnlineDo.ReplaceDB(db)
return a
}
type appConversationTemplateOnlineDo struct{ gen.DO }
type IAppConversationTemplateOnlineDo interface {
gen.SubQuery
Debug() IAppConversationTemplateOnlineDo
WithContext(ctx context.Context) IAppConversationTemplateOnlineDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppConversationTemplateOnlineDo
WriteDB() IAppConversationTemplateOnlineDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppConversationTemplateOnlineDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppConversationTemplateOnlineDo
Not(conds ...gen.Condition) IAppConversationTemplateOnlineDo
Or(conds ...gen.Condition) IAppConversationTemplateOnlineDo
Select(conds ...field.Expr) IAppConversationTemplateOnlineDo
Where(conds ...gen.Condition) IAppConversationTemplateOnlineDo
Order(conds ...field.Expr) IAppConversationTemplateOnlineDo
Distinct(cols ...field.Expr) IAppConversationTemplateOnlineDo
Omit(cols ...field.Expr) IAppConversationTemplateOnlineDo
Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo
Group(cols ...field.Expr) IAppConversationTemplateOnlineDo
Having(conds ...gen.Condition) IAppConversationTemplateOnlineDo
Limit(limit int) IAppConversationTemplateOnlineDo
Offset(offset int) IAppConversationTemplateOnlineDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateOnlineDo
Unscoped() IAppConversationTemplateOnlineDo
Create(values ...*model.AppConversationTemplateOnline) error
CreateInBatches(values []*model.AppConversationTemplateOnline, batchSize int) error
Save(values ...*model.AppConversationTemplateOnline) error
First() (*model.AppConversationTemplateOnline, error)
Take() (*model.AppConversationTemplateOnline, error)
Last() (*model.AppConversationTemplateOnline, error)
Find() ([]*model.AppConversationTemplateOnline, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateOnline, err error)
FindInBatches(result *[]*model.AppConversationTemplateOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppConversationTemplateOnline) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo
Assign(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo
Joins(fields ...field.RelationField) IAppConversationTemplateOnlineDo
Preload(fields ...field.RelationField) IAppConversationTemplateOnlineDo
FirstOrInit() (*model.AppConversationTemplateOnline, error)
FirstOrCreate() (*model.AppConversationTemplateOnline, error)
FindByPage(offset int, limit int) (result []*model.AppConversationTemplateOnline, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAppConversationTemplateOnlineDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a appConversationTemplateOnlineDo) Debug() IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Debug())
}
func (a appConversationTemplateOnlineDo) WithContext(ctx context.Context) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appConversationTemplateOnlineDo) ReadDB() IAppConversationTemplateOnlineDo {
return a.Clauses(dbresolver.Read)
}
func (a appConversationTemplateOnlineDo) WriteDB() IAppConversationTemplateOnlineDo {
return a.Clauses(dbresolver.Write)
}
func (a appConversationTemplateOnlineDo) Session(config *gorm.Session) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Session(config))
}
func (a appConversationTemplateOnlineDo) Clauses(conds ...clause.Expression) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appConversationTemplateOnlineDo) Returning(value interface{}, columns ...string) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appConversationTemplateOnlineDo) Not(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appConversationTemplateOnlineDo) Or(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appConversationTemplateOnlineDo) Select(conds ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appConversationTemplateOnlineDo) Where(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appConversationTemplateOnlineDo) Order(conds ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appConversationTemplateOnlineDo) Distinct(cols ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appConversationTemplateOnlineDo) Omit(cols ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appConversationTemplateOnlineDo) Join(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appConversationTemplateOnlineDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appConversationTemplateOnlineDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appConversationTemplateOnlineDo) Group(cols ...field.Expr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appConversationTemplateOnlineDo) Having(conds ...gen.Condition) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appConversationTemplateOnlineDo) Limit(limit int) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appConversationTemplateOnlineDo) Offset(offset int) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appConversationTemplateOnlineDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appConversationTemplateOnlineDo) Unscoped() IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Unscoped())
}
func (a appConversationTemplateOnlineDo) Create(values ...*model.AppConversationTemplateOnline) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appConversationTemplateOnlineDo) CreateInBatches(values []*model.AppConversationTemplateOnline, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appConversationTemplateOnlineDo) Save(values ...*model.AppConversationTemplateOnline) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appConversationTemplateOnlineDo) First() (*model.AppConversationTemplateOnline, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateOnline), nil
}
}
func (a appConversationTemplateOnlineDo) Take() (*model.AppConversationTemplateOnline, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateOnline), nil
}
}
func (a appConversationTemplateOnlineDo) Last() (*model.AppConversationTemplateOnline, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateOnline), nil
}
}
func (a appConversationTemplateOnlineDo) Find() ([]*model.AppConversationTemplateOnline, error) {
result, err := a.DO.Find()
return result.([]*model.AppConversationTemplateOnline), err
}
func (a appConversationTemplateOnlineDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppConversationTemplateOnline, err error) {
buf := make([]*model.AppConversationTemplateOnline, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appConversationTemplateOnlineDo) FindInBatches(result *[]*model.AppConversationTemplateOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appConversationTemplateOnlineDo) Attrs(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appConversationTemplateOnlineDo) Assign(attrs ...field.AssignExpr) IAppConversationTemplateOnlineDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appConversationTemplateOnlineDo) Joins(fields ...field.RelationField) IAppConversationTemplateOnlineDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appConversationTemplateOnlineDo) Preload(fields ...field.RelationField) IAppConversationTemplateOnlineDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appConversationTemplateOnlineDo) FirstOrInit() (*model.AppConversationTemplateOnline, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateOnline), nil
}
}
func (a appConversationTemplateOnlineDo) FirstOrCreate() (*model.AppConversationTemplateOnline, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppConversationTemplateOnline), nil
}
}
func (a appConversationTemplateOnlineDo) FindByPage(offset int, limit int) (result []*model.AppConversationTemplateOnline, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appConversationTemplateOnlineDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appConversationTemplateOnlineDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appConversationTemplateOnlineDo) Delete(models ...*model.AppConversationTemplateOnline) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appConversationTemplateOnlineDo) withDO(do gen.Dao) *appConversationTemplateOnlineDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,408 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newAppDynamicConversationDraft(db *gorm.DB, opts ...gen.DOOption) appDynamicConversationDraft {
_appDynamicConversationDraft := appDynamicConversationDraft{}
_appDynamicConversationDraft.appDynamicConversationDraftDo.UseDB(db, opts...)
_appDynamicConversationDraft.appDynamicConversationDraftDo.UseModel(&model.AppDynamicConversationDraft{})
tableName := _appDynamicConversationDraft.appDynamicConversationDraftDo.TableName()
_appDynamicConversationDraft.ALL = field.NewAsterisk(tableName)
_appDynamicConversationDraft.ID = field.NewInt64(tableName, "id")
_appDynamicConversationDraft.AppID = field.NewInt64(tableName, "app_id")
_appDynamicConversationDraft.Name = field.NewString(tableName, "name")
_appDynamicConversationDraft.UserID = field.NewInt64(tableName, "user_id")
_appDynamicConversationDraft.ConnectorID = field.NewInt64(tableName, "connector_id")
_appDynamicConversationDraft.ConversationID = field.NewInt64(tableName, "conversation_id")
_appDynamicConversationDraft.CreatedAt = field.NewInt64(tableName, "created_at")
_appDynamicConversationDraft.DeletedAt = field.NewField(tableName, "deleted_at")
_appDynamicConversationDraft.fillFieldMap()
return _appDynamicConversationDraft
}
type appDynamicConversationDraft struct {
appDynamicConversationDraftDo
ALL field.Asterisk
ID field.Int64 // id
AppID field.Int64 // app id
Name field.String // conversion name
UserID field.Int64 // user id
ConnectorID field.Int64 // connector id
ConversationID field.Int64 // conversation id
CreatedAt field.Int64 // create time in millisecond
DeletedAt field.Field // delete time in millisecond
fieldMap map[string]field.Expr
}
func (a appDynamicConversationDraft) Table(newTableName string) *appDynamicConversationDraft {
a.appDynamicConversationDraftDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appDynamicConversationDraft) As(alias string) *appDynamicConversationDraft {
a.appDynamicConversationDraftDo.DO = *(a.appDynamicConversationDraftDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appDynamicConversationDraft) updateTableName(table string) *appDynamicConversationDraft {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.AppID = field.NewInt64(table, "app_id")
a.Name = field.NewString(table, "name")
a.UserID = field.NewInt64(table, "user_id")
a.ConnectorID = field.NewInt64(table, "connector_id")
a.ConversationID = field.NewInt64(table, "conversation_id")
a.CreatedAt = field.NewInt64(table, "created_at")
a.DeletedAt = field.NewField(table, "deleted_at")
a.fillFieldMap()
return a
}
func (a *appDynamicConversationDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appDynamicConversationDraft) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 8)
a.fieldMap["id"] = a.ID
a.fieldMap["app_id"] = a.AppID
a.fieldMap["name"] = a.Name
a.fieldMap["user_id"] = a.UserID
a.fieldMap["connector_id"] = a.ConnectorID
a.fieldMap["conversation_id"] = a.ConversationID
a.fieldMap["created_at"] = a.CreatedAt
a.fieldMap["deleted_at"] = a.DeletedAt
}
func (a appDynamicConversationDraft) clone(db *gorm.DB) appDynamicConversationDraft {
a.appDynamicConversationDraftDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appDynamicConversationDraft) replaceDB(db *gorm.DB) appDynamicConversationDraft {
a.appDynamicConversationDraftDo.ReplaceDB(db)
return a
}
type appDynamicConversationDraftDo struct{ gen.DO }
type IAppDynamicConversationDraftDo interface {
gen.SubQuery
Debug() IAppDynamicConversationDraftDo
WithContext(ctx context.Context) IAppDynamicConversationDraftDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppDynamicConversationDraftDo
WriteDB() IAppDynamicConversationDraftDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppDynamicConversationDraftDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppDynamicConversationDraftDo
Not(conds ...gen.Condition) IAppDynamicConversationDraftDo
Or(conds ...gen.Condition) IAppDynamicConversationDraftDo
Select(conds ...field.Expr) IAppDynamicConversationDraftDo
Where(conds ...gen.Condition) IAppDynamicConversationDraftDo
Order(conds ...field.Expr) IAppDynamicConversationDraftDo
Distinct(cols ...field.Expr) IAppDynamicConversationDraftDo
Omit(cols ...field.Expr) IAppDynamicConversationDraftDo
Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo
Group(cols ...field.Expr) IAppDynamicConversationDraftDo
Having(conds ...gen.Condition) IAppDynamicConversationDraftDo
Limit(limit int) IAppDynamicConversationDraftDo
Offset(offset int) IAppDynamicConversationDraftDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationDraftDo
Unscoped() IAppDynamicConversationDraftDo
Create(values ...*model.AppDynamicConversationDraft) error
CreateInBatches(values []*model.AppDynamicConversationDraft, batchSize int) error
Save(values ...*model.AppDynamicConversationDraft) error
First() (*model.AppDynamicConversationDraft, error)
Take() (*model.AppDynamicConversationDraft, error)
Last() (*model.AppDynamicConversationDraft, error)
Find() ([]*model.AppDynamicConversationDraft, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationDraft, err error)
FindInBatches(result *[]*model.AppDynamicConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppDynamicConversationDraft) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo
Assign(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo
Joins(fields ...field.RelationField) IAppDynamicConversationDraftDo
Preload(fields ...field.RelationField) IAppDynamicConversationDraftDo
FirstOrInit() (*model.AppDynamicConversationDraft, error)
FirstOrCreate() (*model.AppDynamicConversationDraft, error)
FindByPage(offset int, limit int) (result []*model.AppDynamicConversationDraft, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAppDynamicConversationDraftDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a appDynamicConversationDraftDo) Debug() IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Debug())
}
func (a appDynamicConversationDraftDo) WithContext(ctx context.Context) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appDynamicConversationDraftDo) ReadDB() IAppDynamicConversationDraftDo {
return a.Clauses(dbresolver.Read)
}
func (a appDynamicConversationDraftDo) WriteDB() IAppDynamicConversationDraftDo {
return a.Clauses(dbresolver.Write)
}
func (a appDynamicConversationDraftDo) Session(config *gorm.Session) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Session(config))
}
func (a appDynamicConversationDraftDo) Clauses(conds ...clause.Expression) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appDynamicConversationDraftDo) Returning(value interface{}, columns ...string) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appDynamicConversationDraftDo) Not(conds ...gen.Condition) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appDynamicConversationDraftDo) Or(conds ...gen.Condition) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appDynamicConversationDraftDo) Select(conds ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appDynamicConversationDraftDo) Where(conds ...gen.Condition) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appDynamicConversationDraftDo) Order(conds ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appDynamicConversationDraftDo) Distinct(cols ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appDynamicConversationDraftDo) Omit(cols ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appDynamicConversationDraftDo) Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appDynamicConversationDraftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appDynamicConversationDraftDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appDynamicConversationDraftDo) Group(cols ...field.Expr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appDynamicConversationDraftDo) Having(conds ...gen.Condition) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appDynamicConversationDraftDo) Limit(limit int) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appDynamicConversationDraftDo) Offset(offset int) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appDynamicConversationDraftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appDynamicConversationDraftDo) Unscoped() IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Unscoped())
}
func (a appDynamicConversationDraftDo) Create(values ...*model.AppDynamicConversationDraft) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appDynamicConversationDraftDo) CreateInBatches(values []*model.AppDynamicConversationDraft, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appDynamicConversationDraftDo) Save(values ...*model.AppDynamicConversationDraft) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appDynamicConversationDraftDo) First() (*model.AppDynamicConversationDraft, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationDraft), nil
}
}
func (a appDynamicConversationDraftDo) Take() (*model.AppDynamicConversationDraft, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationDraft), nil
}
}
func (a appDynamicConversationDraftDo) Last() (*model.AppDynamicConversationDraft, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationDraft), nil
}
}
func (a appDynamicConversationDraftDo) Find() ([]*model.AppDynamicConversationDraft, error) {
result, err := a.DO.Find()
return result.([]*model.AppDynamicConversationDraft), err
}
func (a appDynamicConversationDraftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationDraft, err error) {
buf := make([]*model.AppDynamicConversationDraft, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appDynamicConversationDraftDo) FindInBatches(result *[]*model.AppDynamicConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appDynamicConversationDraftDo) Attrs(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appDynamicConversationDraftDo) Assign(attrs ...field.AssignExpr) IAppDynamicConversationDraftDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appDynamicConversationDraftDo) Joins(fields ...field.RelationField) IAppDynamicConversationDraftDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appDynamicConversationDraftDo) Preload(fields ...field.RelationField) IAppDynamicConversationDraftDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appDynamicConversationDraftDo) FirstOrInit() (*model.AppDynamicConversationDraft, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationDraft), nil
}
}
func (a appDynamicConversationDraftDo) FirstOrCreate() (*model.AppDynamicConversationDraft, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationDraft), nil
}
}
func (a appDynamicConversationDraftDo) FindByPage(offset int, limit int) (result []*model.AppDynamicConversationDraft, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appDynamicConversationDraftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appDynamicConversationDraftDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appDynamicConversationDraftDo) Delete(models ...*model.AppDynamicConversationDraft) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appDynamicConversationDraftDo) withDO(do gen.Dao) *appDynamicConversationDraftDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,408 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newAppDynamicConversationOnline(db *gorm.DB, opts ...gen.DOOption) appDynamicConversationOnline {
_appDynamicConversationOnline := appDynamicConversationOnline{}
_appDynamicConversationOnline.appDynamicConversationOnlineDo.UseDB(db, opts...)
_appDynamicConversationOnline.appDynamicConversationOnlineDo.UseModel(&model.AppDynamicConversationOnline{})
tableName := _appDynamicConversationOnline.appDynamicConversationOnlineDo.TableName()
_appDynamicConversationOnline.ALL = field.NewAsterisk(tableName)
_appDynamicConversationOnline.ID = field.NewInt64(tableName, "id")
_appDynamicConversationOnline.AppID = field.NewInt64(tableName, "app_id")
_appDynamicConversationOnline.Name = field.NewString(tableName, "name")
_appDynamicConversationOnline.UserID = field.NewInt64(tableName, "user_id")
_appDynamicConversationOnline.ConnectorID = field.NewInt64(tableName, "connector_id")
_appDynamicConversationOnline.ConversationID = field.NewInt64(tableName, "conversation_id")
_appDynamicConversationOnline.CreatedAt = field.NewInt64(tableName, "created_at")
_appDynamicConversationOnline.DeletedAt = field.NewField(tableName, "deleted_at")
_appDynamicConversationOnline.fillFieldMap()
return _appDynamicConversationOnline
}
type appDynamicConversationOnline struct {
appDynamicConversationOnlineDo
ALL field.Asterisk
ID field.Int64 // id
AppID field.Int64 // app id
Name field.String // conversion name
UserID field.Int64 // user id
ConnectorID field.Int64 // connector id
ConversationID field.Int64 // conversation id
CreatedAt field.Int64 // create time in millisecond
DeletedAt field.Field // delete time in millisecond
fieldMap map[string]field.Expr
}
func (a appDynamicConversationOnline) Table(newTableName string) *appDynamicConversationOnline {
a.appDynamicConversationOnlineDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appDynamicConversationOnline) As(alias string) *appDynamicConversationOnline {
a.appDynamicConversationOnlineDo.DO = *(a.appDynamicConversationOnlineDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appDynamicConversationOnline) updateTableName(table string) *appDynamicConversationOnline {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.AppID = field.NewInt64(table, "app_id")
a.Name = field.NewString(table, "name")
a.UserID = field.NewInt64(table, "user_id")
a.ConnectorID = field.NewInt64(table, "connector_id")
a.ConversationID = field.NewInt64(table, "conversation_id")
a.CreatedAt = field.NewInt64(table, "created_at")
a.DeletedAt = field.NewField(table, "deleted_at")
a.fillFieldMap()
return a
}
func (a *appDynamicConversationOnline) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appDynamicConversationOnline) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 8)
a.fieldMap["id"] = a.ID
a.fieldMap["app_id"] = a.AppID
a.fieldMap["name"] = a.Name
a.fieldMap["user_id"] = a.UserID
a.fieldMap["connector_id"] = a.ConnectorID
a.fieldMap["conversation_id"] = a.ConversationID
a.fieldMap["created_at"] = a.CreatedAt
a.fieldMap["deleted_at"] = a.DeletedAt
}
func (a appDynamicConversationOnline) clone(db *gorm.DB) appDynamicConversationOnline {
a.appDynamicConversationOnlineDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appDynamicConversationOnline) replaceDB(db *gorm.DB) appDynamicConversationOnline {
a.appDynamicConversationOnlineDo.ReplaceDB(db)
return a
}
type appDynamicConversationOnlineDo struct{ gen.DO }
type IAppDynamicConversationOnlineDo interface {
gen.SubQuery
Debug() IAppDynamicConversationOnlineDo
WithContext(ctx context.Context) IAppDynamicConversationOnlineDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppDynamicConversationOnlineDo
WriteDB() IAppDynamicConversationOnlineDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppDynamicConversationOnlineDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppDynamicConversationOnlineDo
Not(conds ...gen.Condition) IAppDynamicConversationOnlineDo
Or(conds ...gen.Condition) IAppDynamicConversationOnlineDo
Select(conds ...field.Expr) IAppDynamicConversationOnlineDo
Where(conds ...gen.Condition) IAppDynamicConversationOnlineDo
Order(conds ...field.Expr) IAppDynamicConversationOnlineDo
Distinct(cols ...field.Expr) IAppDynamicConversationOnlineDo
Omit(cols ...field.Expr) IAppDynamicConversationOnlineDo
Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo
Group(cols ...field.Expr) IAppDynamicConversationOnlineDo
Having(conds ...gen.Condition) IAppDynamicConversationOnlineDo
Limit(limit int) IAppDynamicConversationOnlineDo
Offset(offset int) IAppDynamicConversationOnlineDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationOnlineDo
Unscoped() IAppDynamicConversationOnlineDo
Create(values ...*model.AppDynamicConversationOnline) error
CreateInBatches(values []*model.AppDynamicConversationOnline, batchSize int) error
Save(values ...*model.AppDynamicConversationOnline) error
First() (*model.AppDynamicConversationOnline, error)
Take() (*model.AppDynamicConversationOnline, error)
Last() (*model.AppDynamicConversationOnline, error)
Find() ([]*model.AppDynamicConversationOnline, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationOnline, err error)
FindInBatches(result *[]*model.AppDynamicConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppDynamicConversationOnline) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo
Assign(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo
Joins(fields ...field.RelationField) IAppDynamicConversationOnlineDo
Preload(fields ...field.RelationField) IAppDynamicConversationOnlineDo
FirstOrInit() (*model.AppDynamicConversationOnline, error)
FirstOrCreate() (*model.AppDynamicConversationOnline, error)
FindByPage(offset int, limit int) (result []*model.AppDynamicConversationOnline, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAppDynamicConversationOnlineDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a appDynamicConversationOnlineDo) Debug() IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Debug())
}
func (a appDynamicConversationOnlineDo) WithContext(ctx context.Context) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appDynamicConversationOnlineDo) ReadDB() IAppDynamicConversationOnlineDo {
return a.Clauses(dbresolver.Read)
}
func (a appDynamicConversationOnlineDo) WriteDB() IAppDynamicConversationOnlineDo {
return a.Clauses(dbresolver.Write)
}
func (a appDynamicConversationOnlineDo) Session(config *gorm.Session) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Session(config))
}
func (a appDynamicConversationOnlineDo) Clauses(conds ...clause.Expression) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appDynamicConversationOnlineDo) Returning(value interface{}, columns ...string) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appDynamicConversationOnlineDo) Not(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appDynamicConversationOnlineDo) Or(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appDynamicConversationOnlineDo) Select(conds ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appDynamicConversationOnlineDo) Where(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appDynamicConversationOnlineDo) Order(conds ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appDynamicConversationOnlineDo) Distinct(cols ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appDynamicConversationOnlineDo) Omit(cols ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appDynamicConversationOnlineDo) Join(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appDynamicConversationOnlineDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appDynamicConversationOnlineDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appDynamicConversationOnlineDo) Group(cols ...field.Expr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appDynamicConversationOnlineDo) Having(conds ...gen.Condition) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appDynamicConversationOnlineDo) Limit(limit int) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appDynamicConversationOnlineDo) Offset(offset int) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appDynamicConversationOnlineDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appDynamicConversationOnlineDo) Unscoped() IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Unscoped())
}
func (a appDynamicConversationOnlineDo) Create(values ...*model.AppDynamicConversationOnline) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appDynamicConversationOnlineDo) CreateInBatches(values []*model.AppDynamicConversationOnline, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appDynamicConversationOnlineDo) Save(values ...*model.AppDynamicConversationOnline) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appDynamicConversationOnlineDo) First() (*model.AppDynamicConversationOnline, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationOnline), nil
}
}
func (a appDynamicConversationOnlineDo) Take() (*model.AppDynamicConversationOnline, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationOnline), nil
}
}
func (a appDynamicConversationOnlineDo) Last() (*model.AppDynamicConversationOnline, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationOnline), nil
}
}
func (a appDynamicConversationOnlineDo) Find() ([]*model.AppDynamicConversationOnline, error) {
result, err := a.DO.Find()
return result.([]*model.AppDynamicConversationOnline), err
}
func (a appDynamicConversationOnlineDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppDynamicConversationOnline, err error) {
buf := make([]*model.AppDynamicConversationOnline, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appDynamicConversationOnlineDo) FindInBatches(result *[]*model.AppDynamicConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appDynamicConversationOnlineDo) Attrs(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appDynamicConversationOnlineDo) Assign(attrs ...field.AssignExpr) IAppDynamicConversationOnlineDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appDynamicConversationOnlineDo) Joins(fields ...field.RelationField) IAppDynamicConversationOnlineDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appDynamicConversationOnlineDo) Preload(fields ...field.RelationField) IAppDynamicConversationOnlineDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appDynamicConversationOnlineDo) FirstOrInit() (*model.AppDynamicConversationOnline, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationOnline), nil
}
}
func (a appDynamicConversationOnlineDo) FirstOrCreate() (*model.AppDynamicConversationOnline, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppDynamicConversationOnline), nil
}
}
func (a appDynamicConversationOnlineDo) FindByPage(offset int, limit int) (result []*model.AppDynamicConversationOnline, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appDynamicConversationOnlineDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appDynamicConversationOnlineDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appDynamicConversationOnlineDo) Delete(models ...*model.AppDynamicConversationOnline) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appDynamicConversationOnlineDo) withDO(do gen.Dao) *appDynamicConversationOnlineDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,404 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newAppStaticConversationDraft(db *gorm.DB, opts ...gen.DOOption) appStaticConversationDraft {
_appStaticConversationDraft := appStaticConversationDraft{}
_appStaticConversationDraft.appStaticConversationDraftDo.UseDB(db, opts...)
_appStaticConversationDraft.appStaticConversationDraftDo.UseModel(&model.AppStaticConversationDraft{})
tableName := _appStaticConversationDraft.appStaticConversationDraftDo.TableName()
_appStaticConversationDraft.ALL = field.NewAsterisk(tableName)
_appStaticConversationDraft.ID = field.NewInt64(tableName, "id")
_appStaticConversationDraft.TemplateID = field.NewInt64(tableName, "template_id")
_appStaticConversationDraft.UserID = field.NewInt64(tableName, "user_id")
_appStaticConversationDraft.ConnectorID = field.NewInt64(tableName, "connector_id")
_appStaticConversationDraft.ConversationID = field.NewInt64(tableName, "conversation_id")
_appStaticConversationDraft.CreatedAt = field.NewInt64(tableName, "created_at")
_appStaticConversationDraft.DeletedAt = field.NewField(tableName, "deleted_at")
_appStaticConversationDraft.fillFieldMap()
return _appStaticConversationDraft
}
type appStaticConversationDraft struct {
appStaticConversationDraftDo
ALL field.Asterisk
ID field.Int64 // id
TemplateID field.Int64 // template id
UserID field.Int64 // user id
ConnectorID field.Int64 // connector id
ConversationID field.Int64 // conversation id
CreatedAt field.Int64 // create time in millisecond
DeletedAt field.Field // delete time in millisecond
fieldMap map[string]field.Expr
}
func (a appStaticConversationDraft) Table(newTableName string) *appStaticConversationDraft {
a.appStaticConversationDraftDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appStaticConversationDraft) As(alias string) *appStaticConversationDraft {
a.appStaticConversationDraftDo.DO = *(a.appStaticConversationDraftDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appStaticConversationDraft) updateTableName(table string) *appStaticConversationDraft {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.TemplateID = field.NewInt64(table, "template_id")
a.UserID = field.NewInt64(table, "user_id")
a.ConnectorID = field.NewInt64(table, "connector_id")
a.ConversationID = field.NewInt64(table, "conversation_id")
a.CreatedAt = field.NewInt64(table, "created_at")
a.DeletedAt = field.NewField(table, "deleted_at")
a.fillFieldMap()
return a
}
func (a *appStaticConversationDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appStaticConversationDraft) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 7)
a.fieldMap["id"] = a.ID
a.fieldMap["template_id"] = a.TemplateID
a.fieldMap["user_id"] = a.UserID
a.fieldMap["connector_id"] = a.ConnectorID
a.fieldMap["conversation_id"] = a.ConversationID
a.fieldMap["created_at"] = a.CreatedAt
a.fieldMap["deleted_at"] = a.DeletedAt
}
func (a appStaticConversationDraft) clone(db *gorm.DB) appStaticConversationDraft {
a.appStaticConversationDraftDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appStaticConversationDraft) replaceDB(db *gorm.DB) appStaticConversationDraft {
a.appStaticConversationDraftDo.ReplaceDB(db)
return a
}
type appStaticConversationDraftDo struct{ gen.DO }
type IAppStaticConversationDraftDo interface {
gen.SubQuery
Debug() IAppStaticConversationDraftDo
WithContext(ctx context.Context) IAppStaticConversationDraftDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppStaticConversationDraftDo
WriteDB() IAppStaticConversationDraftDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppStaticConversationDraftDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppStaticConversationDraftDo
Not(conds ...gen.Condition) IAppStaticConversationDraftDo
Or(conds ...gen.Condition) IAppStaticConversationDraftDo
Select(conds ...field.Expr) IAppStaticConversationDraftDo
Where(conds ...gen.Condition) IAppStaticConversationDraftDo
Order(conds ...field.Expr) IAppStaticConversationDraftDo
Distinct(cols ...field.Expr) IAppStaticConversationDraftDo
Omit(cols ...field.Expr) IAppStaticConversationDraftDo
Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo
Group(cols ...field.Expr) IAppStaticConversationDraftDo
Having(conds ...gen.Condition) IAppStaticConversationDraftDo
Limit(limit int) IAppStaticConversationDraftDo
Offset(offset int) IAppStaticConversationDraftDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationDraftDo
Unscoped() IAppStaticConversationDraftDo
Create(values ...*model.AppStaticConversationDraft) error
CreateInBatches(values []*model.AppStaticConversationDraft, batchSize int) error
Save(values ...*model.AppStaticConversationDraft) error
First() (*model.AppStaticConversationDraft, error)
Take() (*model.AppStaticConversationDraft, error)
Last() (*model.AppStaticConversationDraft, error)
Find() ([]*model.AppStaticConversationDraft, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationDraft, err error)
FindInBatches(result *[]*model.AppStaticConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppStaticConversationDraft) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAppStaticConversationDraftDo
Assign(attrs ...field.AssignExpr) IAppStaticConversationDraftDo
Joins(fields ...field.RelationField) IAppStaticConversationDraftDo
Preload(fields ...field.RelationField) IAppStaticConversationDraftDo
FirstOrInit() (*model.AppStaticConversationDraft, error)
FirstOrCreate() (*model.AppStaticConversationDraft, error)
FindByPage(offset int, limit int) (result []*model.AppStaticConversationDraft, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAppStaticConversationDraftDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a appStaticConversationDraftDo) Debug() IAppStaticConversationDraftDo {
return a.withDO(a.DO.Debug())
}
func (a appStaticConversationDraftDo) WithContext(ctx context.Context) IAppStaticConversationDraftDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appStaticConversationDraftDo) ReadDB() IAppStaticConversationDraftDo {
return a.Clauses(dbresolver.Read)
}
func (a appStaticConversationDraftDo) WriteDB() IAppStaticConversationDraftDo {
return a.Clauses(dbresolver.Write)
}
func (a appStaticConversationDraftDo) Session(config *gorm.Session) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Session(config))
}
func (a appStaticConversationDraftDo) Clauses(conds ...clause.Expression) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appStaticConversationDraftDo) Returning(value interface{}, columns ...string) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appStaticConversationDraftDo) Not(conds ...gen.Condition) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appStaticConversationDraftDo) Or(conds ...gen.Condition) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appStaticConversationDraftDo) Select(conds ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appStaticConversationDraftDo) Where(conds ...gen.Condition) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appStaticConversationDraftDo) Order(conds ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appStaticConversationDraftDo) Distinct(cols ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appStaticConversationDraftDo) Omit(cols ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appStaticConversationDraftDo) Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appStaticConversationDraftDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appStaticConversationDraftDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appStaticConversationDraftDo) Group(cols ...field.Expr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appStaticConversationDraftDo) Having(conds ...gen.Condition) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appStaticConversationDraftDo) Limit(limit int) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appStaticConversationDraftDo) Offset(offset int) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appStaticConversationDraftDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appStaticConversationDraftDo) Unscoped() IAppStaticConversationDraftDo {
return a.withDO(a.DO.Unscoped())
}
func (a appStaticConversationDraftDo) Create(values ...*model.AppStaticConversationDraft) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appStaticConversationDraftDo) CreateInBatches(values []*model.AppStaticConversationDraft, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appStaticConversationDraftDo) Save(values ...*model.AppStaticConversationDraft) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appStaticConversationDraftDo) First() (*model.AppStaticConversationDraft, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationDraft), nil
}
}
func (a appStaticConversationDraftDo) Take() (*model.AppStaticConversationDraft, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationDraft), nil
}
}
func (a appStaticConversationDraftDo) Last() (*model.AppStaticConversationDraft, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationDraft), nil
}
}
func (a appStaticConversationDraftDo) Find() ([]*model.AppStaticConversationDraft, error) {
result, err := a.DO.Find()
return result.([]*model.AppStaticConversationDraft), err
}
func (a appStaticConversationDraftDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationDraft, err error) {
buf := make([]*model.AppStaticConversationDraft, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appStaticConversationDraftDo) FindInBatches(result *[]*model.AppStaticConversationDraft, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appStaticConversationDraftDo) Attrs(attrs ...field.AssignExpr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appStaticConversationDraftDo) Assign(attrs ...field.AssignExpr) IAppStaticConversationDraftDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appStaticConversationDraftDo) Joins(fields ...field.RelationField) IAppStaticConversationDraftDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appStaticConversationDraftDo) Preload(fields ...field.RelationField) IAppStaticConversationDraftDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appStaticConversationDraftDo) FirstOrInit() (*model.AppStaticConversationDraft, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationDraft), nil
}
}
func (a appStaticConversationDraftDo) FirstOrCreate() (*model.AppStaticConversationDraft, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationDraft), nil
}
}
func (a appStaticConversationDraftDo) FindByPage(offset int, limit int) (result []*model.AppStaticConversationDraft, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appStaticConversationDraftDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appStaticConversationDraftDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appStaticConversationDraftDo) Delete(models ...*model.AppStaticConversationDraft) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appStaticConversationDraftDo) withDO(do gen.Dao) *appStaticConversationDraftDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,400 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newAppStaticConversationOnline(db *gorm.DB, opts ...gen.DOOption) appStaticConversationOnline {
_appStaticConversationOnline := appStaticConversationOnline{}
_appStaticConversationOnline.appStaticConversationOnlineDo.UseDB(db, opts...)
_appStaticConversationOnline.appStaticConversationOnlineDo.UseModel(&model.AppStaticConversationOnline{})
tableName := _appStaticConversationOnline.appStaticConversationOnlineDo.TableName()
_appStaticConversationOnline.ALL = field.NewAsterisk(tableName)
_appStaticConversationOnline.ID = field.NewInt64(tableName, "id")
_appStaticConversationOnline.TemplateID = field.NewInt64(tableName, "template_id")
_appStaticConversationOnline.UserID = field.NewInt64(tableName, "user_id")
_appStaticConversationOnline.ConnectorID = field.NewInt64(tableName, "connector_id")
_appStaticConversationOnline.ConversationID = field.NewInt64(tableName, "conversation_id")
_appStaticConversationOnline.CreatedAt = field.NewInt64(tableName, "created_at")
_appStaticConversationOnline.fillFieldMap()
return _appStaticConversationOnline
}
type appStaticConversationOnline struct {
appStaticConversationOnlineDo
ALL field.Asterisk
ID field.Int64 // id
TemplateID field.Int64 // template id
UserID field.Int64 // user id
ConnectorID field.Int64 // connector id
ConversationID field.Int64 // conversation id
CreatedAt field.Int64 // create time in millisecond
fieldMap map[string]field.Expr
}
func (a appStaticConversationOnline) Table(newTableName string) *appStaticConversationOnline {
a.appStaticConversationOnlineDo.UseTable(newTableName)
return a.updateTableName(newTableName)
}
func (a appStaticConversationOnline) As(alias string) *appStaticConversationOnline {
a.appStaticConversationOnlineDo.DO = *(a.appStaticConversationOnlineDo.As(alias).(*gen.DO))
return a.updateTableName(alias)
}
func (a *appStaticConversationOnline) updateTableName(table string) *appStaticConversationOnline {
a.ALL = field.NewAsterisk(table)
a.ID = field.NewInt64(table, "id")
a.TemplateID = field.NewInt64(table, "template_id")
a.UserID = field.NewInt64(table, "user_id")
a.ConnectorID = field.NewInt64(table, "connector_id")
a.ConversationID = field.NewInt64(table, "conversation_id")
a.CreatedAt = field.NewInt64(table, "created_at")
a.fillFieldMap()
return a
}
func (a *appStaticConversationOnline) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := a.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (a *appStaticConversationOnline) fillFieldMap() {
a.fieldMap = make(map[string]field.Expr, 6)
a.fieldMap["id"] = a.ID
a.fieldMap["template_id"] = a.TemplateID
a.fieldMap["user_id"] = a.UserID
a.fieldMap["connector_id"] = a.ConnectorID
a.fieldMap["conversation_id"] = a.ConversationID
a.fieldMap["created_at"] = a.CreatedAt
}
func (a appStaticConversationOnline) clone(db *gorm.DB) appStaticConversationOnline {
a.appStaticConversationOnlineDo.ReplaceConnPool(db.Statement.ConnPool)
return a
}
func (a appStaticConversationOnline) replaceDB(db *gorm.DB) appStaticConversationOnline {
a.appStaticConversationOnlineDo.ReplaceDB(db)
return a
}
type appStaticConversationOnlineDo struct{ gen.DO }
type IAppStaticConversationOnlineDo interface {
gen.SubQuery
Debug() IAppStaticConversationOnlineDo
WithContext(ctx context.Context) IAppStaticConversationOnlineDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IAppStaticConversationOnlineDo
WriteDB() IAppStaticConversationOnlineDo
As(alias string) gen.Dao
Session(config *gorm.Session) IAppStaticConversationOnlineDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IAppStaticConversationOnlineDo
Not(conds ...gen.Condition) IAppStaticConversationOnlineDo
Or(conds ...gen.Condition) IAppStaticConversationOnlineDo
Select(conds ...field.Expr) IAppStaticConversationOnlineDo
Where(conds ...gen.Condition) IAppStaticConversationOnlineDo
Order(conds ...field.Expr) IAppStaticConversationOnlineDo
Distinct(cols ...field.Expr) IAppStaticConversationOnlineDo
Omit(cols ...field.Expr) IAppStaticConversationOnlineDo
Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo
LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo
RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo
Group(cols ...field.Expr) IAppStaticConversationOnlineDo
Having(conds ...gen.Condition) IAppStaticConversationOnlineDo
Limit(limit int) IAppStaticConversationOnlineDo
Offset(offset int) IAppStaticConversationOnlineDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationOnlineDo
Unscoped() IAppStaticConversationOnlineDo
Create(values ...*model.AppStaticConversationOnline) error
CreateInBatches(values []*model.AppStaticConversationOnline, batchSize int) error
Save(values ...*model.AppStaticConversationOnline) error
First() (*model.AppStaticConversationOnline, error)
Take() (*model.AppStaticConversationOnline, error)
Last() (*model.AppStaticConversationOnline, error)
Find() ([]*model.AppStaticConversationOnline, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationOnline, err error)
FindInBatches(result *[]*model.AppStaticConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.AppStaticConversationOnline) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo
Assign(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo
Joins(fields ...field.RelationField) IAppStaticConversationOnlineDo
Preload(fields ...field.RelationField) IAppStaticConversationOnlineDo
FirstOrInit() (*model.AppStaticConversationOnline, error)
FirstOrCreate() (*model.AppStaticConversationOnline, error)
FindByPage(offset int, limit int) (result []*model.AppStaticConversationOnline, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IAppStaticConversationOnlineDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (a appStaticConversationOnlineDo) Debug() IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Debug())
}
func (a appStaticConversationOnlineDo) WithContext(ctx context.Context) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.WithContext(ctx))
}
func (a appStaticConversationOnlineDo) ReadDB() IAppStaticConversationOnlineDo {
return a.Clauses(dbresolver.Read)
}
func (a appStaticConversationOnlineDo) WriteDB() IAppStaticConversationOnlineDo {
return a.Clauses(dbresolver.Write)
}
func (a appStaticConversationOnlineDo) Session(config *gorm.Session) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Session(config))
}
func (a appStaticConversationOnlineDo) Clauses(conds ...clause.Expression) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Clauses(conds...))
}
func (a appStaticConversationOnlineDo) Returning(value interface{}, columns ...string) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Returning(value, columns...))
}
func (a appStaticConversationOnlineDo) Not(conds ...gen.Condition) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Not(conds...))
}
func (a appStaticConversationOnlineDo) Or(conds ...gen.Condition) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Or(conds...))
}
func (a appStaticConversationOnlineDo) Select(conds ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Select(conds...))
}
func (a appStaticConversationOnlineDo) Where(conds ...gen.Condition) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Where(conds...))
}
func (a appStaticConversationOnlineDo) Order(conds ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Order(conds...))
}
func (a appStaticConversationOnlineDo) Distinct(cols ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Distinct(cols...))
}
func (a appStaticConversationOnlineDo) Omit(cols ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Omit(cols...))
}
func (a appStaticConversationOnlineDo) Join(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Join(table, on...))
}
func (a appStaticConversationOnlineDo) LeftJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.LeftJoin(table, on...))
}
func (a appStaticConversationOnlineDo) RightJoin(table schema.Tabler, on ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.RightJoin(table, on...))
}
func (a appStaticConversationOnlineDo) Group(cols ...field.Expr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Group(cols...))
}
func (a appStaticConversationOnlineDo) Having(conds ...gen.Condition) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Having(conds...))
}
func (a appStaticConversationOnlineDo) Limit(limit int) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Limit(limit))
}
func (a appStaticConversationOnlineDo) Offset(offset int) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Offset(offset))
}
func (a appStaticConversationOnlineDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Scopes(funcs...))
}
func (a appStaticConversationOnlineDo) Unscoped() IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Unscoped())
}
func (a appStaticConversationOnlineDo) Create(values ...*model.AppStaticConversationOnline) error {
if len(values) == 0 {
return nil
}
return a.DO.Create(values)
}
func (a appStaticConversationOnlineDo) CreateInBatches(values []*model.AppStaticConversationOnline, batchSize int) error {
return a.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (a appStaticConversationOnlineDo) Save(values ...*model.AppStaticConversationOnline) error {
if len(values) == 0 {
return nil
}
return a.DO.Save(values)
}
func (a appStaticConversationOnlineDo) First() (*model.AppStaticConversationOnline, error) {
if result, err := a.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationOnline), nil
}
}
func (a appStaticConversationOnlineDo) Take() (*model.AppStaticConversationOnline, error) {
if result, err := a.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationOnline), nil
}
}
func (a appStaticConversationOnlineDo) Last() (*model.AppStaticConversationOnline, error) {
if result, err := a.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationOnline), nil
}
}
func (a appStaticConversationOnlineDo) Find() ([]*model.AppStaticConversationOnline, error) {
result, err := a.DO.Find()
return result.([]*model.AppStaticConversationOnline), err
}
func (a appStaticConversationOnlineDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.AppStaticConversationOnline, err error) {
buf := make([]*model.AppStaticConversationOnline, 0, batchSize)
err = a.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (a appStaticConversationOnlineDo) FindInBatches(result *[]*model.AppStaticConversationOnline, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return a.DO.FindInBatches(result, batchSize, fc)
}
func (a appStaticConversationOnlineDo) Attrs(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Attrs(attrs...))
}
func (a appStaticConversationOnlineDo) Assign(attrs ...field.AssignExpr) IAppStaticConversationOnlineDo {
return a.withDO(a.DO.Assign(attrs...))
}
func (a appStaticConversationOnlineDo) Joins(fields ...field.RelationField) IAppStaticConversationOnlineDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Joins(_f))
}
return &a
}
func (a appStaticConversationOnlineDo) Preload(fields ...field.RelationField) IAppStaticConversationOnlineDo {
for _, _f := range fields {
a = *a.withDO(a.DO.Preload(_f))
}
return &a
}
func (a appStaticConversationOnlineDo) FirstOrInit() (*model.AppStaticConversationOnline, error) {
if result, err := a.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationOnline), nil
}
}
func (a appStaticConversationOnlineDo) FirstOrCreate() (*model.AppStaticConversationOnline, error) {
if result, err := a.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.AppStaticConversationOnline), nil
}
}
func (a appStaticConversationOnlineDo) FindByPage(offset int, limit int) (result []*model.AppStaticConversationOnline, count int64, err error) {
result, err = a.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = a.Offset(-1).Limit(-1).Count()
return
}
func (a appStaticConversationOnlineDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = a.Count()
if err != nil {
return
}
err = a.Offset(offset).Limit(limit).Scan(result)
return
}
func (a appStaticConversationOnlineDo) Scan(result interface{}) (err error) {
return a.DO.Scan(result)
}
func (a appStaticConversationOnlineDo) Delete(models ...*model.AppStaticConversationOnline) (result gen.ResultInfo, err error) {
return a.DO.Delete(models)
}
func (a *appStaticConversationOnlineDo) withDO(do gen.Dao) *appStaticConversationOnlineDo {
a.DO = *do.(*gen.DO)
return a
}

View File

@ -0,0 +1,440 @@
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
// Code generated by gorm.io/gen. DO NOT EDIT.
package query
import (
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/schema"
"gorm.io/gen"
"gorm.io/gen/field"
"gorm.io/plugin/dbresolver"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
)
func newChatFlowRoleConfig(db *gorm.DB, opts ...gen.DOOption) chatFlowRoleConfig {
_chatFlowRoleConfig := chatFlowRoleConfig{}
_chatFlowRoleConfig.chatFlowRoleConfigDo.UseDB(db, opts...)
_chatFlowRoleConfig.chatFlowRoleConfigDo.UseModel(&model.ChatFlowRoleConfig{})
tableName := _chatFlowRoleConfig.chatFlowRoleConfigDo.TableName()
_chatFlowRoleConfig.ALL = field.NewAsterisk(tableName)
_chatFlowRoleConfig.ID = field.NewInt64(tableName, "id")
_chatFlowRoleConfig.WorkflowID = field.NewInt64(tableName, "workflow_id")
_chatFlowRoleConfig.Name = field.NewString(tableName, "name")
_chatFlowRoleConfig.Description = field.NewString(tableName, "description")
_chatFlowRoleConfig.Version = field.NewString(tableName, "version")
_chatFlowRoleConfig.Avatar = field.NewString(tableName, "avatar")
_chatFlowRoleConfig.BackgroundImageInfo = field.NewString(tableName, "background_image_info")
_chatFlowRoleConfig.OnboardingInfo = field.NewString(tableName, "onboarding_info")
_chatFlowRoleConfig.SuggestReplyInfo = field.NewString(tableName, "suggest_reply_info")
_chatFlowRoleConfig.AudioConfig = field.NewString(tableName, "audio_config")
_chatFlowRoleConfig.UserInputConfig = field.NewString(tableName, "user_input_config")
_chatFlowRoleConfig.CreatorID = field.NewInt64(tableName, "creator_id")
_chatFlowRoleConfig.CreatedAt = field.NewInt64(tableName, "created_at")
_chatFlowRoleConfig.UpdatedAt = field.NewInt64(tableName, "updated_at")
_chatFlowRoleConfig.DeletedAt = field.NewField(tableName, "deleted_at")
_chatFlowRoleConfig.ConnectorID = field.NewInt64(tableName, "connector_id")
_chatFlowRoleConfig.fillFieldMap()
return _chatFlowRoleConfig
}
type chatFlowRoleConfig struct {
chatFlowRoleConfigDo
ALL field.Asterisk
ID field.Int64 // id
WorkflowID field.Int64 // workflow id
Name field.String // role name
Description field.String // role description
Version field.String // version
Avatar field.String // avatar uri
BackgroundImageInfo field.String // background image information, object structure
OnboardingInfo field.String // intro information, object structure
SuggestReplyInfo field.String // user suggestions, object structure
AudioConfig field.String // agent audio config, object structure
UserInputConfig field.String // user input config, object structure
CreatorID field.Int64 // creator id
CreatedAt field.Int64 // create time in millisecond
UpdatedAt field.Int64 // update time in millisecond
DeletedAt field.Field // delete time in millisecond
ConnectorID field.Int64 // connector id
fieldMap map[string]field.Expr
}
func (c chatFlowRoleConfig) Table(newTableName string) *chatFlowRoleConfig {
c.chatFlowRoleConfigDo.UseTable(newTableName)
return c.updateTableName(newTableName)
}
func (c chatFlowRoleConfig) As(alias string) *chatFlowRoleConfig {
c.chatFlowRoleConfigDo.DO = *(c.chatFlowRoleConfigDo.As(alias).(*gen.DO))
return c.updateTableName(alias)
}
func (c *chatFlowRoleConfig) updateTableName(table string) *chatFlowRoleConfig {
c.ALL = field.NewAsterisk(table)
c.ID = field.NewInt64(table, "id")
c.WorkflowID = field.NewInt64(table, "workflow_id")
c.Name = field.NewString(table, "name")
c.Description = field.NewString(table, "description")
c.Version = field.NewString(table, "version")
c.Avatar = field.NewString(table, "avatar")
c.BackgroundImageInfo = field.NewString(table, "background_image_info")
c.OnboardingInfo = field.NewString(table, "onboarding_info")
c.SuggestReplyInfo = field.NewString(table, "suggest_reply_info")
c.AudioConfig = field.NewString(table, "audio_config")
c.UserInputConfig = field.NewString(table, "user_input_config")
c.CreatorID = field.NewInt64(table, "creator_id")
c.CreatedAt = field.NewInt64(table, "created_at")
c.UpdatedAt = field.NewInt64(table, "updated_at")
c.DeletedAt = field.NewField(table, "deleted_at")
c.ConnectorID = field.NewInt64(table, "connector_id")
c.fillFieldMap()
return c
}
func (c *chatFlowRoleConfig) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
_f, ok := c.fieldMap[fieldName]
if !ok || _f == nil {
return nil, false
}
_oe, ok := _f.(field.OrderExpr)
return _oe, ok
}
func (c *chatFlowRoleConfig) fillFieldMap() {
c.fieldMap = make(map[string]field.Expr, 16)
c.fieldMap["id"] = c.ID
c.fieldMap["workflow_id"] = c.WorkflowID
c.fieldMap["name"] = c.Name
c.fieldMap["description"] = c.Description
c.fieldMap["version"] = c.Version
c.fieldMap["avatar"] = c.Avatar
c.fieldMap["background_image_info"] = c.BackgroundImageInfo
c.fieldMap["onboarding_info"] = c.OnboardingInfo
c.fieldMap["suggest_reply_info"] = c.SuggestReplyInfo
c.fieldMap["audio_config"] = c.AudioConfig
c.fieldMap["user_input_config"] = c.UserInputConfig
c.fieldMap["creator_id"] = c.CreatorID
c.fieldMap["created_at"] = c.CreatedAt
c.fieldMap["updated_at"] = c.UpdatedAt
c.fieldMap["deleted_at"] = c.DeletedAt
c.fieldMap["connector_id"] = c.ConnectorID
}
func (c chatFlowRoleConfig) clone(db *gorm.DB) chatFlowRoleConfig {
c.chatFlowRoleConfigDo.ReplaceConnPool(db.Statement.ConnPool)
return c
}
func (c chatFlowRoleConfig) replaceDB(db *gorm.DB) chatFlowRoleConfig {
c.chatFlowRoleConfigDo.ReplaceDB(db)
return c
}
type chatFlowRoleConfigDo struct{ gen.DO }
type IChatFlowRoleConfigDo interface {
gen.SubQuery
Debug() IChatFlowRoleConfigDo
WithContext(ctx context.Context) IChatFlowRoleConfigDo
WithResult(fc func(tx gen.Dao)) gen.ResultInfo
ReplaceDB(db *gorm.DB)
ReadDB() IChatFlowRoleConfigDo
WriteDB() IChatFlowRoleConfigDo
As(alias string) gen.Dao
Session(config *gorm.Session) IChatFlowRoleConfigDo
Columns(cols ...field.Expr) gen.Columns
Clauses(conds ...clause.Expression) IChatFlowRoleConfigDo
Not(conds ...gen.Condition) IChatFlowRoleConfigDo
Or(conds ...gen.Condition) IChatFlowRoleConfigDo
Select(conds ...field.Expr) IChatFlowRoleConfigDo
Where(conds ...gen.Condition) IChatFlowRoleConfigDo
Order(conds ...field.Expr) IChatFlowRoleConfigDo
Distinct(cols ...field.Expr) IChatFlowRoleConfigDo
Omit(cols ...field.Expr) IChatFlowRoleConfigDo
Join(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo
LeftJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo
RightJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo
Group(cols ...field.Expr) IChatFlowRoleConfigDo
Having(conds ...gen.Condition) IChatFlowRoleConfigDo
Limit(limit int) IChatFlowRoleConfigDo
Offset(offset int) IChatFlowRoleConfigDo
Count() (count int64, err error)
Scopes(funcs ...func(gen.Dao) gen.Dao) IChatFlowRoleConfigDo
Unscoped() IChatFlowRoleConfigDo
Create(values ...*model.ChatFlowRoleConfig) error
CreateInBatches(values []*model.ChatFlowRoleConfig, batchSize int) error
Save(values ...*model.ChatFlowRoleConfig) error
First() (*model.ChatFlowRoleConfig, error)
Take() (*model.ChatFlowRoleConfig, error)
Last() (*model.ChatFlowRoleConfig, error)
Find() ([]*model.ChatFlowRoleConfig, error)
FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatFlowRoleConfig, err error)
FindInBatches(result *[]*model.ChatFlowRoleConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error
Pluck(column field.Expr, dest interface{}) error
Delete(...*model.ChatFlowRoleConfig) (info gen.ResultInfo, err error)
Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
Updates(value interface{}) (info gen.ResultInfo, err error)
UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error)
UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error)
UpdateColumns(value interface{}) (info gen.ResultInfo, err error)
UpdateFrom(q gen.SubQuery) gen.Dao
Attrs(attrs ...field.AssignExpr) IChatFlowRoleConfigDo
Assign(attrs ...field.AssignExpr) IChatFlowRoleConfigDo
Joins(fields ...field.RelationField) IChatFlowRoleConfigDo
Preload(fields ...field.RelationField) IChatFlowRoleConfigDo
FirstOrInit() (*model.ChatFlowRoleConfig, error)
FirstOrCreate() (*model.ChatFlowRoleConfig, error)
FindByPage(offset int, limit int) (result []*model.ChatFlowRoleConfig, count int64, err error)
ScanByPage(result interface{}, offset int, limit int) (count int64, err error)
Scan(result interface{}) (err error)
Returning(value interface{}, columns ...string) IChatFlowRoleConfigDo
UnderlyingDB() *gorm.DB
schema.Tabler
}
func (c chatFlowRoleConfigDo) Debug() IChatFlowRoleConfigDo {
return c.withDO(c.DO.Debug())
}
func (c chatFlowRoleConfigDo) WithContext(ctx context.Context) IChatFlowRoleConfigDo {
return c.withDO(c.DO.WithContext(ctx))
}
func (c chatFlowRoleConfigDo) ReadDB() IChatFlowRoleConfigDo {
return c.Clauses(dbresolver.Read)
}
func (c chatFlowRoleConfigDo) WriteDB() IChatFlowRoleConfigDo {
return c.Clauses(dbresolver.Write)
}
func (c chatFlowRoleConfigDo) Session(config *gorm.Session) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Session(config))
}
func (c chatFlowRoleConfigDo) Clauses(conds ...clause.Expression) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Clauses(conds...))
}
func (c chatFlowRoleConfigDo) Returning(value interface{}, columns ...string) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Returning(value, columns...))
}
func (c chatFlowRoleConfigDo) Not(conds ...gen.Condition) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Not(conds...))
}
func (c chatFlowRoleConfigDo) Or(conds ...gen.Condition) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Or(conds...))
}
func (c chatFlowRoleConfigDo) Select(conds ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Select(conds...))
}
func (c chatFlowRoleConfigDo) Where(conds ...gen.Condition) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Where(conds...))
}
func (c chatFlowRoleConfigDo) Order(conds ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Order(conds...))
}
func (c chatFlowRoleConfigDo) Distinct(cols ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Distinct(cols...))
}
func (c chatFlowRoleConfigDo) Omit(cols ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Omit(cols...))
}
func (c chatFlowRoleConfigDo) Join(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Join(table, on...))
}
func (c chatFlowRoleConfigDo) LeftJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.LeftJoin(table, on...))
}
func (c chatFlowRoleConfigDo) RightJoin(table schema.Tabler, on ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.RightJoin(table, on...))
}
func (c chatFlowRoleConfigDo) Group(cols ...field.Expr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Group(cols...))
}
func (c chatFlowRoleConfigDo) Having(conds ...gen.Condition) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Having(conds...))
}
func (c chatFlowRoleConfigDo) Limit(limit int) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Limit(limit))
}
func (c chatFlowRoleConfigDo) Offset(offset int) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Offset(offset))
}
func (c chatFlowRoleConfigDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Scopes(funcs...))
}
func (c chatFlowRoleConfigDo) Unscoped() IChatFlowRoleConfigDo {
return c.withDO(c.DO.Unscoped())
}
func (c chatFlowRoleConfigDo) Create(values ...*model.ChatFlowRoleConfig) error {
if len(values) == 0 {
return nil
}
return c.DO.Create(values)
}
func (c chatFlowRoleConfigDo) CreateInBatches(values []*model.ChatFlowRoleConfig, batchSize int) error {
return c.DO.CreateInBatches(values, batchSize)
}
// Save : !!! underlying implementation is different with GORM
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
func (c chatFlowRoleConfigDo) Save(values ...*model.ChatFlowRoleConfig) error {
if len(values) == 0 {
return nil
}
return c.DO.Save(values)
}
func (c chatFlowRoleConfigDo) First() (*model.ChatFlowRoleConfig, error) {
if result, err := c.DO.First(); err != nil {
return nil, err
} else {
return result.(*model.ChatFlowRoleConfig), nil
}
}
func (c chatFlowRoleConfigDo) Take() (*model.ChatFlowRoleConfig, error) {
if result, err := c.DO.Take(); err != nil {
return nil, err
} else {
return result.(*model.ChatFlowRoleConfig), nil
}
}
func (c chatFlowRoleConfigDo) Last() (*model.ChatFlowRoleConfig, error) {
if result, err := c.DO.Last(); err != nil {
return nil, err
} else {
return result.(*model.ChatFlowRoleConfig), nil
}
}
func (c chatFlowRoleConfigDo) Find() ([]*model.ChatFlowRoleConfig, error) {
result, err := c.DO.Find()
return result.([]*model.ChatFlowRoleConfig), err
}
func (c chatFlowRoleConfigDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatFlowRoleConfig, err error) {
buf := make([]*model.ChatFlowRoleConfig, 0, batchSize)
err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
defer func() { results = append(results, buf...) }()
return fc(tx, batch)
})
return results, err
}
func (c chatFlowRoleConfigDo) FindInBatches(result *[]*model.ChatFlowRoleConfig, batchSize int, fc func(tx gen.Dao, batch int) error) error {
return c.DO.FindInBatches(result, batchSize, fc)
}
func (c chatFlowRoleConfigDo) Attrs(attrs ...field.AssignExpr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Attrs(attrs...))
}
func (c chatFlowRoleConfigDo) Assign(attrs ...field.AssignExpr) IChatFlowRoleConfigDo {
return c.withDO(c.DO.Assign(attrs...))
}
func (c chatFlowRoleConfigDo) Joins(fields ...field.RelationField) IChatFlowRoleConfigDo {
for _, _f := range fields {
c = *c.withDO(c.DO.Joins(_f))
}
return &c
}
func (c chatFlowRoleConfigDo) Preload(fields ...field.RelationField) IChatFlowRoleConfigDo {
for _, _f := range fields {
c = *c.withDO(c.DO.Preload(_f))
}
return &c
}
func (c chatFlowRoleConfigDo) FirstOrInit() (*model.ChatFlowRoleConfig, error) {
if result, err := c.DO.FirstOrInit(); err != nil {
return nil, err
} else {
return result.(*model.ChatFlowRoleConfig), nil
}
}
func (c chatFlowRoleConfigDo) FirstOrCreate() (*model.ChatFlowRoleConfig, error) {
if result, err := c.DO.FirstOrCreate(); err != nil {
return nil, err
} else {
return result.(*model.ChatFlowRoleConfig), nil
}
}
func (c chatFlowRoleConfigDo) FindByPage(offset int, limit int) (result []*model.ChatFlowRoleConfig, count int64, err error) {
result, err = c.Offset(offset).Limit(limit).Find()
if err != nil {
return
}
if size := len(result); 0 < limit && 0 < size && size < limit {
count = int64(size + offset)
return
}
count, err = c.Offset(-1).Limit(-1).Count()
return
}
func (c chatFlowRoleConfigDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
count, err = c.Count()
if err != nil {
return
}
err = c.Offset(offset).Limit(limit).Scan(result)
return
}
func (c chatFlowRoleConfigDo) Scan(result interface{}) (err error) {
return c.DO.Scan(result)
}
func (c chatFlowRoleConfigDo) Delete(models ...*model.ChatFlowRoleConfig) (result gen.ResultInfo, err error) {
return c.DO.Delete(models)
}
func (c *chatFlowRoleConfigDo) withDO(do gen.Dao) *chatFlowRoleConfigDo {
c.DO = *do.(*gen.DO)
return c
}

View File

@ -16,20 +16,34 @@ import (
)
var (
Q = new(Query)
ConnectorWorkflowVersion *connectorWorkflowVersion
NodeExecution *nodeExecution
WorkflowDraft *workflowDraft
WorkflowExecution *workflowExecution
WorkflowMeta *workflowMeta
WorkflowReference *workflowReference
WorkflowSnapshot *workflowSnapshot
WorkflowVersion *workflowVersion
Q = new(Query)
ConnectorWorkflowVersion *connectorWorkflowVersion
AppConversationTemplateDraft *appConversationTemplateDraft
AppConversationTemplateOnline *appConversationTemplateOnline
AppDynamicConversationDraft *appDynamicConversationDraft
AppDynamicConversationOnline *appDynamicConversationOnline
AppStaticConversationDraft *appStaticConversationDraft
AppStaticConversationOnline *appStaticConversationOnline
ChatFlowRoleConfig *chatFlowRoleConfig
NodeExecution *nodeExecution
WorkflowDraft *workflowDraft
WorkflowExecution *workflowExecution
WorkflowMeta *workflowMeta
WorkflowReference *workflowReference
WorkflowSnapshot *workflowSnapshot
WorkflowVersion *workflowVersion
)
func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
*Q = *Use(db, opts...)
ConnectorWorkflowVersion = &Q.ConnectorWorkflowVersion
AppConversationTemplateDraft = &Q.AppConversationTemplateDraft
AppConversationTemplateOnline = &Q.AppConversationTemplateOnline
AppDynamicConversationDraft = &Q.AppDynamicConversationDraft
AppDynamicConversationOnline = &Q.AppDynamicConversationOnline
AppStaticConversationDraft = &Q.AppStaticConversationDraft
AppStaticConversationOnline = &Q.AppStaticConversationOnline
ChatFlowRoleConfig = &Q.ChatFlowRoleConfig
NodeExecution = &Q.NodeExecution
WorkflowDraft = &Q.WorkflowDraft
WorkflowExecution = &Q.WorkflowExecution
@ -41,44 +55,65 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) {
func Use(db *gorm.DB, opts ...gen.DOOption) *Query {
return &Query{
db: db,
ConnectorWorkflowVersion: newConnectorWorkflowVersion(db, opts...),
NodeExecution: newNodeExecution(db, opts...),
WorkflowDraft: newWorkflowDraft(db, opts...),
WorkflowExecution: newWorkflowExecution(db, opts...),
WorkflowMeta: newWorkflowMeta(db, opts...),
WorkflowReference: newWorkflowReference(db, opts...),
WorkflowSnapshot: newWorkflowSnapshot(db, opts...),
WorkflowVersion: newWorkflowVersion(db, opts...),
db: db,
ConnectorWorkflowVersion: newConnectorWorkflowVersion(db, opts...),
AppConversationTemplateDraft: newAppConversationTemplateDraft(db, opts...),
AppConversationTemplateOnline: newAppConversationTemplateOnline(db, opts...),
AppDynamicConversationDraft: newAppDynamicConversationDraft(db, opts...),
AppDynamicConversationOnline: newAppDynamicConversationOnline(db, opts...),
AppStaticConversationDraft: newAppStaticConversationDraft(db, opts...),
AppStaticConversationOnline: newAppStaticConversationOnline(db, opts...),
ChatFlowRoleConfig: newChatFlowRoleConfig(db, opts...),
NodeExecution: newNodeExecution(db, opts...),
WorkflowDraft: newWorkflowDraft(db, opts...),
WorkflowExecution: newWorkflowExecution(db, opts...),
WorkflowMeta: newWorkflowMeta(db, opts...),
WorkflowReference: newWorkflowReference(db, opts...),
WorkflowSnapshot: newWorkflowSnapshot(db, opts...),
WorkflowVersion: newWorkflowVersion(db, opts...),
}
}
type Query struct {
db *gorm.DB
ConnectorWorkflowVersion connectorWorkflowVersion
NodeExecution nodeExecution
WorkflowDraft workflowDraft
WorkflowExecution workflowExecution
WorkflowMeta workflowMeta
WorkflowReference workflowReference
WorkflowSnapshot workflowSnapshot
WorkflowVersion workflowVersion
ConnectorWorkflowVersion connectorWorkflowVersion
AppConversationTemplateDraft appConversationTemplateDraft
AppConversationTemplateOnline appConversationTemplateOnline
AppDynamicConversationDraft appDynamicConversationDraft
AppDynamicConversationOnline appDynamicConversationOnline
AppStaticConversationDraft appStaticConversationDraft
AppStaticConversationOnline appStaticConversationOnline
ChatFlowRoleConfig chatFlowRoleConfig
NodeExecution nodeExecution
WorkflowDraft workflowDraft
WorkflowExecution workflowExecution
WorkflowMeta workflowMeta
WorkflowReference workflowReference
WorkflowSnapshot workflowSnapshot
WorkflowVersion workflowVersion
}
func (q *Query) Available() bool { return q.db != nil }
func (q *Query) clone(db *gorm.DB) *Query {
return &Query{
db: db,
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.clone(db),
NodeExecution: q.NodeExecution.clone(db),
WorkflowDraft: q.WorkflowDraft.clone(db),
WorkflowExecution: q.WorkflowExecution.clone(db),
WorkflowMeta: q.WorkflowMeta.clone(db),
WorkflowReference: q.WorkflowReference.clone(db),
WorkflowSnapshot: q.WorkflowSnapshot.clone(db),
WorkflowVersion: q.WorkflowVersion.clone(db),
db: db,
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.clone(db),
AppConversationTemplateDraft: q.AppConversationTemplateDraft.clone(db),
AppConversationTemplateOnline: q.AppConversationTemplateOnline.clone(db),
AppDynamicConversationDraft: q.AppDynamicConversationDraft.clone(db),
AppDynamicConversationOnline: q.AppDynamicConversationOnline.clone(db),
AppStaticConversationDraft: q.AppStaticConversationDraft.clone(db),
AppStaticConversationOnline: q.AppStaticConversationOnline.clone(db),
ChatFlowRoleConfig: q.ChatFlowRoleConfig.clone(db),
NodeExecution: q.NodeExecution.clone(db),
WorkflowDraft: q.WorkflowDraft.clone(db),
WorkflowExecution: q.WorkflowExecution.clone(db),
WorkflowMeta: q.WorkflowMeta.clone(db),
WorkflowReference: q.WorkflowReference.clone(db),
WorkflowSnapshot: q.WorkflowSnapshot.clone(db),
WorkflowVersion: q.WorkflowVersion.clone(db),
}
}
@ -92,39 +127,60 @@ func (q *Query) WriteDB() *Query {
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
return &Query{
db: db,
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.replaceDB(db),
NodeExecution: q.NodeExecution.replaceDB(db),
WorkflowDraft: q.WorkflowDraft.replaceDB(db),
WorkflowExecution: q.WorkflowExecution.replaceDB(db),
WorkflowMeta: q.WorkflowMeta.replaceDB(db),
WorkflowReference: q.WorkflowReference.replaceDB(db),
WorkflowSnapshot: q.WorkflowSnapshot.replaceDB(db),
WorkflowVersion: q.WorkflowVersion.replaceDB(db),
db: db,
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.replaceDB(db),
AppConversationTemplateDraft: q.AppConversationTemplateDraft.replaceDB(db),
AppConversationTemplateOnline: q.AppConversationTemplateOnline.replaceDB(db),
AppDynamicConversationDraft: q.AppDynamicConversationDraft.replaceDB(db),
AppDynamicConversationOnline: q.AppDynamicConversationOnline.replaceDB(db),
AppStaticConversationDraft: q.AppStaticConversationDraft.replaceDB(db),
AppStaticConversationOnline: q.AppStaticConversationOnline.replaceDB(db),
ChatFlowRoleConfig: q.ChatFlowRoleConfig.replaceDB(db),
NodeExecution: q.NodeExecution.replaceDB(db),
WorkflowDraft: q.WorkflowDraft.replaceDB(db),
WorkflowExecution: q.WorkflowExecution.replaceDB(db),
WorkflowMeta: q.WorkflowMeta.replaceDB(db),
WorkflowReference: q.WorkflowReference.replaceDB(db),
WorkflowSnapshot: q.WorkflowSnapshot.replaceDB(db),
WorkflowVersion: q.WorkflowVersion.replaceDB(db),
}
}
type queryCtx struct {
ConnectorWorkflowVersion IConnectorWorkflowVersionDo
NodeExecution INodeExecutionDo
WorkflowDraft IWorkflowDraftDo
WorkflowExecution IWorkflowExecutionDo
WorkflowMeta IWorkflowMetaDo
WorkflowReference IWorkflowReferenceDo
WorkflowSnapshot IWorkflowSnapshotDo
WorkflowVersion IWorkflowVersionDo
ConnectorWorkflowVersion IConnectorWorkflowVersionDo
AppConversationTemplateDraft IAppConversationTemplateDraftDo
AppConversationTemplateOnline IAppConversationTemplateOnlineDo
AppDynamicConversationDraft IAppDynamicConversationDraftDo
AppDynamicConversationOnline IAppDynamicConversationOnlineDo
AppStaticConversationDraft IAppStaticConversationDraftDo
AppStaticConversationOnline IAppStaticConversationOnlineDo
ChatFlowRoleConfig IChatFlowRoleConfigDo
NodeExecution INodeExecutionDo
WorkflowDraft IWorkflowDraftDo
WorkflowExecution IWorkflowExecutionDo
WorkflowMeta IWorkflowMetaDo
WorkflowReference IWorkflowReferenceDo
WorkflowSnapshot IWorkflowSnapshotDo
WorkflowVersion IWorkflowVersionDo
}
func (q *Query) WithContext(ctx context.Context) *queryCtx {
return &queryCtx{
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.WithContext(ctx),
NodeExecution: q.NodeExecution.WithContext(ctx),
WorkflowDraft: q.WorkflowDraft.WithContext(ctx),
WorkflowExecution: q.WorkflowExecution.WithContext(ctx),
WorkflowMeta: q.WorkflowMeta.WithContext(ctx),
WorkflowReference: q.WorkflowReference.WithContext(ctx),
WorkflowSnapshot: q.WorkflowSnapshot.WithContext(ctx),
WorkflowVersion: q.WorkflowVersion.WithContext(ctx),
ConnectorWorkflowVersion: q.ConnectorWorkflowVersion.WithContext(ctx),
AppConversationTemplateDraft: q.AppConversationTemplateDraft.WithContext(ctx),
AppConversationTemplateOnline: q.AppConversationTemplateOnline.WithContext(ctx),
AppDynamicConversationDraft: q.AppDynamicConversationDraft.WithContext(ctx),
AppDynamicConversationOnline: q.AppDynamicConversationOnline.WithContext(ctx),
AppStaticConversationDraft: q.AppStaticConversationDraft.WithContext(ctx),
AppStaticConversationOnline: q.AppStaticConversationOnline.WithContext(ctx),
ChatFlowRoleConfig: q.ChatFlowRoleConfig.WithContext(ctx),
NodeExecution: q.NodeExecution.WithContext(ctx),
WorkflowDraft: q.WorkflowDraft.WithContext(ctx),
WorkflowExecution: q.WorkflowExecution.WithContext(ctx),
WorkflowMeta: q.WorkflowMeta.WithContext(ctx),
WorkflowReference: q.WorkflowReference.WithContext(ctx),
WorkflowSnapshot: q.WorkflowSnapshot.WithContext(ctx),
WorkflowVersion: q.WorkflowVersion.WithContext(ctx),
}
}

View File

@ -314,13 +314,16 @@ func (r *RepositoryImpl) CreateVersion(ctx context.Context, id int64, info *vo.V
func (r *RepositoryImpl) CreateOrUpdateDraft(ctx context.Context, id int64, draft *vo.DraftInfo) error {
d := &model.WorkflowDraft{
ID: id,
Canvas: draft.Canvas,
InputParams: draft.InputParamsStr,
OutputParams: draft.OutputParamsStr,
Modified: draft.Modified,
TestRunSuccess: draft.TestRunSuccess,
CommitID: draft.CommitID,
ID: id,
Canvas: draft.Canvas,
InputParams: draft.InputParamsStr,
OutputParams: draft.OutputParamsStr,
CommitID: draft.CommitID,
}
if draft.DraftMeta != nil {
d.Modified = draft.DraftMeta.Modified
d.TestRunSuccess = draft.DraftMeta.TestRunSuccess
}
if err := r.query.WorkflowDraft.WithContext(ctx).Save(d); err != nil {
@ -598,6 +601,115 @@ func (r *RepositoryImpl) GetEntity(ctx context.Context, policy *vo.GetPolicy) (_
}, nil
}
func (r *RepositoryImpl) CreateChatFlowRoleConfig(ctx context.Context, chatFlowRole *entity.ChatFlowRole) (int64, error) {
id, err := r.GenID(ctx)
if err != nil {
return 0, vo.WrapError(errno.ErrIDGenError, err)
}
chatFlowRoleConfig := &model.ChatFlowRoleConfig{
ID: id,
WorkflowID: chatFlowRole.WorkflowID,
Name: chatFlowRole.Name,
Description: chatFlowRole.Description,
Avatar: chatFlowRole.AvatarUri,
AudioConfig: chatFlowRole.AudioConfig,
BackgroundImageInfo: chatFlowRole.BackgroundImageInfo,
OnboardingInfo: chatFlowRole.OnboardingInfo,
SuggestReplyInfo: chatFlowRole.SuggestReplyInfo,
UserInputConfig: chatFlowRole.UserInputConfig,
CreatorID: chatFlowRole.CreatorID,
}
if err := r.query.ChatFlowRoleConfig.WithContext(ctx).Create(chatFlowRoleConfig); err != nil {
return 0, vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("create chat flow role: %w", err))
}
return id, nil
}
func (r *RepositoryImpl) UpdateChatFlowRoleConfig(ctx context.Context, workflowID int64, chatFlowRole *vo.ChatFlowRoleUpdate) error {
var expressions []field.AssignExpr
if chatFlowRole.Name != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.Name.Value(*chatFlowRole.Name))
}
if chatFlowRole.Description != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.Description.Value(*chatFlowRole.Description))
}
if chatFlowRole.AvatarUri != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.Avatar.Value(*chatFlowRole.AvatarUri))
}
if chatFlowRole.AudioConfig != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.AudioConfig.Value(*chatFlowRole.AudioConfig))
}
if chatFlowRole.BackgroundImageInfo != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.BackgroundImageInfo.Value(*chatFlowRole.BackgroundImageInfo))
}
if chatFlowRole.OnboardingInfo != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.OnboardingInfo.Value(*chatFlowRole.OnboardingInfo))
}
if chatFlowRole.SuggestReplyInfo != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.SuggestReplyInfo.Value(*chatFlowRole.SuggestReplyInfo))
}
if chatFlowRole.UserInputConfig != nil {
expressions = append(expressions, r.query.ChatFlowRoleConfig.UserInputConfig.Value(*chatFlowRole.UserInputConfig))
}
if len(expressions) == 0 {
return nil
}
_, err := r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID)).
UpdateColumnSimple(expressions...)
if err != nil {
return vo.WrapError(errno.ErrDatabaseError, fmt.Errorf("update chat flow role: %w", err))
}
return nil
}
func (r *RepositoryImpl) GetChatFlowRoleConfig(ctx context.Context, workflowID int64, version string) (_ *entity.ChatFlowRole, err error, isExist bool) {
defer func() {
if err != nil {
err = vo.WrapIfNeeded(errno.ErrDatabaseError, err)
}
}()
role := &model.ChatFlowRoleConfig{}
if version != "" {
role, err = r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID), r.query.ChatFlowRoleConfig.Version.Eq(version)).First()
} else {
role, err = r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID)).First()
}
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, err, false
}
return nil, fmt.Errorf("failed to get chat flow role for chatflowID %d: %w", workflowID, err), true
}
res := &entity.ChatFlowRole{
ID: role.ID,
WorkflowID: role.WorkflowID,
Name: role.Name,
Description: role.Description,
AvatarUri: role.Avatar,
AudioConfig: role.AudioConfig,
BackgroundImageInfo: role.BackgroundImageInfo,
OnboardingInfo: role.OnboardingInfo,
SuggestReplyInfo: role.SuggestReplyInfo,
UserInputConfig: role.UserInputConfig,
CreatorID: role.CreatorID,
CreatedAt: time.UnixMilli(role.CreatedAt),
}
if role.UpdatedAt > 0 {
res.UpdatedAt = time.UnixMilli(role.UpdatedAt)
}
return res, err, true
}
func (r *RepositoryImpl) DeleteChatFlowRoleConfig(ctx context.Context, id int64, workflowID int64) error {
_, err := r.query.ChatFlowRoleConfig.WithContext(ctx).Where(r.query.ChatFlowRoleConfig.ID.Eq(id), r.query.ChatFlowRoleConfig.WorkflowID.Eq(workflowID)).Delete()
return err
}
func (r *RepositoryImpl) GetVersion(ctx context.Context, id int64, version string) (_ *vo.VersionInfo, err error) {
defer func() {
if err != nil {
@ -761,6 +873,10 @@ func (r *RepositoryImpl) MGetDrafts(ctx context.Context, policy *vo.MGetPolicy)
conditions = append(conditions, r.query.WorkflowMeta.AppID.Eq(0))
}
if q.Mode != nil {
conditions = append(conditions, r.query.WorkflowMeta.Mode.Eq(int32(*q.Mode)))
}
type combinedDraft struct {
model.WorkflowDraft
Name string `gorm:"column:name"`
@ -1583,6 +1699,10 @@ func (r *RepositoryImpl) BatchCreateConnectorWorkflowVersion(ctx context.Context
return nil
}
func (r *RepositoryImpl) GetObjectUrl(ctx context.Context, objectKey string, opts ...storage.GetOptFn) (string, error) {
return r.tos.GetObjectUrl(ctx, objectKey, opts...)
}
func filterDisabledAPIParameters(parametersCfg []*workflow3.APIParameter, m map[string]any) map[string]any {
result := make(map[string]any, len(m))
responseParameterMap := slices.ToMap(parametersCfg, func(p *workflow3.APIParameter) (string, *workflow3.APIParameter) {

View File

@ -0,0 +1,321 @@
package service
import (
"context"
"fmt"
cloudworkflow "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
"github.com/coze-dev/coze-studio/backend/types/consts"
"github.com/coze-dev/coze-studio/backend/types/errno"
)
type conversationImpl struct {
repo workflow.Repository
}
func (c *conversationImpl) CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error) {
var (
spaceID = template.SpaceID
appID = template.AppID
name = template.Name
userID = template.UserID
)
existed, err := c.IsDraftConversationNameExist(ctx, appID, userID, template.Name)
if err != nil {
return 0, err
}
if existed {
return 0, vo.WrapError(errno.ErrConversationNameIsDuplicated, fmt.Errorf("conversation name %s exists", name), errorx.KV("name", name))
}
return c.repo.CreateDraftConversationTemplate(ctx, &vo.CreateConversationTemplateMeta{
SpaceID: spaceID,
AppID: appID,
Name: name,
UserID: userID,
})
}
func (c *conversationImpl) IsDraftConversationNameExist(ctx context.Context, appID int64, userID int64, name string) (bool, error) {
_, existed, err := c.repo.GetDynamicConversationByName(ctx, vo.Draft, appID, consts.CozeConnectorID, userID, name)
if err != nil {
return false, err
}
if existed {
return true, nil
}
_, existed, err = c.repo.GetConversationTemplate(ctx, vo.Draft, vo.GetConversationTemplatePolicy{AppID: ptr.Of(appID), Name: ptr.Of(name)})
if err != nil {
return false, err
}
if existed {
return true, nil
}
return false, nil
}
func (c *conversationImpl) UpdateDraftConversationTemplateName(ctx context.Context, appID int64, userID int64, templateID int64, modifiedName string) error {
template, existed, err := c.repo.GetConversationTemplate(ctx, vo.Draft, vo.GetConversationTemplatePolicy{TemplateID: ptr.Of(templateID)})
if err != nil {
return err
}
if existed && template.Name == modifiedName {
return nil
}
existed, err = c.IsDraftConversationNameExist(ctx, appID, userID, modifiedName)
if err != nil {
return err
}
if existed {
return vo.WrapError(errno.ErrConversationNameIsDuplicated, fmt.Errorf("conversation name %s exists", modifiedName), errorx.KV("name", modifiedName))
}
wfs, err := c.findReplaceWorkflowByConversationName(ctx, appID, template.Name)
if err != nil {
return err
}
err = c.replaceWorkflowsConversationName(ctx, wfs, slices.ToMap(wfs, func(e *entity.Workflow) (int64, string) {
return e.ID, modifiedName
}))
if err != nil {
return err
}
return c.repo.UpdateDraftConversationTemplateName(ctx, templateID, modifiedName)
}
func (c *conversationImpl) CheckWorkflowsToReplace(ctx context.Context, appID int64, templateID int64) ([]*entity.Workflow, error) {
template, existed, err := c.repo.GetConversationTemplate(ctx, vo.Draft, vo.GetConversationTemplatePolicy{TemplateID: ptr.Of(templateID)})
if err != nil {
return nil, err
}
if existed {
return c.findReplaceWorkflowByConversationName(ctx, appID, template.Name)
}
return []*entity.Workflow{}, nil
}
func (c *conversationImpl) DeleteDraftConversationTemplate(ctx context.Context, templateID int64, wfID2ConversationName map[int64]string) (int64, error) {
if len(wfID2ConversationName) == 0 {
return c.repo.DeleteDraftConversationTemplate(ctx, templateID)
}
workflowIDs := make([]int64, 0)
for id := range wfID2ConversationName {
workflowIDs = append(workflowIDs, id)
}
wfs, _, err := c.repo.MGetDrafts(ctx, &vo.MGetPolicy{
MetaQuery: vo.MetaQuery{
IDs: workflowIDs,
},
QType: vo.FromDraft,
})
if err != nil {
return 0, err
}
err = c.replaceWorkflowsConversationName(ctx, wfs, wfID2ConversationName)
if err != nil {
return 0, err
}
return c.repo.DeleteDraftConversationTemplate(ctx, templateID)
}
func (c *conversationImpl) ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
var (
err error
templates []*entity.ConversationTemplate
appID = policy.AppID
)
templates, err = c.repo.ListConversationTemplate(ctx, env, &vo.ListConversationTemplatePolicy{
AppID: appID,
Page: policy.Page,
NameLike: policy.NameLike,
Version: policy.Version,
})
if err != nil {
return nil, err
}
return templates, nil
}
func (c *conversationImpl) MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
return c.repo.MGetStaticConversation(ctx, env, userID, connectorID, templateIDs)
}
func (c *conversationImpl) ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
return c.repo.ListDynamicConversation(ctx, env, policy)
}
func (c *conversationImpl) ReleaseConversationTemplate(ctx context.Context, appID int64, version string) error {
templates, err := c.repo.ListConversationTemplate(ctx, vo.Draft, &vo.ListConversationTemplatePolicy{
AppID: appID,
})
if err != nil {
return err
}
if len(templates) == 0 {
return nil
}
return c.repo.BatchCreateOnlineConversationTemplate(ctx, templates, version)
}
func (c *conversationImpl) InitApplicationDefaultConversationTemplate(ctx context.Context, spaceID, appID int64, userID int64) error {
_, err := c.repo.CreateDraftConversationTemplate(ctx, &vo.CreateConversationTemplateMeta{
AppID: appID,
SpaceID: spaceID,
UserID: userID,
Name: "Default",
})
if err != nil {
return err
}
return nil
}
func (c *conversationImpl) findReplaceWorkflowByConversationName(ctx context.Context, appID int64, name string) ([]*entity.Workflow, error) {
wfs, _, err := c.repo.MGetDrafts(ctx, &vo.MGetPolicy{
QType: vo.FromDraft,
MetaQuery: vo.MetaQuery{
AppID: ptr.Of(appID),
Mode: ptr.Of(cloudworkflow.WorkflowMode_ChatFlow),
},
})
if err != nil {
return nil, err
}
shouldReplacedWorkflow := func(nodes []*vo.Node) (bool, error) {
var startNode *vo.Node
for _, node := range nodes {
if node.Type == vo.BlockTypeBotStart {
startNode = node
}
}
if startNode == nil {
return false, fmt.Errorf("start node not found for block type")
}
for _, vAny := range startNode.Data.Outputs {
v, err := vo.ParseVariable(vAny)
if err != nil {
return false, err
}
if v.Name == "CONVERSATION_NAME" && v.DefaultValue == name {
return true, nil
}
}
return false, nil
}
shouldReplacedWorkflows := make([]*entity.Workflow, 0)
for idx := range wfs {
wf := wfs[idx]
canvas := &vo.Canvas{}
err = sonic.UnmarshalString(wf.Canvas, canvas)
if err != nil {
return nil, err
}
ok, err := shouldReplacedWorkflow(canvas.Nodes)
if err != nil {
return nil, err
}
if ok {
shouldReplacedWorkflows = append(shouldReplacedWorkflows, wf)
}
}
return shouldReplacedWorkflows, nil
}
func (c *conversationImpl) replaceWorkflowsConversationName(ctx context.Context, wfs []*entity.Workflow, workflowID2ConversionName map[int64]string) error {
replaceConversionName := func(nodes []*vo.Node, conversionName string) error {
var startNode *vo.Node
for _, node := range nodes {
if node.Type == vo.BlockTypeBotStart {
startNode = node
}
}
if startNode == nil {
return fmt.Errorf("start node not found for block type")
}
for idx, vAny := range startNode.Data.Outputs {
v, err := vo.ParseVariable(vAny)
if err != nil {
return err
}
if v.Name == "CONVERSATION_NAME" {
v.DefaultValue = conversionName
}
startNode.Data.Outputs[idx] = v
}
return nil
}
for _, wf := range wfs {
canvas := &vo.Canvas{}
err := sonic.UnmarshalString(wf.Canvas, canvas)
if err != nil {
return err
}
conversationName := workflowID2ConversionName[wf.ID]
err = replaceConversionName(canvas.Nodes, conversationName)
if err != nil {
return err
}
replaceCanvas, err := sonic.MarshalString(canvas)
if err != nil {
return err
}
err = c.repo.CreateOrUpdateDraft(ctx, wf.ID, &vo.DraftInfo{
DraftMeta: &vo.DraftMeta{
TestRunSuccess: false,
Modified: true,
},
Canvas: replaceCanvas,
})
if err != nil {
return err
}
}
return nil
}
func (c *conversationImpl) DeleteDynamicConversation(ctx context.Context, env vo.Env, templateID int64) (int64, error) {
return c.repo.DeleteDynamicConversation(ctx, env, templateID)
}

View File

@ -52,6 +52,7 @@ type impl struct {
repo workflow.Repository
*asToolImpl
*executableImpl
*conversationImpl
}
func NewWorkflowService(repo workflow.Repository) workflow.Service {
@ -63,6 +64,7 @@ func NewWorkflowService(repo workflow.Repository) workflow.Service {
executableImpl: &executableImpl{
repo: repo,
},
conversationImpl: &conversationImpl{repo: repo},
}
}
@ -429,7 +431,7 @@ func (i *impl) collectNodePropertyMap(ctx context.Context, canvas *vo.Canvas) (m
if err != nil {
return nil, err
}
blockType, err := entityNodeTypeToBlockType(nodeSchema.Type)
blockType, err := entity.NodeTypeToBlockType(nodeSchema.Type)
if err != nil {
return nil, err
}
@ -481,7 +483,7 @@ func (i *impl) collectNodePropertyMap(ctx context.Context, canvas *vo.Canvas) (m
return nil, err
}
for _, nodeSchema := range nodeSchemas {
blockType, err := entityNodeTypeToBlockType(nodeSchema.Type)
blockType, err := entity.NodeTypeToBlockType(nodeSchema.Type)
if err != nil {
return nil, err
}
@ -498,6 +500,142 @@ func (i *impl) collectNodePropertyMap(ctx context.Context, canvas *vo.Canvas) (m
return nodePropertyMap, nil
}
func (i *impl) CreateChatFlowRole(ctx context.Context, role *vo.ChatFlowRoleCreate) (int64, error) {
id, err := i.repo.CreateChatFlowRoleConfig(ctx, &entity.ChatFlowRole{
Name: role.Name,
Description: role.Description,
WorkflowID: role.WorkflowID,
CreatorID: role.CreatorID,
AudioConfig: role.AudioConfig,
UserInputConfig: role.UserInputConfig,
AvatarUri: role.AvatarUri,
BackgroundImageInfo: role.BackgroundImageInfo,
OnboardingInfo: role.OnboardingInfo,
SuggestReplyInfo: role.SuggestReplyInfo,
})
if err != nil {
return 0, err
}
return id, nil
}
func (i *impl) UpdateChatFlowRole(ctx context.Context, workflowID int64, role *vo.ChatFlowRoleUpdate) error {
err := i.repo.UpdateChatFlowRoleConfig(ctx, workflowID, role)
if err != nil {
return err
}
return nil
}
func (i *impl) GetChatFlowRole(ctx context.Context, workflowID int64, version string) (*entity.ChatFlowRole, error) {
role, err, isExist := i.repo.GetChatFlowRoleConfig(ctx, workflowID, version)
if !isExist {
logs.CtxWarnf(ctx, "chat flow role not exist, workflow id %v, version %v", workflowID, version)
// Return (nil, nil) on 'NotExist' to align with the production behavior,
// where the GET API may be called before the CREATE API during chatflow creation.
return nil, nil
}
if err != nil {
return nil, err
}
return role, nil
}
func (i *impl) DeleteChatFlowRole(ctx context.Context, id int64, workflowID int64) error {
return i.repo.DeleteChatFlowRoleConfig(ctx, id, workflowID)
}
func (i *impl) CopyChatFlowRole(ctx context.Context, policy *vo.CopyRolePolicy) error {
if policy.SourceID == 0 || policy.TargetID == 0 || policy.CreatorID == 0 {
logs.CtxErrorf(ctx, "invalid copy role policy, source id %v, target id %v, creator id %v should not be zero", policy.SourceID, policy.TargetID, policy.CreatorID)
return vo.WrapError(errno.ErrInvalidParameter, fmt.Errorf("invalid copy role policy, source id %v, target id %v, creator id %v should not be zero", policy.SourceID, policy.TargetID, policy.CreatorID))
}
wf, err := i.repo.GetEntity(ctx, &vo.GetPolicy{
ID: policy.SourceID,
MetaOnly: true,
})
if err != nil {
return err
}
if wf.Mode != cloudworkflow.WorkflowMode_ChatFlow {
return vo.WrapError(errno.ErrChatFlowRoleOperationFail, fmt.Errorf("workflow id %v, mode %v is not a chatflow", policy.SourceID, wf.Mode))
}
role, err, isExist := i.repo.GetChatFlowRoleConfig(ctx, policy.SourceID, "")
if !isExist {
logs.CtxErrorf(ctx, "get draft chat flow role nil, workflow id %v", policy.SourceID)
return vo.WrapError(errno.ErrChatFlowRoleOperationFail, fmt.Errorf("get draft chat flow role nil, workflow id %v", policy.SourceID))
}
if err != nil {
return vo.WrapIfNeeded(errno.ErrChatFlowRoleOperationFail, err)
}
_, err = i.repo.CreateChatFlowRoleConfig(ctx, &entity.ChatFlowRole{
Name: role.Name,
Description: role.Description,
WorkflowID: policy.TargetID,
CreatorID: policy.CreatorID,
AudioConfig: role.AudioConfig,
UserInputConfig: role.UserInputConfig,
AvatarUri: role.AvatarUri,
BackgroundImageInfo: role.BackgroundImageInfo,
OnboardingInfo: role.OnboardingInfo,
SuggestReplyInfo: role.SuggestReplyInfo,
})
if err != nil {
return err
}
return nil
}
func (i *impl) PublishChatFlowRole(ctx context.Context, policy *vo.PublishRolePolicy) error {
if policy.WorkflowID == 0 || policy.CreatorID == 0 || policy.Version == "" {
logs.CtxErrorf(ctx, "invalid publish role policy, workflow id %v, creator id %v should not be zero, version %v should not be empty", policy.WorkflowID, policy.CreatorID, policy.Version)
return vo.WrapError(errno.ErrInvalidParameter, fmt.Errorf("invalid publish role policy, workflow id %v, creator id %v should not be zero, version %v should not be empty", policy.WorkflowID, policy.CreatorID, policy.Version))
}
wf, err := i.repo.GetEntity(ctx, &vo.GetPolicy{
ID: policy.WorkflowID,
MetaOnly: true,
})
if err != nil {
return err
}
if wf.Mode != cloudworkflow.WorkflowMode_ChatFlow {
return vo.WrapError(errno.ErrChatFlowRoleOperationFail, fmt.Errorf("workflow id %v, mode %v is not a chatflow", policy.WorkflowID, wf.Mode))
}
role, err, isExist := i.repo.GetChatFlowRoleConfig(ctx, policy.WorkflowID, "")
if !isExist {
logs.CtxErrorf(ctx, "get draft chat flow role nil, workflow id %v", policy.WorkflowID)
return vo.WrapError(errno.ErrChatFlowRoleOperationFail, fmt.Errorf("get draft chat flow role nil, workflow id %v", policy.WorkflowID))
}
if err != nil {
return vo.WrapIfNeeded(errno.ErrChatFlowRoleOperationFail, err)
}
_, err = i.repo.CreateChatFlowRoleConfig(ctx, &entity.ChatFlowRole{
Name: role.Name,
Description: role.Description,
WorkflowID: policy.WorkflowID,
CreatorID: policy.CreatorID,
AudioConfig: role.AudioConfig,
UserInputConfig: role.UserInputConfig,
AvatarUri: role.AvatarUri,
BackgroundImageInfo: role.BackgroundImageInfo,
OnboardingInfo: role.OnboardingInfo,
SuggestReplyInfo: role.SuggestReplyInfo,
Version: policy.Version,
})
if err != nil {
return err
}
return nil
}
func canvasToRefs(referringID int64, canvasStr string) (map[entity.WorkflowReferenceKey]struct{}, error) {
var canvas vo.Canvas
if err := sonic.UnmarshalString(canvasStr, &canvas); err != nil {
@ -779,6 +917,11 @@ func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, con
}
}
err = i.ReleaseConversationTemplate(ctx, appID, config.Version)
if err != nil {
return nil, err
}
for _, connectorID := range config.ConnectorIDs {
err = i.repo.BatchCreateConnectorWorkflowVersion(ctx, appID, connectorID, workflowIDs, config.Version)
if err != nil {

View File

@ -19,6 +19,7 @@ import (
workflow0 "github.com/coze-dev/coze-studio/backend/domain/workflow"
entity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
vo "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
storage "github.com/coze-dev/coze-studio/backend/infra/contract/storage"
gomock "go.uber.org/mock/gomock"
)
@ -104,6 +105,35 @@ func (mr *MockServiceMockRecorder) Cancel(ctx, wfExeID, wfID, spaceID any) *gomo
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Cancel", reflect.TypeOf((*MockService)(nil).Cancel), ctx, wfExeID, wfID, spaceID)
}
// CheckWorkflowsToReplace mocks base method.
func (m *MockService) CheckWorkflowsToReplace(ctx context.Context, appID, templateID int64) ([]*entity.Workflow, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CheckWorkflowsToReplace", ctx, appID, templateID)
ret0, _ := ret[0].([]*entity.Workflow)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CheckWorkflowsToReplace indicates an expected call of CheckWorkflowsToReplace.
func (mr *MockServiceMockRecorder) CheckWorkflowsToReplace(ctx, appID, templateID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckWorkflowsToReplace", reflect.TypeOf((*MockService)(nil).CheckWorkflowsToReplace), ctx, appID, templateID)
}
// CopyChatFlowRole mocks base method.
func (m *MockService) CopyChatFlowRole(ctx context.Context, policy *vo.CopyRolePolicy) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CopyChatFlowRole", ctx, policy)
ret0, _ := ret[0].(error)
return ret0
}
// CopyChatFlowRole indicates an expected call of CopyChatFlowRole.
func (mr *MockServiceMockRecorder) CopyChatFlowRole(ctx, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyChatFlowRole", reflect.TypeOf((*MockService)(nil).CopyChatFlowRole), ctx, policy)
}
// CopyWorkflow mocks base method.
func (m *MockService) CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error) {
m.ctrl.T.Helper()
@ -150,6 +180,36 @@ func (mr *MockServiceMockRecorder) Create(ctx, meta any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockService)(nil).Create), ctx, meta)
}
// CreateChatFlowRole mocks base method.
func (m *MockService) CreateChatFlowRole(ctx context.Context, role *vo.ChatFlowRoleCreate) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateChatFlowRole", ctx, role)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateChatFlowRole indicates an expected call of CreateChatFlowRole.
func (mr *MockServiceMockRecorder) CreateChatFlowRole(ctx, role any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateChatFlowRole", reflect.TypeOf((*MockService)(nil).CreateChatFlowRole), ctx, role)
}
// CreateDraftConversationTemplate mocks base method.
func (m *MockService) CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateDraftConversationTemplate", ctx, template)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateDraftConversationTemplate indicates an expected call of CreateDraftConversationTemplate.
func (mr *MockServiceMockRecorder) CreateDraftConversationTemplate(ctx, template any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDraftConversationTemplate", reflect.TypeOf((*MockService)(nil).CreateDraftConversationTemplate), ctx, template)
}
// Delete mocks base method.
func (m *MockService) Delete(ctx context.Context, policy *vo.DeletePolicy) error {
m.ctrl.T.Helper()
@ -164,6 +224,50 @@ func (mr *MockServiceMockRecorder) Delete(ctx, policy any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockService)(nil).Delete), ctx, policy)
}
// DeleteChatFlowRole mocks base method.
func (m *MockService) DeleteChatFlowRole(ctx context.Context, id, workflowID int64) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteChatFlowRole", ctx, id, workflowID)
ret0, _ := ret[0].(error)
return ret0
}
// DeleteChatFlowRole indicates an expected call of DeleteChatFlowRole.
func (mr *MockServiceMockRecorder) DeleteChatFlowRole(ctx, id, workflowID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteChatFlowRole", reflect.TypeOf((*MockService)(nil).DeleteChatFlowRole), ctx, id, workflowID)
}
// DeleteDraftConversationTemplate mocks base method.
func (m *MockService) DeleteDraftConversationTemplate(ctx context.Context, templateID int64, wfID2ConversationName map[int64]string) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteDraftConversationTemplate", ctx, templateID, wfID2ConversationName)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DeleteDraftConversationTemplate indicates an expected call of DeleteDraftConversationTemplate.
func (mr *MockServiceMockRecorder) DeleteDraftConversationTemplate(ctx, templateID, wfID2ConversationName any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDraftConversationTemplate", reflect.TypeOf((*MockService)(nil).DeleteDraftConversationTemplate), ctx, templateID, wfID2ConversationName)
}
// DeleteDynamicConversation mocks base method.
func (m *MockService) DeleteDynamicConversation(ctx context.Context, env vo.Env, templateID int64) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteDynamicConversation", ctx, env, templateID)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DeleteDynamicConversation indicates an expected call of DeleteDynamicConversation.
func (mr *MockServiceMockRecorder) DeleteDynamicConversation(ctx, env, templateID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDynamicConversation", reflect.TypeOf((*MockService)(nil).DeleteDynamicConversation), ctx, env, templateID)
}
// DuplicateWorkflowsByAppID mocks base method.
func (m *MockService) DuplicateWorkflowsByAppID(ctx context.Context, sourceAPPID, targetAppID int64, related vo.ExternalResourceRelated) error {
m.ctrl.T.Helper()
@ -193,6 +297,21 @@ func (mr *MockServiceMockRecorder) Get(ctx, policy any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockService)(nil).Get), ctx, policy)
}
// GetChatFlowRole mocks base method.
func (m *MockService) GetChatFlowRole(ctx context.Context, workflowID int64, version string) (*entity.ChatFlowRole, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetChatFlowRole", ctx, workflowID, version)
ret0, _ := ret[0].(*entity.ChatFlowRole)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetChatFlowRole indicates an expected call of GetChatFlowRole.
func (mr *MockServiceMockRecorder) GetChatFlowRole(ctx, workflowID, version any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChatFlowRole", reflect.TypeOf((*MockService)(nil).GetChatFlowRole), ctx, workflowID, version)
}
// GetExecution mocks base method.
func (m *MockService) GetExecution(ctx context.Context, wfExe *entity.WorkflowExecution, includeNodes bool) (*entity.WorkflowExecution, error) {
m.ctrl.T.Helper()
@ -287,6 +406,50 @@ func (mr *MockServiceMockRecorder) GetWorkflowReference(ctx, id any) *gomock.Cal
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowReference", reflect.TypeOf((*MockService)(nil).GetWorkflowReference), ctx, id)
}
// InitApplicationDefaultConversationTemplate mocks base method.
func (m *MockService) InitApplicationDefaultConversationTemplate(ctx context.Context, spaceID, appID, userID int64) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InitApplicationDefaultConversationTemplate", ctx, spaceID, appID, userID)
ret0, _ := ret[0].(error)
return ret0
}
// InitApplicationDefaultConversationTemplate indicates an expected call of InitApplicationDefaultConversationTemplate.
func (mr *MockServiceMockRecorder) InitApplicationDefaultConversationTemplate(ctx, spaceID, appID, userID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitApplicationDefaultConversationTemplate", reflect.TypeOf((*MockService)(nil).InitApplicationDefaultConversationTemplate), ctx, spaceID, appID, userID)
}
// ListConversationTemplate mocks base method.
func (m *MockService) ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListConversationTemplate", ctx, env, policy)
ret0, _ := ret[0].([]*entity.ConversationTemplate)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListConversationTemplate indicates an expected call of ListConversationTemplate.
func (mr *MockServiceMockRecorder) ListConversationTemplate(ctx, env, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListConversationTemplate", reflect.TypeOf((*MockService)(nil).ListConversationTemplate), ctx, env, policy)
}
// ListDynamicConversation mocks base method.
func (m *MockService) ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListDynamicConversation", ctx, env, policy)
ret0, _ := ret[0].([]*entity.DynamicConversation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListDynamicConversation indicates an expected call of ListDynamicConversation.
func (mr *MockServiceMockRecorder) ListDynamicConversation(ctx, env, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDynamicConversation", reflect.TypeOf((*MockService)(nil).ListDynamicConversation), ctx, env, policy)
}
// ListNodeMeta mocks base method.
func (m *MockService) ListNodeMeta(ctx context.Context, nodeTypes map[entity.NodeType]bool) (map[string][]*entity.NodeTypeMeta, []entity.Category, error) {
m.ctrl.T.Helper()
@ -319,6 +482,21 @@ func (mr *MockServiceMockRecorder) MGet(ctx, policy any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MGet", reflect.TypeOf((*MockService)(nil).MGet), ctx, policy)
}
// MGetStaticConversation mocks base method.
func (m *MockService) MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MGetStaticConversation", ctx, env, userID, connectorID, templateIDs)
ret0, _ := ret[0].([]*entity.StaticConversation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// MGetStaticConversation indicates an expected call of MGetStaticConversation.
func (mr *MockServiceMockRecorder) MGetStaticConversation(ctx, env, userID, connectorID, templateIDs any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MGetStaticConversation", reflect.TypeOf((*MockService)(nil).MGetStaticConversation), ctx, env, userID, connectorID, templateIDs)
}
// Publish mocks base method.
func (m *MockService) Publish(ctx context.Context, policy *vo.PublishPolicy) error {
m.ctrl.T.Helper()
@ -333,6 +511,20 @@ func (mr *MockServiceMockRecorder) Publish(ctx, policy any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Publish", reflect.TypeOf((*MockService)(nil).Publish), ctx, policy)
}
// PublishChatFlowRole mocks base method.
func (m *MockService) PublishChatFlowRole(ctx context.Context, policy *vo.PublishRolePolicy) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PublishChatFlowRole", ctx, policy)
ret0, _ := ret[0].(error)
return ret0
}
// PublishChatFlowRole indicates an expected call of PublishChatFlowRole.
func (mr *MockServiceMockRecorder) PublishChatFlowRole(ctx, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishChatFlowRole", reflect.TypeOf((*MockService)(nil).PublishChatFlowRole), ctx, policy)
}
// QueryNodeProperties mocks base method.
func (m *MockService) QueryNodeProperties(ctx context.Context, id int64) (map[string]*vo.NodeProperty, error) {
m.ctrl.T.Helper()
@ -363,6 +555,20 @@ func (mr *MockServiceMockRecorder) ReleaseApplicationWorkflows(ctx, appID, confi
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReleaseApplicationWorkflows", reflect.TypeOf((*MockService)(nil).ReleaseApplicationWorkflows), ctx, appID, config)
}
// ReleaseConversationTemplate mocks base method.
func (m *MockService) ReleaseConversationTemplate(ctx context.Context, appID int64, version string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ReleaseConversationTemplate", ctx, appID, version)
ret0, _ := ret[0].(error)
return ret0
}
// ReleaseConversationTemplate indicates an expected call of ReleaseConversationTemplate.
func (mr *MockServiceMockRecorder) ReleaseConversationTemplate(ctx, appID, version any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReleaseConversationTemplate", reflect.TypeOf((*MockService)(nil).ReleaseConversationTemplate), ctx, appID, version)
}
// Save mocks base method.
func (m *MockService) Save(ctx context.Context, id int64, arg2 string) error {
m.ctrl.T.Helper()
@ -437,6 +643,34 @@ func (mr *MockServiceMockRecorder) SyncRelatedWorkflowResources(ctx, appID, rela
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SyncRelatedWorkflowResources", reflect.TypeOf((*MockService)(nil).SyncRelatedWorkflowResources), ctx, appID, relatedWorkflows, related)
}
// UpdateChatFlowRole mocks base method.
func (m *MockService) UpdateChatFlowRole(ctx context.Context, workflowID int64, role *vo.ChatFlowRoleUpdate) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateChatFlowRole", ctx, workflowID, role)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateChatFlowRole indicates an expected call of UpdateChatFlowRole.
func (mr *MockServiceMockRecorder) UpdateChatFlowRole(ctx, workflowID, role any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateChatFlowRole", reflect.TypeOf((*MockService)(nil).UpdateChatFlowRole), ctx, workflowID, role)
}
// UpdateDraftConversationTemplateName mocks base method.
func (m *MockService) UpdateDraftConversationTemplateName(ctx context.Context, appID, userID, templateID int64, name string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateDraftConversationTemplateName", ctx, appID, userID, templateID, name)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateDraftConversationTemplateName indicates an expected call of UpdateDraftConversationTemplateName.
func (mr *MockServiceMockRecorder) UpdateDraftConversationTemplateName(ctx, appID, userID, templateID, name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDraftConversationTemplateName", reflect.TypeOf((*MockService)(nil).UpdateDraftConversationTemplateName), ctx, appID, userID, templateID, name)
}
// UpdateMeta mocks base method.
func (m *MockService) UpdateMeta(ctx context.Context, id int64, metaUpdate *vo.MetaUpdate) error {
m.ctrl.T.Helper()
@ -548,6 +782,34 @@ func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder {
return m.recorder
}
// BatchCreateConnectorWorkflowVersion mocks base method.
func (m *MockRepository) BatchCreateConnectorWorkflowVersion(ctx context.Context, appID, connectorID int64, workflowIDs []int64, version string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BatchCreateConnectorWorkflowVersion", ctx, appID, connectorID, workflowIDs, version)
ret0, _ := ret[0].(error)
return ret0
}
// BatchCreateConnectorWorkflowVersion indicates an expected call of BatchCreateConnectorWorkflowVersion.
func (mr *MockRepositoryMockRecorder) BatchCreateConnectorWorkflowVersion(ctx, appID, connectorID, workflowIDs, version any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchCreateConnectorWorkflowVersion", reflect.TypeOf((*MockRepository)(nil).BatchCreateConnectorWorkflowVersion), ctx, appID, connectorID, workflowIDs, version)
}
// BatchCreateOnlineConversationTemplate mocks base method.
func (m *MockRepository) BatchCreateOnlineConversationTemplate(ctx context.Context, templates []*entity.ConversationTemplate, version string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BatchCreateOnlineConversationTemplate", ctx, templates, version)
ret0, _ := ret[0].(error)
return ret0
}
// BatchCreateOnlineConversationTemplate indicates an expected call of BatchCreateOnlineConversationTemplate.
func (mr *MockRepositoryMockRecorder) BatchCreateOnlineConversationTemplate(ctx, templates, version any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchCreateOnlineConversationTemplate", reflect.TypeOf((*MockRepository)(nil).BatchCreateOnlineConversationTemplate), ctx, templates, version)
}
// CancelAllRunningNodes mocks base method.
func (m *MockRepository) CancelAllRunningNodes(ctx context.Context, wfExeID int64) error {
m.ctrl.T.Helper()
@ -577,6 +839,36 @@ func (mr *MockRepositoryMockRecorder) CopyWorkflow(ctx, workflowID, policy any)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyWorkflow", reflect.TypeOf((*MockRepository)(nil).CopyWorkflow), ctx, workflowID, policy)
}
// CreateChatFlowRoleConfig mocks base method.
func (m *MockRepository) CreateChatFlowRoleConfig(ctx context.Context, chatFlowRole *entity.ChatFlowRole) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateChatFlowRoleConfig", ctx, chatFlowRole)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateChatFlowRoleConfig indicates an expected call of CreateChatFlowRoleConfig.
func (mr *MockRepositoryMockRecorder) CreateChatFlowRoleConfig(ctx, chatFlowRole any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateChatFlowRoleConfig", reflect.TypeOf((*MockRepository)(nil).CreateChatFlowRoleConfig), ctx, chatFlowRole)
}
// CreateDraftConversationTemplate mocks base method.
func (m *MockRepository) CreateDraftConversationTemplate(ctx context.Context, template *vo.CreateConversationTemplateMeta) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateDraftConversationTemplate", ctx, template)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CreateDraftConversationTemplate indicates an expected call of CreateDraftConversationTemplate.
func (mr *MockRepositoryMockRecorder) CreateDraftConversationTemplate(ctx, template any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateDraftConversationTemplate", reflect.TypeOf((*MockRepository)(nil).CreateDraftConversationTemplate), ctx, template)
}
// CreateMeta mocks base method.
func (m *MockRepository) CreateMeta(ctx context.Context, meta *vo.Meta) (int64, error) {
m.ctrl.T.Helper()
@ -676,6 +968,50 @@ func (mr *MockRepositoryMockRecorder) Delete(ctx, id any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockRepository)(nil).Delete), ctx, id)
}
// DeleteChatFlowRoleConfig mocks base method.
func (m *MockRepository) DeleteChatFlowRoleConfig(ctx context.Context, id, workflowID int64) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteChatFlowRoleConfig", ctx, id, workflowID)
ret0, _ := ret[0].(error)
return ret0
}
// DeleteChatFlowRoleConfig indicates an expected call of DeleteChatFlowRoleConfig.
func (mr *MockRepositoryMockRecorder) DeleteChatFlowRoleConfig(ctx, id, workflowID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteChatFlowRoleConfig", reflect.TypeOf((*MockRepository)(nil).DeleteChatFlowRoleConfig), ctx, id, workflowID)
}
// DeleteDraftConversationTemplate mocks base method.
func (m *MockRepository) DeleteDraftConversationTemplate(ctx context.Context, templateID int64) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteDraftConversationTemplate", ctx, templateID)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DeleteDraftConversationTemplate indicates an expected call of DeleteDraftConversationTemplate.
func (mr *MockRepositoryMockRecorder) DeleteDraftConversationTemplate(ctx, templateID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDraftConversationTemplate", reflect.TypeOf((*MockRepository)(nil).DeleteDraftConversationTemplate), ctx, templateID)
}
// DeleteDynamicConversation mocks base method.
func (m *MockRepository) DeleteDynamicConversation(ctx context.Context, env vo.Env, id int64) (int64, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteDynamicConversation", ctx, env, id)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// DeleteDynamicConversation indicates an expected call of DeleteDynamicConversation.
func (mr *MockRepositoryMockRecorder) DeleteDynamicConversation(ctx, env, id any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteDynamicConversation", reflect.TypeOf((*MockRepository)(nil).DeleteDynamicConversation), ctx, env, id)
}
// DraftV2 mocks base method.
func (m *MockRepository) DraftV2(ctx context.Context, id int64, commitID string) (*vo.DraftInfo, error) {
m.ctrl.T.Helper()
@ -737,6 +1073,38 @@ func (mr *MockRepositoryMockRecorder) Get(ctx, checkPointID any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, checkPointID)
}
// GetChatFlowRoleConfig mocks base method.
func (m *MockRepository) GetChatFlowRoleConfig(ctx context.Context, workflowID int64, version string) (*entity.ChatFlowRole, error, bool) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetChatFlowRoleConfig", ctx, workflowID, version)
ret0, _ := ret[0].(*entity.ChatFlowRole)
ret1, _ := ret[1].(error)
ret2, _ := ret[2].(bool)
return ret0, ret1, ret2
}
// GetChatFlowRoleConfig indicates an expected call of GetChatFlowRoleConfig.
func (mr *MockRepositoryMockRecorder) GetChatFlowRoleConfig(ctx, workflowID, version any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChatFlowRoleConfig", reflect.TypeOf((*MockRepository)(nil).GetChatFlowRoleConfig), ctx, workflowID, version)
}
// GetConversationTemplate mocks base method.
func (m *MockRepository) GetConversationTemplate(ctx context.Context, env vo.Env, policy vo.GetConversationTemplatePolicy) (*entity.ConversationTemplate, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetConversationTemplate", ctx, env, policy)
ret0, _ := ret[0].(*entity.ConversationTemplate)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// GetConversationTemplate indicates an expected call of GetConversationTemplate.
func (mr *MockRepositoryMockRecorder) GetConversationTemplate(ctx, env, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetConversationTemplate", reflect.TypeOf((*MockRepository)(nil).GetConversationTemplate), ctx, env, policy)
}
// GetDraftWorkflowsByAppID mocks base method.
func (m *MockRepository) GetDraftWorkflowsByAppID(ctx context.Context, AppID int64) (map[int64]*vo.DraftInfo, map[int64]string, error) {
m.ctrl.T.Helper()
@ -753,6 +1121,22 @@ func (mr *MockRepositoryMockRecorder) GetDraftWorkflowsByAppID(ctx, AppID any) *
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDraftWorkflowsByAppID", reflect.TypeOf((*MockRepository)(nil).GetDraftWorkflowsByAppID), ctx, AppID)
}
// GetDynamicConversationByName mocks base method.
func (m *MockRepository) GetDynamicConversationByName(ctx context.Context, env vo.Env, appID, connectorID, userID int64, name string) (*entity.DynamicConversation, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetDynamicConversationByName", ctx, env, appID, connectorID, userID, name)
ret0, _ := ret[0].(*entity.DynamicConversation)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// GetDynamicConversationByName indicates an expected call of GetDynamicConversationByName.
func (mr *MockRepositoryMockRecorder) GetDynamicConversationByName(ctx, env, appID, connectorID, userID, name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDynamicConversationByName", reflect.TypeOf((*MockRepository)(nil).GetDynamicConversationByName), ctx, env, appID, connectorID, userID, name)
}
// GetEntity mocks base method.
func (m *MockRepository) GetEntity(ctx context.Context, policy *vo.GetPolicy) (*entity.Workflow, error) {
m.ctrl.T.Helper()
@ -875,6 +1259,74 @@ func (mr *MockRepositoryMockRecorder) GetNodeExecutionsByWfExeID(ctx, wfExeID an
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNodeExecutionsByWfExeID", reflect.TypeOf((*MockRepository)(nil).GetNodeExecutionsByWfExeID), ctx, wfExeID)
}
// GetObjectUrl mocks base method.
func (m *MockRepository) GetObjectUrl(ctx context.Context, objectKey string, opts ...storage.GetOptFn) (string, error) {
m.ctrl.T.Helper()
varargs := []any{ctx, objectKey}
for _, a := range opts {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "GetObjectUrl", varargs...)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetObjectUrl indicates an expected call of GetObjectUrl.
func (mr *MockRepositoryMockRecorder) GetObjectUrl(ctx, objectKey any, opts ...any) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]any{ctx, objectKey}, opts...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetObjectUrl", reflect.TypeOf((*MockRepository)(nil).GetObjectUrl), varargs...)
}
// GetOrCreateDynamicConversation mocks base method.
func (m *MockRepository) GetOrCreateDynamicConversation(ctx context.Context, env vo.Env, idGen workflow0.ConversationIDGenerator, meta *vo.CreateDynamicConversation) (int64, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetOrCreateDynamicConversation", ctx, env, idGen, meta)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// GetOrCreateDynamicConversation indicates an expected call of GetOrCreateDynamicConversation.
func (mr *MockRepositoryMockRecorder) GetOrCreateDynamicConversation(ctx, env, idGen, meta any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrCreateDynamicConversation", reflect.TypeOf((*MockRepository)(nil).GetOrCreateDynamicConversation), ctx, env, idGen, meta)
}
// GetOrCreateStaticConversation mocks base method.
func (m *MockRepository) GetOrCreateStaticConversation(ctx context.Context, env vo.Env, idGen workflow0.ConversationIDGenerator, meta *vo.CreateStaticConversation) (int64, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetOrCreateStaticConversation", ctx, env, idGen, meta)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// GetOrCreateStaticConversation indicates an expected call of GetOrCreateStaticConversation.
func (mr *MockRepositoryMockRecorder) GetOrCreateStaticConversation(ctx, env, idGen, meta any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrCreateStaticConversation", reflect.TypeOf((*MockRepository)(nil).GetOrCreateStaticConversation), ctx, env, idGen, meta)
}
// GetStaticConversationByTemplateID mocks base method.
func (m *MockRepository) GetStaticConversationByTemplateID(ctx context.Context, env vo.Env, userID, connectorID, templateID int64) (*entity.StaticConversation, bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetStaticConversationByTemplateID", ctx, env, userID, connectorID, templateID)
ret0, _ := ret[0].(*entity.StaticConversation)
ret1, _ := ret[1].(bool)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// GetStaticConversationByTemplateID indicates an expected call of GetStaticConversationByTemplateID.
func (mr *MockRepositoryMockRecorder) GetStaticConversationByTemplateID(ctx, env, userID, connectorID, templateID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStaticConversationByTemplateID", reflect.TypeOf((*MockRepository)(nil).GetStaticConversationByTemplateID), ctx, env, userID, connectorID, templateID)
}
// GetTestRunLatestExeID mocks base method.
func (m *MockRepository) GetTestRunLatestExeID(ctx context.Context, wfID, uID int64) (int64, error) {
m.ctrl.T.Helper()
@ -936,6 +1388,51 @@ func (mr *MockRepositoryMockRecorder) GetWorkflowExecution(ctx, id any) *gomock.
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowExecution", reflect.TypeOf((*MockRepository)(nil).GetWorkflowExecution), ctx, id)
}
// IsApplicationConnectorWorkflowVersion mocks base method.
func (m *MockRepository) IsApplicationConnectorWorkflowVersion(ctx context.Context, connectorID, workflowID int64, version string) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsApplicationConnectorWorkflowVersion", ctx, connectorID, workflowID, version)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// IsApplicationConnectorWorkflowVersion indicates an expected call of IsApplicationConnectorWorkflowVersion.
func (mr *MockRepositoryMockRecorder) IsApplicationConnectorWorkflowVersion(ctx, connectorID, workflowID, version any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsApplicationConnectorWorkflowVersion", reflect.TypeOf((*MockRepository)(nil).IsApplicationConnectorWorkflowVersion), ctx, connectorID, workflowID, version)
}
// ListConversationTemplate mocks base method.
func (m *MockRepository) ListConversationTemplate(ctx context.Context, env vo.Env, policy *vo.ListConversationTemplatePolicy) ([]*entity.ConversationTemplate, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListConversationTemplate", ctx, env, policy)
ret0, _ := ret[0].([]*entity.ConversationTemplate)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListConversationTemplate indicates an expected call of ListConversationTemplate.
func (mr *MockRepositoryMockRecorder) ListConversationTemplate(ctx, env, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListConversationTemplate", reflect.TypeOf((*MockRepository)(nil).ListConversationTemplate), ctx, env, policy)
}
// ListDynamicConversation mocks base method.
func (m *MockRepository) ListDynamicConversation(ctx context.Context, env vo.Env, policy *vo.ListConversationPolicy) ([]*entity.DynamicConversation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListDynamicConversation", ctx, env, policy)
ret0, _ := ret[0].([]*entity.DynamicConversation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ListDynamicConversation indicates an expected call of ListDynamicConversation.
func (mr *MockRepositoryMockRecorder) ListDynamicConversation(ctx, env, policy any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListDynamicConversation", reflect.TypeOf((*MockRepository)(nil).ListDynamicConversation), ctx, env, policy)
}
// ListInterruptEvents mocks base method.
func (m *MockRepository) ListInterruptEvents(ctx context.Context, wfExeID int64) ([]*entity.InterruptEvent, error) {
m.ctrl.T.Helper()
@ -1028,6 +1525,21 @@ func (mr *MockRepositoryMockRecorder) MGetReferences(ctx, policy any) *gomock.Ca
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MGetReferences", reflect.TypeOf((*MockRepository)(nil).MGetReferences), ctx, policy)
}
// MGetStaticConversation mocks base method.
func (m *MockRepository) MGetStaticConversation(ctx context.Context, env vo.Env, userID, connectorID int64, templateIDs []int64) ([]*entity.StaticConversation, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "MGetStaticConversation", ctx, env, userID, connectorID, templateIDs)
ret0, _ := ret[0].([]*entity.StaticConversation)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// MGetStaticConversation indicates an expected call of MGetStaticConversation.
func (mr *MockRepositoryMockRecorder) MGetStaticConversation(ctx, env, userID, connectorID, templateIDs any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MGetStaticConversation", reflect.TypeOf((*MockRepository)(nil).MGetStaticConversation), ctx, env, userID, connectorID, templateIDs)
}
// PopFirstInterruptEvent mocks base method.
func (m *MockRepository) PopFirstInterruptEvent(ctx context.Context, wfExeID int64) (*entity.InterruptEvent, bool, error) {
m.ctrl.T.Helper()
@ -1130,6 +1642,48 @@ func (mr *MockRepositoryMockRecorder) TryLockWorkflowExecution(ctx, wfExeID, res
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryLockWorkflowExecution", reflect.TypeOf((*MockRepository)(nil).TryLockWorkflowExecution), ctx, wfExeID, resumingEventID)
}
// UpdateChatFlowRoleConfig mocks base method.
func (m *MockRepository) UpdateChatFlowRoleConfig(ctx context.Context, workflowID int64, chatFlowRole *vo.ChatFlowRoleUpdate) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateChatFlowRoleConfig", ctx, workflowID, chatFlowRole)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateChatFlowRoleConfig indicates an expected call of UpdateChatFlowRoleConfig.
func (mr *MockRepositoryMockRecorder) UpdateChatFlowRoleConfig(ctx, workflowID, chatFlowRole any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateChatFlowRoleConfig", reflect.TypeOf((*MockRepository)(nil).UpdateChatFlowRoleConfig), ctx, workflowID, chatFlowRole)
}
// UpdateDraftConversationTemplateName mocks base method.
func (m *MockRepository) UpdateDraftConversationTemplateName(ctx context.Context, templateID int64, name string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateDraftConversationTemplateName", ctx, templateID, name)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateDraftConversationTemplateName indicates an expected call of UpdateDraftConversationTemplateName.
func (mr *MockRepositoryMockRecorder) UpdateDraftConversationTemplateName(ctx, templateID, name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDraftConversationTemplateName", reflect.TypeOf((*MockRepository)(nil).UpdateDraftConversationTemplateName), ctx, templateID, name)
}
// UpdateDynamicConversationNameByID mocks base method.
func (m *MockRepository) UpdateDynamicConversationNameByID(ctx context.Context, env vo.Env, templateID int64, name string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateDynamicConversationNameByID", ctx, env, templateID, name)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateDynamicConversationNameByID indicates an expected call of UpdateDynamicConversationNameByID.
func (mr *MockRepositoryMockRecorder) UpdateDynamicConversationNameByID(ctx, env, templateID, name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDynamicConversationNameByID", reflect.TypeOf((*MockRepository)(nil).UpdateDynamicConversationNameByID), ctx, env, templateID, name)
}
// UpdateFirstInterruptEvent mocks base method.
func (m *MockRepository) UpdateFirstInterruptEvent(ctx context.Context, wfExeID int64, event *entity.InterruptEvent) error {
m.ctrl.T.Helper()
@ -1172,6 +1726,20 @@ func (mr *MockRepositoryMockRecorder) UpdateNodeExecution(ctx, execution any) *g
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateNodeExecution", reflect.TypeOf((*MockRepository)(nil).UpdateNodeExecution), ctx, execution)
}
// UpdateNodeExecutionStreaming mocks base method.
func (m *MockRepository) UpdateNodeExecutionStreaming(ctx context.Context, execution *entity.NodeExecution) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateNodeExecutionStreaming", ctx, execution)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateNodeExecutionStreaming indicates an expected call of UpdateNodeExecutionStreaming.
func (mr *MockRepositoryMockRecorder) UpdateNodeExecutionStreaming(ctx, execution any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateNodeExecutionStreaming", reflect.TypeOf((*MockRepository)(nil).UpdateNodeExecutionStreaming), ctx, execution)
}
// UpdateWorkflowDraftTestRunSuccess mocks base method.
func (m *MockRepository) UpdateWorkflowDraftTestRunSuccess(ctx context.Context, id int64) error {
m.ctrl.T.Helper()

View File

@ -32,3 +32,15 @@ func TransformKey[K1, K2 comparable, V any](m map[K1]V, f func(K1) K2) map[K2]V
}
return n
}
func TransformKeyWithErrorCheck[K1, K2 comparable, V any](m map[K1]V, f func(K1) (K2, error)) (map[K2]V, error) {
n := make(map[K2]V, len(m))
for k1, v := range m {
k2, err := f(k1)
if err != nil {
return nil, err
}
n[k2] = v
}
return n, nil
}

View File

@ -154,6 +154,17 @@ var path2Table2Columns2Model = map[string]map[string]map[string]any{
"node_execution": {},
"workflow_snapshot": {},
"connector_workflow_version": {},
"chat_flow_role_config": {},
"app_conversation_template_draft": {},
"app_conversation_template_online": {},
"app_static_conversation_draft": {},
"app_static_conversation_online": {},
"app_dynamic_conversation_draft": {},
"app_dynamic_conversation_online": {},
},
"domain/openauth/openapiauth/internal/dal/query": {

View File

@ -22,25 +22,31 @@ import (
)
const (
ErrWorkflowNotPublished = 720702011
ErrMissingRequiredParam = 720702002
ErrInterruptNotSupported = 720702078
ErrInvalidParameter = 720702001
ErrArrIndexOutOfRange = 720712014
ErrWorkflowExecuteFail = 720701013
ErrCodeExecuteFail = 305000002
ErrQuestionOptionsEmpty = 720712049
ErrNodeOutputParseFail = 720712023
ErrWorkflowTimeout = 720702085
ErrWorkflowNotFound = 720702004
ErrSerializationDeserializationFail = 720701011
ErrInternalBadRequest = 720701007
ErrSchemaConversionFail = 720702089
ErrWorkflowCompileFail = 720701003
ErrPluginAPIErr = 720701004
ErrWorkflowNotPublished = 720702011
ErrMissingRequiredParam = 720702002
ErrInterruptNotSupported = 720702078
ErrInvalidParameter = 720702001
ErrArrIndexOutOfRange = 720712014
ErrWorkflowExecuteFail = 720701013
ErrCodeExecuteFail = 305000002
ErrQuestionOptionsEmpty = 720712049
ErrNodeOutputParseFail = 720712023
ErrWorkflowTimeout = 720702085
ErrWorkflowNotFound = 720702004
ErrSerializationDeserializationFail = 720701011
ErrInternalBadRequest = 720701007
ErrSchemaConversionFail = 720702089
ErrWorkflowCompileFail = 720701003
ErrPluginAPIErr = 720701004
ErrConversationNameIsDuplicated = 720702200
ErrConversationOfAppNotFound = 720702201
ErrConversationNodeInvalidOperation = 720702250
ErrOnlyDefaultConversationAllowInAgentScenario = 720712033
)
const (
ErrChatFlowRoleOperationFail = 777777780
ErrConversationOfAppOperationFail = 777777779
ErrWorkflowSpecifiedVersionNotFound = 777777778
ErrWorkflowCanceledByUser = 777777777
ErrNodeTimeout = 777777776
@ -57,6 +63,7 @@ const (
ErrAuthorizationRequired = 777777765
ErrVariablesAPIFail = 777777764
ErrInputFieldMissing = 777777763
ErrConversationNodesNotAvailable = 702093204
)
// stability problems
@ -122,6 +129,12 @@ func init() {
code.WithAffectStability(false),
)
code.Register(
ErrChatFlowRoleOperationFail,
"ChatFlowRole operation failure: {cause}",
code.WithAffectStability(false),
)
code.Register(
ErrCodeExecuteFail,
"Function execution failed, please check the code of the function. Detail: {detail}",
@ -146,6 +159,12 @@ func init() {
code.WithAffectStability(false),
)
code.Register(
ErrConversationOfAppOperationFail,
"Conversation management operation failure: {cause}",
code.WithAffectStability(false),
)
code.Register(
ErrNodeTimeout,
"node timeout",
@ -192,6 +211,12 @@ func init() {
code.WithAffectStability(false),
)
code.Register(
ErrConversationOfAppNotFound,
"conversation not found, please check if the application conversation exists",
code.WithAffectStability(false),
)
code.Register(
ErrSerializationDeserializationFail,
"data serialization/deserialization fail, please contact support team",
@ -240,6 +265,12 @@ func init() {
code.WithAffectStability(false),
)
code.Register(
ErrConversationNameIsDuplicated,
"conversation name {name} is duplicated",
code.WithAffectStability(false),
)
code.Register(
ErrPluginIDNotFound,
"plugin {id} not found",
@ -275,6 +306,25 @@ func init() {
"input field {name} not found",
code.WithAffectStability(false),
)
code.Register(
ErrConversationNodesNotAvailable,
"Conversation nodes are unavailable in agent scenarios and require an app binding.",
code.WithAffectStability(false),
)
code.Register(
ErrConversationNodeInvalidOperation,
"Only conversation created through nodes are allowed to be modified or deleted.",
code.WithAffectStability(false),
)
code.Register(
ErrOnlyDefaultConversationAllowInAgentScenario,
"Only default conversation allow in agent scenario",
code.WithAffectStability(false),
)
}
var errnoMap = map[int]int{

View File

@ -0,0 +1,100 @@
-- Create "app_conversation_template_draft" table
CREATE TABLE `opencoze`.`app_conversation_template_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`space_id` bigint unsigned NOT NULL COMMENT "space id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`updated_at` bigint unsigned NULL COMMENT "update time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_space_id_app_id_template_id` (`space_id`, `app_id`, `template_id`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_conversation_template_online" table
CREATE TABLE `opencoze`.`app_conversation_template_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`space_id` bigint unsigned NOT NULL COMMENT "space id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`version` varchar(256) NOT NULL COMMENT "version name",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_space_id_app_id_template_id_version` (`space_id`, `app_id`, `template_id`, `version`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_dynamic_conversation_draft" table
CREATE TABLE `opencoze`.`app_dynamic_conversation_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`),
INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_dynamic_conversation_online" table
CREATE TABLE `opencoze`.`app_dynamic_conversation_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`),
INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_static_conversation_draft" table
CREATE TABLE `opencoze`.`app_static_conversation_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_static_conversation_online" table
CREATE TABLE `opencoze`.`app_static_conversation_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "chat_flow_role_config" table
CREATE TABLE `opencoze`.`chat_flow_role_config` (
`id` bigint unsigned NOT NULL COMMENT "id",
`workflow_id` bigint unsigned NOT NULL COMMENT "workflow id",
`connector_id` bigint unsigned NULL COMMENT "connector id",
`name` varchar(256) NOT NULL COMMENT "role name",
`description` mediumtext NOT NULL COMMENT "role description",
`version` varchar(256) NOT NULL COMMENT "version",
`avatar` varchar(256) NOT NULL COMMENT "avatar uri",
`background_image_info` mediumtext NOT NULL COMMENT "background image information, object structure",
`onboarding_info` mediumtext NOT NULL COMMENT "intro information, object structure",
`suggest_reply_info` mediumtext NOT NULL COMMENT "user suggestions, object structure",
`audio_config` mediumtext NOT NULL COMMENT "agent audio config, object structure",
`user_input_config` varchar(256) NOT NULL COMMENT "user input config, object structure",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`updated_at` bigint unsigned NULL COMMENT "update time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_version` (`connector_id`, `version`),
INDEX `idx_workflow_id_version` (`workflow_id`, `version`)
) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -1,4 +1,4 @@
h1:6MVlbZNblz3Fs7fkT8xJhLsjCBfs8+PpnALEU+5WANo=
h1:mjD5wFUroybNtMu0UfsDLG84zv7nCz8ZKQNlBjl+zYc=
20250703095335_initial.sql h1:/joaeUTMhXqAEc0KwsSve5+bYM0qPOp+9OizJtsRc+U=
20250703115304_update.sql h1:cbYo6Q6Lh96hB4hu5KW2Nn/Mr0VDpg7a1WPgpIb1SOc=
20250704040445_update.sql h1:QWmoPY//oQ+GFZwET9w/oAWa8mM0KVaD5G8Yiu9bMqY=
@ -6,3 +6,4 @@ h1:6MVlbZNblz3Fs7fkT8xJhLsjCBfs8+PpnALEU+5WANo=
20250710100212_update.sql h1:mN/3iKQDoIw2BTkMwWp3I/qOAcVGrQJ5tOJ0OqH4ZWU=
20250711034533_update.sql h1:EWeK//5urS9hJIRCeD3lwQYWNH9AIKEWG9pMLdw7KPc=
20250717125913_update.sql h1:WtPR99RlWZn0rXZsB19qp1hq0FwO5qmFhcTcV6EnFYs=
20250718104121_update.sql h1:m03VvzsDIemdZQO9z0eq7bogu3panmdT0f3kAhqHDHA=

View File

@ -335,6 +335,122 @@ table "app_connector_release_ref" {
columns = [column.record_id, column.connector_id]
}
}
table "app_conversation_template_draft" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "app_id" {
null = false
type = bigint
unsigned = true
comment = "app id"
}
column "space_id" {
null = false
type = bigint
unsigned = true
comment = "space id"
}
column "name" {
null = false
type = varchar(256)
comment = "conversation name"
}
column "template_id" {
null = false
type = bigint
unsigned = true
comment = "template id"
}
column "creator_id" {
null = false
type = bigint
unsigned = true
comment = "creator id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
column "updated_at" {
null = true
type = bigint
unsigned = true
comment = "update time in millisecond"
}
column "deleted_at" {
null = true
type = datetime(3)
comment = "delete time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_space_id_app_id_template_id" {
columns = [column.space_id, column.app_id, column.template_id]
}
}
table "app_conversation_template_online" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "app_id" {
null = false
type = bigint
unsigned = true
comment = "app id"
}
column "space_id" {
null = false
type = bigint
unsigned = true
comment = "space id"
}
column "name" {
null = false
type = varchar(256)
comment = "conversation name"
}
column "template_id" {
null = false
type = bigint
unsigned = true
comment = "template id"
}
column "version" {
null = false
type = varchar(256)
comment = "version name"
}
column "creator_id" {
null = false
type = bigint
unsigned = true
comment = "creator id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_space_id_app_id_template_id_version" {
columns = [column.space_id, column.app_id, column.template_id, column.version]
}
}
table "app_draft" {
schema = schema.opencoze
comment = "Draft Application"
@ -399,6 +515,122 @@ table "app_draft" {
columns = [column.id]
}
}
table "app_dynamic_conversation_draft" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "app_id" {
null = false
type = bigint
unsigned = true
comment = "app id"
}
column "name" {
null = false
type = varchar(256)
comment = "conversation name"
}
column "user_id" {
null = false
type = bigint
unsigned = true
comment = "user id"
}
column "connector_id" {
null = false
type = bigint
unsigned = true
comment = "connector id"
}
column "conversation_id" {
null = false
type = bigint
unsigned = true
comment = "conversation id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
column "deleted_at" {
null = true
type = datetime(3)
comment = "delete time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_app_id_connector_id_user_id" {
columns = [column.app_id, column.connector_id, column.user_id]
}
index "idx_connector_id_user_id_name" {
columns = [column.connector_id, column.user_id, column.name]
}
}
table "app_dynamic_conversation_online" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "app_id" {
null = false
type = bigint
unsigned = true
comment = "app id"
}
column "name" {
null = false
type = varchar(256)
comment = "conversation name"
}
column "user_id" {
null = false
type = bigint
unsigned = true
comment = "user id"
}
column "connector_id" {
null = false
type = bigint
unsigned = true
comment = "connector id"
}
column "conversation_id" {
null = false
type = bigint
unsigned = true
comment = "conversation id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
column "deleted_at" {
null = true
type = datetime(3)
comment = "delete time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_app_id_connector_id_user_id" {
columns = [column.app_id, column.connector_id, column.user_id]
}
index "idx_connector_id_user_id_name" {
columns = [column.connector_id, column.user_id, column.name]
}
}
table "app_release_record" {
schema = schema.opencoze
comment = "Application Release Record"
@ -506,6 +738,199 @@ table "app_release_record" {
columns = [column.app_id, column.version]
}
}
table "app_static_conversation_draft" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "template_id" {
null = false
type = bigint
unsigned = true
comment = "template id"
}
column "user_id" {
null = false
type = bigint
unsigned = true
comment = "user id"
}
column "connector_id" {
null = false
type = bigint
unsigned = true
comment = "connector id"
}
column "conversation_id" {
null = false
type = bigint
unsigned = true
comment = "conversation id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
column "deleted_at" {
null = true
type = datetime(3)
comment = "delete time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_connector_id_user_id_template_id" {
columns = [column.connector_id, column.user_id, column.template_id]
}
}
table "app_static_conversation_online" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "template_id" {
null = false
type = bigint
unsigned = true
comment = "template id"
}
column "user_id" {
null = false
type = bigint
unsigned = true
comment = "user id"
}
column "connector_id" {
null = false
type = bigint
unsigned = true
comment = "connector id"
}
column "conversation_id" {
null = false
type = bigint
unsigned = true
comment = "conversation id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_connector_id_user_id_template_id" {
columns = [column.connector_id, column.user_id, column.template_id]
}
}
table "chat_flow_role_config" {
schema = schema.opencoze
column "id" {
null = false
type = bigint
unsigned = true
comment = "id"
}
column "workflow_id" {
null = false
type = bigint
unsigned = true
comment = "workflow id"
}
column "connector_id" {
null = true
type = bigint
unsigned = true
comment = "connector id"
}
column "name" {
null = false
type = varchar(256)
comment = "role name"
}
column "description" {
null = false
type = mediumtext
comment = "role description"
}
column "version" {
null = false
type = varchar(256)
comment = "version"
}
column "avatar" {
null = false
type = varchar(256)
comment = "avatar uri"
}
column "background_image_info" {
null = false
type = mediumtext
comment = "background image information, object structure"
}
column "onboarding_info" {
null = false
type = mediumtext
comment = "intro information, object structure"
}
column "suggest_reply_info" {
null = false
type = mediumtext
comment = "user suggestions, object structure"
}
column "audio_config" {
null = false
type = mediumtext
comment = "agent audio config, object structure"
}
column "user_input_config" {
null = false
type = varchar(256)
comment = "user input config, object structure"
}
column "creator_id" {
null = false
type = bigint
unsigned = true
comment = "creator id"
}
column "created_at" {
null = false
type = bigint
unsigned = true
comment = "create time in millisecond"
}
column "updated_at" {
null = true
type = bigint
unsigned = true
comment = "update time in millisecond"
}
column "deleted_at" {
null = true
type = datetime(3)
comment = "delete time in millisecond"
}
primary_key {
columns = [column.id]
}
index "idx_connector_id_version" {
columns = [column.connector_id, column.version]
}
index "idx_workflow_id_version" {
columns = [column.workflow_id, column.version]
}
}
table "connector_workflow_version" {
schema = schema.opencoze
column "id" {

View File

@ -72,6 +72,33 @@ CREATE TABLE IF NOT EXISTS `app_connector_release_ref` (
PRIMARY KEY (`id`),
UNIQUE INDEX `uniq_record_connector` (`record_id`, `connector_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "Connector Release Record Reference";
-- Create "app_conversation_template_draft" table
CREATE TABLE IF NOT EXISTS `app_conversation_template_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`space_id` bigint unsigned NOT NULL COMMENT "space id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`updated_at` bigint unsigned NULL COMMENT "update time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_space_id_app_id_template_id` (`space_id`, `app_id`, `template_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_conversation_template_online" table
CREATE TABLE IF NOT EXISTS `app_conversation_template_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`space_id` bigint unsigned NOT NULL COMMENT "space id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`version` varchar(256) NOT NULL COMMENT "version name",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_space_id_app_id_template_id_version` (`space_id`, `app_id`, `template_id`, `version`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_draft" table
CREATE TABLE IF NOT EXISTS `app_draft` (
`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT "APP ID",
@ -85,6 +112,34 @@ CREATE TABLE IF NOT EXISTS `app_draft` (
`deleted_at` datetime NULL COMMENT "Delete Time",
PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "Draft Application";
-- Create "app_dynamic_conversation_draft" table
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`),
INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_dynamic_conversation_online" table
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`),
INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_release_record" table
CREATE TABLE IF NOT EXISTS `app_release_record` (
`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT "Publish Record ID",
@ -106,6 +161,51 @@ CREATE TABLE IF NOT EXISTS `app_release_record` (
INDEX `idx_app_publish_at` (`app_id`, `publish_at`),
UNIQUE INDEX `uniq_idx_app_version_connector` (`app_id`, `version`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "Application Release Record";
-- Create "app_static_conversation_draft" table
CREATE TABLE IF NOT EXISTS `app_static_conversation_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_static_conversation_online" table
CREATE TABLE IF NOT EXISTS `app_static_conversation_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "chat_flow_role_config" table
CREATE TABLE IF NOT EXISTS `chat_flow_role_config` (
`id` bigint unsigned NOT NULL COMMENT "id",
`workflow_id` bigint unsigned NOT NULL COMMENT "workflow id",
`connector_id` bigint unsigned NULL COMMENT "connector id",
`name` varchar(256) NOT NULL COMMENT "role name",
`description` mediumtext NOT NULL COMMENT "role description",
`version` varchar(256) NOT NULL COMMENT "version",
`avatar` varchar(256) NOT NULL COMMENT "avatar uri",
`background_image_info` mediumtext NOT NULL COMMENT "background image information, object structure",
`onboarding_info` mediumtext NOT NULL COMMENT "intro information, object structure",
`suggest_reply_info` mediumtext NOT NULL COMMENT "user suggestions, object structure",
`audio_config` mediumtext NOT NULL COMMENT "agent audio config, object structure",
`user_input_config` varchar(256) NOT NULL COMMENT "user input config, object structure",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`updated_at` bigint unsigned NULL COMMENT "update time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_version` (`connector_id`, `version`),
INDEX `idx_workflow_id_version` (`workflow_id`, `version`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "connector_workflow_version" table
CREATE TABLE IF NOT EXISTS `connector_workflow_version` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "id",

View File

@ -72,6 +72,33 @@ CREATE TABLE IF NOT EXISTS `app_connector_release_ref` (
PRIMARY KEY (`id`),
UNIQUE INDEX `uniq_record_connector` (`record_id`, `connector_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "Connector Release Record Reference";
-- Create "app_conversation_template_draft" table
CREATE TABLE IF NOT EXISTS `app_conversation_template_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`space_id` bigint unsigned NOT NULL COMMENT "space id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`updated_at` bigint unsigned NULL COMMENT "update time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_space_id_app_id_template_id` (`space_id`, `app_id`, `template_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_conversation_template_online" table
CREATE TABLE IF NOT EXISTS `app_conversation_template_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`space_id` bigint unsigned NOT NULL COMMENT "space id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`version` varchar(256) NOT NULL COMMENT "version name",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_space_id_app_id_template_id_version` (`space_id`, `app_id`, `template_id`, `version`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_draft" table
CREATE TABLE IF NOT EXISTS `app_draft` (
`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT "APP ID",
@ -85,6 +112,34 @@ CREATE TABLE IF NOT EXISTS `app_draft` (
`deleted_at` datetime NULL COMMENT "Delete Time",
PRIMARY KEY (`id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "Draft Application";
-- Create "app_dynamic_conversation_draft" table
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`),
INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_dynamic_conversation_online" table
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`app_id` bigint unsigned NOT NULL COMMENT "app id",
`name` varchar(256) NOT NULL COMMENT "conversation name",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`),
INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_release_record" table
CREATE TABLE IF NOT EXISTS `app_release_record` (
`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT "Publish Record ID",
@ -106,6 +161,51 @@ CREATE TABLE IF NOT EXISTS `app_release_record` (
INDEX `idx_app_publish_at` (`app_id`, `publish_at`),
UNIQUE INDEX `uniq_idx_app_version_connector` (`app_id`, `version`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT "Application Release Record";
-- Create "app_static_conversation_draft" table
CREATE TABLE IF NOT EXISTS `app_static_conversation_draft` (
`id` bigint unsigned NOT NULL COMMENT "id",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "app_static_conversation_online" table
CREATE TABLE IF NOT EXISTS `app_static_conversation_online` (
`id` bigint unsigned NOT NULL COMMENT "id",
`template_id` bigint unsigned NOT NULL COMMENT "template id",
`user_id` bigint unsigned NOT NULL COMMENT "user id",
`connector_id` bigint unsigned NOT NULL COMMENT "connector id",
`conversation_id` bigint unsigned NOT NULL COMMENT "conversation id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "chat_flow_role_config" table
CREATE TABLE IF NOT EXISTS `chat_flow_role_config` (
`id` bigint unsigned NOT NULL COMMENT "id",
`workflow_id` bigint unsigned NOT NULL COMMENT "workflow id",
`connector_id` bigint unsigned NULL COMMENT "connector id",
`name` varchar(256) NOT NULL COMMENT "role name",
`description` mediumtext NOT NULL COMMENT "role description",
`version` varchar(256) NOT NULL COMMENT "version",
`avatar` varchar(256) NOT NULL COMMENT "avatar uri",
`background_image_info` mediumtext NOT NULL COMMENT "background image information, object structure",
`onboarding_info` mediumtext NOT NULL COMMENT "intro information, object structure",
`suggest_reply_info` mediumtext NOT NULL COMMENT "user suggestions, object structure",
`audio_config` mediumtext NOT NULL COMMENT "agent audio config, object structure",
`user_input_config` varchar(256) NOT NULL COMMENT "user input config, object structure",
`creator_id` bigint unsigned NOT NULL COMMENT "creator id",
`created_at` bigint unsigned NOT NULL COMMENT "create time in millisecond",
`updated_at` bigint unsigned NULL COMMENT "update time in millisecond",
`deleted_at` datetime(3) NULL COMMENT "delete time in millisecond",
PRIMARY KEY (`id`),
INDEX `idx_connector_id_version` (`connector_id`, `version`),
INDEX `idx_workflow_id_version` (`workflow_id`, `version`)
) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create "connector_workflow_version" table
CREATE TABLE IF NOT EXISTS `connector_workflow_version` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT "id",

View File

@ -137,7 +137,10 @@ enum NodeType{
Input = 30,
Batch = 28,
Continue = 29,
MessageList = 37,
AssignVariable = 40,
ConversationList = 53,
CreateMessage = 55,
JsonSerialization = 58,
JsonDeserialization = 59,
DatasetDelete = 60,
@ -172,11 +175,14 @@ enum NodeTemplateType{
Input = 30,
Batch = 28,
Continue = 29,
MessageList = 37,
AssignVariable = 40,
DatabaseInsert = 41,
DatabaseUpdate = 42,
DatabasesELECT = 43,
DatabaseDelete = 44,
ConversationList = 53,
CreateMessage = 55,
JsonSerialization = 58,
JsonDeserialization = 59,
DatasetDelete = 60,
@ -1780,45 +1786,46 @@ struct BackgroundImageDetail {
}
struct BackgroundImageInfo {
1: optional BackgroundImageDetail WebBackgroundImage (agw.key="web_background_image",go.tag = "json:\"web_background_image\"") , // web端背景图
2: optional BackgroundImageDetail MobileBackgroundImage (agw.key="mobile_background_image"go.tag = "json:\"mobile_background_image\"") , // 移动端背景图
1: optional BackgroundImageDetail WebBackgroundImage (agw.key="web_background_image", go.tag = "json:\"web_background_image\"") , // web端背景图
2: optional BackgroundImageDetail MobileBackgroundImage (agw.key="mobile_background_image", go.tag = "json:\"mobile_background_image\"") , // 移动端背景图
}
struct AvatarConfig{
1: string ImageUri (agw.key="image_uri", go.tag = "json:\"image_uri\"")
2: string ImageUrl (agw.key="image_url",go.tag = "json:\"image_url\"")
2: string ImageUrl (agw.key="image_url", go.tag = "json:\"image_url\"")
}
struct ChatFlowRole{
1: string ID (agw.key = "id",go.tag = "json:\"id\"")
2: string WorkflowID (agw.key = "workflow_id",go.tag = "json:\"workflow_id\"")
3: string ConnectorID (agw.key="connector_id",go.tag = "json:\"connector_id\"") // 渠道ID
4: optional AvatarConfig Avatar (agw.key="avatar",go.tag = "json:\"avatar\"") // 角色头像
5: optional string Description (agw.key="description",go.tag = "json:\"description\"")// 角色描述
6: optional OnboardingInfo OnboardingInfo (agw.key="onboarding_info",go.tag = "json:\"onboarding_info\"")// 开场白
7: optional string Name (agw.key="name",go.tag = "json:\"name\"") // 角色名称
8: optional SuggestReplyInfo SuggestReplyInfo (agw.key="suggest_reply_info",go.tag = "json:\"suggest_reply_info\"")// 用户问题建议
9: optional BackgroundImageInfo BackgroundImageInfo (agw.key="background_image_info",go.tag = "json:\"background_image_info\"")// 背景图
10: optional AudioConfig AudioConfig (agw.key="audio_config",go.tag = "json:\"audio_config\"")// 语音配置:音色、电话等
11: optional UserInputConfig UserInputConfig (agw.key="user_input_config",go.tag = "json:\"user_input_config\"") // 用户输入方式
12: optional string ProjectVersion (agw.key="project_version",go.tag = "json:\"project_version\"") // 项目版本
1: string ID (agw.key = "id", go.tag = "json:\"id\"")
2: string WorkflowID (agw.key = "workflow_id", go.tag = "json:\"workflow_id\"")
3: string ConnectorID (agw.key="connector_id", go.tag = "json:\"connector_id\"") // 渠道ID
4: optional AvatarConfig Avatar (agw.key="avatar", go.tag = "json:\"avatar\"") // 角色头像
5: optional string Description (agw.key="description", go.tag = "json:\"description\"")// 角色描述
6: optional OnboardingInfo OnboardingInfo (agw.key="onboarding_info", go.tag = "json:\"onboarding_info\"")// 开场白
7: optional string Name (agw.key="name", go.tag = "json:\"name\"") // 角色名称
8: optional SuggestReplyInfo SuggestReplyInfo (agw.key="suggest_reply_info", go.tag = "json:\"suggest_reply_info\"")// 用户问题建议
9: optional BackgroundImageInfo BackgroundImageInfo (agw.key="background_image_info", go.tag = "json:\"background_image_info\"")// 背景图
10: optional AudioConfig AudioConfig (agw.key="audio_config", go.tag = "json:\"audio_config\"")// 语音配置:音色、电话等
11: optional UserInputConfig UserInputConfig (agw.key="user_input_config", go.tag = "json:\"user_input_config\"") // 用户输入方式
12: optional string ProjectVersion (agw.key="project_version", go.tag = "json:\"project_version\"") // 项目版本
}
struct CreateChatFlowRoleRequest{
1: ChatFlowRole ChatFlowRole(agw.key= "chat_flow_role",go.tag="json:\"chat_flow_role\"")
1: ChatFlowRole ChatFlowRole(agw.key= "chat_flow_role", go.tag="json:\"chat_flow_role\"", api.query = "chat_flow_role")
255: optional base.Base Base
}
struct CreateChatFlowRoleResponse{
1: string ID // 数据库中ID
1: string ID (agw.key = "id", go.tag = "json:\"id\"", api.query = "id") // 数据库中ID
253: required i64 code
254: required string msg
255: required base.BaseResp BaseResp
}
struct DeleteChatFlowRoleRequest{
1: string WorkflowID
2: string ConnectorID
4: string ID // 数据库中ID
1: string WorkflowID (agw.key = "workflow_id", go.tag = "json:\"workflow_id\"", api.query = "workflow_id")
2: string ConnectorID (agw.key = "connector_id", go.tag = "json:\"connector_id\"", api.query = "connector_id")
4: string ID (agw.key = "id", go.tag = "json:\"id\"", api.query = "id") // 数据库中ID
255: optional base.Base Base
}
@ -1829,18 +1836,20 @@ struct DeleteChatFlowRoleResponse{
}
struct GetChatFlowRoleRequest{
1: string WorkflowID (agw.key = "workflow_id")
2: string ConnectorID (agw.key = "connector_id")
3: bool IsDebug (agw.key = "is_debug")
1: string WorkflowID (agw.key = "workflow_id", go.tag = "json:\"workflow_id\"", api.query = "workflow_id")
2: string ConnectorID (agw.key = "connector_id", go.tag = "json:\"connector_id\"", api.query = "connector_id")
3: bool IsDebug (agw.key = "is_debug", go.tag = "json:\"is_debug\"", api.query = "is_debug")
// 4: optional string AppID (api.query = "app_id")
5: optional map<string,string> Ext (api.query = "ext")
255: optional base.Base Base
255: optional base.Base Base (go.tag = "json:\"base\"", api.query = "base")
}
struct GetChatFlowRoleResponse{
1 : optional ChatFlowRole Role (agw.key = "role")
1: required i64 code
2: required string msg
3: optional ChatFlowRole Role (agw.key = "role", go.tag = "json:\"role\"", api.query = "role")
255: required base.BaseResp BaseResp
255: required base.BaseResp BaseResp (go.tag = "json:\"base_resp\"", api.query = "base_resp")
}
enum NodePanelSearchType {

View File

@ -12,4 +12,5 @@ enum Scene{
PromptOptimize = 7, //prompt优化
GenerateAgentInfo = 8 // createbot的nl2bot功能
SceneOpenApi = 9, //openapi
}
SceneWorkflow = 50 , // 工作流
}