From b5f3e7ff96e21586fa2b8e8fe6c484e114971a09 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 19 Mar 2025 22:47:10 +0800 Subject: [PATCH] change: remove unused code --- internal/version/VERSION | 2 +- uixt/ai/llm.go | 1 - uixt/ai/parser.go | 5 ----- uixt/ai/planner.go | 40 --------------------------------------- uixt/ai/prompt-ui-tars.go | 17 +++++++---------- 5 files changed, 8 insertions(+), 57 deletions(-) diff --git a/internal/version/VERSION b/internal/version/VERSION index 68e980f5..8fb242b1 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2503192228 +v5.0.0-beta-2503192247 diff --git a/uixt/ai/llm.go b/uixt/ai/llm.go index 711b7a8d..7ff3888e 100644 --- a/uixt/ai/llm.go +++ b/uixt/ai/llm.go @@ -55,5 +55,4 @@ const ( ActionTypeCallUser ActionType = "call_user" ActionTypeType ActionType = "type" ActionTypeScroll ActionType = "scroll" - ActionTypeHotkey ActionType = "hotkey" ) diff --git a/uixt/ai/parser.go b/uixt/ai/parser.go index 68e308da..cc7ecf1e 100644 --- a/uixt/ai/parser.go +++ b/uixt/ai/parser.go @@ -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] diff --git a/uixt/ai/planner.go b/uixt/ai/planner.go index 7e0ef9ab..6aa3f672 100644 --- a/uixt/ai/planner.go +++ b/uixt/ai/planner.go @@ -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 diff --git a/uixt/ai/prompt-ui-tars.go b/uixt/ai/prompt-ui-tars.go index e503ebc8..76af2def 100644 --- a/uixt/ai/prompt-ui-tars.go +++ b/uixt/ai/prompt-ui-tars.go @@ -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.