diff --git a/internal/types/entities/plugin_entities/config.go b/internal/types/entities/plugin_entities/config.go index e2537d3..5c9fd70 100644 --- a/internal/types/entities/plugin_entities/config.go +++ b/internal/types/entities/plugin_entities/config.go @@ -10,17 +10,19 @@ import ( type ConfigType string const ( - CONFIG_TYPE_SECRET_INPUT ConfigType = SECRET_INPUT - CONFIG_TYPE_TEXT_INPUT ConfigType = TEXT_INPUT - CONFIG_TYPE_SELECT ConfigType = SELECT - CONFIG_TYPE_BOOLEAN ConfigType = BOOLEAN - CONFIG_TYPE_MODEL_CONFIG ConfigType = MODEL_CONFIG - CONFIG_TYPE_APP_SELECTOR ConfigType = APP_SELECTOR + CONFIG_TYPE_SECRET_INPUT ConfigType = SECRET_INPUT + CONFIG_TYPE_TEXT_INPUT ConfigType = TEXT_INPUT + CONFIG_TYPE_SELECT ConfigType = SELECT + CONFIG_TYPE_BOOLEAN ConfigType = BOOLEAN + CONFIG_TYPE_MODEL_CONFIG ConfigType = MODEL_CONFIG + CONFIG_TYPE_APP_SELECTOR ConfigType = APP_SELECTOR + CONFIG_TYPE_TOOL_SELECTOR ConfigType = TOOL_SELECTOR ) type ModelConfigScope string const ( + MODEL_CONFIG_SCOPE_ALL ModelConfigScope = "all" MODEL_CONFIG_SCOPE_LLM ModelConfigScope = "llm" MODEL_CONFIG_SCOPE_TEXT_EMBEDDING ModelConfigScope = "text-embedding" MODEL_CONFIG_SCOPE_RERANK ModelConfigScope = "rerank" @@ -39,6 +41,15 @@ const ( APP_SELECTOR_SCOPE_COMPLETION AppSelectorScope = "completion" ) +type ToolSelectorScope string + +const ( + TOOL_SELECTOR_SCOPE_ALL ToolSelectorScope = "all" + TOOL_SELECTOR_SCOPE_PLUGIN ToolSelectorScope = "plugin" + TOOL_SELECTOR_SCOPE_API ToolSelectorScope = "api" + TOOL_SELECTOR_SCOPE_WORKFLOW ToolSelectorScope = "workflow" +) + func isCredentialType(fl validator.FieldLevel) bool { value := fl.Field().String() switch value { @@ -84,6 +95,17 @@ func isAppSelectorScope(fl validator.FieldLevel) bool { return false } +func isToolSelectorScope(fl validator.FieldLevel) bool { + value := fl.Field().String() + switch value { + case string(TOOL_SELECTOR_SCOPE_ALL), + string(TOOL_SELECTOR_SCOPE_PLUGIN), + string(TOOL_SELECTOR_SCOPE_API), + string(TOOL_SELECTOR_SCOPE_WORKFLOW): + return true + } + return false +} func isScope(fl validator.FieldLevel) bool { // get parent and check if it's a provider config parent := fl.Parent().Interface() @@ -93,6 +115,8 @@ func isScope(fl validator.FieldLevel) bool { return isAppSelectorScope(fl) } else if provider_config.Type == CONFIG_TYPE_MODEL_CONFIG { return isModelConfigScope(fl) + } else if provider_config.Type == CONFIG_TYPE_TOOL_SELECTOR { + return isToolSelectorScope(fl) } else { return false } @@ -143,6 +167,19 @@ func init() { return t }, ) + + validators.GlobalEntitiesValidator.RegisterValidation("is_tool_selector_scope", isToolSelectorScope) + validators.GlobalEntitiesValidator.RegisterTranslation( + "is_tool_selector_scope", + translator, + func(ut ut.Translator) error { + return ut.Add("is_tool_selector_scope", "{0} is not a valid tool selector scope", true) + }, + func(ut ut.Translator, fe validator.FieldError) string { + t, _ := ut.T("is_tool_selector_scope", fe.Field()) + return t + }, + ) } type ProviderConfig struct { diff --git a/internal/types/entities/plugin_entities/constant.go b/internal/types/entities/plugin_entities/constant.go index 946d1c3..e07cc6a 100644 --- a/internal/types/entities/plugin_entities/constant.go +++ b/internal/types/entities/plugin_entities/constant.go @@ -1,13 +1,14 @@ package plugin_entities const ( - SECRET_INPUT = "secret-input" - TEXT_INPUT = "text-input" - SELECT = "select" - STRING = "string" - NUMBER = "number" - FILE = "file" - BOOLEAN = "boolean" - APP_SELECTOR = "app-selector" - MODEL_CONFIG = "model-config" + SECRET_INPUT = "secret-input" + TEXT_INPUT = "text-input" + SELECT = "select" + STRING = "string" + NUMBER = "number" + FILE = "file" + BOOLEAN = "boolean" + APP_SELECTOR = "app-selector" + MODEL_CONFIG = "model-config" + TOOL_SELECTOR = "tool-selector" ) diff --git a/internal/types/entities/plugin_entities/tool_configuration.go b/internal/types/entities/plugin_entities/tool_configuration.go index 46639ba..941cf93 100644 --- a/internal/types/entities/plugin_entities/tool_configuration.go +++ b/internal/types/entities/plugin_entities/tool_configuration.go @@ -26,14 +26,15 @@ type ToolParameterOption struct { type ToolParameterType string const ( - TOOL_PARAMETER_TYPE_STRING ToolParameterType = STRING - TOOL_PARAMETER_TYPE_NUMBER ToolParameterType = NUMBER - TOOL_PARAMETER_TYPE_BOOLEAN ToolParameterType = BOOLEAN - TOOL_PARAMETER_TYPE_SELECT ToolParameterType = SELECT - TOOL_PARAMETER_TYPE_SECRET_INPUT ToolParameterType = SECRET_INPUT - TOOL_PARAMETER_TYPE_FILE ToolParameterType = FILE - TOOL_PARAMETER_TYPE_APP_SELECTOR ToolParameterType = APP_SELECTOR - TOOL_PARAMETER_TYPE_MODEL_CONFIG ToolParameterType = MODEL_CONFIG + TOOL_PARAMETER_TYPE_STRING ToolParameterType = STRING + TOOL_PARAMETER_TYPE_NUMBER ToolParameterType = NUMBER + TOOL_PARAMETER_TYPE_BOOLEAN ToolParameterType = BOOLEAN + TOOL_PARAMETER_TYPE_SELECT ToolParameterType = SELECT + TOOL_PARAMETER_TYPE_SECRET_INPUT ToolParameterType = SECRET_INPUT + TOOL_PARAMETER_TYPE_FILE ToolParameterType = FILE + TOOL_PARAMETER_TYPE_APP_SELECTOR ToolParameterType = APP_SELECTOR + TOOL_PARAMETER_TYPE_MODEL_CONFIG ToolParameterType = MODEL_CONFIG + TOOL_PARAMETER_TYPE_TOOL_SELECTOR ToolParameterType = TOOL_SELECTOR ) func isToolParameterType(fl validator.FieldLevel) bool { @@ -46,7 +47,8 @@ func isToolParameterType(fl validator.FieldLevel) bool { string(TOOL_PARAMETER_TYPE_SECRET_INPUT), string(TOOL_PARAMETER_TYPE_FILE), string(TOOL_PARAMETER_TYPE_APP_SELECTOR), - string(TOOL_PARAMETER_TYPE_MODEL_CONFIG): + string(TOOL_PARAMETER_TYPE_MODEL_CONFIG), + string(TOOL_PARAMETER_TYPE_TOOL_SELECTOR): return true } return false