feat(backend): support open api for chat flow run

This commit is contained in:
zhuangjie.1125
2025-07-31 15:40:27 +08:00
committed by lvxinyu.1117
parent f9bbdffa02
commit 3b6408de6e
11 changed files with 34 additions and 34 deletions

View File

@ -80,7 +80,7 @@ func staticFileRegister(r *server.Hertz) {
"code": 0,
"msg": "ok",
"data": map[string]interface{}{
"access_token": "pat_ab1212d883ba6e0a63c28dd47a6e13629f7d5885b78b55d933e9caf9aae737c2",
"access_token": "pat_5732f3b083385561af45c67ac93ab67ff41e81dd82b27d4581688237841d81af",
"expires_in": 1753998220,
"token_type": "Bearer",
},

View File

@ -26,7 +26,7 @@ import (
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossmessage"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"

View File

@ -18,7 +18,7 @@ package vo
import (
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
)
type ExecuteConfig struct {

View File

@ -23,7 +23,7 @@ import (
"strings"
"github.com/cloudwego/eino/schema"
oceanworkflow "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
workflow2 "github.com/coze-dev/coze-studio/backend/api/model/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"
@ -163,7 +163,7 @@ func GetConversationHistoryFromCtx(ctx context.Context, rounds int64) ([]any, er
return nil, nil
}
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
if exeCtx.ExeCfg.WorkflowMode != workflow2.WorkflowMode_ChatFlow {
return nil, nil
}

View File

@ -21,7 +21,7 @@ import (
"errors"
"fmt"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
"github.com/coze-dev/coze-studio/backend/api/model/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"

View File

@ -22,7 +22,7 @@ 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/api/model/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"
@ -62,7 +62,7 @@ func (t *historyChatTemplate) Format(ctx context.Context, vs map[string]any, opt
return baseMessages, nil
}
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
if exeCtx.ExeCfg.WorkflowMode != workflow.WorkflowMode_ChatFlow {
return baseMessages, nil
}

View File

@ -23,7 +23,7 @@ import (
"github.com/spf13/cast"
einoSchema "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/api/model/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"
@ -221,7 +221,7 @@ func (kr *Retrieve) GetChatHistoryOrNil(ctx context.Context, ChatHistorySetting
logs.CtxWarnf(ctx, "execute context is nil, skipping chat history")
return nil
}
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
if exeCtx.ExeCfg.WorkflowMode != workflow.WorkflowMode_ChatFlow {
return nil
}

View File

@ -23,7 +23,7 @@ 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/api/model/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"
@ -321,7 +321,7 @@ func (p *promptsWithChatHistory) Format(ctx context.Context, vs map[string]any,
return baseMessages, nil
}
if exeCtx.ExeCfg.WorkflowMode != oceanworkflow.WorkflowMode_ChatFlow {
if exeCtx.ExeCfg.WorkflowMode != workflow.WorkflowMode_ChatFlow {
return baseMessages, nil
}

View File

@ -20,7 +20,7 @@ import (
"context"
"fmt"
cloudworkflow "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
workflow2 "github.com/coze-dev/coze-studio/backend/api/model/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"
@ -220,7 +220,7 @@ func (c *conversationImpl) findReplaceWorkflowByConversationName(ctx context.Con
QType: vo.FromDraft,
MetaQuery: vo.MetaQuery{
AppID: ptr.Of(appID),
Mode: ptr.Of(cloudworkflow.WorkflowMode_ChatFlow),
Mode: ptr.Of(workflow2.WorkflowMode_ChatFlow),
},
})
if err != nil {

View File

@ -22,8 +22,8 @@ import (
"strconv"
"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/api/model/workflow"
wf "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"
@ -105,17 +105,17 @@ func validateWorkflowTree(ctx context.Context, config vo.ValidateTreeConfig) ([]
return issues, nil
}
func convertToValidationError(issue *validate.Issue) *cloudworkflow.ValidateErrorData {
e := &cloudworkflow.ValidateErrorData{}
func convertToValidationError(issue *validate.Issue) *workflow.ValidateErrorData {
e := &workflow.ValidateErrorData{}
e.Message = issue.Message
if issue.NodeErr != nil {
e.Type = cloudworkflow.ValidateErrorType_BotValidateNodeErr
e.NodeError = &cloudworkflow.NodeError{
e.Type = workflow.ValidateErrorType_BotValidateNodeErr
e.NodeError = &workflow.NodeError{
NodeID: issue.NodeErr.NodeID,
}
} else if issue.PathErr != nil {
e.Type = cloudworkflow.ValidateErrorType_BotValidatePathErr
e.PathError = &cloudworkflow.PathError{
e.Type = workflow.ValidateErrorType_BotValidatePathErr
e.PathError = &workflow.PathError{
Start: issue.PathErr.StartNode,
End: issue.PathErr.EndNode,
}
@ -124,8 +124,8 @@ func convertToValidationError(issue *validate.Issue) *cloudworkflow.ValidateErro
return e
}
func toValidateErrorData(issues []*validate.Issue) []*cloudworkflow.ValidateErrorData {
validateErrors := make([]*cloudworkflow.ValidateErrorData, 0, len(issues))
func toValidateErrorData(issues []*validate.Issue) []*workflow.ValidateErrorData {
validateErrors := make([]*workflow.ValidateErrorData, 0, len(issues))
for _, issue := range issues {
validateErrors = append(validateErrors, convertToValidationError(issue))
}
@ -201,14 +201,14 @@ func isIncremental(prev version, next version) bool {
return next.Patch > prev.Patch
}
func GetAllNodesRecursively(ctx context.Context, wfEntity *entity.Workflow, repo workflow.Repository) ([]*vo.Node, error) {
func GetAllNodesRecursively(ctx context.Context, wfEntity *entity.Workflow, repo wf.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 {
func getAllNodesRecursiveHelper(ctx context.Context, wfEntity *entity.Workflow, repo wf.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
@ -223,7 +223,7 @@ func getAllNodesRecursiveHelper(ctx context.Context, wfEntity *entity.Workflow,
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 {
func collectNodes(ctx context.Context, nodes []*vo.Node, repo wf.Repository, visited map[string]struct{}, allNodes *[]*vo.Node) error {
for _, node := range nodes {
if node == nil {
continue

View File

@ -11,23 +11,23 @@ CREATE TABLE IF NOT EXISTS `api_key` (`id` bigint unsigned NOT NULL AUTO_INCREME
-- Create 'app_connector_release_ref' table
CREATE TABLE IF NOT EXISTS `app_connector_release_ref` (`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Primary Key', `record_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Publish Record ID', `connector_id` bigint unsigned NULL COMMENT 'Publish Connector ID', `publish_config` json NULL COMMENT 'Publish Configuration', `publish_status` tinyint NOT NULL DEFAULT 0 COMMENT 'Publish Status', `created_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Create Time in Milliseconds', `updated_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Update Time in Milliseconds', PRIMARY KEY (`id`), UNIQUE INDEX `uniq_record_connector` (`record_id`, `connector_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Connector Release Record Reference';
-- Create 'app_conversation_template_draft' table
CREATE TABLE IF NOT EXISTS `app_conversation_template_draft` (`id` bigint unsigned NOT NULL COMMENT `id`, `app_id` bigint unsigned NOT NULL COMMENT `app id`, `space_id` bigint unsigned NOT NULL COMMENT `space id`, `name` varchar(256) NOT NULL COMMENT `conversation name`, `template_id` bigint unsigned NOT NULL COMMENT `template id`, `creator_id` bigint unsigned NOT NULL COMMENT `creator id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, `updated_at` bigint unsigned NULL COMMENT `update time in millisecond`, `deleted_at` datetime(3) NULL COMMENT `delete time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_space_id_app_id_template_id` (`space_id`, `app_id`, `template_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `app_conversation_template_draft` (`id` bigint unsigned NOT NULL COMMENT 'id', `app_id` bigint unsigned NOT NULL COMMENT 'app id', `space_id` bigint unsigned NOT NULL COMMENT 'space id', `name` varchar(256) NOT NULL COMMENT 'conversation name', `template_id` bigint unsigned NOT NULL COMMENT 'template id', `creator_id` bigint unsigned NOT NULL COMMENT 'creator id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', `updated_at` bigint unsigned NULL COMMENT 'update time in millisecond', `deleted_at` datetime(3) NULL COMMENT 'delete time in millisecond', PRIMARY KEY (`id`), INDEX `idx_space_id_app_id_template_id` (`space_id`, `app_id`, `template_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'app_conversation_template_online' table
CREATE TABLE IF NOT EXISTS `app_conversation_template_online` (`id` bigint unsigned NOT NULL COMMENT `id`, `app_id` bigint unsigned NOT NULL COMMENT `app id`, `space_id` bigint unsigned NOT NULL COMMENT `space id`, `name` varchar(256) NOT NULL COMMENT `conversation name`, `template_id` bigint unsigned NOT NULL COMMENT `template id`, `version` varchar(256) NOT NULL COMMENT `version name`, `creator_id` bigint unsigned NOT NULL COMMENT `creator id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_space_id_app_id_template_id_version` (`space_id`, `app_id`, `template_id`, `version`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `app_conversation_template_online` (`id` bigint unsigned NOT NULL COMMENT 'id', `app_id` bigint unsigned NOT NULL COMMENT 'app id', `space_id` bigint unsigned NOT NULL COMMENT 'space id', `name` varchar(256) NOT NULL COMMENT 'conversation name', `template_id` bigint unsigned NOT NULL COMMENT 'template id', `version` varchar(256) NOT NULL COMMENT 'version name', `creator_id` bigint unsigned NOT NULL COMMENT 'creator id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', PRIMARY KEY (`id`), INDEX `idx_space_id_app_id_template_id_version` (`space_id`, `app_id`, `template_id`, `version`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'app_draft' table
CREATE TABLE IF NOT EXISTS `app_draft` (`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'APP ID', `space_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Space ID', `owner_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner ID', `icon_uri` varchar(512) NOT NULL DEFAULT '' COMMENT 'Icon URI', `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Application Name', `description` text NULL COMMENT 'Application Description', `created_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Create Time in Milliseconds', `updated_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Update Time in Milliseconds', `deleted_at` datetime NULL COMMENT 'Delete Time', PRIMARY KEY (`id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Draft Application';
-- Create 'app_dynamic_conversation_draft' table
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_draft` (`id` bigint unsigned NOT NULL COMMENT `id`, `app_id` bigint unsigned NOT NULL COMMENT `app id`, `name` varchar(256) NOT NULL COMMENT `conversation name`, `user_id` bigint unsigned NOT NULL COMMENT `user id`, `connector_id` bigint unsigned NOT NULL COMMENT `connector id`, `conversation_id` bigint unsigned NOT NULL COMMENT `conversation id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, `deleted_at` datetime(3) NULL COMMENT `delete time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`), INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_draft` (`id` bigint unsigned NOT NULL COMMENT 'id', `app_id` bigint unsigned NOT NULL COMMENT 'app id', `name` varchar(256) NOT NULL COMMENT 'conversation name', `user_id` bigint unsigned NOT NULL COMMENT 'user id', `connector_id` bigint unsigned NOT NULL COMMENT 'connector id', `conversation_id` bigint unsigned NOT NULL COMMENT 'conversation id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', `deleted_at` datetime(3) NULL COMMENT 'delete time in millisecond', PRIMARY KEY (`id`), INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`), INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'app_dynamic_conversation_online' table
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_online` (`id` bigint unsigned NOT NULL COMMENT `id`, `app_id` bigint unsigned NOT NULL COMMENT `app id`, `name` varchar(256) NOT NULL COMMENT `conversation name`, `user_id` bigint unsigned NOT NULL COMMENT `user id`, `connector_id` bigint unsigned NOT NULL COMMENT `connector id`, `conversation_id` bigint unsigned NOT NULL COMMENT `conversation id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, `deleted_at` datetime(3) NULL COMMENT `delete time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`), INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `app_dynamic_conversation_online` (`id` bigint unsigned NOT NULL COMMENT 'id', `app_id` bigint unsigned NOT NULL COMMENT 'app id', `name` varchar(256) NOT NULL COMMENT 'conversation name', `user_id` bigint unsigned NOT NULL COMMENT 'user id', `connector_id` bigint unsigned NOT NULL COMMENT 'connector id', `conversation_id` bigint unsigned NOT NULL COMMENT 'conversation id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', `deleted_at` datetime(3) NULL COMMENT 'delete time in millisecond', PRIMARY KEY (`id`), INDEX `idx_app_id_connector_id_user_id` (`app_id`, `connector_id`, `user_id`), INDEX `idx_connector_id_user_id_name` (`connector_id`, `user_id`, `name`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'app_release_record' table
CREATE TABLE IF NOT EXISTS `app_release_record` (`id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Publish Record ID', `app_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Application ID', `space_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Space ID', `owner_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner ID', `icon_uri` varchar(512) NOT NULL DEFAULT '' COMMENT 'Icon URI', `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Application Name', `description` text NULL COMMENT 'Application Description', `connector_ids` json NULL COMMENT 'Publish Connector IDs', `extra_info` json NULL COMMENT 'Publish Extra Info', `version` varchar(255) NOT NULL DEFAULT '' COMMENT 'Release Version', `version_desc` text NULL COMMENT 'Version Description', `publish_status` tinyint NOT NULL DEFAULT 0 COMMENT 'Publish Status', `publish_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Publish Time in Milliseconds', `created_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Create Time in Milliseconds', `updated_at` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'Update Time in Milliseconds', PRIMARY KEY (`id`), INDEX `idx_app_publish_at` (`app_id`, `publish_at`), UNIQUE INDEX `uniq_idx_app_version_connector` (`app_id`, `version`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'Application Release Record';
-- Create 'app_static_conversation_draft' table
CREATE TABLE IF NOT EXISTS `app_static_conversation_draft` (`id` bigint unsigned NOT NULL COMMENT `id`, `template_id` bigint unsigned NOT NULL COMMENT `template id`, `user_id` bigint unsigned NOT NULL COMMENT `user id`, `connector_id` bigint unsigned NOT NULL COMMENT `connector id`, `conversation_id` bigint unsigned NOT NULL COMMENT `conversation id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, `deleted_at` datetime(3) NULL COMMENT `delete time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `app_static_conversation_draft` (`id` bigint unsigned NOT NULL COMMENT 'id', `template_id` bigint unsigned NOT NULL COMMENT 'template id', `user_id` bigint unsigned NOT NULL COMMENT 'user id', `connector_id` bigint unsigned NOT NULL COMMENT 'connector id', `conversation_id` bigint unsigned NOT NULL COMMENT 'conversation id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', `deleted_at` datetime(3) NULL COMMENT 'delete time in millisecond', PRIMARY KEY (`id`), INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'app_static_conversation_online' table
CREATE TABLE IF NOT EXISTS `app_static_conversation_online` (`id` bigint unsigned NOT NULL COMMENT `id`, `template_id` bigint unsigned NOT NULL COMMENT `template id`, `user_id` bigint unsigned NOT NULL COMMENT `user id`, `connector_id` bigint unsigned NOT NULL COMMENT `connector id`, `conversation_id` bigint unsigned NOT NULL COMMENT `conversation id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `app_static_conversation_online` (`id` bigint unsigned NOT NULL COMMENT 'id', `template_id` bigint unsigned NOT NULL COMMENT 'template id', `user_id` bigint unsigned NOT NULL COMMENT 'user id', `connector_id` bigint unsigned NOT NULL COMMENT 'connector id', `conversation_id` bigint unsigned NOT NULL COMMENT 'conversation id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', PRIMARY KEY (`id`), INDEX `idx_connector_id_user_id_template_id` (`connector_id`, `user_id`, `template_id`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'chat_flow_role_config' table
CREATE TABLE IF NOT EXISTS `chat_flow_role_config` ( `id` bigint unsigned NOT NULL COMMENT `id`, `workflow_id` bigint unsigned NOT NULL COMMENT `workflow id`, `connector_id` bigint unsigned NULL COMMENT `connector id`, `name` varchar(256) NOT NULL COMMENT `role name`, `description` mediumtext NOT NULL COMMENT `role description`, `version` varchar(256) NOT NULL COMMENT `version`, `avatar` varchar(256) NOT NULL COMMENT `avatar uri`, `background_image_info` mediumtext NOT NULL COMMENT `background image information, object structure`, `onboarding_info` mediumtext NOT NULL COMMENT `intro information, object structure`, `suggest_reply_info` mediumtext NOT NULL COMMENT `user suggestions, object structure`, `audio_config` mediumtext NOT NULL COMMENT `agent audio config, object structure`, `user_input_config` varchar(256) NOT NULL COMMENT `user input config, object structure`, `creator_id` bigint unsigned NOT NULL COMMENT `creator id`, `created_at` bigint unsigned NOT NULL COMMENT `create time in millisecond`, `updated_at` bigint unsigned NULL COMMENT `update time in millisecond`, `deleted_at` datetime(3) NULL COMMENT `delete time in millisecond`, PRIMARY KEY (`id`), INDEX `idx_connector_id_version` (`connector_id`, `version`), INDEX `idx_workflow_id_version` (`workflow_id`, `version`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `chat_flow_role_config` ( `id` bigint unsigned NOT NULL COMMENT 'id', `workflow_id` bigint unsigned NOT NULL COMMENT 'workflow id', `connector_id` bigint unsigned NULL COMMENT 'connector id', `name` varchar(256) NOT NULL COMMENT 'role name', `description` mediumtext NOT NULL COMMENT 'role description', `version` varchar(256) NOT NULL COMMENT 'version', `avatar` varchar(256) NOT NULL COMMENT 'avatar uri', `background_image_info` mediumtext NOT NULL COMMENT 'background image information, object structure', `onboarding_info` mediumtext NOT NULL COMMENT 'intro information, object structure', `suggest_reply_info` mediumtext NOT NULL COMMENT 'user suggestions, object structure', `audio_config` mediumtext NOT NULL COMMENT 'agent audio config, object structure', `user_input_config` varchar(256) NOT NULL COMMENT 'user input config, object structure', `creator_id` bigint unsigned NOT NULL COMMENT 'creator id', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', `updated_at` bigint unsigned NULL COMMENT 'update time in millisecond', `deleted_at` datetime(3) NULL COMMENT 'delete time in millisecond', PRIMARY KEY (`id`), INDEX `idx_connector_id_version` (`connector_id`, `version`), INDEX `idx_workflow_id_version` (`workflow_id`, `version`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Create 'connector_workflow_version' table
CREATE TABLE IF NOT EXISTS `connector_workflow_version` (`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `app_id` bigint unsigned NOT NULL COMMENT 'app id', `connector_id` bigint unsigned NOT NULL COMMENT 'connector id', `workflow_id` bigint unsigned NOT NULL COMMENT 'workflow id', `version` varchar(256) NOT NULL COMMENT 'version', `created_at` bigint unsigned NOT NULL COMMENT 'create time in millisecond', PRIMARY KEY (`id`), INDEX `idx_connector_id_workflow_id_create_at` (`connector_id`, `workflow_id`, `created_at`), UNIQUE INDEX `uniq_connector_id_workflow_id_version` (`connector_id`, `workflow_id`, `version`)) ENGINE=InnoDB CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'connector workflow version';
-- Create 'conversation' table