mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-10-13 19:21:08 +02:00
Add files via upload
This commit is contained in:
2 files changed
+22
-10
No files matched your search
+11
-10
@@ -163,16 +163,17 @@ type ToolConfig struct {
|
|||||||
|
|
||||||
// ParameterConfig 参数配置
|
// ParameterConfig 参数配置
|
||||||
type ParameterConfig struct {
|
type ParameterConfig struct {
|
||||||
Name string `yaml:"name"` // 参数名称
|
Name string `yaml:"name"` // 参数名称
|
||||||
Type string `yaml:"type"` // 参数类型: string, int, bool, array
|
Type string `yaml:"type"` // 参数类型: string, int, bool, array
|
||||||
Description string `yaml:"description"` // 参数描述
|
Description string `yaml:"description"` // 参数描述
|
||||||
Required bool `yaml:"required,omitempty"` // 是否必需
|
Required bool `yaml:"required,omitempty"` // 是否必需
|
||||||
Default interface{} `yaml:"default,omitempty"` // 默认值
|
Default interface{} `yaml:"default,omitempty"` // 默认值
|
||||||
Flag string `yaml:"flag,omitempty"` // 命令行标志,如 "-u", "--url", "-p"
|
ItemType string `yaml:"item_type,omitempty"` // 当 type 为 array 时,数组元素类型,如 string, number, object
|
||||||
Position *int `yaml:"position,omitempty"` // 位置参数的位置(从0开始)
|
Flag string `yaml:"flag,omitempty"` // 命令行标志,如 "-u", "--url", "-p"
|
||||||
Format string `yaml:"format,omitempty"` // 参数格式: "flag", "positional", "combined" (flag=value), "template"
|
Position *int `yaml:"position,omitempty"` // 位置参数的位置(从0开始)
|
||||||
Template string `yaml:"template,omitempty"` // 模板字符串,如 "{flag} {value}" 或 "{value}"
|
Format string `yaml:"format,omitempty"` // 参数格式: "flag", "positional", "combined" (flag=value), "template"
|
||||||
Options []string `yaml:"options,omitempty"` // 可选值列表(用于枚举)
|
Template string `yaml:"template,omitempty"` // 模板字符串,如 "{flag} {value}" 或 "{value}"
|
||||||
|
Options []string `yaml:"options,omitempty"` // 可选值列表(用于枚举)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load(path string) (*Config, error) {
|
func Load(path string) (*Config, error) {
|
||||||
|
|||||||
@@ -1229,6 +1229,17 @@ func (e *Executor) buildInputSchema(toolConfig *config.ToolConfig) map[string]in
|
|||||||
"description": param.Description,
|
"description": param.Description,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSON Schema/OpenAI 要求 array 类型必须包含 items,否则 API 报 invalid_function_parameters
|
||||||
|
if openAIType == "array" {
|
||||||
|
itemType := strings.TrimSpace(param.ItemType)
|
||||||
|
if itemType == "" {
|
||||||
|
itemType = "string"
|
||||||
|
}
|
||||||
|
prop["items"] = map[string]interface{}{
|
||||||
|
"type": e.convertToOpenAIType(itemType),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 添加默认值
|
// 添加默认值
|
||||||
if param.Default != nil {
|
if param.Default != nil {
|
||||||
prop["default"] = param.Default
|
prop["default"] = param.Default
|
||||||
|
|||||||
Reference in new issue
Block a user