fix(translator): handle non-string types in tools result processing
- Skip setting values for non-string `type` fields to prevent runtime errors. Closes: #2226
This commit is contained in:
@@ -284,7 +284,11 @@ func ConvertGeminiRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
|
||||
util.Walk(toolsResult, "", "type", &pathsToLower)
|
||||
for _, p := range pathsToLower {
|
||||
fullPath := fmt.Sprintf("tools.%s", p)
|
||||
out, _ = sjson.SetBytes(out, fullPath, strings.ToLower(gjson.GetBytes(out, fullPath).String()))
|
||||
typeValue := gjson.GetBytes(out, fullPath)
|
||||
if typeValue.Type != gjson.String {
|
||||
continue
|
||||
}
|
||||
out, _ = sjson.SetBytes(out, fullPath, strings.ToLower(typeValue.String()))
|
||||
}
|
||||
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user