diff --git a/uixt/ai/wings_service.go b/uixt/ai/wings_service.go index 8e134714..35fa77db 100644 --- a/uixt/ai/wings_service.go +++ b/uixt/ai/wings_service.go @@ -345,8 +345,8 @@ func (w *WingsService) extractScreenshotFromMessage(message *schema.Message) (st } // getDeviceInfoFromContext gets device info from context with fallback -func (w *WingsService) getDeviceInfoFromContext(ctx context.Context, screenshot string) WingsDeviceInfo { - // Fallback to default device info +func (w *WingsService) getDeviceInfoFromContext(_ context.Context, screenshot string) WingsDeviceInfo { + // use default device info return WingsDeviceInfo{ DeviceID: "default-device", NowImage: screenshot, diff --git a/uixt/driver_ext_ai.go b/uixt/driver_ext_ai.go index 1b384f6f..fa376cba 100644 --- a/uixt/driver_ext_ai.go +++ b/uixt/driver_ext_ai.go @@ -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 -} diff --git a/uixt/sdk.go b/uixt/sdk.go index 8175fdfc..cd00f036 100644 --- a/uixt/sdk.go +++ b/uixt/sdk.go @@ -29,23 +29,29 @@ func NewXTDriver(driver IDriver, opts ...option.AIServiceOption) (*XTDriver, err // Handle LLM service initialization if services.LLMConfig != nil { - // Use advanced LLM configuration if provided + // Use advanced LLM service configuration if provided driverExt.LLMService, err = ai.NewLLMServiceWithOptionConfig(services.LLMConfig) if err != nil { - log.Warn().Err(err).Msg("init llm service with config failed, Wings service will be used") + log.Warn().Err(err).Msg("init llm service with config failed") } else { log.Info().Msg("LLM service initialized with advanced config") } } else if services.LLMService != "" { - // Fallback to simple LLM service if no config provided + // Use simple LLM service configuration if provided driverExt.LLMService, err = ai.NewLLMService(services.LLMService) if err != nil { - log.Warn().Err(err).Msg("init llm service failed, Wings service will be used") + log.Warn().Err(err).Msg("init llm service failed") } else { - log.Info().Msg("LLM service initialized") + log.Info().Msg("LLM service initialized with simple config") } } else { - log.Info().Msg("no LLM service config provided, using Wings service only") + // Use Wings service as fallback + driverExt.LLMService, err = ai.NewWingsService() + if err != nil { + log.Warn().Err(err).Msg("init Wings service failed") + } else { + log.Info().Msg("Wings service initialized") + } } // Register uixt MCP tools to LLM service if it exists