fix: add direction parameter support for scroll operations in UI-TARS parser

- Handle direction parameter in convertProcessedArgs for scroll actions
- Ensure scroll operations map to swipe with both coordinates and direction
- Add comprehensive test coverage for scroll action parsing
- Fix issue where scroll direction was missing from tool call arguments
This commit is contained in:
lilong.129
2025-06-10 16:40:10 +08:00
parent c322d7c36c
commit 98bd41ff33
5 changed files with 105 additions and 3 deletions
+20
View File
@@ -290,6 +290,26 @@ func convertProcessedArgs(processedArgs map[string]interface{}, actionType strin
return options.ToMap(), nil
}
// For scroll operations, handle both coordinates and direction
if actionType == "scroll" && hasStartBox {
startCoords, ok := startBox.([]float64)
if !ok {
return nil, fmt.Errorf("invalid coordinate format for scroll operation")
}
options := option.ActionOptions{
X: builtin.RoundToOneDecimal(startCoords[0]),
Y: builtin.RoundToOneDecimal(startCoords[1]),
}
// Add direction parameter if present
if direction, hasDirection := processedArgs["direction"]; hasDirection {
options.Direction = direction.(string)
}
return options.ToMap(), nil
}
// For single coordinate operations, return the coordinate array directly
if hasStartBox {
startCoords, ok := startBox.([]float64)