fix: device_info -> device_infos

This commit is contained in:
余泓铮
2025-08-11 15:30:18 +08:00
parent 1ff41e3bc8
commit d75744fdb2
3 changed files with 43 additions and 47 deletions

View File

@@ -1 +1 @@
v5.0.0-250731 v5.0.0-250811

View File

@@ -77,11 +77,11 @@ 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: w.history,
DeviceInfo: deviceInfo, DeviceInfos: deviceInfo,
StepText: fmt.Sprintf("%s", opts.UserInstruction), StepText: fmt.Sprintf("%s", opts.UserInstruction),
BizId: w.bizId, BizId: w.bizId,
TextCase: fmt.Sprintf("整体描述:\n前置条件\n操作步骤\n%s\n停止操作。\n注意事项\n", opts.UserInstruction), TextCase: fmt.Sprintf("整体描述:\n前置条件\n操作步骤\n%s\n停止操作。\n注意事项\n", opts.UserInstruction),
Base: WingsBase{ Base: WingsBase{
LogID: generateWingsUUID(), LogID: generateWingsUUID(),
}, },
@@ -112,9 +112,7 @@ func (w *WingsService) Plan(ctx context.Context, opts *PlanningOptions) (*Planni
// Update history with response data // Update history with response data
newHistoryEntry := History{ newHistoryEntry := History{
Observation: response.ThoughtChain.Observation, ThoughtChain: response.ThoughtChain,
Thought: response.ThoughtChain.Thought,
Summary: response.ThoughtChain.Summary,
StepText: response.StepText, StepText: response.StepText,
StepTextTrans: response.StepTextTrans, StepTextTrans: response.StepTextTrans,
OriStepIndex: response.OriStepIndex, OriStepIndex: response.OriStepIndex,
@@ -169,15 +167,15 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
cleanScreenshot := w.cleanScreenshotDataURL(opts.Screenshot) cleanScreenshot := w.cleanScreenshotDataURL(opts.Screenshot)
// Get device info from context (if available) // Get device info from context (if available)
deviceInfo := w.getDeviceInfoFromScreenshot(ctx, cleanScreenshot) deviceInfos := w.getDeviceInfoFromScreenshot(ctx, cleanScreenshot)
// Prepare Wings API request for assertion // Prepare Wings API request for assertion
apiRequest := WingsActionRequest{ apiRequest := WingsActionRequest{
Historys: []History{}, Historys: []History{},
DeviceInfo: deviceInfo, DeviceInfos: deviceInfos,
StepText: fmt.Sprintf("断言:%s", opts.Assertion), StepText: fmt.Sprintf("断言:%s", opts.Assertion),
BizId: w.bizId, BizId: w.bizId,
TextCase: fmt.Sprintf("整体描述:\n前置条件\n操作步骤\n断言: %s\n停止操作。\n注意事项\n", opts.Assertion), TextCase: fmt.Sprintf("整体描述:\n前置条件\n操作步骤\n断言: %s\n停止操作。\n注意事项\n", opts.Assertion),
Base: WingsBase{ Base: WingsBase{
LogID: generateWingsUUID(), LogID: generateWingsUUID(),
}, },
@@ -208,16 +206,13 @@ func (w *WingsService) Assert(ctx context.Context, opts *AssertOptions) (*Assert
// Update history with response data // Update history with response data
newHistoryEntry := History{ newHistoryEntry := History{
Observation: response.ThoughtChain.Observation, ThoughtChain: response.ThoughtChain,
Thought: response.ThoughtChain.Thought,
Summary: response.ThoughtChain.Summary,
StepText: response.StepText, StepText: response.StepText,
StepTextTrans: response.StepTextTrans, StepTextTrans: response.StepTextTrans,
OriStepIndex: response.OriStepIndex, OriStepIndex: response.OriStepIndex,
DeviceID: deviceInfo[0].DeviceID, DeviceID: response.DeviceId,
AgentType: response.AgentType, AgentType: response.AgentType,
ActionResult: "", // Always empty as requested DeviceInfos: &apiRequest.DeviceInfos,
DeviceInfos: &deviceInfo,
ActionParams: response.ActionParams, ActionParams: response.ActionParams,
} }
w.history = append(w.history, newHistoryEntry) w.history = append(w.history, newHistoryEntry)
@@ -269,12 +264,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 []History `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"` TextCase string `json:"text_case"`
TextCase string `json:"text_case"` BizId string `json:"biz_id"`
Base WingsBase `json:"Base"` TaskType string `json:"task_type"`
Base WingsBase `json:"Base"`
} }
type WingsDeviceInfo struct { type WingsDeviceInfo struct {
@@ -292,14 +288,16 @@ type WingsBase struct {
} }
type WingsActionResponse struct { type WingsActionResponse struct {
AgentType string `json:"agent_type" thrift:"agent_type,1,required"` AgentType string `json:"agent_type"`
StepText string `json:"step_text" thrift:"step_text,2,required"` StepText string `json:"step_text"`
StepTextTrans string `json:"step_text_trans" thrift:"step_text_trans,3,required"` StepTextTrans string `json:"step_text_trans"`
OriStepIndex int `json:"ori_step_index" thrift:"ori_step_index,4,required"` OriStepIndex int `json:"ori_step_index"`
StepType string `json:"step_type" thrift:"step_type,5,required"` StepType string `json:"step_type"`
ActionParams string `json:"action_params" thrift:"action_params,6,required"` ActionParams string `json:"action_params"`
ThoughtChain WingsThoughtChain `json:"thought_chain" thrift:"thought_chain,7,required"` DeviceId string `json:"device_id"`
BaseResp WingsBaseResp `json:"BaseResp" thrift:"BaseResp,255,optional"` NextIsFinish bool `json:"next_is_finish"`
ThoughtChain WingsThoughtChain `json:"thought_chain"`
BaseResp WingsBaseResp `json:"BaseResp"`
} }
type WingsThoughtChain struct { type WingsThoughtChain struct {
@@ -321,17 +319,15 @@ type WingsExtra struct {
// History structure for request and response // History structure for request and response
type History struct { type History struct {
Observation string `json:"observation" thrift:"observation,1,required"` // 思考结果 ThoughtChain WingsThoughtChain `json:"thought_chain"` // 思考结果
Thought string `json:"thought" thrift:"thought,2,required"` // 思考结果 StepText string `json:"step_text"` // 操作的指令
Summary string `json:"summary" thrift:"summary,3,required"` // 思考结果 DeviceID string `json:"device_id"` // 操作的设备id
StepText string `json:"step_text" thrift:"step_text,4"` // 操作的指令 AgentType string `json:"agent_type"` // 最终决策的agent类型
DeviceID string `json:"device_id" thrift:"device_id,5"` // 操作的设备id ActionResult string `json:"action_result"` // 操作结果, 断言=断言结果, 自动化=自动化操作是否成功, 物料构造=物料构造结果
AgentType string `json:"agent_type" thrift:"agent_type,7"` // 最终决策的agent类型 DeviceInfos *[]WingsDeviceInfo `json:"device_infos"` // 所有设备的信息
ActionResult string `json:"action_result" thrift:"action_result,8"` // 操作结果, 断言=断言结果, 自动化=自动化操作是否成功, 物料构造=物料构造结果 ActionParams string `json:"action_params"` // 历史操作解析结果(断言,自动化,物料构造)
DeviceInfos *[]WingsDeviceInfo `json:"device_infos,omitempty" thrift:"device_infos,9"` // 所有设备的信息 StepTextTrans string `json:"step_text_trans"` // 归一化的步骤文本(为后续的实际执行解析文本)
ActionParams string `json:"action_params,omitempty" thrift:"action_params,10"` // 历史操作解析结果(断言,自动化,物料构造) OriStepIndex int `json:"ori_step_index"` // 原本的执行序列(扩展前、目标导向原始文本步骤)
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

View File

@@ -292,7 +292,7 @@ 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.StartToGoal(context.Background(), prompt)