fix(singleagent): chatsdk shortcmd is not display (#1981)

main
junwen-lee 2 months ago committed by GitHub
parent f7b5096d69
commit 18a1b7e3ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 935
      backend/api/model/app/bot_common/bot_common.go
  2. 62
      backend/application/singleagent/single_agent.go
  3. 58
      backend/crossdomain/contract/agent/single_agent.go
  4. 18
      idl/app/bot_common.thrift

File diff suppressed because it is too large Load Diff

@ -38,6 +38,7 @@ import (
"github.com/coze-dev/coze-studio/backend/api/model/data/database/table"
"github.com/coze-dev/coze-studio/backend/api/model/playground"
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/agent"
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
singleagent "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/service"
@ -733,16 +734,64 @@ func (s *SingleAgentApplicationService) getAgentInfo(ctx context.Context, botID
sc := &bot_common.ShortcutCommandComponent{
Name: i.Name,
Description: i.Description,
Type: i.InputType.String(),
Type: getShortcutCommandComponentType(i.InputType),
ToolParameter: ptr.Of(i.Parameter),
Options: i.Options,
IsHide: i.Hide,
}
if i.DefaultValue != nil {
sc.DefaultValue = ptr.Of(i.DefaultValue.Value)
}
switch i.InputType {
case playground.InputType_Select:
sc.Options = i.Options
case playground.InputType_MixUpload:
options := make([]string, 0, len(i.UploadOptions))
for _, uploadOption := range i.UploadOptions {
options = append(options, string(getShortcutCommandComponentFileType(uploadOption)))
}
sc.Options = options
case playground.InputType_UploadImage, playground.InputType_UploadDoc, playground.InputType_UploadTable, playground.InputType_UploadAudio,
playground.InputType_VIDEO, playground.InputType_ARCHIVE, playground.InputType_CODE, playground.InputType_TXT,
playground.InputType_PPT:
sc.Options = []string{string(getShortcutCommandComponentFileType(i.InputType))}
default:
}
return sc
}),
Tool: &bot_common.ShortcutCommandToolInfo{
Name: si.ToolInfo.ToolName,
Type: func() string {
if si.ToolType == 1 {
return string(agent.ShortcutCommandToolTypePlugin)
}
if si.ToolType == 2 {
return string(agent.ShortcutCommandToolTypeWorkflow)
}
return ""
}(),
PluginID: ptr.Of(si.PluginID),
WorkflowID: ptr.Of(si.WorkFlowID),
PluginAPIName: &si.PluginToolName,
Params: slices.Transform(si.ToolInfo.ToolParamsList, func(i *playground.ToolParams) *bot_common.ShortcutToolParam {
return &bot_common.ShortcutToolParam{
Name: i.Name,
Type: i.Type,
DefaultValue: i.DefaultValue,
IsReferComponent: i.ReferComponent,
IsRequired: i.Required,
Description: i.Desc,
}
}),
},
SendType: func() *bot_common.ShortcutSendType {
if si.SendType == 1 {
return ptr.Of(bot_common.ShortcutSendTypePanel)
}
return ptr.Of(bot_common.ShortcutSendTypeQuery)
}(),
CardSchema: ptr.Of(si.CardSchema),
}
})
@ -767,3 +816,12 @@ func (s *SingleAgentApplicationService) OpenGetBotInfo(ctx context.Context, req
resp.Data = agentInfo
return resp, nil
}
func getShortcutCommandComponentType(inputType playground.InputType) string {
componentType := agent.ShortcutCommandComponentTypeMapping[inputType]
return string(componentType)
}
func getShortcutCommandComponentFileType(inputType playground.InputType) string {
return string(agent.ShortcutCommandComponentFileTypeMapping[inputType])
}

