change: update examples

This commit is contained in:
lilong.129
2025-06-30 14:03:36 +08:00
parent ae0d28c26d
commit 3cd4e5b836
3 changed files with 19 additions and 12 deletions

View File

@@ -2,7 +2,7 @@
"config": {
"name": "羊了个羊小游戏自动化测试",
"ai_options": {
"llm_service": "doubao-1.5-ui-tars-250328"
"llm_service": "doubao-1.5-thinking-vision-pro-250428"
}
},
"teststeps": [
@@ -48,8 +48,8 @@
{
"check": "ui_ai",
"assert": "ai_assert",
"expect": "当前位于抖音「羊了个羊」小游戏页面",
"msg": "assert ai prompt [当前位于抖音「羊了个羊」小游戏页面] failed"
"expect": "当前页面底部包含「移出」「撤回」「洗牌」按钮",
"msg": "assert ai prompt [当前页面底部包含「移出」「撤回」「洗牌」按钮] failed"
}
]
},
@@ -62,7 +62,7 @@
"method": "start_to_goal",
"params": "羊了个羊是一款热门的消除类小游戏,玩法简单但具有挑战性。以下是游戏的基本规则说明:\n1. 游戏目标: 玩家需要通过消除图案来完成关卡,最终目标是清空所有图案。\n2. 消除规则:\n- 游戏界面中会出现多个图案,玩家需要点击图案将其放入底部的槽中。\n- 图案存在多层堆叠的情况,只能点击最上层的完整图案。\n- 当槽中有三个相同的图案时,这三个图案会自动消除。\n- 玩家需要尽量避免槽中积累过多不同的图案,以免无法继续消除。\n- 严禁点击收集槽里的图案,严禁观看广告和使用道具(移出、撤回、洗牌)。\n- 请持续推进游戏进程,游戏通关后继续下一关,游戏失败后重新开始。\n3. 游戏界面: 图案通常以堆叠的方式呈现,玩家需要逐层消除。\n4. 关卡设计: 游戏包含多个关卡,随着关卡的推进,图案的复杂度和数量会增加。\n5. 策略性: 玩家需要规划消除顺序,以避免槽中积累过多无法消除的图案。\n\n请严格按照以上游戏规则开始游戏\n",
"options": {
"max_retry_times": 50,
"timeout": 300,
"pre_mark_operation": true
}
}

View File

@@ -28,7 +28,7 @@ func TestGameYanglegeyang(t *testing.T) {
testCase := &hrp.TestCase{
Config: hrp.NewConfig("羊了个羊小游戏自动化测试").
SetLLMService(option.DOUBAO_1_5_UI_TARS_250328),
SetLLMService(option.DOUBAO_1_5_THINKING_VISION_PRO_250428),
TestSteps: []hrp.IStep{
hrp.NewStep("启动抖音 app").
Android().
@@ -41,12 +41,12 @@ func TestGameYanglegeyang(t *testing.T) {
StartToGoal("搜索「羊了个羊星球」,进入小程序,加入羊群进入游戏",
option.WithPreMarkOperation(true)).
Validate().
AssertAI("当前位于抖音「羊了个羊」小游戏页面"),
AssertAI("当前页面底部包含「移出」「撤回」「洗牌」按钮"),
hrp.NewStep("开始游戏").
Android().
StartToGoal(userInstruction,
option.WithPreMarkOperation(true),
option.WithMaxRetryTimes(50)),
option.WithTimeout(300)), // 5 minutes
},
}
err := testCase.Dump2JSON("game_yanglegeyang.json")

View File

@@ -18,9 +18,14 @@ import (
func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...option.ActionOption) ([]*PlanningExecutionResult, error) {
options := option.NewActionOptions(opts...)
log.Info().Int("max_retry_times", options.MaxRetryTimes).
Int("timeout_seconds", options.Timeout).
Msg("StartToGoal")
logger := log.Info().Str("prompt", prompt)
if options.MaxRetryTimes > 0 {
logger = logger.Int("max_retry_times", options.MaxRetryTimes)
}
if options.Timeout > 0 {
logger = logger.Int("timeout_seconds", options.Timeout)
}
logger.Msg("StartToGoal")
// Create timeout context for entire StartToGoal process if Timeout is specified
if options.Timeout > 0 {
@@ -130,9 +135,8 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
}()
if err := dExt.invokeToolCall(ctx, toolCall, opts...); err != nil {
log.Warn().
log.Error().Err(err).
Str("action", toolCall.Function.Name).
Err(err).
Msg("invoke tool call failed")
subActionResult.Error = err
return err
@@ -195,6 +199,9 @@ func (dExt *XTDriver) AIAction(ctx context.Context, prompt string, opts ...optio
for _, toolCall := range planningResult.ToolCalls {
err = dExt.invokeToolCall(ctx, toolCall, opts...)
if err != nil {
log.Error().Err(err).
Str("action", toolCall.Function.Name).
Msg("invoke tool call failed")
aiExecutionResult.Error = err.Error()
return aiExecutionResult, errors.Wrap(err, "invoke tool call failed")
}