瀏覽代碼

fix: agent output schema

Yeuoly 6 月之前
父節點
當前提交
3e6e49671d
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      pkg/entities/plugin_entities/tool_declaration.go

+ 11 - 2
pkg/entities/plugin_entities/tool_declaration.go

@@ -140,9 +140,18 @@ type ToolDeclaration struct {
 
 func isJSONSchema(fl validator.FieldLevel) bool {
 	// get schema from interface
-	schemaMap, ok := fl.Field().Interface().(ToolOutputSchema)
+	schemaMapInf := fl.Field().Interface()
+	// convert to map[string]any
+	var schemaMap map[string]any
+	toolSchemaMap, ok := schemaMapInf.(ToolOutputSchema)
 	if !ok {
-		return false
+		agentSchemaMap, ok := schemaMapInf.(AgentStrategyOutputSchema)
+		if !ok {
+			return false
+		}
+		schemaMap = agentSchemaMap
+	} else {
+		schemaMap = toolSchemaMap
 	}
 
 	// validate root schema must be object type