change: remove addDeviceContextForWings

This commit is contained in:
lilong.129
2025-07-21 15:14:11 +08:00
parent 5eb00f3949
commit 4890c098fa
3 changed files with 15 additions and 50 deletions
+1 -42
View File
@@ -245,8 +245,6 @@ func (dExt *XTDriver) AIAssert(assertion string, opts ...option.ActionOption) (*
return nil, errors.New("LLM service is not initialized")
}
ctx := dExt.addDeviceContextForWings(context.Background())
// Step 1: Take screenshot and convert to base64
screenResult, err := dExt.GetScreenResult(
option.WithScreenShotFileName("ai_assert"),
@@ -270,7 +268,7 @@ func (dExt *XTDriver) AIAssert(assertion string, opts ...option.ActionOption) (*
Screenshot: screenResult.Base64,
Size: screenResult.Resolution,
}
result, err := dExt.LLMService.Assert(ctx, assertOpts)
result, err := dExt.LLMService.Assert(context.Background(), assertOpts)
assertResult.ModelCallElapsed = time.Since(modelCallStartTime).Milliseconds()
assertResult.AssertionResult = result
@@ -294,8 +292,6 @@ func (dExt *XTDriver) PlanNextAction(ctx context.Context, prompt string, opts ..
return nil, errors.New("LLM service is not initialized")
}
ctx = dExt.addDeviceContextForWings(ctx)
// Parse action options to get ResetHistory setting
options := option.NewActionOptions(opts...)
resetHistory := options.ResetHistory
@@ -505,40 +501,3 @@ func (dExt *XTDriver) AIQuery(text string, opts ...option.ActionOption) (*AIExec
}
return aiResult, nil
}
// Context key types to avoid collisions
type contextKey string
const (
deviceIDKey contextKey = "device_id"
platformTypeKey contextKey = "platform_type"
)
// addDeviceContextForWings adds device information to context for Wings service
func (dExt *XTDriver) addDeviceContextForWings(ctx context.Context) context.Context {
device := dExt.GetDevice()
if device == nil {
return ctx
}
// Add device ID to context
ctx = context.WithValue(ctx, deviceIDKey, device.UUID())
// Add platform type to context
platformType := "android" // default
switch device.(type) {
case *AndroidDevice:
platformType = "android"
case *IOSDevice:
platformType = "ios"
case *HarmonyDevice:
platformType = "harmony"
case *BrowserDevice:
platformType = "browser"
default:
platformType = "unknown"
}
ctx = context.WithValue(ctx, platformTypeKey, platformType)
return ctx
}