Compare commits
1 Commits
feat/chatf
...
feat/knowl
| Author | SHA1 | Date | |
|---|---|---|---|
| 64efcef3ea |
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -150,7 +150,6 @@
|
||||
/frontend/packages/studio/publish-manage-hooks/ @duwenhan2byte @evan-crash
|
||||
/frontend/packages/foundation/layout/ @evan-crash @duwenhan2byte
|
||||
/frontend/packages/studio/open-platform/open-auth/ @evan-crash @DingGao-Devin
|
||||
/frontend/packages/studio/open-platform/open-chat/ @tomasyu985 @DingGao-Devin
|
||||
/frontend/packages/agent-ide/entry-adapter/ @Hezi-crypto @duwenhan2byte @catee @evan-crash @haozhenfei
|
||||
/frontend/packages/agent-ide/entry/ @soonco @duwenhan2byte @catee @evan-crash
|
||||
/frontend/packages/agent-ide/bot-config-area-adapter/ @haozhenfei @Hezi-crypto @duwenhan2byte @catee @evan-crash
|
||||
|
||||
@ -28,7 +28,7 @@ Before you submit your Pull Request (PR) consider the following guidelines:
|
||||
3. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) the coze-dev {project_name} repo.
|
||||
4. In your forked repository, make your changes in a new git branch:
|
||||
```
|
||||
git checkout -b my-fix-branch main
|
||||
git checkout -b my-fix-branch develop
|
||||
```
|
||||
5. Create your patch, including appropriate test cases.
|
||||
6. Follow our [Style Guides](#code-style-guides).
|
||||
@ -38,7 +38,7 @@ Before you submit your Pull Request (PR) consider the following guidelines:
|
||||
```
|
||||
git push origin my-fix-branch
|
||||
```
|
||||
9. In GitHub, send a pull request to `{project_name}:main`
|
||||
9. In GitHub, send a pull request to `{project_name}:develop`
|
||||
|
||||
## Contribution Prerequisites
|
||||
- Our development environment keeps up with [Go Official](https://golang.org/project/).
|
||||
|
||||
2
Makefile
2
Makefile
@ -28,7 +28,7 @@ fe:
|
||||
@echo "Building frontend..."
|
||||
@bash $(BUILD_FE_SCRIPT)
|
||||
|
||||
server: env setup_es_index
|
||||
server: env
|
||||
@if [ ! -d "$(STATIC_DIR)" ]; then \
|
||||
echo "Static directory '$(STATIC_DIR)' not found, building frontend..."; \
|
||||
$(MAKE) fe; \
|
||||
|
||||
@ -555,11 +555,7 @@ func CreateProjectConversationDef(ctx context.Context, c *app.RequestContext) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appworkflow.SVC.CreateApplicationConversationDef(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(workflow.CreateProjectConversationDefResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -574,11 +570,8 @@ func UpdateProjectConversationDef(ctx context.Context, c *app.RequestContext) {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := appworkflow.SVC.UpdateApplicationConversationDef(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(workflow.UpdateProjectConversationDefResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -594,11 +587,7 @@ func DeleteProjectConversationDef(ctx context.Context, c *app.RequestContext) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appworkflow.SVC.DeleteApplicationConversationDef(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(workflow.DeleteProjectConversationDefResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -614,11 +603,7 @@ func ListProjectConversationDef(ctx context.Context, c *app.RequestContext) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appworkflow.SVC.ListApplicationConversationDef(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(workflow.ListProjectConversationResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -738,11 +723,7 @@ func GetChatFlowRole(ctx context.Context, c *app.RequestContext) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appworkflow.SVC.GetChatFlowRole(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(workflow.GetChatFlowRoleResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -757,11 +738,8 @@ func CreateChatFlowRole(ctx context.Context, c *app.RequestContext) {
|
||||
invalidParamRequestResponse(c, err.Error())
|
||||
return
|
||||
}
|
||||
resp, err := appworkflow.SVC.CreateChatFlowRole(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
|
||||
resp := new(workflow.CreateChatFlowRoleResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
@ -777,11 +755,7 @@ func DeleteChatFlowRole(ctx context.Context, c *app.RequestContext) {
|
||||
return
|
||||
}
|
||||
|
||||
resp, err := appworkflow.SVC.DeleteChatFlowRole(ctx, &req)
|
||||
if err != nil {
|
||||
internalServerErrorResponse(ctx, c, err)
|
||||
return
|
||||
}
|
||||
resp := new(workflow.DeleteChatFlowRoleResponse)
|
||||
|
||||
c.JSON(consts.StatusOK, resp)
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ import (
|
||||
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/bytedance/mockey"
|
||||
"github.com/cloudwego/eino/callbacks"
|
||||
model2 "github.com/cloudwego/eino/components/model"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
@ -103,11 +102,6 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
callbacks.AppendGlobalHandlers(service.GetTokenCallbackHandler())
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
type wfTestRunner struct {
|
||||
t *testing.T
|
||||
h *server.Hertz
|
||||
|
||||
@ -26,8 +26,6 @@ const (
|
||||
Scene_GenerateAgentInfo Scene = 8
|
||||
//openapi
|
||||
Scene_SceneOpenApi Scene = 9
|
||||
// 工作流
|
||||
Scene_SceneWorkflow Scene = 50
|
||||
)
|
||||
|
||||
func (p Scene) String() string {
|
||||
|
||||
@ -263,7 +263,6 @@ func toAPIParameter(paramMeta paramMetaInfo, sc *openapi3.Schema) (*common.APIPa
|
||||
}
|
||||
|
||||
if sc.Default != nil {
|
||||
apiParam.GlobalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
|
||||
apiParam.LocalDefault = ptr.Of(fmt.Sprintf("%v", sc.Default))
|
||||
}
|
||||
|
||||
|
||||
@ -473,10 +473,7 @@ 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
|
||||
@ -536,14 +533,8 @@ 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:
|
||||
@ -608,14 +599,8 @@ 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":
|
||||
@ -672,14 +657,11 @@ 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
|
||||
@ -741,8 +723,6 @@ 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:
|
||||
@ -753,10 +733,6 @@ 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:
|
||||
@ -823,8 +799,6 @@ 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":
|
||||
@ -835,10 +809,6 @@ 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":
|
||||
@ -64133,7 +64103,7 @@ func (p *ChatFlowRole) String() string {
|
||||
}
|
||||
|
||||
type CreateChatFlowRoleRequest struct {
|
||||
ChatFlowRole *ChatFlowRole `thrift:"ChatFlowRole,1" json:"chat_flow_role" query:"chat_flow_role" `
|
||||
ChatFlowRole *ChatFlowRole `thrift:"ChatFlowRole,1" json:"chat_flow_role" form:"ChatFlowRole" query:"ChatFlowRole"`
|
||||
Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"`
|
||||
}
|
||||
|
||||
@ -64332,9 +64302,7 @@ func (p *CreateChatFlowRoleRequest) String() string {
|
||||
|
||||
type CreateChatFlowRoleResponse struct {
|
||||
// 数据库中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"`
|
||||
ID string `thrift:"ID,1" form:"ID" json:"ID" query:"ID"`
|
||||
BaseResp *base.BaseResp `thrift:"BaseResp,255,required" form:"BaseResp,required" json:"BaseResp,required" query:"BaseResp,required"`
|
||||
}
|
||||
|
||||
@ -64349,14 +64317,6 @@ 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) {
|
||||
@ -64368,8 +64328,6 @@ func (p *CreateChatFlowRoleResponse) GetBaseResp() (v *base.BaseResp) {
|
||||
|
||||
var fieldIDToName_CreateChatFlowRoleResponse = map[int16]string{
|
||||
1: "ID",
|
||||
253: "code",
|
||||
254: "msg",
|
||||
255: "BaseResp",
|
||||
}
|
||||
|
||||
@ -64380,8 +64338,6 @@ 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 {
|
||||
@ -64406,24 +64362,6 @@ 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 {
|
||||
@ -64446,16 +64384,6 @@ 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
|
||||
@ -64489,28 +64417,6 @@ 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 {
|
||||
@ -64530,14 +64436,6 @@ 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
|
||||
@ -64576,38 +64474,6 @@ 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
|
||||
@ -64634,10 +64500,10 @@ func (p *CreateChatFlowRoleResponse) String() string {
|
||||
}
|
||||
|
||||
type DeleteChatFlowRoleRequest struct {
|
||||
WorkflowID string `thrift:"WorkflowID,1" json:"workflow_id" query:"workflow_id" `
|
||||
ConnectorID string `thrift:"ConnectorID,2" json:"connector_id" query:"connector_id" `
|
||||
WorkflowID string `thrift:"WorkflowID,1" form:"WorkflowID" json:"WorkflowID" query:"WorkflowID"`
|
||||
ConnectorID string `thrift:"ConnectorID,2" form:"ConnectorID" json:"ConnectorID" query:"ConnectorID"`
|
||||
// 数据库中ID
|
||||
ID string `thrift:"ID,4" json:"id" query:"id" `
|
||||
ID string `thrift:"ID,4" form:"ID" json:"ID" query:"ID"`
|
||||
Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"`
|
||||
}
|
||||
|
||||
@ -65070,12 +64936,12 @@ func (p *DeleteChatFlowRoleResponse) String() string {
|
||||
}
|
||||
|
||||
type GetChatFlowRoleRequest struct {
|
||||
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" `
|
||||
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"`
|
||||
// 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" json:"base" query:"base" `
|
||||
Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"`
|
||||
}
|
||||
|
||||
func NewGetChatFlowRoleRequest() *GetChatFlowRoleRequest {
|
||||
@ -65438,10 +65304,8 @@ func (p *GetChatFlowRoleRequest) String() string {
|
||||
}
|
||||
|
||||
type GetChatFlowRoleResponse struct {
|
||||
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" `
|
||||
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"`
|
||||
}
|
||||
|
||||
func NewGetChatFlowRoleResponse() *GetChatFlowRoleResponse {
|
||||
@ -65451,14 +65315,6 @@ 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) {
|
||||
@ -65478,9 +65334,7 @@ func (p *GetChatFlowRoleResponse) GetBaseResp() (v *base.BaseResp) {
|
||||
}
|
||||
|
||||
var fieldIDToName_GetChatFlowRoleResponse = map[int16]string{
|
||||
1: "code",
|
||||
2: "msg",
|
||||
3: "Role",
|
||||
1: "Role",
|
||||
255: "BaseResp",
|
||||
}
|
||||
|
||||
@ -65495,8 +65349,6 @@ 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 {
|
||||
@ -65514,26 +65366,8 @@ func (p *GetChatFlowRoleResponse) Read(iprot thrift.TProtocol) (err error) {
|
||||
|
||||
switch fieldId {
|
||||
case 1:
|
||||
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 {
|
||||
if err = p.ReadField1(iprot); err != nil {
|
||||
goto ReadFieldError
|
||||
}
|
||||
} else if err = iprot.Skip(fieldTypeId); err != nil {
|
||||
@ -65561,16 +65395,6 @@ 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
|
||||
@ -65594,28 +65418,6 @@ 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
|
||||
@ -65642,14 +65444,6 @@ 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
|
||||
@ -65673,40 +65467,8 @@ 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, 3); err != nil {
|
||||
if err = oprot.WriteFieldBegin("Role", thrift.STRUCT, 1); err != nil {
|
||||
goto WriteFieldBeginError
|
||||
}
|
||||
if err := p.Role.Write(oprot); err != nil {
|
||||
@ -65718,9 +65480,9 @@ func (p *GetChatFlowRoleResponse) writeField3(oprot thrift.TProtocol) (err error
|
||||
}
|
||||
return nil
|
||||
WriteFieldBeginError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
|
||||
WriteFieldEndError:
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
|
||||
return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
|
||||
}
|
||||
func (p *GetChatFlowRoleResponse) writeField255(oprot thrift.TProtocol) (err error) {
|
||||
if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil {
|
||||
|
||||
@ -20,9 +20,10 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop_common"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
@ -32,6 +33,14 @@ import (
|
||||
func APIParamsToOpenapiOperation(reqParams, respParams []*common.APIParameter) (*openapi3.Operation, error) {
|
||||
op := &openapi3.Operation{}
|
||||
|
||||
if reqParams != nil && len(reqParams) == 0 {
|
||||
op.Parameters = []*openapi3.ParameterRef{}
|
||||
op.RequestBody = entity.DefaultOpenapi3RequestBody()
|
||||
}
|
||||
if respParams != nil && len(respParams) == 0 {
|
||||
op.Responses = entity.DefaultOpenapi3Responses()
|
||||
}
|
||||
|
||||
hasSetReqBody := false
|
||||
hasSetParams := false
|
||||
|
||||
@ -127,16 +136,6 @@ func APIParamsToOpenapiOperation(reqParams, respParams []*common.APIParameter) (
|
||||
}
|
||||
}
|
||||
|
||||
if op.Parameters == nil {
|
||||
op.Parameters = []*openapi3.ParameterRef{}
|
||||
}
|
||||
if op.RequestBody == nil {
|
||||
op.RequestBody = entity.DefaultOpenapi3RequestBody()
|
||||
}
|
||||
if op.Responses == nil {
|
||||
op.Responses = entity.DefaultOpenapi3Responses()
|
||||
}
|
||||
|
||||
return op, nil
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ import (
|
||||
"github.com/cloudwego/eino-ext/components/model/qwen"
|
||||
"github.com/cloudwego/eino/components/prompt"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/embedding/http"
|
||||
"github.com/milvus-io/milvus/client/v2/milvusclient"
|
||||
"github.com/volcengine/volc-sdk-golang/service/vikingdb"
|
||||
"github.com/volcengine/volc-sdk-golang/service/visual"
|
||||
@ -372,21 +371,6 @@ func getEmbedding(ctx context.Context) (embedding.Embedder, error) {
|
||||
return nil, fmt.Errorf("init ollama embedding failed, err=%w", err)
|
||||
}
|
||||
|
||||
|
||||
case "http":
|
||||
var (
|
||||
httpEmbeddingBaseURL = os.Getenv("HTTP_EMBEDDING_ADDR")
|
||||
httpEmbeddingDims = os.Getenv("HTTP_EMBEDDING_DIMS")
|
||||
)
|
||||
dims, err := strconv.ParseInt(httpEmbeddingDims, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init http embedding dims failed, err=%w", err)
|
||||
}
|
||||
emb, err = http.NewEmbedding(httpEmbeddingBaseURL, dims)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init http embedding failed, err=%w", err)
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("init knowledge embedding failed, type not configured")
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ func (p *PluginApplicationService) RegisterPluginMeta(ctx context.Context, req *
|
||||
if req.GetLocation() == common.AuthorizationServiceLocation_Query {
|
||||
loc = model.ParamInQuery
|
||||
} else if req.GetLocation() == common.AuthorizationServiceLocation_Header {
|
||||
loc = model.ParamInHeader
|
||||
loc = model.ParamInPath
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid location '%s'", req.GetLocation())
|
||||
}
|
||||
|
||||
@ -1,264 +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 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
|
||||
}
|
||||
@ -17,12 +17,10 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"github.com/cloudwego/eino/callbacks"
|
||||
"github.com/cloudwego/eino/compose"
|
||||
"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"
|
||||
@ -36,7 +34,6 @@ 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"
|
||||
@ -44,7 +41,6 @@ import (
|
||||
crosssearch "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search"
|
||||
crossvariable "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||
workflowservice "github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
@ -82,8 +78,6 @@ 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())
|
||||
callbacks.AppendGlobalHandlers(workflowservice.GetTokenCallbackHandler())
|
||||
|
||||
SVC.DomainSVC = workflowDomainSVC
|
||||
SVC.ImageX = components.ImageX
|
||||
|
||||
@ -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 := entity.BlockType2EntityNodeType(t)
|
||||
entityType, err := nodeType2EntityNodeType(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 := entity.NodeTypeToAPINodeTemplateType(nodeMeta.Type)
|
||||
tplType, err := entityNodeTypeToAPINodeTemplateType(nodeMeta.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -169,21 +169,6 @@ 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,
|
||||
@ -195,13 +180,6 @@ 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 {
|
||||
@ -1056,18 +1034,6 @@ 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
|
||||
}
|
||||
@ -1161,7 +1127,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
||||
}
|
||||
|
||||
func convertNodeExecution(nodeExe *entity.NodeExecution) (*workflow.NodeResult, error) {
|
||||
nType, err := entity.NodeTypeToAPINodeTemplateType(nodeExe.NodeType)
|
||||
nType, err := entityNodeTypeToAPINodeTemplateType(nodeExe.NodeType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1351,7 +1317,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
||||
}
|
||||
|
||||
var nodeType workflow.NodeTemplateType
|
||||
nodeType, err = entity.NodeTypeToAPINodeTemplateType(msg.NodeType)
|
||||
nodeType, err = entityNodeTypeToAPINodeTemplateType(msg.NodeType)
|
||||
if err != nil {
|
||||
logs.Errorf("convert node type %v failed, err:=%v", msg.NodeType, err)
|
||||
nodeType = workflow.NodeTemplateType(0)
|
||||
@ -2121,11 +2087,6 @@ func (w *ApplicationService) ListWorkflow(ctx context.Context, req *workflow.Get
|
||||
},
|
||||
}
|
||||
|
||||
ww.CheckResult, err = GetWorkflowDomainSVC().WorkflowSchemaCheck(ctx, w, req.Checker)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if qType == vo.FromDraft {
|
||||
ww.UpdateTime = w.DraftMeta.Timestamp.Unix()
|
||||
} else if qType == vo.FromLatestVersion || qType == vo.FromSpecificVersion {
|
||||
@ -3377,6 +3338,178 @@ 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
|
||||
@ -3680,357 +3813,3 @@ 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 {
|
||||
vl, err := GetWorkflowDomainSVC().GetWorkflowVersionsByConnector(ctx, mustParseInt64(req.GetConnectorID()), wf.ID, 1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(vl) > 0 {
|
||||
version = vl[0]
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@ -20,13 +20,10 @@ 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
|
||||
|
||||
@ -20,16 +20,13 @@ 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
|
||||
|
||||
@ -20,10 +20,8 @@ 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"
|
||||
)
|
||||
@ -39,13 +37,10 @@ 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"
|
||||
|
||||
@ -21,7 +21,6 @@ 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"
|
||||
)
|
||||
|
||||
@ -41,11 +40,3 @@ 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)
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ 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"
|
||||
)
|
||||
|
||||
@ -54,11 +53,3 @@ 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)
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ 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"
|
||||
@ -73,14 +72,6 @@ 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{
|
||||
|
||||
@ -1,201 +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"
|
||||
"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
|
||||
}
|
||||
@ -1,380 +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 (
|
||||
"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)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,6 @@ func (k *Knowledge) Retrieve(ctx context.Context, r *crossknowledge.RetrieveRequ
|
||||
Query: r.Query,
|
||||
KnowledgeIDs: r.KnowledgeIDs,
|
||||
Strategy: rs,
|
||||
ChatHistory: r.ChatHistory,
|
||||
}
|
||||
|
||||
response, err := k.client.Retrieve(ctx, req)
|
||||
|
||||
@ -29,7 +29,6 @@ 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"
|
||||
@ -68,11 +67,6 @@ 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
|
||||
}
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ func (suite *KnowledgeTestSuite) SetupSuite() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
emb, err := hembed.NewEmbedding(embEndpoint, 1024)
|
||||
emb, err := hembed.NewEmbedding(embEndpoint)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -157,6 +157,7 @@ func NewDefaultPluginManifest() *PluginManifest {
|
||||
Value: "Coze/1.0",
|
||||
},
|
||||
},
|
||||
model.ParamInPath: {},
|
||||
model.ParamInQuery: {},
|
||||
},
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ import (
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"github.com/tidwall/sjson"
|
||||
|
||||
einoCompose "github.com/cloudwego/eino/compose"
|
||||
|
||||
@ -480,6 +479,11 @@ func (t *toolExecutor) execute(ctx context.Context, argumentsInJson string) (res
|
||||
return nil, err
|
||||
}
|
||||
|
||||
requestStr, err := sonic.MarshalString(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpReq, err := t.buildHTTPRequest(ctx, args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -500,29 +504,18 @@ func (t *toolExecutor) execute(ctx context.Context, argumentsInJson string) (res
|
||||
}
|
||||
|
||||
var reqBodyBytes []byte
|
||||
if httpReq.GetBody != nil {
|
||||
reqBody, err := httpReq.GetBody()
|
||||
if httpReq.Body != nil {
|
||||
reqBodyBytes, err = io.ReadAll(httpReq.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer reqBody.Close()
|
||||
|
||||
reqBodyBytes, err = io.ReadAll(reqBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
requestStr, err := genRequestString(httpReq, reqBodyBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
restyReq := t.svc.httpCli.NewRequest()
|
||||
restyReq.Header = httpReq.Header
|
||||
restyReq.Method = httpReq.Method
|
||||
restyReq.URL = httpReq.URL.String()
|
||||
if reqBodyBytes != nil {
|
||||
if len(reqBodyBytes) > 0 {
|
||||
restyReq.SetBody(reqBodyBytes)
|
||||
}
|
||||
restyReq.SetContext(ctx)
|
||||
@ -566,46 +559,6 @@ func (t *toolExecutor) execute(ctx context.Context, argumentsInJson string) (res
|
||||
}, nil
|
||||
}
|
||||
|
||||
func genRequestString(req *http.Request, body []byte) (string, error) {
|
||||
type Request struct {
|
||||
Path string `json:"path"`
|
||||
Header map[string]string `json:"header"`
|
||||
Query map[string]string `json:"query"`
|
||||
Body *[]byte `json:"body"`
|
||||
}
|
||||
|
||||
req_ := &Request{
|
||||
Path: req.URL.Path,
|
||||
Header: map[string]string{},
|
||||
Query: map[string]string{},
|
||||
}
|
||||
|
||||
if len(req.Header) > 0 {
|
||||
for k, v := range req.Header {
|
||||
req_.Header[k] = v[0]
|
||||
}
|
||||
}
|
||||
if len(req.URL.Query()) > 0 {
|
||||
for k, v := range req.URL.Query() {
|
||||
req_.Query[k] = v[0]
|
||||
}
|
||||
}
|
||||
|
||||
requestStr, err := sonic.MarshalString(req_)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("[genRequestString] marshal failed, err=%s", err)
|
||||
}
|
||||
|
||||
if body != nil {
|
||||
requestStr, err = sjson.SetRaw(requestStr, "body", string(body))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("[genRequestString] set body failed, err=%s", err)
|
||||
}
|
||||
}
|
||||
|
||||
return requestStr, nil
|
||||
}
|
||||
|
||||
func (t *toolExecutor) preprocessArgumentsInJson(ctx context.Context, argumentsInJson string) (args map[string]any, err error) {
|
||||
args, err = t.prepareArguments(ctx, argumentsInJson)
|
||||
if err != nil {
|
||||
@ -700,13 +653,23 @@ func (t *toolExecutor) buildHTTPRequest(ctx context.Context, argMaps map[string]
|
||||
return nil, err
|
||||
}
|
||||
|
||||
commonParams := t.plugin.Manifest.CommonParams
|
||||
|
||||
reqURL, err := locArgs.buildHTTPRequestURL(ctx, rawURL, commonParams)
|
||||
reqURL, err := locArgs.buildHTTPRequestURL(ctx, rawURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpReq, err = http.NewRequestWithContext(ctx, tool.GetMethod(), reqURL.String(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
header, err := locArgs.buildHTTPRequestHeader(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpReq.Header = header
|
||||
|
||||
bodyArgs := map[string]any{}
|
||||
for k, v := range argMaps {
|
||||
if _, ok := locArgs.header[k]; ok {
|
||||
@ -721,27 +684,13 @@ func (t *toolExecutor) buildHTTPRequest(ctx context.Context, argMaps map[string]
|
||||
bodyArgs[k] = v
|
||||
}
|
||||
|
||||
commonBody := commonParams[model.ParamInBody]
|
||||
bodyBytes, contentType, err := t.buildRequestBody(ctx, tool.Operation, bodyArgs, commonBody)
|
||||
bodyBytes, contentType, err := t.buildRequestBody(ctx, tool.Operation, bodyArgs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpReq, err = http.NewRequestWithContext(ctx, tool.GetMethod(), reqURL.String(), bytes.NewBuffer(bodyBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
commonHeader := commonParams[model.ParamInHeader]
|
||||
header, err := locArgs.buildHTTPRequestHeader(ctx, commonHeader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
httpReq.Header = header
|
||||
|
||||
if len(bodyBytes) > 0 {
|
||||
httpReq.Header.Set("Content-Type", contentType)
|
||||
httpReq.Body = io.NopCloser(bytes.NewReader(bodyBytes))
|
||||
}
|
||||
|
||||
return httpReq, nil
|
||||
@ -749,6 +698,13 @@ func (t *toolExecutor) buildHTTPRequest(ctx context.Context, argMaps map[string]
|
||||
|
||||
func (t *toolExecutor) prepareArguments(_ context.Context, argumentsInJson string) (map[string]any, error) {
|
||||
args := map[string]any{}
|
||||
for loc, params := range t.plugin.Manifest.CommonParams {
|
||||
for _, p := range params {
|
||||
if loc != model.ParamInBody {
|
||||
args[p.Name] = p.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
decoder := sonic.ConfigDefault.NewDecoder(bytes.NewBufferString(argumentsInJson))
|
||||
decoder.UseNumber()
|
||||
@ -1219,9 +1175,7 @@ type valueWithSchema struct {
|
||||
paramSchema *openapi3.Parameter
|
||||
}
|
||||
|
||||
func (l *locationArguments) buildHTTPRequestURL(_ context.Context, rawURL string,
|
||||
commonParams map[model.HTTPParamLocation][]*common.CommonParamSchema) (reqURL *url.URL, err error) {
|
||||
|
||||
func (l *locationArguments) buildHTTPRequestURL(_ context.Context, rawURL string) (reqURL *url.URL, err error) {
|
||||
if len(l.path) > 0 {
|
||||
for k, v := range l.path {
|
||||
vStr, err := encoder.EncodeParameter(v.paramSchema, v.argValue)
|
||||
@ -1232,8 +1186,9 @@ func (l *locationArguments) buildHTTPRequestURL(_ context.Context, rawURL string
|
||||
}
|
||||
}
|
||||
|
||||
query := url.Values{}
|
||||
encodeQuery := ""
|
||||
if len(l.query) > 0 {
|
||||
query := url.Values{}
|
||||
for k, val := range l.query {
|
||||
switch v := val.argValue.(type) {
|
||||
case []any:
|
||||
@ -1244,18 +1199,10 @@ func (l *locationArguments) buildHTTPRequestURL(_ context.Context, rawURL string
|
||||
query.Add(k, encoder.MustString(v))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commonQuery := commonParams[model.ParamInQuery]
|
||||
for _, v := range commonQuery {
|
||||
if _, ok := l.query[v.Name]; ok {
|
||||
continue
|
||||
}
|
||||
query.Add(v.Name, v.Value)
|
||||
encodeQuery = query.Encode()
|
||||
}
|
||||
|
||||
encodeQuery := query.Encode()
|
||||
|
||||
reqURL, err = url.Parse(rawURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1270,7 +1217,7 @@ func (l *locationArguments) buildHTTPRequestURL(_ context.Context, rawURL string
|
||||
return reqURL, nil
|
||||
}
|
||||
|
||||
func (l *locationArguments) buildHTTPRequestHeader(_ context.Context, commonHeaders []*common.CommonParamSchema) (http.Header, error) {
|
||||
func (l *locationArguments) buildHTTPRequestHeader(_ context.Context) (http.Header, error) {
|
||||
header := http.Header{}
|
||||
if len(l.header) > 0 {
|
||||
for k, v := range l.header {
|
||||
@ -1285,64 +1232,44 @@ func (l *locationArguments) buildHTTPRequestHeader(_ context.Context, commonHead
|
||||
}
|
||||
}
|
||||
|
||||
for _, h := range commonHeaders {
|
||||
if header.Get(h.Name) != "" {
|
||||
continue
|
||||
}
|
||||
header.Add(h.Name, h.Value)
|
||||
}
|
||||
|
||||
return header, nil
|
||||
}
|
||||
|
||||
func (t *toolExecutor) buildRequestBody(ctx context.Context, op *model.Openapi3Operation, bodyArgs map[string]any,
|
||||
commonBody []*common.CommonParamSchema) (body []byte, contentType string, err error) {
|
||||
|
||||
var bodyMap map[string]any
|
||||
|
||||
func (t *toolExecutor) buildRequestBody(ctx context.Context, op *model.Openapi3Operation, bodyArgs map[string]any) (body []byte, contentType string, err error) {
|
||||
contentType, bodySchema := t.getReqBodySchema(op)
|
||||
if bodySchema != nil && len(bodySchema.Value.Properties) > 0 {
|
||||
bodyMap, err = t.injectRequestBodyDefaultValue(ctx, bodySchema.Value, bodyArgs)
|
||||
if bodySchema == nil || bodySchema.Value == nil {
|
||||
return nil, "", nil
|
||||
}
|
||||
|
||||
if len(bodySchema.Value.Properties) == 0 {
|
||||
return nil, "", nil
|
||||
}
|
||||
|
||||
bodyMap, err := t.injectRequestBodyDefaultValue(ctx, bodySchema.Value, bodyArgs)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
for paramName, prop := range bodySchema.Value.Properties {
|
||||
value, ok := bodyMap[paramName]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
_value, err := encoder.TryFixValueType(paramName, prop, value)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
for paramName, prop := range bodySchema.Value.Properties {
|
||||
value, ok := bodyMap[paramName]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
_value, err := encoder.TryFixValueType(paramName, prop, value)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
bodyMap[paramName] = _value
|
||||
}
|
||||
|
||||
body, err = encoder.EncodeBodyWithContentType(contentType, bodyMap)
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("[buildRequestBody] EncodeBodyWithContentType failed, err=%v", err)
|
||||
}
|
||||
bodyMap[paramName] = _value
|
||||
}
|
||||
|
||||
commonBody_ := make([]*common.CommonParamSchema, 0, len(commonBody))
|
||||
for _, v := range commonBody {
|
||||
if _, ok := bodyMap[v.Name]; ok {
|
||||
continue
|
||||
}
|
||||
commonBody_ = append(commonBody_, v)
|
||||
reqBodyStr, err := encoder.EncodeBodyWithContentType(contentType, bodyMap)
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("[buildRequestBody] EncodeBodyWithContentType failed, err=%v", err)
|
||||
}
|
||||
|
||||
for _, v := range commonBody_ {
|
||||
body, err = sjson.SetRawBytes(body, v.Name, []byte(v.Value))
|
||||
if err != nil {
|
||||
return nil, "", fmt.Errorf("[buildRequestBody] SetRawBytes failed, err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return body, contentType, nil
|
||||
return reqBodyStr, contentType, nil
|
||||
}
|
||||
|
||||
func (t *toolExecutor) injectRequestBodyDefaultValue(ctx context.Context, sc *openapi3.Schema, vals map[string]any) (newVals map[string]any, err error) {
|
||||
@ -1400,7 +1327,7 @@ func (t *toolExecutor) injectRequestBodyDefaultValue(ctx context.Context, sc *op
|
||||
}
|
||||
|
||||
func (t *toolExecutor) getReqBodySchema(op *model.Openapi3Operation) (string, *openapi3.SchemaRef) {
|
||||
if op.RequestBody == nil || len(op.RequestBody.Value.Content) == 0 {
|
||||
if op.RequestBody == nil || op.RequestBody.Value == nil || len(op.RequestBody.Value.Content) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
|
||||
@ -1,49 +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 service
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
. "github.com/bytedance/mockey"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGenRequestString(t *testing.T) {
|
||||
PatchConvey("", t, func() {
|
||||
requestStr, err := genRequestString(&http.Request{
|
||||
Header: http.Header{
|
||||
"Content-Type": []string{"application/json"},
|
||||
},
|
||||
Method: http.MethodPost,
|
||||
URL: &url.URL{Path: "/test"},
|
||||
}, []byte(`{"a": 1}`))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `{"header":{"Content-Type":["application/json"]},"query":null,"path":"/test","body":{"a": 1}}`, requestStr)
|
||||
})
|
||||
|
||||
PatchConvey("", t, func() {
|
||||
var body []byte
|
||||
requestStr, err := genRequestString(&http.Request{
|
||||
URL: &url.URL{Path: "/test"},
|
||||
}, body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, `{"header":null,"query":null,"path":"/test","body":null}`, requestStr)
|
||||
})
|
||||
}
|
||||
@ -46,7 +46,6 @@ import (
|
||||
|
||||
func (p *pluginServiceImpl) CreateDraftPlugin(ctx context.Context, req *CreateDraftPluginRequest) (pluginID int64, err error) {
|
||||
mf := entity.NewDefaultPluginManifest()
|
||||
mf.CommonParams = map[model.HTTPParamLocation][]*plugin_develop_common.CommonParamSchema{}
|
||||
mf.NameForHuman = req.Name
|
||||
mf.NameForModel = req.Name
|
||||
mf.DescriptionForHuman = req.Desc
|
||||
@ -66,11 +65,11 @@ func (p *pluginServiceImpl) CreateDraftPlugin(ctx context.Context, req *CreateDr
|
||||
return 0, fmt.Errorf("invalid location '%s'", loc.String())
|
||||
}
|
||||
for _, param := range params {
|
||||
mf.CommonParams[location] = append(mf.CommonParams[location],
|
||||
&plugin_develop_common.CommonParamSchema{
|
||||
Name: param.Name,
|
||||
Value: param.Value,
|
||||
})
|
||||
mParams := mf.CommonParams[location]
|
||||
mParams = append(mParams, &plugin_develop_common.CommonParamSchema{
|
||||
Name: param.Name,
|
||||
Value: param.Value,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ func (p *pluginServiceImpl) getAccessTokenByAuthorizationCode(ctx context.Contex
|
||||
meta := ci.Meta
|
||||
info, exist, err := p.oauthRepo.GetAuthorizationCode(ctx, ci.Meta)
|
||||
if err != nil {
|
||||
return "", errorx.Wrapf(err, "GetAuthorizationCode failed, userID=%s, pluginID=%d, isDraft=%t",
|
||||
return "", errorx.Wrapf(err, "GetAuthorizationCode failed, userID=%s, pluginID=%d, isDraft=%p",
|
||||
meta.UserID, meta.PluginID, meta.IsDraft)
|
||||
}
|
||||
if !exist {
|
||||
|
||||
@ -53,20 +53,6 @@ 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)
|
||||
@ -104,22 +90,3 @@ 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
|
||||
}
|
||||
|
||||
@ -16,116 +16,46 @@
|
||||
|
||||
package conversation
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
import "context"
|
||||
|
||||
type ClearMessageRequest struct {
|
||||
Name string
|
||||
}
|
||||
type ClearMessageResponse struct {
|
||||
IsSuccess bool
|
||||
}
|
||||
type CreateConversationRequest struct {
|
||||
AppID int64
|
||||
UserID int64
|
||||
ConnectorID int64
|
||||
Name string
|
||||
}
|
||||
|
||||
type CreateMessageRequest struct {
|
||||
ConversationID int64
|
||||
Role string
|
||||
Content string
|
||||
ContentType string
|
||||
UserID int64
|
||||
AppID int64
|
||||
RunID int64
|
||||
type CreateConversationResponse struct {
|
||||
Result map[string]any
|
||||
}
|
||||
|
||||
type MessageListRequest struct {
|
||||
ConversationID int64
|
||||
Limit int64
|
||||
BeforeID *string
|
||||
AfterID *string
|
||||
UserID int64
|
||||
AppID int64
|
||||
OrderBy *string
|
||||
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 MessageListResponse struct {
|
||||
type ListMessageResponse struct {
|
||||
Messages []*Message
|
||||
FirstID string
|
||||
LastID string
|
||||
HasMore bool
|
||||
}
|
||||
|
||||
var conversationManagerImpl ConversationManager
|
||||
var ConversationManagerImpl ConversationManager
|
||||
|
||||
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
|
||||
ClearMessage(context.Context, *ClearMessageRequest) (*ClearMessageResponse, error)
|
||||
CreateConversation(ctx context.Context, c *CreateConversationRequest) (*CreateConversationResponse, error)
|
||||
MessageList(ctx context.Context, req *ListMessageRequest) (*ListMessageResponse, error)
|
||||
}
|
||||
|
||||
@ -1,159 +0,0 @@
|
||||
// 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)
|
||||
}
|
||||
@ -19,7 +19,6 @@ package knowledge
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
)
|
||||
|
||||
@ -88,7 +87,6 @@ type RetrieveRequest struct {
|
||||
Query string
|
||||
KnowledgeIDs []int64
|
||||
RetrievalStrategy *RetrievalStrategy
|
||||
ChatHistory []*schema.Message
|
||||
}
|
||||
|
||||
type Slice struct {
|
||||
|
||||
@ -35,7 +35,6 @@ type LLMParams struct {
|
||||
TopP *float64 `json:"topP"`
|
||||
TopK *int `json:"topK"`
|
||||
EnableChatHistory bool `json:"enableChatHistory"`
|
||||
ChatHistoryRound int64 `json:"chatHistoryRound"`
|
||||
SystemPrompt string `json:"systemPrompt"`
|
||||
ResponseFormat ResponseFormat `json:"responseFormat"`
|
||||
}
|
||||
|
||||
@ -1,37 +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 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
|
||||
}
|
||||
@ -1,39 +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 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
|
||||
}
|
||||
@ -16,15 +16,6 @@
|
||||
|
||||
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 {
|
||||
@ -125,11 +116,8 @@ const (
|
||||
NodeTypeCodeRunner NodeType = "CodeRunner"
|
||||
NodeTypePlugin NodeType = "Plugin"
|
||||
NodeTypeCreateConversation NodeType = "CreateConversation"
|
||||
NodeTypeConversationList NodeType = "ConversationList"
|
||||
NodeTypeMessageList NodeType = "MessageList"
|
||||
NodeTypeCreateMessage NodeType = "CreateMessage"
|
||||
NodeTypeEditMessage NodeType = "EditMessage"
|
||||
NodeTypeDeleteMessage NodeType = "DeleteMessage"
|
||||
NodeTypeClearMessage NodeType = "ClearMessage"
|
||||
NodeTypeLambda NodeType = "Lambda"
|
||||
NodeTypeLLM NodeType = "LLM"
|
||||
NodeTypeSelector NodeType = "Selector"
|
||||
@ -137,93 +125,9 @@ 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))
|
||||
|
||||
}
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
|
||||
)
|
||||
@ -483,6 +481,7 @@ 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,
|
||||
@ -493,13 +492,14 @@ var NodeTypeMetas = []*NodeTypeMeta{
|
||||
},
|
||||
{
|
||||
ID: 38,
|
||||
Name: "清空会话历史",
|
||||
Type: NodeTypeClearConversationHistory,
|
||||
Name: "清除上下文",
|
||||
Type: NodeTypeClearMessage,
|
||||
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,25 +508,6 @@ 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: "创建会话",
|
||||
@ -536,51 +517,15 @@ 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: "变量赋值",
|
||||
@ -687,83 +632,13 @@ 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{
|
||||
@ -781,7 +656,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{
|
||||
@ -987,133 +862,6 @@ 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))
|
||||
}
|
||||
|
||||
@ -70,16 +70,15 @@ type Data struct {
|
||||
}
|
||||
|
||||
type Inputs struct {
|
||||
InputParameters []*Param `json:"inputParameters"`
|
||||
Content *BlockInput `json:"content"`
|
||||
TerminatePlan *TerminatePlan `json:"terminatePlan,omitempty"`
|
||||
StreamingOutput bool `json:"streamingOutput,omitempty"`
|
||||
CallTransferVoice bool `json:"callTransferVoice,omitempty"`
|
||||
ChatHistoryWriting string `json:"chatHistoryWriting,omitempty"`
|
||||
ChatHistorySetting *ChatHistorySetting `json:"chatHistorySetting,omitempty"`
|
||||
LLMParam any `json:"llmParam,omitempty"` // The LLMParam type may be one of the LLMParam or IntentDetectorLLMParam type or QALLMParam type
|
||||
FCParam *FCParam `json:"fcParam,omitempty"`
|
||||
SettingOnError *SettingOnError `json:"settingOnError,omitempty"`
|
||||
InputParameters []*Param `json:"inputParameters"`
|
||||
Content *BlockInput `json:"content"`
|
||||
TerminatePlan *TerminatePlan `json:"terminatePlan,omitempty"`
|
||||
StreamingOutput bool `json:"streamingOutput,omitempty"`
|
||||
CallTransferVoice bool `json:"callTransferVoice,omitempty"`
|
||||
ChatHistoryWriting string `json:"chatHistoryWriting,omitempty"`
|
||||
LLMParam any `json:"llmParam,omitempty"` // The LLMParam type may be one of the LLMParam or IntentDetectorLLMParam type or QALLMParam type
|
||||
FCParam *FCParam `json:"fcParam,omitempty"`
|
||||
SettingOnError *SettingOnError `json:"settingOnError,omitempty"`
|
||||
|
||||
LoopType LoopType `json:"loopType,omitempty"`
|
||||
LoopCount *BlockInput `json:"loopCount,omitempty"`
|
||||
@ -373,8 +372,9 @@ type DatabaseInfo struct {
|
||||
}
|
||||
|
||||
type IntentDetector struct {
|
||||
Intents []*Intent `json:"intents,omitempty"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
ChatHistorySetting *ChatHistorySetting `json:"chatHistorySetting,omitempty"`
|
||||
Intents []*Intent `json:"intents,omitempty"`
|
||||
Mode string `json:"mode,omitempty"`
|
||||
}
|
||||
type ChatHistorySetting struct {
|
||||
EnableChatHistory bool `json:"enableChatHistory,omitempty"`
|
||||
@ -445,47 +445,37 @@ 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"
|
||||
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"
|
||||
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"
|
||||
)
|
||||
|
||||
type VariableType string
|
||||
|
||||
@ -1,54 +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 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
|
||||
}
|
||||
@ -1,74 +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 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
|
||||
}
|
||||
@ -16,27 +16,22 @@
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
type ExecuteMode string
|
||||
@ -47,8 +42,6 @@ const (
|
||||
ExecuteModeNodeDebug ExecuteMode = "node_debug"
|
||||
)
|
||||
|
||||
type WorkflowMode = workflow.WorkflowMode
|
||||
|
||||
type TaskType string
|
||||
|
||||
const (
|
||||
|
||||
@ -80,5 +80,4 @@ type MetaQuery struct {
|
||||
LibOnly bool
|
||||
NeedTotalNumber bool
|
||||
DescByUpdate bool
|
||||
Mode *workflow.WorkflowMode
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -38,21 +38,12 @@ type Service interface {
|
||||
Publish(ctx context.Context, policy *vo.PublishPolicy) (err error)
|
||||
UpdateMeta(ctx context.Context, id int64, metaUpdate *vo.MetaUpdate) (err error)
|
||||
CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error)
|
||||
WorkflowSchemaCheck(ctx context.Context, wf *entity.Workflow, checks []workflow.CheckType) ([]*workflow.CheckResult, error)
|
||||
|
||||
QueryNodeProperties(ctx context.Context, id int64) (map[string]*vo.NodeProperty, error) // only draft
|
||||
ValidateTree(ctx context.Context, id int64, validateConfig vo.ValidateTreeConfig) ([]*workflow.ValidateTreeInfo, error)
|
||||
|
||||
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
|
||||
GetWorkflowVersionsByConnector(ctx context.Context, connectorID, workflowID int64, limit int) ([]string, error)
|
||||
|
||||
Executable
|
||||
AsTool
|
||||
|
||||
@ -61,24 +52,17 @@ 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)
|
||||
UpdateMeta(ctx context.Context, id int64, metaUpdate *vo.MetaUpdate) error
|
||||
GetVersion(ctx context.Context, id int64, version string) (*vo.VersionInfo, error)
|
||||
GetVersionListByConnectorAndWorkflowID(ctx context.Context, connectorID, workflowID int64, limit int) ([]string, error)
|
||||
|
||||
GetEntity(ctx context.Context, policy *vo.GetPolicy) (*entity.Workflow, error)
|
||||
|
||||
@ -110,11 +94,8 @@ 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
|
||||
|
||||
@ -210,43 +210,33 @@ 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.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,
|
||||
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,
|
||||
}
|
||||
|
||||
var blockTypeToSkip = map[vo.BlockType]bool{
|
||||
@ -1120,10 +1110,6 @@ func toIntentDetectorSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema, err
|
||||
ns.SetConfigKV("IsFastMode", true)
|
||||
}
|
||||
|
||||
if n.Data.Inputs.ChatHistorySetting != nil {
|
||||
ns.SetConfigKV("ChatHistorySetting", n.Data.Inputs.ChatHistorySetting)
|
||||
}
|
||||
|
||||
if err = SetInputsForNodeSchema(n, ns); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1408,10 +1394,11 @@ 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:
|
||||
@ -1521,10 +1508,6 @@ func toKnowledgeRetrieverSchema(n *vo.Node, _ ...OptionFn) (*compose.NodeSchema,
|
||||
}
|
||||
ns.SetConfigKV("KnowledgeIDs", knowledgeIDs)
|
||||
|
||||
if n.Data.Inputs.ChatHistorySetting != nil {
|
||||
ns.SetConfigKV("ChatHistorySetting", n.Data.Inputs.ChatHistorySetting)
|
||||
}
|
||||
|
||||
retrievalStrategy := &knowledge.RetrievalStrategy{}
|
||||
|
||||
var getDesignatedParamContent = func(name string) (any, bool) {
|
||||
@ -1961,180 +1944,6 @@ 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 {
|
||||
|
||||
@ -495,14 +495,7 @@ func LLMParamsToLLMParam(params vo.LLMParam) (*model.LLMParams, error) {
|
||||
case "systemPrompt":
|
||||
strVal := param.Input.Value.Content.(string)
|
||||
p.SystemPrompt = strVal
|
||||
case "chatHistoryRound":
|
||||
strVal := param.Input.Value.Content.(string)
|
||||
int64Val, err := strconv.ParseInt(strVal, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.ChatHistoryRound = int64Val
|
||||
case "generationDiversity", "frequencyPenalty", "presencePenalty":
|
||||
case "chatHistoryRound", "generationDiversity", "frequencyPenalty", "presencePenalty":
|
||||
// do nothing
|
||||
case "topP":
|
||||
strVal := param.Input.Value.Content.(string)
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,89 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,193 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,137 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,191 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,262 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,234 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -1,310 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@ -32,6 +32,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/llm"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
@ -46,6 +47,8 @@ func (r *WorkflowRunner) designateOptions(ctx context.Context) (context.Context,
|
||||
sw = r.streamWriter
|
||||
)
|
||||
|
||||
const tokenCallbackKey = "token_callback_key"
|
||||
|
||||
if wb.AppID != nil && exeCfg.AppID == nil {
|
||||
exeCfg.AppID = wb.AppID
|
||||
}
|
||||
@ -121,6 +124,12 @@ func (r *WorkflowRunner) designateOptions(ctx context.Context) (context.Context,
|
||||
opts = append(opts, einoCompose.WithCheckPointID(strconv.FormatInt(executeID, 10)))
|
||||
}
|
||||
|
||||
if !ctxcache.HasKey(ctx, tokenCallbackKey) {
|
||||
opts = append(opts, einoCompose.WithCallbacks(execute.GetTokenCallbackHandler()))
|
||||
ctx = ctxcache.Init(ctx)
|
||||
ctxcache.Store(ctx, tokenCallbackKey, true)
|
||||
}
|
||||
|
||||
return ctx, opts, nil
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ package compose
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/cloudwego/eino/compose"
|
||||
@ -138,11 +137,7 @@ func (s *NodeSchema) New(ctx context.Context, inner compose.Runnable[map[string]
|
||||
return nil, err
|
||||
}
|
||||
|
||||
initFn := func(ctx context.Context) (context.Context, error) {
|
||||
return ctxcache.Init(ctx), nil
|
||||
}
|
||||
|
||||
return invokableStreamableNodeWO(s, l.Chat, l.ChatStream, withCallbackInputConverter(l.ToCallbackInput), withCallbackOutputConverter(l.ToCallbackOutput), withInit(initFn)), nil
|
||||
return invokableStreamableNodeWO(s, l.Chat, l.ChatStream, withCallbackOutputConverter(l.ToCallbackOutput)), nil
|
||||
case entity.NodeTypeSelector:
|
||||
conf := s.ToSelectorConfig()
|
||||
|
||||
@ -393,10 +388,7 @@ func (s *NodeSchema) New(ctx context.Context, inner compose.Runnable[map[string]
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
initFn := func(ctx context.Context) (context.Context, error) {
|
||||
return ctxcache.Init(ctx), nil
|
||||
}
|
||||
return invokableNode(s, r.Retrieve, withCallbackInputConverter(r.ToCallbackInput), withInit(initFn)), nil
|
||||
return invokableNode(s, r.Retrieve), nil
|
||||
case entity.NodeTypeKnowledgeDeleter:
|
||||
conf, err := s.ToKnowledgeDeleterConfig()
|
||||
if err != nil {
|
||||
@ -440,61 +432,6 @@ 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 {
|
||||
@ -505,26 +442,16 @@ func (s *NodeSchema) New(ctx context.Context, inner compose.Runnable[map[string]
|
||||
return nil, err
|
||||
}
|
||||
return invokableNode(s, r.List), nil
|
||||
case entity.NodeTypeDeleteMessage:
|
||||
conf, err := s.ToDeleteMessageConfig()
|
||||
case entity.NodeTypeClearMessage:
|
||||
conf, err := s.ToClearMessageConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, err := conversation.NewDeleteMessage(ctx, conf)
|
||||
r, err := conversation.NewClearMessage(ctx, conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
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
|
||||
return invokableNode(s, r.Clear), nil
|
||||
case entity.NodeTypeIntentDetector:
|
||||
conf, err := s.ToIntentDetectorConfig(ctx)
|
||||
if err != nil {
|
||||
@ -534,10 +461,8 @@ func (s *NodeSchema) New(ctx context.Context, inner compose.Runnable[map[string]
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
initFn := func(ctx context.Context) (context.Context, error) {
|
||||
return ctxcache.Init(ctx), nil
|
||||
}
|
||||
return invokableNode(s, r.Invoke, withCallbackInputConverter(r.ToCallbackInput), withInit(initFn)), nil
|
||||
|
||||
return invokableNode(s, r.Invoke), nil
|
||||
case entity.NodeTypeSubWorkflow:
|
||||
conf, err := s.ToSubWorkflowConfig(ctx, sc.requireCheckPoint)
|
||||
if err != nil {
|
||||
@ -612,9 +537,6 @@ func (s *NodeSchema) IsEnableChatHistory() bool {
|
||||
case entity.NodeTypeIntentDetector:
|
||||
llmParam := mustGetKey[*model.LLMParams]("LLMParams", s.Configs)
|
||||
return llmParam.EnableChatHistory
|
||||
case entity.NodeTypeKnowledgeRetriever:
|
||||
chatHistorySetting := getKeyOrZero[*vo.ChatHistorySetting]("ChatHistorySetting", s.Configs)
|
||||
return chatHistorySetting != nil && chatHistorySetting.EnableChatHistory
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
@ -86,8 +86,6 @@ 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) {
|
||||
|
||||
@ -20,7 +20,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -97,13 +96,6 @@ func (s *NodeSchema) ToLLMConfig(ctx context.Context) (*llm.Config, error) {
|
||||
modelWithInfo llm.ModelWithInfo
|
||||
)
|
||||
|
||||
if llmParams.EnableChatHistory {
|
||||
llmConf.ChatHistorySetting = &vo.ChatHistorySetting{
|
||||
EnableChatHistory: llmParams.EnableChatHistory,
|
||||
ChatHistoryRound: llmParams.ChatHistoryRound,
|
||||
}
|
||||
}
|
||||
|
||||
chatModel, info, err = model.GetManager().GetModel(ctx, llmParams)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -510,7 +502,6 @@ func (s *NodeSchema) ToDatabaseCustomSQLConfig() (*database.CustomSQLConfig, err
|
||||
OutputConfig: s.OutputTypes,
|
||||
CustomSQLExecutor: crossdatabase.GetDatabaseOperator(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *NodeSchema) ToDatabaseQueryConfig() (*database.QueryConfig, error) {
|
||||
@ -526,7 +517,6 @@ 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,
|
||||
@ -544,7 +534,6 @@ 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),
|
||||
@ -564,10 +553,9 @@ func (s *NodeSchema) ToKnowledgeIndexerConfig() (*knowledge.IndexerConfig, error
|
||||
|
||||
func (s *NodeSchema) ToKnowledgeRetrieveConfig() (*knowledge.RetrieveConfig, error) {
|
||||
return &knowledge.RetrieveConfig{
|
||||
KnowledgeIDs: mustGetKey[[]int64]("KnowledgeIDs", s.Configs),
|
||||
RetrievalStrategy: mustGetKey[*crossknowledge.RetrievalStrategy]("RetrievalStrategy", s.Configs),
|
||||
Retriever: crossknowledge.GetKnowledgeOperator(),
|
||||
ChatHistorySetting: getKeyOrZero[*vo.ChatHistorySetting]("ChatHistorySetting", s.Configs),
|
||||
KnowledgeIDs: mustGetKey[[]int64]("KnowledgeIDs", s.Configs),
|
||||
RetrievalStrategy: mustGetKey[*crossknowledge.RetrievalStrategy]("RetrievalStrategy", s.Configs),
|
||||
Retriever: crossknowledge.GetKnowledgeOperator(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -585,7 +573,6 @@ func (s *NodeSchema) ToPluginConfig() (*plugin.Config, error) {
|
||||
PluginVersion: mustGetKey[string]("PluginVersion", s.Configs),
|
||||
PluginService: crossplugin.GetPluginService(),
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s *NodeSchema) ToCodeRunnerConfig() (*code.Config, error) {
|
||||
@ -599,51 +586,27 @@ func (s *NodeSchema) ToCodeRunnerConfig() (*code.Config, error) {
|
||||
|
||||
func (s *NodeSchema) ToCreateConversationConfig() (*conversation.CreateConversationConfig, error) {
|
||||
return &conversation.CreateConversationConfig{
|
||||
Manager: crossconversation.GetConversationManager(),
|
||||
Creator: crossconversation.ConversationManagerImpl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
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(),
|
||||
func (s *NodeSchema) ToClearMessageConfig() (*conversation.ClearMessageConfig, error) {
|
||||
return &conversation.ClearMessageConfig{
|
||||
Clearer: crossconversation.ConversationManagerImpl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *NodeSchema) ToMessageListConfig() (*conversation.MessageListConfig, error) {
|
||||
return &conversation.MessageListConfig{
|
||||
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(),
|
||||
Lister: crossconversation.ConversationManagerImpl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *NodeSchema) ToIntentDetectorConfig(ctx context.Context) (*intentdetector.Config, error) {
|
||||
cfg := &intentdetector.Config{
|
||||
Intents: mustGetKey[[]string]("Intents", s.Configs),
|
||||
SystemPrompt: getKeyOrZero[string]("SystemPrompt", s.Configs),
|
||||
IsFastMode: getKeyOrZero[bool]("IsFastMode", s.Configs),
|
||||
ChatHistorySetting: getKeyOrZero[*vo.ChatHistorySetting]("ChatHistorySetting", s.Configs),
|
||||
Intents: mustGetKey[[]string]("Intents", s.Configs),
|
||||
SystemPrompt: getKeyOrZero[string]("SystemPrompt", s.Configs),
|
||||
IsFastMode: getKeyOrZero[bool]("IsFastMode", s.Configs),
|
||||
}
|
||||
|
||||
llmParams := mustGetKey[*model.LLMParams]("LLMParams", s.Configs)
|
||||
|
||||
@ -1,122 +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"
|
||||
"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
|
||||
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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
|
||||
}
|
||||
@ -1,229 +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"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
oceanworkflow "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/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/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
||||
const chatHistoryKey contextKey = "chatHistory"
|
||||
|
||||
func ConvertMessageToString(ctx context.Context, msg *conversation.Message) (string, error) {
|
||||
if msg.MultiContent != nil {
|
||||
var textContents []string
|
||||
var otherContents []string
|
||||
for _, m := range msg.MultiContent {
|
||||
if m.Text != nil {
|
||||
textContents = append(textContents, ptr.From(m.Text))
|
||||
} else if m.Uri != nil {
|
||||
url, err := workflow.GetRepository().GetObjectUrl(ctx, ptr.From(m.Uri))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
otherContents = append(otherContents, url)
|
||||
}
|
||||
}
|
||||
|
||||
var allParts []string
|
||||
if len(textContents) > 0 {
|
||||
allParts = append(allParts, textContents...)
|
||||
}
|
||||
if len(otherContents) > 0 {
|
||||
allParts = append(allParts, otherContents...)
|
||||
}
|
||||
return strings.Join(allParts, ","), nil
|
||||
} else if msg.Text != nil {
|
||||
return ptr.From(msg.Text), nil
|
||||
} else {
|
||||
return "", vo.WrapError(errno.ErrInvalidParameter, errors.New("message is invalid"))
|
||||
}
|
||||
}
|
||||
|
||||
func ConvertMessageToSchema(ctx context.Context, msg *conversation.Message) (*schema.Message, error) {
|
||||
schemaMsg := &schema.Message{}
|
||||
|
||||
switch msg.Role {
|
||||
case "user":
|
||||
schemaMsg.Role = schema.User
|
||||
case "assistant":
|
||||
schemaMsg.Role = schema.Assistant
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown role: %s", msg.Role)
|
||||
}
|
||||
|
||||
if msg.Text != nil && *msg.Text != "" {
|
||||
schemaMsg.Content = *msg.Text
|
||||
return schemaMsg, nil
|
||||
}
|
||||
|
||||
if len(msg.MultiContent) > 0 {
|
||||
multiContent := make([]schema.ChatMessagePart, 0, len(msg.MultiContent))
|
||||
for _, part := range msg.MultiContent {
|
||||
schemaPart, err := convertContentPart(ctx, part)
|
||||
if err != nil {
|
||||
logs.CtxWarnf(ctx, "failed to convert content part, skipping: %v", err)
|
||||
continue
|
||||
}
|
||||
multiContent = append(multiContent, schemaPart)
|
||||
}
|
||||
schemaMsg.MultiContent = multiContent
|
||||
return schemaMsg, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("message has no content")
|
||||
}
|
||||
|
||||
func convertContentPart(ctx context.Context, part *conversation.Content) (schema.ChatMessagePart, error) {
|
||||
schemaPart := schema.ChatMessagePart{}
|
||||
uri := ""
|
||||
if part.Uri != nil {
|
||||
uri = *part.Uri
|
||||
}
|
||||
|
||||
switch part.Type {
|
||||
case "text":
|
||||
schemaPart.Type = schema.ChatMessagePartTypeText
|
||||
if part.Text == nil || *part.Text == "" {
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("text is empty for text content part type")
|
||||
}
|
||||
schemaPart.Text = *part.Text
|
||||
case "image":
|
||||
schemaPart.Type = schema.ChatMessagePartTypeImageURL
|
||||
url, err := workflow.GetRepository().GetObjectUrl(ctx, uri)
|
||||
if err != nil {
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("failed to get object url: %w", err)
|
||||
}
|
||||
schemaPart.ImageURL = &schema.ChatMessageImageURL{URL: url}
|
||||
case "audio":
|
||||
schemaPart.Type = schema.ChatMessagePartTypeAudioURL
|
||||
url, err := workflow.GetRepository().GetObjectUrl(ctx, uri)
|
||||
if err != nil {
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("failed to get object url: %w", err)
|
||||
}
|
||||
schemaPart.AudioURL = &schema.ChatMessageAudioURL{URL: url}
|
||||
case "video":
|
||||
schemaPart.Type = schema.ChatMessagePartTypeVideoURL
|
||||
url, err := workflow.GetRepository().GetObjectUrl(ctx, uri)
|
||||
if err != nil {
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("failed to get object url: %w", err)
|
||||
}
|
||||
schemaPart.VideoURL = &schema.ChatMessageVideoURL{URL: url}
|
||||
case "file":
|
||||
schemaPart.Type = schema.ChatMessagePartTypeFileURL
|
||||
url, err := workflow.GetRepository().GetObjectUrl(ctx, uri)
|
||||
if err != nil {
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("failed to get object url: %w", err)
|
||||
}
|
||||
schemaPart.FileURL = &schema.ChatMessageFileURL{URL: url}
|
||||
default:
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("unknown content part type: %s", part.Type)
|
||||
}
|
||||
|
||||
if schemaPart.Type != schema.ChatMessagePartTypeText && uri == "" {
|
||||
return schema.ChatMessagePart{}, fmt.Errorf("uri is empty for non-text content part type %s", part.Type)
|
||||
}
|
||||
|
||||
return schemaPart, nil
|
||||
}
|
||||
|
||||
func GetConversationHistoryFromCtx(ctx context.Context, rounds int64) ([]any, error) {
|
||||
exeCtx := execute.GetExeCtx(ctx)
|
||||
if exeCtx == nil {
|
||||
logs.CtxWarnf(ctx, "execute context is nil, skipping chat history")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
convID := exeCtx.ExeCfg.ConversationID
|
||||
agentID := exeCtx.ExeCfg.AgentID
|
||||
appID := exeCtx.ExeCfg.AppID
|
||||
userID := exeCtx.ExeCfg.Operator
|
||||
|
||||
if convID == nil || *convID == 0 {
|
||||
logs.CtxWarnf(ctx, "ConversationID is 0 or nil, skipping chat history")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var appIDVal int64
|
||||
if appID != nil {
|
||||
appIDVal = *appID
|
||||
} else if agentID != nil {
|
||||
appIDVal = *agentID
|
||||
} else {
|
||||
logs.CtxWarnf(ctx, "AppID and AgentID are both nil, skipping chat history")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
runIdsReq := &conversation.GetLatestRunIDsRequest{
|
||||
ConversationID: *convID,
|
||||
AppID: appIDVal,
|
||||
UserID: userID,
|
||||
Rounds: rounds,
|
||||
}
|
||||
|
||||
runIds, err := conversation.GetConversationManager().GetLatestRunIDs(ctx, runIdsReq)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to get conversation history: %v", err)
|
||||
return nil, nil
|
||||
}
|
||||
if len(runIds) <= 1 {
|
||||
return []any{}, nil
|
||||
}
|
||||
runIds = runIds[1:]
|
||||
|
||||
response, err := conversation.GetConversationManager().GetMessagesByRunIDs(ctx, &conversation.GetMessagesByRunIDsRequest{
|
||||
ConversationID: *convID,
|
||||
RunIDs: runIds,
|
||||
})
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to get conversation history: %v", err)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
ctxcache.Store(ctx, chatHistoryKey, response.Messages)
|
||||
messageList := make([]any, 0, len(response.Messages))
|
||||
for _, msg := range response.Messages {
|
||||
content, err := ConvertMessageToString(ctx, msg)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
messageList = append(messageList, map[string]any{
|
||||
"role": msg.Role,
|
||||
"content": content,
|
||||
})
|
||||
}
|
||||
return messageList, nil
|
||||
}
|
||||
@ -1,128 +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"
|
||||
"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
|
||||
|
||||
}
|
||||
@ -1,169 +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"
|
||||
"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,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, err)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@ -19,31 +19,27 @@ package conversation
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"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/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"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||
)
|
||||
|
||||
type CreateConversationConfig struct {
|
||||
Manager conversation.ConversationManager
|
||||
Creator conversation.ConversationManager
|
||||
}
|
||||
|
||||
type CreateConversation struct {
|
||||
config *CreateConversationConfig
|
||||
}
|
||||
|
||||
func NewCreateConversation(_ context.Context, cfg *CreateConversationConfig) (*CreateConversation, error) {
|
||||
func NewCreateConversation(ctx context.Context, cfg *CreateConversationConfig) (*CreateConversation, error) {
|
||||
if cfg == nil {
|
||||
return nil, errors.New("config is required")
|
||||
}
|
||||
if cfg.Manager == nil {
|
||||
return nil, errors.New("manager is required")
|
||||
if cfg.Creator == nil {
|
||||
return nil, errors.New("creator is required")
|
||||
}
|
||||
return &CreateConversation{
|
||||
config: cfg,
|
||||
@ -51,76 +47,16 @@ func NewCreateConversation(_ context.Context, cfg *CreateConversationConfig) (*C
|
||||
}
|
||||
|
||||
func (c *CreateConversation) 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
|
||||
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"))
|
||||
}
|
||||
|
||||
if appID == nil {
|
||||
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, errors.New("create conversation node, app id is required"))
|
||||
}
|
||||
|
||||
conversationName, ok := input["conversationName"].(string)
|
||||
name, ok := nodes.TakeMapValue(input, compose.FieldPath{"ConversationName"})
|
||||
if !ok {
|
||||
return nil, vo.WrapError(errno.ErrInvalidParameter, errors.New("conversation name is required"))
|
||||
return nil, errors.New("input map should contains 'ConversationName' key ")
|
||||
}
|
||||
|
||||
template, existed, err := workflow.GetRepository().GetConversationTemplate(ctx, env, vo.GetConversationTemplatePolicy{
|
||||
AppID: appID,
|
||||
Name: ptr.Of(conversationName),
|
||||
Version: ptr.Of(version),
|
||||
response, err := c.config.Creator.CreateConversation(ctx, &conversation.CreateConversationRequest{
|
||||
Name: name.(string),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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
|
||||
return response.Result, nil
|
||||
|
||||
}
|
||||
|
||||
@ -1,240 +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"
|
||||
"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
|
||||
}
|
||||
@ -1,96 +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"
|
||||
"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
|
||||
}
|
||||
@ -1,148 +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"
|
||||
"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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,154 +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"
|
||||
"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
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,17 +18,13 @@ package conversation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"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/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"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||
)
|
||||
|
||||
type MessageListConfig struct {
|
||||
@ -38,7 +34,14 @@ type MessageList struct {
|
||||
config *MessageListConfig
|
||||
}
|
||||
|
||||
func NewMessageList(_ context.Context, cfg *MessageListConfig) (*MessageList, error) {
|
||||
type Param struct {
|
||||
ConversationName string
|
||||
Limit *int
|
||||
BeforeID *string
|
||||
AfterID *string
|
||||
}
|
||||
|
||||
func NewMessageList(ctx context.Context, cfg *MessageListConfig) (*MessageList, error) {
|
||||
if cfg == nil {
|
||||
return nil, errors.New("config is required")
|
||||
}
|
||||
@ -53,155 +56,53 @@ func NewMessageList(_ context.Context, cfg *MessageListConfig) (*MessageList, er
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
param := &Param{}
|
||||
name, ok := nodes.TakeMapValue(input, compose.FieldPath{"ConversationName"})
|
||||
if !ok {
|
||||
return nil, vo.WrapError(errno.ErrConversationNodeInvalidOperation, errors.New("ConversationName is required"))
|
||||
return nil, 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)
|
||||
param.ConversationName = name.(string)
|
||||
limit, ok := nodes.TakeMapValue(input, compose.FieldPath{"Limit"})
|
||||
if ok {
|
||||
if limit > 0 && limit <= 50 {
|
||||
req.Limit = limit
|
||||
} else {
|
||||
req.Limit = 50
|
||||
}
|
||||
} else {
|
||||
req.Limit = 50
|
||||
limit := limit.(int)
|
||||
param.Limit = &limit
|
||||
}
|
||||
beforeID, ok := input["beforeId"].(string)
|
||||
beforeID, ok := nodes.TakeMapValue(input, compose.FieldPath{"BeforeID"})
|
||||
if ok {
|
||||
|
||||
req.BeforeID = &beforeID
|
||||
beforeID := beforeID.(string)
|
||||
param.BeforeID = &beforeID
|
||||
}
|
||||
afterID, ok := input["afterId"].(string)
|
||||
afterID, ok := nodes.TakeMapValue(input, compose.FieldPath{"AfterID"})
|
||||
if ok {
|
||||
|
||||
req.AfterID = &afterID
|
||||
afterID := afterID.(string)
|
||||
param.BeforeID = &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)
|
||||
r, err := m.config.Lister.MessageList(ctx, &conversation.ListMessageRequest{
|
||||
ConversationName: param.ConversationName,
|
||||
Limit: param.Limit,
|
||||
BeforeID: param.BeforeID,
|
||||
AfterID: param.AfterID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var messageList []any
|
||||
for _, msg := range ml.Messages {
|
||||
content, err := ConvertMessageToString(ctx, msg)
|
||||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
messageList = append(messageList, map[string]any{
|
||||
"messageId": strconv.FormatInt(msg.ID, 10),
|
||||
"role": msg.Role,
|
||||
"contentType": msg.ContentType,
|
||||
"content": content,
|
||||
})
|
||||
objects = append(objects, object)
|
||||
}
|
||||
|
||||
// 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
|
||||
result["messageList"] = objects
|
||||
result["firstId"] = r.FirstID
|
||||
result["hasMore"] = r.HasMore
|
||||
return result, nil
|
||||
|
||||
}
|
||||
|
||||
@ -1,123 +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"
|
||||
"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
|
||||
|
||||
}
|
||||
@ -29,25 +29,17 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/spf13/cast"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||
nodesconversation "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Intents []string
|
||||
SystemPrompt string
|
||||
IsFastMode bool
|
||||
ChatModel model.BaseChatModel
|
||||
ChatHistorySetting *vo.ChatHistorySetting
|
||||
Intents []string
|
||||
SystemPrompt string
|
||||
IsFastMode bool
|
||||
ChatModel model.BaseChatModel
|
||||
}
|
||||
|
||||
type contextKey string
|
||||
|
||||
const chatHistoryKey contextKey = "chatHistory"
|
||||
|
||||
const SystemIntentPrompt = `
|
||||
# Role
|
||||
You are an intention classification expert, good at being able to judge which classification the user's input belongs to.
|
||||
@ -133,7 +125,7 @@ func NewIntentDetector(ctx context.Context, cfg *Config) (*IntentDetector, error
|
||||
&schema.Message{Content: sptTemplate, Role: schema.System},
|
||||
&schema.Message{Content: "{{query}}", Role: schema.User})
|
||||
|
||||
r, err := chain.AppendChatTemplate(newHistoryChatTemplate(prompts, cfg)).AppendChatModel(cfg.ChatModel).Compile(ctx)
|
||||
r, err := chain.AppendChatTemplate(prompts).AppendChatModel(cfg.ChatModel).Compile(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -218,24 +210,3 @@ func toIntentString(its []string) string {
|
||||
itsBytes, _ := json.Marshal(vs)
|
||||
return string(itsBytes)
|
||||
}
|
||||
|
||||
func (id *IntentDetector) ToCallbackInput(ctx context.Context, in map[string]any) (map[string]any, error) {
|
||||
if id.config.ChatHistorySetting == nil || !id.config.ChatHistorySetting.EnableChatHistory {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
historyMessages, err := nodesconversation.GetConversationHistoryFromCtx(ctx, id.config.ChatHistorySetting.ChatHistoryRound)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to get conversation history: %v", err)
|
||||
return in, nil
|
||||
}
|
||||
if historyMessages == nil {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
ret := map[string]any{
|
||||
"chatHistory": historyMessages,
|
||||
"query": in["query"],
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
@ -1,101 +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 intentdetector
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/cloudwego/eino/components/prompt"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
oceanworkflow "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||
nodesconversation "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
type historyChatTemplate struct {
|
||||
basePrompt prompt.ChatTemplate
|
||||
cfg *Config
|
||||
}
|
||||
|
||||
func newHistoryChatTemplate(basePrompt prompt.ChatTemplate, cfg *Config) prompt.ChatTemplate {
|
||||
return &historyChatTemplate{
|
||||
basePrompt: basePrompt,
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *historyChatTemplate) Format(ctx context.Context, vs map[string]any, opts ...prompt.Option) ([]*schema.Message, error) {
|
||||
baseMessages, err := t.basePrompt.Format(ctx, vs, opts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to format base prompt: %w", err)
|
||||
}
|
||||
if len(baseMessages) == 0 {
|
||||
return nil, fmt.Errorf("base prompt returned no messages")
|
||||
}
|
||||
|
||||
if t.cfg.ChatHistorySetting == nil || !t.cfg.ChatHistorySetting.EnableChatHistory {
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
exeCtx := execute.GetExeCtx(ctx)
|
||||
if exeCtx == nil {
|
||||
logs.CtxWarnf(ctx, "execute context is nil, skipping chat history")
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
historyFromCtx, ok := ctxcache.Get[[]*conversation.Message](ctx, chatHistoryKey)
|
||||
var messages []*conversation.Message
|
||||
if ok {
|
||||
messages = historyFromCtx
|
||||
}
|
||||
|
||||
if len(messages) == 0 {
|
||||
logs.CtxWarnf(ctx, "conversation history is empty")
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
historyMessages := make([]*schema.Message, 0, len(messages))
|
||||
for _, msg := range messages {
|
||||
schemaMsg, err := nodesconversation.ConvertMessageToSchema(ctx, msg)
|
||||
if err != nil {
|
||||
logs.CtxWarnf(ctx, "failed to convert history message, skipping: %v", err)
|
||||
continue
|
||||
}
|
||||
historyMessages = append(historyMessages, schemaMsg)
|
||||
}
|
||||
|
||||
if len(historyMessages) == 0 {
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
finalMessages := make([]*schema.Message, 0, len(baseMessages)+len(historyMessages))
|
||||
finalMessages = append(finalMessages, baseMessages[0]) // System prompt
|
||||
finalMessages = append(finalMessages, historyMessages...)
|
||||
if len(baseMessages) > 1 {
|
||||
finalMessages = append(finalMessages, baseMessages[1:]...) // User prompt and any others
|
||||
}
|
||||
|
||||
return finalMessages, nil
|
||||
}
|
||||
@ -20,29 +20,16 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
oceanworkflow "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||
nodesconversation "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
const outputList = "outputList"
|
||||
|
||||
type contextKey string
|
||||
|
||||
const chatHistoryKey contextKey = "chatHistory"
|
||||
|
||||
type RetrieveConfig struct {
|
||||
KnowledgeIDs []int64
|
||||
RetrievalStrategy *knowledge.RetrievalStrategy
|
||||
Retriever knowledge.KnowledgeOperator
|
||||
ChatHistorySetting *vo.ChatHistorySetting
|
||||
KnowledgeIDs []int64
|
||||
RetrievalStrategy *knowledge.RetrievalStrategy
|
||||
Retriever knowledge.KnowledgeOperator
|
||||
}
|
||||
|
||||
type KnowledgeRetrieve struct {
|
||||
@ -82,7 +69,6 @@ func (kr *KnowledgeRetrieve) Retrieve(ctx context.Context, input map[string]any)
|
||||
Query: query,
|
||||
KnowledgeIDs: kr.config.KnowledgeIDs,
|
||||
RetrievalStrategy: kr.config.RetrievalStrategy,
|
||||
ChatHistory: kr.GetChatHistoryOrNil(ctx, kr.config),
|
||||
}
|
||||
|
||||
response, err := kr.config.Retriever.Retrieve(ctx, req)
|
||||
@ -99,58 +85,3 @@ func (kr *KnowledgeRetrieve) Retrieve(ctx context.Context, input map[string]any)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (kr *KnowledgeRetrieve) GetChatHistoryOrNil(ctx context.Context, cfg *RetrieveConfig) []*schema.Message {
|
||||
if cfg.ChatHistorySetting == nil || !cfg.ChatHistorySetting.EnableChatHistory {
|
||||
return nil
|
||||
}
|
||||
|
||||
exeCtx := execute.GetExeCtx(ctx)
|
||||
if exeCtx == nil {
|
||||
logs.CtxWarnf(ctx, "execute context is nil, skipping chat history")
|
||||
return nil
|
||||
}
|
||||
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
|
||||
return nil
|
||||
}
|
||||
|
||||
historyFromCtx, ok := ctxcache.Get[[]*conversation.Message](ctx, chatHistoryKey)
|
||||
var messages []*conversation.Message
|
||||
if ok {
|
||||
messages = historyFromCtx
|
||||
}
|
||||
|
||||
if len(messages) == 0 {
|
||||
logs.CtxWarnf(ctx, "conversation history is empty")
|
||||
return nil
|
||||
}
|
||||
|
||||
historyMessages := make([]*schema.Message, 0, len(messages))
|
||||
for _, msg := range messages {
|
||||
schemaMsg, err := nodesconversation.ConvertMessageToSchema(ctx, msg)
|
||||
if err != nil {
|
||||
logs.CtxWarnf(ctx, "failed to convert history message, skipping: %v", err)
|
||||
continue
|
||||
}
|
||||
historyMessages = append(historyMessages, schemaMsg)
|
||||
}
|
||||
return historyMessages
|
||||
}
|
||||
|
||||
func (kr *KnowledgeRetrieve) ToCallbackInput(ctx context.Context, in map[string]any) (map[string]any, error) {
|
||||
if kr.config.ChatHistorySetting == nil || !kr.config.ChatHistorySetting.EnableChatHistory {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
messageList, err := nodesconversation.GetConversationHistoryFromCtx(ctx, kr.config.ChatHistorySetting.ChatHistoryRound)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to get conversation history: %v", err)
|
||||
return in, nil
|
||||
}
|
||||
|
||||
ret := map[string]any{
|
||||
"chatHistory": messageList,
|
||||
"Query": in["Query"],
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ import (
|
||||
"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/domain/workflow/internal/nodes"
|
||||
nodesconversation "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
@ -51,10 +50,6 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
||||
const chatHistoryKey contextKey = "chatHistory"
|
||||
|
||||
type Format int
|
||||
|
||||
const (
|
||||
@ -173,17 +168,15 @@ type Config struct {
|
||||
ToolsReturnDirectly map[string]bool
|
||||
KnowledgeRecallConfig *KnowledgeRecallConfig
|
||||
FullSources map[string]*nodes.SourceInfo
|
||||
ChatHistorySetting *vo.ChatHistorySetting
|
||||
}
|
||||
|
||||
type LLM struct {
|
||||
r compose.Runnable[map[string]any, map[string]any]
|
||||
outputFormat Format
|
||||
outputFields map[string]*vo.TypeInfo
|
||||
canStream bool
|
||||
requireCheckpoint bool
|
||||
fullSources map[string]*nodes.SourceInfo
|
||||
ChatHistorySetting *vo.ChatHistorySetting
|
||||
r compose.Runnable[map[string]any, map[string]any]
|
||||
outputFormat Format
|
||||
outputFields map[string]*vo.TypeInfo
|
||||
canStream bool
|
||||
requireCheckpoint bool
|
||||
fullSources map[string]*nodes.SourceInfo
|
||||
}
|
||||
|
||||
const (
|
||||
@ -320,9 +313,8 @@ func New(ctx context.Context, cfg *Config) (*LLM, error) {
|
||||
sp := newPromptTpl(schema.System, cfg.SystemPrompt, inputs, nil)
|
||||
up := newPromptTpl(schema.User, userPrompt, inputs, []string{knowledgeUserPromptTemplateKey})
|
||||
template := newPrompts(sp, up, cfg.ChatModel)
|
||||
templateWithChatHistory := newPromptsWithChatHistory(template, cfg.ChatHistorySetting)
|
||||
|
||||
_ = g.AddChatTemplateNode(templateNodeKey, templateWithChatHistory,
|
||||
_ = g.AddChatTemplateNode(templateNodeKey, template,
|
||||
compose.WithStatePreHandler(func(ctx context.Context, in map[string]any, state llmState) (map[string]any, error) {
|
||||
for k, v := range state {
|
||||
in[k] = v
|
||||
@ -335,9 +327,7 @@ func New(ctx context.Context, cfg *Config) (*LLM, error) {
|
||||
sp := newPromptTpl(schema.System, cfg.SystemPrompt, cfg.InputFields, nil)
|
||||
up := newPromptTpl(schema.User, userPrompt, cfg.InputFields, nil)
|
||||
template := newPrompts(sp, up, cfg.ChatModel)
|
||||
templateWithChatHistory := newPromptsWithChatHistory(template, cfg.ChatHistorySetting)
|
||||
|
||||
_ = g.AddChatTemplateNode(templateNodeKey, templateWithChatHistory)
|
||||
_ = g.AddChatTemplateNode(templateNodeKey, template)
|
||||
|
||||
_ = g.AddEdge(compose.START, templateNodeKey)
|
||||
}
|
||||
@ -481,12 +471,11 @@ func New(ctx context.Context, cfg *Config) (*LLM, error) {
|
||||
}
|
||||
|
||||
llm := &LLM{
|
||||
r: r,
|
||||
outputFormat: format,
|
||||
canStream: canStream,
|
||||
requireCheckpoint: requireCheckpoint,
|
||||
fullSources: cfg.FullSources,
|
||||
ChatHistorySetting: cfg.ChatHistorySetting,
|
||||
r: r,
|
||||
outputFormat: format,
|
||||
canStream: canStream,
|
||||
requireCheckpoint: requireCheckpoint,
|
||||
fullSources: cfg.FullSources,
|
||||
}
|
||||
|
||||
return llm, nil
|
||||
@ -824,26 +813,6 @@ type ToolInterruptEventStore interface {
|
||||
ResumeToolInterruptEvent(llmNodeKey vo.NodeKey, toolCallID string) (string, error)
|
||||
}
|
||||
|
||||
func (l *LLM) ToCallbackInput(ctx context.Context, input map[string]any) (map[string]any, error) {
|
||||
if l.ChatHistorySetting == nil || !l.ChatHistorySetting.EnableChatHistory {
|
||||
return input, nil
|
||||
}
|
||||
|
||||
messageList, err := nodesconversation.GetConversationHistoryFromCtx(ctx, l.ChatHistorySetting.ChatHistoryRound)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to get conversation history: %v", err)
|
||||
return input, nil
|
||||
}
|
||||
|
||||
ret := map[string]any{
|
||||
"chatHistory": messageList,
|
||||
}
|
||||
for k, v := range input {
|
||||
ret[k] = v
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (l *LLM) ToCallbackOutput(ctx context.Context, output map[string]any) (*nodes.StructuredCallbackOutput, error) {
|
||||
c := execute.GetExeCtx(ctx)
|
||||
if c == nil {
|
||||
|
||||
@ -23,15 +23,11 @@ import (
|
||||
"github.com/cloudwego/eino/components/prompt"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
oceanworkflow "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/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/domain/workflow/internal/nodes"
|
||||
nodesconversation "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/conversation"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||
)
|
||||
|
||||
@ -41,11 +37,6 @@ type prompts struct {
|
||||
mwi ModelWithInfo
|
||||
}
|
||||
|
||||
type promptsWithChatHistory struct {
|
||||
prompts *prompts
|
||||
cfg *vo.ChatHistorySetting
|
||||
}
|
||||
|
||||
type promptTpl struct {
|
||||
role schema.RoleType
|
||||
tpl string
|
||||
@ -115,13 +106,6 @@ func newPrompts(sp, up *promptTpl, model ModelWithInfo) *prompts {
|
||||
}
|
||||
}
|
||||
|
||||
func newPromptsWithChatHistory(prompts *prompts, cfg *vo.ChatHistorySetting) *promptsWithChatHistory {
|
||||
return &promptsWithChatHistory{
|
||||
prompts: prompts,
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (pl *promptTpl) render(ctx context.Context, vs map[string]any,
|
||||
sources map[string]*nodes.SourceInfo,
|
||||
supportedModals map[modelmgr.Modal]bool,
|
||||
@ -303,59 +287,3 @@ func (p *prompts) Format(ctx context.Context, vs map[string]any, _ ...prompt.Opt
|
||||
|
||||
return []*schema.Message{systemMsg, userMsg}, nil
|
||||
}
|
||||
|
||||
func (p *promptsWithChatHistory) Format(ctx context.Context, vs map[string]any, _ ...prompt.Option) (
|
||||
[]*schema.Message, error) {
|
||||
baseMessages, err := p.prompts.Format(ctx, vs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if p.cfg == nil || !p.cfg.EnableChatHistory {
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
exeCtx := execute.GetExeCtx(ctx)
|
||||
if exeCtx == nil {
|
||||
logs.CtxWarnf(ctx, "execute context is nil, skipping chat history")
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
historyFromCtx, ok := ctxcache.Get[[]*conversation.Message](ctx, chatHistoryKey)
|
||||
var messages []*conversation.Message
|
||||
if ok {
|
||||
messages = historyFromCtx
|
||||
}
|
||||
|
||||
if len(messages) == 0 {
|
||||
logs.CtxWarnf(ctx, "conversation history is empty")
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
historyMessages := make([]*schema.Message, 0, len(messages))
|
||||
for _, msg := range messages {
|
||||
schemaMsg, err := nodesconversation.ConvertMessageToSchema(ctx, msg)
|
||||
if err != nil {
|
||||
logs.CtxWarnf(ctx, "failed to convert history message, skipping: %v", err)
|
||||
continue
|
||||
}
|
||||
historyMessages = append(historyMessages, schemaMsg)
|
||||
}
|
||||
|
||||
if len(historyMessages) == 0 {
|
||||
return baseMessages, nil
|
||||
}
|
||||
|
||||
finalMessages := make([]*schema.Message, 0, len(baseMessages)+len(historyMessages))
|
||||
if len(baseMessages) > 0 && baseMessages[0].Role == schema.System {
|
||||
finalMessages = append(finalMessages, baseMessages[0])
|
||||
baseMessages = baseMessages[1:]
|
||||
}
|
||||
finalMessages = append(finalMessages, historyMessages...)
|
||||
finalMessages = append(finalMessages, baseMessages...)
|
||||
|
||||
return finalMessages, nil
|
||||
}
|
||||
|
||||
@ -1,726 +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 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)
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,412 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,408 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,408 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,408 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,404 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,400 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -1,440 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@ -16,34 +16,20 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
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
|
||||
Q = new(Query)
|
||||
ConnectorWorkflowVersion *connectorWorkflowVersion
|
||||
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
|
||||
@ -55,65 +41,44 @@ 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...),
|
||||
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...),
|
||||
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...),
|
||||
}
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
db *gorm.DB
|
||||
|
||||
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
|
||||
ConnectorWorkflowVersion connectorWorkflowVersion
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,60 +92,39 @@ func (q *Query) WriteDB() *Query {
|
||||
|
||||
func (q *Query) ReplaceDB(db *gorm.DB) *Query {
|
||||
return &Query{
|
||||
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),
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
type queryCtx struct {
|
||||
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
|
||||
ConnectorWorkflowVersion IConnectorWorkflowVersionDo
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -314,16 +314,13 @@ 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,
|
||||
CommitID: draft.CommitID,
|
||||
}
|
||||
|
||||
if draft.DraftMeta != nil {
|
||||
d.Modified = draft.DraftMeta.Modified
|
||||
d.TestRunSuccess = draft.DraftMeta.TestRunSuccess
|
||||
ID: id,
|
||||
Canvas: draft.Canvas,
|
||||
InputParams: draft.InputParamsStr,
|
||||
OutputParams: draft.OutputParamsStr,
|
||||
Modified: draft.Modified,
|
||||
TestRunSuccess: draft.TestRunSuccess,
|
||||
CommitID: draft.CommitID,
|
||||
}
|
||||
|
||||
if err := r.query.WorkflowDraft.WithContext(ctx).Save(d); err != nil {
|
||||
@ -601,116 +598,6 @@ 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,
|
||||
Version: chatFlowRole.Version,
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -744,30 +631,6 @@ func (r *RepositoryImpl) GetVersion(ctx context.Context, id int64, version strin
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) GetVersionListByConnectorAndWorkflowID(ctx context.Context, connectorID, workflowID int64, limit int) (_ []string, err error) {
|
||||
defer func() {
|
||||
if err != nil {
|
||||
err = vo.WrapIfNeeded(errno.ErrDatabaseError, err)
|
||||
}
|
||||
}()
|
||||
|
||||
connectorWorkflowVersion := r.query.ConnectorWorkflowVersion
|
||||
vl, err := connectorWorkflowVersion.WithContext(ctx).
|
||||
Where(connectorWorkflowVersion.ConnectorID.Eq(connectorID),
|
||||
connectorWorkflowVersion.WorkflowID.Eq(workflowID)).
|
||||
Order(connectorWorkflowVersion.CreatedAt.Desc()).
|
||||
Limit(limit).
|
||||
Find()
|
||||
if err != nil {
|
||||
return nil, vo.WrapError(errno.ErrDatabaseError, err)
|
||||
}
|
||||
var versionList []string
|
||||
for _, v := range vl {
|
||||
versionList = append(versionList, v.Version)
|
||||
}
|
||||
return versionList, nil
|
||||
}
|
||||
|
||||
func (r *RepositoryImpl) IsApplicationConnectorWorkflowVersion(ctx context.Context, connectorID, workflowID int64, version string) (b bool, err error) {
|
||||
connectorWorkflowVersion := r.query.ConnectorWorkflowVersion
|
||||
_, err = connectorWorkflowVersion.WithContext(ctx).
|
||||
@ -898,10 +761,6 @@ 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"`
|
||||
@ -1654,7 +1513,6 @@ func (r *RepositoryImpl) CopyWorkflow(ctx context.Context, workflowID int64, pol
|
||||
IconURI: wfMeta.IconURI,
|
||||
Desc: wfMeta.Description,
|
||||
AppID: ternary.IFElse(wfMeta.AppID == 0, (*int64)(nil), ptr.Of(wfMeta.AppID)),
|
||||
Mode: vo.WorkflowMode(wfMeta.Mode),
|
||||
},
|
||||
CanvasInfo: &vo.CanvasInfo{
|
||||
Canvas: wfDraft.Canvas,
|
||||
@ -1725,10 +1583,6 @@ 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) {
|
||||
|
||||
@ -1,337 +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 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)
|
||||
}
|
||||
@ -61,8 +61,6 @@ func (i *impl) SyncExecute(ctx context.Context, config vo.ExecuteConfig, input m
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
config.WorkflowMode = wfEntity.Mode
|
||||
|
||||
isApplicationWorkflow := wfEntity.AppID != nil
|
||||
if isApplicationWorkflow && config.Mode == vo.ExecuteModeRelease {
|
||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||
@ -208,8 +206,6 @@ func (i *impl) AsyncExecute(ctx context.Context, config vo.ExecuteConfig, input
|
||||
return 0, err
|
||||
}
|
||||
|
||||
config.WorkflowMode = wfEntity.Mode
|
||||
|
||||
isApplicationWorkflow := wfEntity.AppID != nil
|
||||
if isApplicationWorkflow && config.Mode == vo.ExecuteModeRelease {
|
||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||
@ -295,8 +291,6 @@ func (i *impl) AsyncExecuteNode(ctx context.Context, nodeID string, config vo.Ex
|
||||
return 0, err
|
||||
}
|
||||
|
||||
config.WorkflowMode = wfEntity.Mode
|
||||
|
||||
isApplicationWorkflow := wfEntity.AppID != nil
|
||||
if isApplicationWorkflow && config.Mode == vo.ExecuteModeRelease {
|
||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||
|
||||
@ -1,26 +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 service
|
||||
|
||||
import (
|
||||
"github.com/cloudwego/eino/callbacks"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||
)
|
||||
|
||||
func GetTokenCallbackHandler() callbacks.Handler {
|
||||
return execute.GetTokenCallbackHandler()
|
||||
}
|
||||
@ -52,7 +52,6 @@ type impl struct {
|
||||
repo workflow.Repository
|
||||
*asToolImpl
|
||||
*executableImpl
|
||||
*conversationImpl
|
||||
}
|
||||
|
||||
func NewWorkflowService(repo workflow.Repository) workflow.Service {
|
||||
@ -64,7 +63,6 @@ func NewWorkflowService(repo workflow.Repository) workflow.Service {
|
||||
executableImpl: &executableImpl{
|
||||
repo: repo,
|
||||
},
|
||||
conversationImpl: &conversationImpl{repo: repo},
|
||||
}
|
||||
}
|
||||
|
||||
@ -431,7 +429,7 @@ func (i *impl) collectNodePropertyMap(ctx context.Context, canvas *vo.Canvas) (m
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
blockType, err := entity.NodeTypeToBlockType(nodeSchema.Type)
|
||||
blockType, err := entityNodeTypeToBlockType(nodeSchema.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -483,7 +481,7 @@ func (i *impl) collectNodePropertyMap(ctx context.Context, canvas *vo.Canvas) (m
|
||||
return nil, err
|
||||
}
|
||||
for _, nodeSchema := range nodeSchemas {
|
||||
blockType, err := entity.NodeTypeToBlockType(nodeSchema.Type)
|
||||
blockType, err := entityNodeTypeToBlockType(nodeSchema.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -500,146 +498,6 @@ 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) GetWorkflowVersionsByConnector(ctx context.Context, connectorID, workflowID int64, limit int) ([]string, error) {
|
||||
return i.repo.GetVersionListByConnectorAndWorkflowID(ctx, connectorID, workflowID, limit)
|
||||
}
|
||||
|
||||
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 {
|
||||
@ -921,24 +779,6 @@ func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, con
|
||||
}
|
||||
}
|
||||
|
||||
err = i.ReleaseConversationTemplate(ctx, appID, config.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, wf := range wfs {
|
||||
if wf.Mode == cloudworkflow.WorkflowMode_ChatFlow {
|
||||
err = i.PublishChatFlowRole(ctx, &vo.PublishRolePolicy{
|
||||
WorkflowID: wf.ID,
|
||||
CreatorID: wf.CreatorID,
|
||||
Version: 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 {
|
||||
@ -1593,55 +1433,6 @@ func (i *impl) GetWorkflowDependenceResource(ctx context.Context, workflowID int
|
||||
|
||||
}
|
||||
|
||||
// checkBotAgentNodes checks for rules related to BotAgent.
|
||||
// It returns an error with the reason if the check fails.
|
||||
func (i *impl) checkBotAgentNodes(nodes []*vo.Node) error {
|
||||
for _, node := range nodes {
|
||||
if node.Type == vo.BlockTypeCreateConversation || node.Type == vo.BlockTypeConversationDelete || node.Type == vo.BlockTypeConversationUpdate || node.Type == vo.BlockTypeConversationList {
|
||||
return errors.New("不支持在对话流内添加会话相关节点")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *impl) WorkflowSchemaCheck(ctx context.Context, wf *entity.Workflow, checks []cloudworkflow.CheckType) ([]*cloudworkflow.CheckResult, error) {
|
||||
if len(checks) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
nodeList, err := GetAllNodesRecursively(ctx, wf, i.repo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
checkResults := make([]*cloudworkflow.CheckResult, 0, len(checks))
|
||||
for _, checkType := range checks {
|
||||
var checkErr error
|
||||
switch checkType {
|
||||
case cloudworkflow.CheckType_BotAgent:
|
||||
checkErr = i.checkBotAgentNodes(nodeList)
|
||||
// TODO: Add other cases here for new check types
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
if checkErr != nil {
|
||||
checkResults = append(checkResults, &cloudworkflow.CheckResult{
|
||||
IsPass: false,
|
||||
Reason: checkErr.Error(),
|
||||
Type: checkType,
|
||||
})
|
||||
} else {
|
||||
checkResults = append(checkResults, &cloudworkflow.CheckResult{
|
||||
IsPass: true,
|
||||
Type: checkType,
|
||||
Reason: "",
|
||||
})
|
||||
}
|
||||
}
|
||||
return checkResults, nil
|
||||
}
|
||||
|
||||
func (i *impl) MGet(ctx context.Context, policy *vo.MGetPolicy) ([]*entity.Workflow, int64, error) {
|
||||
if policy.MetaOnly {
|
||||
metas, total, err := i.repo.MGetMetas(ctx, &policy.MetaQuery)
|
||||
|
||||
@ -23,14 +23,12 @@ import (
|
||||
"strings"
|
||||
|
||||
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/crossdomain/variable"
|
||||
"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/canvas/adaptor"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/validate"
|
||||
"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/sonic"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
@ -287,70 +285,6 @@ func replaceRelatedWorkflowOrPluginInWorkflowNodes(nodes []*vo.Node, relatedWork
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAllNodesRecursively(ctx context.Context, wfEntity *entity.Workflow, repo workflow.Repository) ([]*vo.Node, error) {
|
||||
visited := make(map[string]struct{})
|
||||
allNodes := make([]*vo.Node, 0)
|
||||
err := getAllNodesRecursiveHelper(ctx, wfEntity, repo, visited, &allNodes)
|
||||
return allNodes, err
|
||||
}
|
||||
|
||||
func getAllNodesRecursiveHelper(ctx context.Context, wfEntity *entity.Workflow, repo workflow.Repository, visited map[string]struct{}, allNodes *[]*vo.Node) error {
|
||||
visitedKey := fmt.Sprintf("%d:%s", wfEntity.ID, wfEntity.GetVersion())
|
||||
if _, ok := visited[visitedKey]; ok {
|
||||
return nil
|
||||
}
|
||||
visited[visitedKey] = struct{}{}
|
||||
|
||||
var canvas vo.Canvas
|
||||
if err := sonic.UnmarshalString(wfEntity.Canvas, &canvas); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal canvas for workflow %d: %w", wfEntity.ID, err)
|
||||
}
|
||||
|
||||
return collectNodes(ctx, canvas.Nodes, repo, visited, allNodes)
|
||||
}
|
||||
|
||||
func collectNodes(ctx context.Context, nodes []*vo.Node, repo workflow.Repository, visited map[string]struct{}, allNodes *[]*vo.Node) error {
|
||||
for _, node := range nodes {
|
||||
if node == nil {
|
||||
continue
|
||||
}
|
||||
*allNodes = append(*allNodes, node)
|
||||
|
||||
if node.Type == vo.BlockTypeBotSubWorkflow && node.Data != nil && node.Data.Inputs != nil {
|
||||
workflowIDStr := node.Data.Inputs.WorkflowID
|
||||
if workflowIDStr == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
workflowID, err := strconv.ParseInt(workflowIDStr, 10, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid workflow ID in sub-workflow node %s: %w", node.ID, err)
|
||||
}
|
||||
|
||||
subWfEntity, err := repo.GetEntity(ctx, &vo.GetPolicy{
|
||||
ID: workflowID,
|
||||
QType: ternary.IFElse(len(node.Data.Inputs.WorkflowVersion) == 0, vo.FromDraft, vo.FromSpecificVersion),
|
||||
Version: node.Data.Inputs.WorkflowVersion,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get sub-workflow entity %d: %w", workflowID, err)
|
||||
}
|
||||
|
||||
if err := getAllNodesRecursiveHelper(ctx, subWfEntity, repo, visited, allNodes); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if len(node.Blocks) > 0 {
|
||||
if err := collectNodes(ctx, node.Blocks, repo, visited, allNodes); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// entityNodeTypeToBlockType converts an entity.NodeType to the corresponding vo.BlockType.
|
||||
func entityNodeTypeToBlockType(nodeType entity.NodeType) (vo.BlockType, error) {
|
||||
switch nodeType {
|
||||
|
||||
@ -54,12 +54,11 @@ require github.com/alicebob/miniredis/v2 v2.34.0
|
||||
|
||||
require (
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.2
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.84.1
|
||||
github.com/cloudwego/eino-ext/components/embedding/ark v0.0.0-20250522060253-ddb617598b09
|
||||
github.com/cloudwego/eino-ext/components/embedding/ollama v0.0.0-20250728060543-79ec300857b8
|
||||
github.com/cloudwego/eino-ext/components/embedding/openai v0.0.0-20250522060253-ddb617598b09
|
||||
github.com/cloudwego/eino-ext/components/model/gemini v0.1.2
|
||||
github.com/cloudwego/eino-ext/components/model/ollama v0.1.0
|
||||
github.com/cloudwego/eino-ext/components/model/ollama v0.0.0-20250610035057-2c4e7c8488a5
|
||||
github.com/cloudwego/eino-ext/components/model/qwen v0.0.0-20250612061754-5a3deb091dc5
|
||||
github.com/dimchansky/utfbom v1.1.1
|
||||
github.com/elastic/go-elasticsearch/v7 v7.17.10
|
||||
@ -85,6 +84,7 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.37 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.18 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.84.1 // indirect
|
||||
github.com/cloudwego/gopkg v0.1.4 // indirect
|
||||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
|
||||
github.com/extrame/ole2 v0.0.0-20160812065207-d69429661ad7 // indirect
|
||||
@ -111,10 +111,10 @@ require (
|
||||
require (
|
||||
github.com/anthropics/anthropic-sdk-go v1.4.0 // indirect
|
||||
github.com/avast/retry-go v3.0.0+incompatible // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.6
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.6 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.11 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/config v1.29.1
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.54
|
||||
github.com/aws/aws-sdk-go-v2/config v1.29.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.54 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.24 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.37 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.37 // indirect
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user