feature: Improves schema flattening and tool use handling

Updates schema flattening logic to handle multiple non-null types, providing a more descriptive "Accepts" hint.

Removes redundant tracking of the current tool name in `Params` as it's no longer needed for streaming limits, simplifying the structure.
This commit is contained in:
이대희
2025-12-17 17:30:23 +09:00
parent 27734a23b1
commit aea337cfe2
3 changed files with 35 additions and 8 deletions

View File

@@ -222,21 +222,30 @@ func flattenTypeArrays(jsonStr string) string {
continue
}
hasNull, firstType := false, ""
hasNull := false
var nonNullTypes []string
for _, item := range res.Array() {
s := item.String()
if s == "null" {
hasNull = true
} else if firstType == "" {
firstType = s
} else if s != "" {
nonNullTypes = append(nonNullTypes, s)
}
}
if firstType == "" {
firstType = "string"
firstType := "string"
if len(nonNullTypes) > 0 {
firstType = nonNullTypes[0]
}
jsonStr, _ = sjson.Set(jsonStr, p, firstType)
parentPath := trimSuffix(p, ".type")
if len(nonNullTypes) > 1 {
hint := "Accepts: " + strings.Join(nonNullTypes, " | ")
jsonStr = appendHint(jsonStr, parentPath, hint)
}
if hasNull {
parts := strings.Split(p, ".")
if len(parts) >= 3 && parts[len(parts)-3] == "properties" {