@ -23,6 +23,7 @@ import (
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent"
"github.com/coze-dev/coze-studio/backend/api/model/playground"
)
// Requests and responses must not reference domain entities and can only use models under api/model/crossdomain.
@ -59,3 +60,60 @@ func DefaultSVC() SingleAgent {
func SetDefaultSVC(svc SingleAgent) {
defaultSVC = svc
}
type ShortcutCommandComponentType string
const (
ShortcutCommandComponentTypeText ShortcutCommandComponentType = "text"
ShortcutCommandComponentTypeSelect ShortcutCommandComponentType = "select"
ShortcutCommandComponentTypeFile ShortcutCommandComponentType = "file"
)
var ShortcutCommandComponentTypeMapping = map[playground.InputType]ShortcutCommandComponentType{
playground.InputType_TextInput: ShortcutCommandComponentTypeText,
playground.InputType_Select: ShortcutCommandComponentTypeSelect,
playground.InputType_MixUpload: ShortcutCommandComponentTypeFile,
playground.InputType_UploadImage: ShortcutCommandComponentTypeFile,
playground.InputType_UploadDoc: ShortcutCommandComponentTypeFile,
playground.InputType_UploadTable: ShortcutCommandComponentTypeFile,
playground.InputType_UploadAudio: ShortcutCommandComponentTypeFile,
playground.InputType_VIDEO: ShortcutCommandComponentTypeFile,
playground.InputType_ARCHIVE: ShortcutCommandComponentTypeFile,
playground.InputType_CODE: ShortcutCommandComponentTypeFile,
playground.InputType_TXT: ShortcutCommandComponentTypeFile,
playground.InputType_PPT: ShortcutCommandComponentTypeFile,
}
type ShortcutCommandComponentFileType string
const (
ShortcutCommandComponentFileTypeImage ShortcutCommandComponentFileType = "image"
ShortcutCommandComponentFileTypeDoc ShortcutCommandComponentFileType = "doc"
ShortcutCommandComponentFileTypeTable ShortcutCommandComponentFileType = "table"
ShortcutCommandComponentFileTypeAudio ShortcutCommandComponentFileType = "audio"
ShortcutCommandComponentFileTypeVideo ShortcutCommandComponentFileType = "video"
ShortcutCommandComponentFileTypeZip ShortcutCommandComponentFileType = "zip"
ShortcutCommandComponentFileTypeCode ShortcutCommandComponentFileType = "code"
ShortcutCommandComponentFileTypeTxt ShortcutCommandComponentFileType = "txt"
ShortcutCommandComponentFileTypePPT ShortcutCommandComponentFileType = "ppt"
)
var ShortcutCommandComponentFileTypeMapping = map[playground.InputType]ShortcutCommandComponentFileType{
playground.InputType_UploadImage: ShortcutCommandComponentFileTypeImage,
playground.InputType_UploadDoc: ShortcutCommandComponentFileTypeDoc,
playground.InputType_UploadTable: ShortcutCommandComponentFileTypeTable,
playground.InputType_UploadAudio: ShortcutCommandComponentFileTypeAudio,
playground.InputType_VIDEO: ShortcutCommandComponentFileTypeVideo,
playground.InputType_ARCHIVE: ShortcutCommandComponentFileTypeZip,
playground.InputType_CODE: ShortcutCommandComponentFileTypeCode,
playground.InputType_TXT: ShortcutCommandComponentFileTypeTxt,
playground.InputType_PPT: ShortcutCommandComponentFileTypePPT,
}
type ShortcutCommandToolType string
const (
ShortcutCommandToolTypeWorkflow ShortcutCommandToolType = "workflow"
ShortcutCommandToolTypePlugin ShortcutCommandToolType = "plugin"
)

@ -487,10 +487,26 @@ struct ShortcutCommandComponent { // Panel parameters
7 : bool is_hide // Whether to hide or not to show, the shortcut command of the online bot tool type does not return the component with hide = true
}
struct ShortcutToolParam {
1: string name
2: bool is_required
3: string description
4: string type
5: string default_value
6: bool is_refer_component
}
struct ShortcutCommandToolInfo {
1: string name //
2: string type // Tool type workflow plugin
3: optional i64 plugin_id (api.js_conv="true")
4: optional string plugin_api_name
5: optional i64 workflow_id (api.js_conv="true")
6: optional list<ShortcutToolParam> params
}
typedef string ShortcutSendType
const ShortcutSendType ShortcutSendTypeQuery = 'query'
const ShortcutSendType ShortcutSendTypePanel = 'panel'
struct ShortcutCommandInfo {
1: i64 id (api.js_conv="true") // Quick Command ID
@ -502,6 +518,8 @@ struct ShortcutCommandInfo {
7: optional list<ShortcutCommandComponent> components // Component list (parameter list)
8: optional ShortcutCommandToolInfo tool // Tool information
9: optional i64 agent_id (api.js_conv="true") //When the multi instruction is executed by which node, it will not be returned without configuration
10: optional ShortcutSendType send_type // chatsdk used
11: optional string card_schema // chatsdk schema
}

Loading…
Cancel
Save