change: remove unused code

This commit is contained in:
lilong.129 2025-03-19 22:47:10 +08:00
parent a4d3c08a6a
commit b5f3e7ff96
5 changed files with 8 additions and 57 deletions

View File

@ -1 +1 @@
v5.0.0-beta-2503192228 v5.0.0-beta-2503192247

View File

@ -55,5 +55,4 @@ const (
ActionTypeCallUser ActionType = "call_user" ActionTypeCallUser ActionType = "call_user"
ActionTypeType ActionType = "type" ActionTypeType ActionType = "type"
ActionTypeScroll ActionType = "scroll" ActionTypeScroll ActionType = "scroll"
ActionTypeHotkey ActionType = "hotkey"
) )

View File

@ -110,7 +110,6 @@ func (p *ActionParser) parseActionText(actionText, thought string) ([]ParsedActi
"left_double": regexp.MustCompile(`left_double\(start_box='([^']+)'\)`), "left_double": regexp.MustCompile(`left_double\(start_box='([^']+)'\)`),
"right_single": regexp.MustCompile(`right_single\(start_box='([^']+)'\)`), "right_single": regexp.MustCompile(`right_single\(start_box='([^']+)'\)`),
"drag": regexp.MustCompile(`drag\(start_box='([^']+)', end_box='([^']+)'\)`), "drag": regexp.MustCompile(`drag\(start_box='([^']+)', end_box='([^']+)'\)`),
"hotkey": regexp.MustCompile(`hotkey\(key='([^']+)'\)`),
"type": regexp.MustCompile(`type\(content='([^']+)'\)`), "type": regexp.MustCompile(`type\(content='([^']+)'\)`),
"scroll": regexp.MustCompile(`scroll\(start_box='([^']+)', direction='([^']+)'\)`), "scroll": regexp.MustCompile(`scroll\(start_box='([^']+)', direction='([^']+)'\)`),
"wait": regexp.MustCompile(`wait\(\)`), "wait": regexp.MustCompile(`wait\(\)`),
@ -156,10 +155,6 @@ func (p *ActionParser) parseActionText(actionText, thought string) ([]ParsedActi
} }
action.ActionInputs["endBox"] = endBox action.ActionInputs["endBox"] = endBox
} }
case ActionTypeHotkey:
if len(matches) > 1 {
action.ActionInputs["key"] = matches[1]
}
case ActionTypeType: case ActionTypeType:
if len(matches) > 1 { if len(matches) > 1 {
action.ActionInputs["content"] = matches[1] action.ActionInputs["content"] = matches[1]

View File

@ -167,13 +167,8 @@ func processVLMResponse(actions []ParsedAction) (*PlanningResult, error) {
case "drag": case "drag":
validateCoordinateAction(&actions[i], "startBox") validateCoordinateAction(&actions[i], "startBox")
validateCoordinateAction(&actions[i], "endBox") validateCoordinateAction(&actions[i], "endBox")
case "scroll":
validateCoordinateAction(&actions[i], "startBox")
validateScrollDirection(&actions[i])
case "type": case "type":
validateTypeContent(&actions[i]) validateTypeContent(&actions[i])
case "hotkey":
validateHotkeyAction(&actions[i])
case "wait", "finished", "call_user": case "wait", "finished", "call_user":
// these actions do not need extra parameters // these actions do not need extra parameters
default: default:
@ -208,22 +203,12 @@ func extractActionSummary(actions []ParsedAction) string {
return "点击操作" return "点击操作"
case "drag": case "drag":
return "拖拽操作" return "拖拽操作"
case "left_double":
return "双击操作"
case "right_single":
return "右键点击操作"
case "scroll":
direction, _ := action.ActionInputs["direction"].(string)
return fmt.Sprintf("滚动操作 (%s)", direction)
case "type": case "type":
content, _ := action.ActionInputs["content"].(string) content, _ := action.ActionInputs["content"].(string)
if len(content) > 20 { if len(content) > 20 {
content = content[:20] + "..." content = content[:20] + "..."
} }
return fmt.Sprintf("输入文本: %s", content) return fmt.Sprintf("输入文本: %s", content)
case "hotkey":
key, _ := action.ActionInputs["key"].(string)
return fmt.Sprintf("快捷键: %s", key)
case "wait": case "wait":
return "等待操作" return "等待操作"
case "finished": case "finished":
@ -240,22 +225,6 @@ func validateCoordinateAction(action *ParsedAction, boxField string) {
// TODO // TODO
} }
// validateScrollDirection 验证滚动方向
func validateScrollDirection(action *ParsedAction) {
if direction, ok := action.ActionInputs["direction"].(string); !ok || direction == "" {
// default to down
action.ActionInputs["direction"] = "down"
} else {
switch strings.ToLower(direction) {
case "up", "down", "left", "right":
// keep original direction
default:
action.ActionInputs["direction"] = "down"
log.Warn().Str("direction", direction).Msg("invalid scroll direction, set to default")
}
}
}
// validateTypeContent 验证输入文本内容 // validateTypeContent 验证输入文本内容
func validateTypeContent(action *ParsedAction) { func validateTypeContent(action *ParsedAction) {
if content, ok := action.ActionInputs["content"]; !ok || content == "" { if content, ok := action.ActionInputs["content"]; !ok || content == "" {
@ -265,15 +234,6 @@ func validateTypeContent(action *ParsedAction) {
} }
} }
// validateHotkeyAction 验证快捷键动作
func validateHotkeyAction(action *ParsedAction) {
if key, ok := action.ActionInputs["key"]; !ok || key == "" {
// 为空或缺失的键设置默认值
action.ActionInputs["key"] = "Enter"
log.Printf("警告: hotkey动作缺少key参数, 已设置默认值")
}
}
// SavePositionImg saves an image with position markers // SavePositionImg saves an image with position markers
func SavePositionImg(params struct { func SavePositionImg(params struct {
InputImgBase64 string InputImgBase64 string

View File

@ -8,16 +8,13 @@ Thought: ...
Action: ... Action: ...
## Action Space ## Action Space
click(start_box='[x1, y1, x2, y2]') click(start_box='<|box_start|>(x1,y1)<|box_end|>')
left_double(start_box='[x1, y1, x2, y2]') long_press(start_box='<|box_start|>(x1,y1)<|box_end|>', time='')
right_single(start_box='[x1, y1, x2, y2]') type(content='')
drag(start_box='[x1, y1, x2, y2]', end_box='[x3, y3, x4, y4]') drag(start_box='<|box_start|>(x1,y1)<|box_end|>', end_box='<|box_start|>(x3,y3)<|box_end|>')
hotkey(key='') press_home()
type(content='') #If you want to submit your input, use "\n" at the end of content. press_back()
scroll(start_box='[x1, y1, x2, y2]', direction='down or up or right or left') finished(content='') # Submit the task regardless of whether it succeeds or fails.
wait() #Sleep for 5s and take a screenshot to check for any changes.
finished()
call_user() # Submit the task and call the user when the task is unsolvable, or when you need the user's help.
## Note ## Note
- Use Chinese in Thought part. - Use Chinese in Thought part.