change: remove unused code
This commit is contained in:
parent
a4d3c08a6a
commit
b5f3e7ff96
|
@ -1 +1 @@
|
|||
v5.0.0-beta-2503192228
|
||||
v5.0.0-beta-2503192247
|
||||
|
|
|
@ -55,5 +55,4 @@ const (
|
|||
ActionTypeCallUser ActionType = "call_user"
|
||||
ActionTypeType ActionType = "type"
|
||||
ActionTypeScroll ActionType = "scroll"
|
||||
ActionTypeHotkey ActionType = "hotkey"
|
||||
)
|
||||
|
|
|
@ -110,7 +110,6 @@ func (p *ActionParser) parseActionText(actionText, thought string) ([]ParsedActi
|
|||
"left_double": regexp.MustCompile(`left_double\(start_box='([^']+)'\)`),
|
||||
"right_single": regexp.MustCompile(`right_single\(start_box='([^']+)'\)`),
|
||||
"drag": regexp.MustCompile(`drag\(start_box='([^']+)', end_box='([^']+)'\)`),
|
||||
"hotkey": regexp.MustCompile(`hotkey\(key='([^']+)'\)`),
|
||||
"type": regexp.MustCompile(`type\(content='([^']+)'\)`),
|
||||
"scroll": regexp.MustCompile(`scroll\(start_box='([^']+)', direction='([^']+)'\)`),
|
||||
"wait": regexp.MustCompile(`wait\(\)`),
|
||||
|
@ -156,10 +155,6 @@ func (p *ActionParser) parseActionText(actionText, thought string) ([]ParsedActi
|
|||
}
|
||||
action.ActionInputs["endBox"] = endBox
|
||||
}
|
||||
case ActionTypeHotkey:
|
||||
if len(matches) > 1 {
|
||||
action.ActionInputs["key"] = matches[1]
|
||||
}
|
||||
case ActionTypeType:
|
||||
if len(matches) > 1 {
|
||||
action.ActionInputs["content"] = matches[1]
|
||||
|
|
|
@ -167,13 +167,8 @@ func processVLMResponse(actions []ParsedAction) (*PlanningResult, error) {
|
|||
case "drag":
|
||||
validateCoordinateAction(&actions[i], "startBox")
|
||||
validateCoordinateAction(&actions[i], "endBox")
|
||||
case "scroll":
|
||||
validateCoordinateAction(&actions[i], "startBox")
|
||||
validateScrollDirection(&actions[i])
|
||||
case "type":
|
||||
validateTypeContent(&actions[i])
|
||||
case "hotkey":
|
||||
validateHotkeyAction(&actions[i])
|
||||
case "wait", "finished", "call_user":
|
||||
// these actions do not need extra parameters
|
||||
default:
|
||||
|
@ -208,22 +203,12 @@ func extractActionSummary(actions []ParsedAction) string {
|
|||
return "点击操作"
|
||||
case "drag":
|
||||
return "拖拽操作"
|
||||
case "left_double":
|
||||
return "双击操作"
|
||||
case "right_single":
|
||||
return "右键点击操作"
|
||||
case "scroll":
|
||||
direction, _ := action.ActionInputs["direction"].(string)
|
||||
return fmt.Sprintf("滚动操作 (%s)", direction)
|
||||
case "type":
|
||||
content, _ := action.ActionInputs["content"].(string)
|
||||
if len(content) > 20 {
|
||||
content = content[:20] + "..."
|
||||
}
|
||||
return fmt.Sprintf("输入文本: %s", content)
|
||||
case "hotkey":
|
||||
key, _ := action.ActionInputs["key"].(string)
|
||||
return fmt.Sprintf("快捷键: %s", key)
|
||||
case "wait":
|
||||
return "等待操作"
|
||||
case "finished":
|
||||
|
@ -240,22 +225,6 @@ func validateCoordinateAction(action *ParsedAction, boxField string) {
|
|||
// 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 验证输入文本内容
|
||||
func validateTypeContent(action *ParsedAction) {
|
||||
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
|
||||
func SavePositionImg(params struct {
|
||||
InputImgBase64 string
|
||||
|
|
|
@ -8,16 +8,13 @@ Thought: ...
|
|||
Action: ...
|
||||
|
||||
## Action Space
|
||||
click(start_box='[x1, y1, x2, y2]')
|
||||
left_double(start_box='[x1, y1, x2, y2]')
|
||||
right_single(start_box='[x1, y1, x2, y2]')
|
||||
drag(start_box='[x1, y1, x2, y2]', end_box='[x3, y3, x4, y4]')
|
||||
hotkey(key='')
|
||||
type(content='') #If you want to submit your input, use "\n" at the end of content.
|
||||
scroll(start_box='[x1, y1, x2, y2]', direction='down or up or right or left')
|
||||
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.
|
||||
click(start_box='<|box_start|>(x1,y1)<|box_end|>')
|
||||
long_press(start_box='<|box_start|>(x1,y1)<|box_end|>', time='')
|
||||
type(content='')
|
||||
drag(start_box='<|box_start|>(x1,y1)<|box_end|>', end_box='<|box_start|>(x3,y3)<|box_end|>')
|
||||
press_home()
|
||||
press_back()
|
||||
finished(content='') # Submit the task regardless of whether it succeeds or fails.
|
||||
|
||||
## Note
|
||||
- Use Chinese in Thought part.
|
||||
|
|
Loading…
Reference in New Issue