From f46fcfb4566ef6e20fdcb3810e36ae06dc6a8438 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Sat, 22 Mar 2025 01:19:23 +0800 Subject: [PATCH] fix: parse result for finished type --- internal/version/VERSION | 2 +- uixt/ai/parser.go | 2 +- uixt/ai/planner_test.go | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/internal/version/VERSION b/internal/version/VERSION index be4eb6ed..258aa071 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2503220107 +v5.0.0-beta-2503220119 diff --git a/uixt/ai/parser.go b/uixt/ai/parser.go index cc7ecf1e..e9ef3b1f 100644 --- a/uixt/ai/parser.go +++ b/uixt/ai/parser.go @@ -113,7 +113,7 @@ func (p *ActionParser) parseActionText(actionText, thought string) ([]ParsedActi "type": regexp.MustCompile(`type\(content='([^']+)'\)`), "scroll": regexp.MustCompile(`scroll\(start_box='([^']+)', direction='([^']+)'\)`), "wait": regexp.MustCompile(`wait\(\)`), - "finished": regexp.MustCompile(`finished\(\)`), + "finished": regexp.MustCompile(`finished\(content='([^']+)'\)`), "call_user": regexp.MustCompile(`call_user\(\)`), } diff --git a/uixt/ai/planner_test.go b/uixt/ai/planner_test.go index dd264493..989875fb 100644 --- a/uixt/ai/planner_test.go +++ b/uixt/ai/planner_test.go @@ -93,9 +93,6 @@ func TestVLMPlanning(t *testing.T) { } func TestXHSPlanning(t *testing.T) { - err := loadEnv() - require.NoError(t, err) - imageBase64, size, err := loadImage("testdata/xhs-feed.jpeg") require.NoError(t, err) @@ -165,6 +162,39 @@ func TestXHSPlanning(t *testing.T) { } } +func TestChatList(t *testing.T) { + imageBase64, size, err := loadImage("testdata/chat_list.jpeg") + require.NoError(t, err) + + userInstruction := "请结合图片的文字信息,请告诉我一共有多少个群聊,哪些群聊右下角有绿点" + + planner, err := NewPlanner(context.Background()) + require.NoError(t, err) + + opts := &PlanningOptions{ + UserInstruction: userInstruction, + Message: &schema.Message{ + Role: schema.User, + MultiContent: []schema.ChatMessagePart{ + { + Type: schema.ChatMessagePartTypeImageURL, + ImageURL: &schema.ChatMessageImageURL{ + URL: imageBase64, + }, + }, + }, + }, + Size: size, + } + + // 执行规划 + result, err := planner.Call(opts) + + // 验证结果 + require.NoError(t, err) + require.NotNil(t, result) +} + func TestValidateInput(t *testing.T) { imageBase64, size, err := loadImage("testdata/popup_risk_warning.png") require.NoError(t, err)