mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
Merge branch 'revert_wings_merge' into 'master'
revert: wings merge See merge request iesqa/httprunner!145
This commit is contained in:
+1
-12
@@ -664,22 +664,14 @@ func (d *Device) installViaABBExec(apk io.ReadSeeker, args ...string) (raw []byt
|
|||||||
tp transport
|
tp transport
|
||||||
filesize int64
|
filesize int64
|
||||||
)
|
)
|
||||||
timeout := 8
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Minute)
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
filesize, err = apk.Seek(0, io.SeekEnd)
|
filesize, err = apk.Seek(0, io.SeekEnd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if tp, err = d.createDeviceTransport(4 * time.Minute); err != nil {
|
if tp, err = d.createDeviceTransport(5 * time.Minute); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer func() { _ = tp.Close() }()
|
defer func() { _ = tp.Close() }()
|
||||||
go func() {
|
|
||||||
<-ctx.Done()
|
|
||||||
_ = tp.Close()
|
|
||||||
}()
|
|
||||||
cmd := "abb_exec:package\x00install\x00-t"
|
cmd := "abb_exec:package\x00install\x00-t"
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
cmd += "\x00" + arg
|
cmd += "\x00" + arg
|
||||||
@@ -698,9 +690,6 @@ func (d *Device) installViaABBExec(apk io.ReadSeeker, args ...string) (raw []byt
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
raw, err = tp.ReadBytesAll()
|
raw, err = tp.ReadBytesAll()
|
||||||
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
|
|
||||||
return nil, fmt.Errorf("installation timed out after %d minutes", timeout)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+38
-115
@@ -26,7 +26,6 @@ type WingsService struct {
|
|||||||
bizId string
|
bizId string
|
||||||
accessKey string
|
accessKey string
|
||||||
secretKey string
|
secretKey string
|
||||||
history []History // Conversation history for Wings API
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWingsService creates a new Wings service instance
|
// NewWingsService creates a new Wings service instance
|
||||||
@@ -50,7 +49,6 @@ func NewWingsService() (ILLMService, error) {
|
|||||||
bizId: bizID,
|
bizId: bizID,
|
||||||
accessKey: accessKey,
|
accessKey: accessKey,
|
||||||
secretKey: secretKey,
|
secretKey: secretKey,
|
||||||
history: []History{},
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,11 +59,6 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
return nil, errors.Wrap(err, "validate planning parameters failed")
|
return nil, errors.Wrap(err, "validate planning parameters failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset history if requested
|
|
||||||
if opts.ResetHistory {
|
|
||||||
w.resetHistory()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract screenshot from message
|
// Extract screenshot from message
|
||||||
screenshot, err := w.extractScreenshotFromMessage(opts.Message)
|
screenshot, err := w.extractScreenshotFromMessage(opts.Message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -77,11 +70,15 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
|
|
||||||
// Prepare Wings API request
|
// Prepare Wings API request
|
||||||
apiRequest := WingsActionRequest{
|
apiRequest := WingsActionRequest{
|
||||||
Historys: w.history,
|
Historys: []interface{}{}, // empty as specified
|
||||||
DeviceInfo: deviceInfo,
|
DeviceInfos: []WingsDeviceInfo{
|
||||||
StepText: fmt.Sprintf("%s", opts.UserInstruction),
|
deviceInfo,
|
||||||
|
},
|
||||||
|
StepText: opts.UserInstruction,
|
||||||
BizId: w.bizId,
|
BizId: w.bizId,
|
||||||
TextCase: fmt.Sprintf("整体描述:\n前置条件:\n操作步骤:\n%s\n停止操作。\n注意事项:\n", opts.UserInstruction),
|
TextCase: "整体描述:\\n前置条件:\\n获取 1 台设备 A。\\n获取 1 个[万粉创作者]账号a。\\n获取 2 个[普通]账号 b、c。\\n账号 a 和账号 b 互相关注。\\n账号 a 和账号 c 互相关注。\\n账号 a 给账号 b 设置备注为 “11131b”。\\n账号 a 给账号 c 设置备注为 “11131c”。\\n账号 a 创建一个粉丝群 m。\\n 账号 a 修改粉丝群 m 名称为“11131群”。\\n 账号 a 邀请账号 b 加入粉丝群 m。\\n账号 a 邀请账号 c 加入粉丝群 m。\\n账号 a 给群聊 m 发送一条文字消息。\\n设备 A 打开抖音 app。\\n设备 A 登录账号 a。\\n设备 A 退出抖音 app。\\n操作步骤:\\n账号a打开抖音app。\\n点击“消息”。\\n点击“11131群”cell。\\n点击“聊天信息页入口”按钮。\\n点击“分享公开群”按钮。\\n点击文字“群口令”。\\n断言:屏幕中存在文字“口令复制成功”。\\n停止操作。\\n注意事项:\\n",
|
||||||
|
StepType: "automation",
|
||||||
|
DeviceID: deviceInfo.DeviceID,
|
||||||
Base: WingsBase{
|
Base: WingsBase{
|
||||||
LogID: generateWingsUUID(),
|
LogID: generateWingsUUID(),
|
||||||
},
|
},
|
||||||
@@ -101,7 +98,7 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check API response status
|
// Check API response status
|
||||||
if response.BaseResp.StatusCode != 0 && response.BaseResp.StatusCode != 200 {
|
if response.BaseResp.StatusCode != 0 {
|
||||||
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
||||||
return &PlanningResult{
|
return &PlanningResult{
|
||||||
Thought: response.ThoughtChain.Thought,
|
Thought: response.ThoughtChain.Thought,
|
||||||
@@ -110,25 +107,8 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update history with response data
|
|
||||||
newHistoryEntry := History{
|
|
||||||
Observation: response.ThoughtChain.Observation,
|
|
||||||
Thought: response.ThoughtChain.Thought,
|
|
||||||
Summary: response.ThoughtChain.Summary,
|
|
||||||
StepText: response.StepText,
|
|
||||||
StepTextTrans: response.StepTextTrans,
|
|
||||||
OriStepIndex: response.OriStepIndex,
|
|
||||||
DeviceID: deviceInfo[0].DeviceID,
|
|
||||||
AgentType: response.AgentType,
|
|
||||||
ActionResult: "", // Always empty as requested
|
|
||||||
DeviceInfos: &deviceInfo,
|
|
||||||
ActionParams: response.ActionParams,
|
|
||||||
}
|
|
||||||
w.history = append(w.history, newHistoryEntry)
|
|
||||||
var toolCalls []schema.ToolCall
|
|
||||||
if response.StepType != "FINISH" {
|
|
||||||
// Convert Wings API response to tool calls
|
// Convert Wings API response to tool calls
|
||||||
toolCalls, err = w.convertWingsResponseToToolCalls(response.ActionParams)
|
toolCalls, err := w.convertWingsResponseToToolCalls(response.ActionParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &PlanningResult{
|
return &PlanningResult{
|
||||||
Thought: response.ThoughtChain.Thought,
|
Thought: response.ThoughtChain.Thought,
|
||||||
@@ -136,24 +116,17 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
|
|||||||
ModelName: "wings-api",
|
ModelName: "wings-api",
|
||||||
}, errors.Wrap(err, "convert Wings response to tool calls failed")
|
}, errors.Wrap(err, "convert Wings response to tool calls failed")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// No need to update ActionResult as per user request
|
|
||||||
// ActionResult should always be empty
|
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("thought", response.ThoughtChain.Thought).
|
Str("thought", response.ThoughtChain.Thought).
|
||||||
Str("action", response.AgentType).
|
|
||||||
Str("action_params", response.ActionParams).
|
|
||||||
Str("log_id", fmt.Sprintf("%v", response.BaseResp.Extra)).
|
|
||||||
Int("tool_calls_count", len(toolCalls)).
|
Int("tool_calls_count", len(toolCalls)).
|
||||||
Int64("elapsed_ms", elapsed).
|
Int64("elapsed_ms", elapsed).
|
||||||
Msg("Wings API planning completed")
|
Msg("Wings API planning completed")
|
||||||
|
|
||||||
return &PlanningResult{
|
return &PlanningResult{
|
||||||
ToolCalls: toolCalls,
|
ToolCalls: toolCalls,
|
||||||
Thought: response.StepTextTrans,
|
Thought: response.ThoughtChain.Thought,
|
||||||
Content: response.StepTextTrans,
|
Content: response.ThoughtChain.Summary,
|
||||||
ModelName: "wings-api",
|
ModelName: "wings-api",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -173,15 +146,20 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
|
|
||||||
// Prepare Wings API request for assertion
|
// Prepare Wings API request for assertion
|
||||||
apiRequest := WingsActionRequest{
|
apiRequest := WingsActionRequest{
|
||||||
Historys: []History{},
|
Historys: []interface{}{}, // empty as specified
|
||||||
DeviceInfo: deviceInfo,
|
DeviceInfos: []WingsDeviceInfo{
|
||||||
StepText: fmt.Sprintf("断言:%s", opts.Assertion),
|
deviceInfo,
|
||||||
|
},
|
||||||
|
StepText: opts.Assertion,
|
||||||
BizId: w.bizId,
|
BizId: w.bizId,
|
||||||
TextCase: fmt.Sprintf("整体描述:\n前置条件:\n操作步骤:\n断言: %s\n停止操作。\n注意事项:\n", opts.Assertion),
|
TextCase: "整体描述:\\n前置条件:\\n获取 1 台设备 A。\\n获取 1 个[万粉创作者]账号a。\\n获取 2 个[普通]账号 b、c。\\n账号 a 和账号 b 互相关注。\\n账号 a 和账号 c 互相关注。\\n账号 a 给账号 b 设置备注为 “11131b”。\\n账号 a 给账号 c 设置备注为 “11131c”。\\n账号 a 创建一个粉丝群 m。\\n 账号 a 修改粉丝群 m 名称为“11131群”。\\n 账号 a 邀请账号 b 加入粉丝群 m。\\n账号 a 邀请账号 c 加入粉丝群 m。\\n账号 a 给群聊 m 发送一条文字消息。\\n设备 A 打开抖音 app。\\n设备 A 登录账号 a。\\n设备 A 退出抖音 app。\\n操作步骤:\\n账号a打开抖音app。\\n点击“消息”。\\n点击“11131群”cell。\\n点击“聊天信息页入口”按钮。\\n点击“分享公开群”按钮。\\n点击文字“群口令”。\\n断言:屏幕中存在文字“口令复制成功”。\\n停止操作。\\n注意事项:\\n",
|
||||||
|
StepType: "assert", // Different from automation
|
||||||
|
DeviceID: deviceInfo.DeviceID,
|
||||||
Base: WingsBase{
|
Base: WingsBase{
|
||||||
LogID: generateWingsUUID(),
|
LogID: generateWingsUUID(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
log.Info().Interface("apiRequest", apiRequest).Msg("Wings API request")
|
||||||
|
|
||||||
// Call Wings API
|
// Call Wings API
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
@@ -197,7 +175,7 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check API response status
|
// Check API response status
|
||||||
if response.BaseResp.StatusCode != 0 && response.BaseResp.StatusCode != 200 {
|
if response.BaseResp.StatusCode != 0 {
|
||||||
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
err = fmt.Errorf("API returned error: %s", response.BaseResp.StatusMessage)
|
||||||
return &AssertionResult{
|
return &AssertionResult{
|
||||||
Pass: false,
|
Pass: false,
|
||||||
@@ -206,22 +184,6 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update history with response data
|
|
||||||
newHistoryEntry := History{
|
|
||||||
Observation: response.ThoughtChain.Observation,
|
|
||||||
Thought: response.ThoughtChain.Thought,
|
|
||||||
Summary: response.ThoughtChain.Summary,
|
|
||||||
StepText: response.StepText,
|
|
||||||
StepTextTrans: response.StepTextTrans,
|
|
||||||
OriStepIndex: response.OriStepIndex,
|
|
||||||
DeviceID: deviceInfo[0].DeviceID,
|
|
||||||
AgentType: response.AgentType,
|
|
||||||
ActionResult: "", // Always empty as requested
|
|
||||||
DeviceInfos: &deviceInfo,
|
|
||||||
ActionParams: response.ActionParams,
|
|
||||||
}
|
|
||||||
w.history = append(w.history, newHistoryEntry)
|
|
||||||
|
|
||||||
// Parse assertion result from action_params
|
// Parse assertion result from action_params
|
||||||
passed, assertionThought, err := w.parseAssertionResult(response.ActionParams, response.ThoughtChain)
|
passed, assertionThought, err := w.parseAssertionResult(response.ActionParams, response.ThoughtChain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -232,9 +194,6 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
|
|||||||
}, errors.Wrap(err, "parse assertion result failed")
|
}, errors.Wrap(err, "parse assertion result failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// No need to update ActionResult as per user request
|
|
||||||
// ActionResult should always be empty
|
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Bool("passed", passed).
|
Bool("passed", passed).
|
||||||
Str("thought", assertionThought).
|
Str("thought", assertionThought).
|
||||||
@@ -269,11 +228,13 @@ func (w *WingsService) RegisterTools(tools []*schema.ToolInfo) error {
|
|||||||
|
|
||||||
// Wings API data structures
|
// Wings API data structures
|
||||||
type WingsActionRequest struct {
|
type WingsActionRequest struct {
|
||||||
Historys []History `json:"historys"`
|
Historys []interface{} `json:"historys"`
|
||||||
DeviceInfo []WingsDeviceInfo `json:"device_infos"`
|
DeviceInfos []WingsDeviceInfo `json:"device_infos"`
|
||||||
StepText string `json:"step_text"`
|
StepText string `json:"step_text"`
|
||||||
BizId string `json:"biz_id"`
|
BizId string `json:"biz_id"`
|
||||||
TextCase string `json:"text_case"`
|
TextCase string `json:"text_case"`
|
||||||
|
StepType string `json:"step_type"`
|
||||||
|
DeviceID string `json:"device_id"`
|
||||||
Base WingsBase `json:"Base"`
|
Base WingsBase `json:"Base"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,14 +253,10 @@ type WingsBase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WingsActionResponse struct {
|
type WingsActionResponse struct {
|
||||||
AgentType string `json:"agent_type" thrift:"agent_type,1,required"`
|
StepType string `json:"step_type"`
|
||||||
StepText string `json:"step_text" thrift:"step_text,2,required"`
|
ActionParams string `json:"action_params"`
|
||||||
StepTextTrans string `json:"step_text_trans" thrift:"step_text_trans,3,required"`
|
ThoughtChain WingsThoughtChain `json:"thought_chain"`
|
||||||
OriStepIndex int `json:"ori_step_index" thrift:"ori_step_index,4,required"`
|
BaseResp WingsBaseResp `json:"BaseResp"`
|
||||||
StepType string `json:"step_type" thrift:"step_type,5,required"`
|
|
||||||
ActionParams string `json:"action_params" thrift:"action_params,6,required"`
|
|
||||||
ThoughtChain WingsThoughtChain `json:"thought_chain" thrift:"thought_chain,7,required"`
|
|
||||||
BaseResp WingsBaseResp `json:"BaseResp" thrift:"BaseResp,255,optional"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type WingsThoughtChain struct {
|
type WingsThoughtChain struct {
|
||||||
@@ -319,21 +276,6 @@ type WingsExtra struct {
|
|||||||
LogID string `json:"_log_id"`
|
LogID string `json:"_log_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// History structure for request and response
|
|
||||||
type History struct {
|
|
||||||
Observation string `json:"observation" thrift:"observation,1,required"` // 思考结果
|
|
||||||
Thought string `json:"thought" thrift:"thought,2,required"` // 思考结果
|
|
||||||
Summary string `json:"summary" thrift:"summary,3,required"` // 思考结果
|
|
||||||
StepText string `json:"step_text" thrift:"step_text,4"` // 操作的指令
|
|
||||||
DeviceID string `json:"device_id" thrift:"device_id,5"` // 操作的设备id
|
|
||||||
AgentType string `json:"agent_type" thrift:"agent_type,7"` // 最终决策的agent类型
|
|
||||||
ActionResult string `json:"action_result" thrift:"action_result,8"` // 操作结果, 断言=断言结果, 自动化=自动化操作是否成功, 物料构造=物料构造结果
|
|
||||||
DeviceInfos *[]WingsDeviceInfo `json:"device_infos,omitempty" thrift:"device_infos,9"` // 所有设备的信息
|
|
||||||
ActionParams string `json:"action_params,omitempty" thrift:"action_params,10"` // 历史操作解析结果(断言,自动化,物料构造)
|
|
||||||
StepTextTrans string `json:"step_text_trans,omitempty" thrift:"step_text_trans,13"` // 归一化的步骤文本(为后续的实际执行解析文本)
|
|
||||||
OriStepIndex int `json:"ori_step_index,omitempty" thrift:"ori_step_index,14"` // 原本的执行序列(扩展前、目标导向原始文本步骤)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Action parameter structures
|
// Action parameter structures
|
||||||
type WingsActionParams struct {
|
type WingsActionParams struct {
|
||||||
Type string `json:"Type"`
|
Type string `json:"Type"`
|
||||||
@@ -373,11 +315,6 @@ type WingsTextParams struct {
|
|||||||
|
|
||||||
// Helper methods
|
// Helper methods
|
||||||
|
|
||||||
// resetHistory resets the conversation history
|
|
||||||
func (w *WingsService) resetHistory() {
|
|
||||||
w.history = []History{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// generateWingsUUID generates a random UUID for LogID
|
// generateWingsUUID generates a random UUID for LogID
|
||||||
func generateWingsUUID() string {
|
func generateWingsUUID() string {
|
||||||
return uuid.New().String()
|
return uuid.New().String()
|
||||||
@@ -408,29 +345,19 @@ func (w *WingsService) extractScreenshotFromMessage(message *schema.Message) (st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getDeviceInfoFromContext gets device info from context with fallback
|
// getDeviceInfoFromContext gets device info from context with fallback
|
||||||
func (w *WingsService) getDeviceInfoFromContext(_ context.Context, screenshot string) []WingsDeviceInfo {
|
func (w *WingsService) getDeviceInfoFromContext(_ context.Context, screenshot string) WingsDeviceInfo {
|
||||||
// TODO: Extract device info from context if available
|
// use default device info
|
||||||
|
return WingsDeviceInfo{
|
||||||
// Use last history's NowImage as PreImage if history exists
|
|
||||||
preImage := screenshot
|
|
||||||
if len(w.history) > 0 && w.history[len(w.history)-1].DeviceInfos != nil && len(*w.history[len(w.history)-1].DeviceInfos) > 0 {
|
|
||||||
preImage = (*w.history[len(w.history)-1].DeviceInfos)[0].NowImage
|
|
||||||
}
|
|
||||||
|
|
||||||
// use default device info with optimized PreImage
|
|
||||||
return []WingsDeviceInfo{
|
|
||||||
{
|
|
||||||
DeviceID: "default-device",
|
DeviceID: "default-device",
|
||||||
NowImage: screenshot,
|
NowImage: screenshot,
|
||||||
PreImage: preImage,
|
PreImage: screenshot,
|
||||||
NowLayoutJSON: "",
|
NowLayoutJSON: "",
|
||||||
OperationSystem: "android",
|
OperationSystem: "android",
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDeviceInfoFromScreenshot gets device info from screenshot (for Assert)
|
// getDeviceInfoFromScreenshot gets device info from screenshot (for Assert)
|
||||||
func (w *WingsService) getDeviceInfoFromScreenshot(ctx context.Context, screenshot string) []WingsDeviceInfo {
|
func (w *WingsService) getDeviceInfoFromScreenshot(ctx context.Context, screenshot string) WingsDeviceInfo {
|
||||||
return w.getDeviceInfoFromContext(ctx, screenshot)
|
return w.getDeviceInfoFromContext(ctx, screenshot)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,8 +390,6 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
// Set headers
|
// Set headers
|
||||||
httpReq.Header.Set("Content-Type", "application/json")
|
httpReq.Header.Set("Content-Type", "application/json")
|
||||||
httpReq.Header.Set("Accept", "application/json")
|
httpReq.Header.Set("Accept", "application/json")
|
||||||
httpReq.Header.Add("x-use-ppe", "1")
|
|
||||||
httpReq.Header.Add("x-tt-env", "ppe_refactor_merge")
|
|
||||||
|
|
||||||
// Add authentication headers if using external API
|
// Add authentication headers if using external API
|
||||||
if w.accessKey != "" && w.secretKey != "" {
|
if w.accessKey != "" && w.secretKey != "" {
|
||||||
@@ -478,7 +403,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
|
|
||||||
// Execute HTTP request
|
// Execute HTTP request
|
||||||
client := &http.Client{
|
client := &http.Client{
|
||||||
Timeout: 120 * time.Second,
|
Timeout: 60 * time.Second,
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := client.Do(httpReq)
|
resp, err := client.Do(httpReq)
|
||||||
@@ -486,9 +411,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
return nil, errors.Wrap(err, "HTTP request failed")
|
return nil, errors.Wrap(err, "HTTP request failed")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
// resp X-Tt-Logid
|
|
||||||
logID := resp.Header.Get("X-Tt-Logid")
|
|
||||||
log.Info().Str("step_text", request.StepText).Str("log_id", logID).Str("biz_id", request.BizId).Str("url", w.apiURL).Msg("call wings api")
|
|
||||||
// Read response body
|
// Read response body
|
||||||
responseBody, err := io.ReadAll(resp.Body)
|
responseBody, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -511,7 +434,7 @@ func (w *WingsService) callWingsAPI(ctx context.Context, request WingsActionRequ
|
|||||||
|
|
||||||
// convertWingsResponseToToolCalls converts Wings API response to tool calls using generic approach
|
// convertWingsResponseToToolCalls converts Wings API response to tool calls using generic approach
|
||||||
func (w *WingsService) convertWingsResponseToToolCalls(actionParamsStr string) ([]schema.ToolCall, error) {
|
func (w *WingsService) convertWingsResponseToToolCalls(actionParamsStr string) ([]schema.ToolCall, error) {
|
||||||
if actionParamsStr == "" || actionParamsStr == "FINISH" {
|
if actionParamsStr == "" {
|
||||||
return []schema.ToolCall{}, nil
|
return []schema.ToolCall{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -240,12 +240,12 @@ func (dev *AndroidDevice) installViaInstaller(apkPath string, args ...string) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// 等待安装完成或超时
|
// 等待安装完成或超时
|
||||||
timeout := 8 * time.Minute
|
timeout := 3 * time.Minute
|
||||||
select {
|
select {
|
||||||
case err := <-done:
|
case err := <-done:
|
||||||
return err
|
return err
|
||||||
case <-time.After(timeout):
|
case <-time.After(timeout):
|
||||||
return fmt.Errorf("install via installer timed out after %v", timeout)
|
return fmt.Errorf("installation timed out after %v", timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ func setupADBDriverExt(t *testing.T) *XTDriver {
|
|||||||
Serial: "", // Let it auto-detect the device serial
|
Serial: "", // Let it auto-detect the device serial
|
||||||
AIOptions: []option.AIServiceOption{
|
AIOptions: []option.AIServiceOption{
|
||||||
option.WithCVService(option.CVServiceTypeVEDEM),
|
option.WithCVService(option.CVServiceTypeVEDEM),
|
||||||
|
option.WithLLMConfig(
|
||||||
|
option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328).
|
||||||
|
WithPlannerModel(option.WINGS_SERVICE).
|
||||||
|
WithAsserterModel(option.WINGS_SERVICE),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -292,14 +292,31 @@ func TestDriverExt_AIAction(t *testing.T) {
|
|||||||
func TestDriverExt_AIAction_CompareWithAIAction(t *testing.T) {
|
func TestDriverExt_AIAction_CompareWithAIAction(t *testing.T) {
|
||||||
driver := setupDriverExt(t)
|
driver := setupDriverExt(t)
|
||||||
|
|
||||||
prompt := "[目标导向]向上滑动屏幕2次"
|
prompt := "点击搜索按钮"
|
||||||
|
|
||||||
// Test both methods with the same prompt
|
// Test both methods with the same prompt
|
||||||
aiResult, aiErr := driver.StartToGoal(context.Background(), prompt)
|
aiResult, aiErr := driver.AIAction(context.Background(), prompt)
|
||||||
|
|
||||||
// Both should execute without critical errors (may have different implementations)
|
// Both should execute without critical errors (may have different implementations)
|
||||||
t.Logf("AIAction error: %v", aiErr)
|
t.Logf("AIAction error: %v", aiErr)
|
||||||
t.Logf("AIAction result: %v", aiResult)
|
|
||||||
|
// If both succeed, compare results
|
||||||
|
if aiResult != nil {
|
||||||
|
assert.Equal(t, "action", aiResult.Type, "AIAction result type should be 'action'")
|
||||||
|
|
||||||
|
// Both should have timing information
|
||||||
|
assert.Greater(t, aiResult.ModelCallElapsed, int64(0), "AIAction should have model call elapsed time")
|
||||||
|
|
||||||
|
// Both should have screenshot information
|
||||||
|
assert.NotEmpty(t, aiResult.ImagePath, "AIAction should have image path")
|
||||||
|
|
||||||
|
// Compare model names
|
||||||
|
if aiResult.PlanningResult != nil {
|
||||||
|
t.Logf("AIAction model: %s", aiResult.PlanningResult.ModelName)
|
||||||
|
|
||||||
|
assert.Equal(t, "wings-api", aiResult.PlanningResult.ModelName, "AIAction should use wings-api")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestDriverExt_AIAction_ErrorHandling tests AIAction error handling
|
// TestDriverExt_AIAction_ErrorHandling tests AIAction error handling
|
||||||
|
|||||||
Reference in New Issue
Block a user