diff --git a/config.go b/config.go index 5c0506d3..a31ce92a 100644 --- a/config.go +++ b/config.go @@ -4,7 +4,6 @@ import ( "reflect" "github.com/httprunner/httprunner/v5/internal/builtin" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" ) @@ -43,8 +42,8 @@ type TConfig struct { Path string `json:"path,omitempty" yaml:"path,omitempty"` // testcase file path PluginSetting *PluginConfig `json:"plugin,omitempty" yaml:"plugin,omitempty"` // plugin config IgnorePopup bool `json:"ignore_popup,omitempty" yaml:"ignore_popup,omitempty"` - LLMService ai.LLMServiceType `json:"llm_service,omitempty" yaml:"llm_service,omitempty"` - CVService ai.CVServiceType `json:"cv_service,omitempty" yaml:"cv_service,omitempty"` + LLMService option.LLMServiceType `json:"llm_service,omitempty" yaml:"llm_service,omitempty"` + CVService option.CVServiceType `json:"cv_service,omitempty" yaml:"cv_service,omitempty"` } func (c *TConfig) Get() *TConfig { @@ -112,13 +111,13 @@ func (c *TConfig) SetWeight(weight int) *TConfig { } // SetLLMService sets LLM service for current testcase. -func (c *TConfig) SetLLMService(llmService ai.LLMServiceType) *TConfig { +func (c *TConfig) SetLLMService(llmService option.LLMServiceType) *TConfig { c.LLMService = llmService return c } // SetCVService sets CV service for current testcase. -func (c *TConfig) SetCVService(cvService ai.CVServiceType) *TConfig { +func (c *TConfig) SetCVService(cvService option.CVServiceType) *TConfig { c.CVService = cvService return c } diff --git a/examples/uitest/bili/android/cli.go b/examples/uitest/bili/android/cli.go index d0ceed39..947d7595 100644 --- a/examples/uitest/bili/android/cli.go +++ b/examples/uitest/bili/android/cli.go @@ -52,7 +52,7 @@ func launchAppDriver(pkgName string) (driverExt *uixt.XTDriver, err error) { time.Sleep(15 * time.Second) - driverExt = uixt.NewXTDriver(driver) + driverExt, _ = uixt.NewXTDriver(driver) // 处理弹窗 err = driverExt.ClosePopupsHandler() diff --git a/examples/uitest/bili/ios/cli.go b/examples/uitest/bili/ios/cli.go index 2daa6399..27cb9193 100644 --- a/examples/uitest/bili/ios/cli.go +++ b/examples/uitest/bili/ios/cli.go @@ -7,7 +7,6 @@ import ( "time" "github.com/httprunner/httprunner/v5/uixt" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" ) @@ -53,8 +52,8 @@ func launchAppDriver(pkgName string) (driverExt *uixt.XTDriver, err error) { time.Sleep(15 * time.Second) - driverExt = uixt.NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, _ = uixt.NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM)) // 处理弹窗 err = driverExt.ClosePopupsHandler() diff --git a/examples/worldcup/cli.go b/examples/worldcup/cli.go index 31c95d71..6d1b2942 100644 --- a/examples/worldcup/cli.go +++ b/examples/worldcup/cli.go @@ -8,7 +8,6 @@ import ( "github.com/spf13/cobra" "github.com/httprunner/httprunner/v5/uixt" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" ) @@ -39,8 +38,8 @@ var rootCmd = &cobra.Command{ return errors.New("android or ios app bundldID is required") } - driverExt := uixt.NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM), + driverExt, _ := uixt.NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM), ) wc := NewWorldCupLive(driverExt, matchName, bundleID, duration, interval) diff --git a/examples/worldcup/main.go b/examples/worldcup/main.go index 4afbf986..cfdfa4fc 100644 --- a/examples/worldcup/main.go +++ b/examples/worldcup/main.go @@ -48,7 +48,7 @@ func initIOSDriver(uuid string) *uixt.XTDriver { log.Fatal().Err(err).Msg("failed to init ios device") } driver, _ := device.NewDriver() - driverExt := uixt.NewXTDriver(driver) + driverExt, _ := uixt.NewXTDriver(driver) return driverExt } @@ -58,7 +58,7 @@ func initAndroidDriver(uuid string) *uixt.XTDriver { log.Fatal().Err(err).Msg("failed to init android device") } driver, _ := device.NewDriver() - driverExt := uixt.NewXTDriver(driver) + driverExt, _ := uixt.NewXTDriver(driver) return driverExt } diff --git a/go.mod b/go.mod index 5f7fcac6..4c678b72 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( github.com/andybalholm/brotli v1.0.4 github.com/bytedance/sonic v1.13.2 github.com/cloudwego/eino v0.3.26 - github.com/cloudwego/eino-ext/components/model/ark v0.1.6 github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250417123744-154d7ca4d3cd github.com/cloudwego/eino-ext/components/tool/mcp v0.0.0-20250328102648-b47e7f1587fa github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250417123744-154d7ca4d3cd @@ -42,6 +41,7 @@ require ( ) require ( + github.com/bytedance/mockey v1.2.14 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cloudwego/base64x v0.1.5 // indirect @@ -100,8 +100,6 @@ require ( github.com/tadglines/go-pkgs v0.0.0-20210623144937-b983b20f54f9 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect - github.com/volcengine/volc-sdk-golang v1.0.23 // indirect - github.com/volcengine/volcengine-go-sdk v1.0.185 // indirect github.com/yargevad/filepathx v1.0.0 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 // indirect diff --git a/go.sum b/go.sum index 10c191b7..0815c3a9 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,8 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/airbrake/gobrake v3.6.1+incompatible/go.mod h1:wM4gu3Cn0W0K7GUuVWnlXZU11AGBXMILnrdOU8Kn00o= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bugsnag/bugsnag-go v1.4.0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= @@ -19,18 +16,14 @@ github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCN github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20190105021004-abcd57078448/go.mod h1:GJKEexRPVJrBSOjoqN5VNOIKJ5Q3RViH6eu3puDRwx4= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/cloudwego/eino v0.3.26 h1:FdJJTCdNrc9xPcYkLZiEyr7AA+WgyCKCbY+VNDXIaCE= github.com/cloudwego/eino v0.3.26/go.mod h1:wUjz990apdsaOraOXdh6CdhVXq8DJsOvLsVlxNTcNfY= -github.com/cloudwego/eino-ext/components/model/ark v0.1.6 h1:k17Z9VIRBL0/t7Ty1drGgY9tVOraM5xuO6gy7Qx7xus= -github.com/cloudwego/eino-ext/components/model/ark v0.1.6/go.mod h1:13kQjYGLMgla6xTbejlpqhuk3i5BPlNv5S+1pmknlOo= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250417123744-154d7ca4d3cd h1:XEI7RezzV/cnOnhc1YeBJi6a0UoM41JTph4AZZR7+D8= github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250417123744-154d7ca4d3cd/go.mod h1:8gMakAGQUR+IaWTSD0cpcD4U5FYq5puZ73/QjXqs1oU= github.com/cloudwego/eino-ext/components/tool/mcp v0.0.0-20250328102648-b47e7f1587fa h1:Jrmw8Q9g1WcE+x5t3o0TsEBM8RoMRURJI6P52I/ld74= @@ -53,8 +46,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/elazarl/goproxy v0.0.0-20240726154733-8b0c20506380 h1:1NyRx2f4W4WBRyg0Kys0ZbaNmDDzZ2R/C7DTi+bbsJ0= github.com/elazarl/goproxy v0.0.0-20240726154733-8b0c20506380/go.mod h1:thX175TtLTzLj3p7N/Q9IiKZ7NF+p72cvL91emV0hzo= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= @@ -106,27 +97,12 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -135,7 +111,6 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/goph/emperror v0.17.2 h1:yLapQcmEsO0ipe9p5TaN22djm3OFV/TfM/fcYP0/J18= @@ -186,7 +161,6 @@ github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQe github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -259,7 +233,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs= github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.40.1-0.20231203135336-87ef8ec48d55 h1:I4N3ZRnkZPbDN935Tg8QDf8fRpHp3bZ0U0/L42jBgNE= @@ -299,7 +272,6 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -316,10 +288,6 @@ github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6 github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/volcengine/volc-sdk-golang v1.0.23 h1:anOslb2Qp6ywnsbyq9jqR0ljuO63kg9PY+4OehIk5R8= -github.com/volcengine/volc-sdk-golang v1.0.23/go.mod h1:AfG/PZRUkHJ9inETvbjNifTDgut25Wbkm2QoYBTbvyU= -github.com/volcengine/volcengine-go-sdk v1.0.185 h1:MIH+YgdWZhO1fNg/vxLohl8ad7hlklaf46wpaTS1TN0= -github.com/volcengine/volcengine-go-sdk v1.0.185/go.mod h1:gfEDc1s7SYaGoY+WH2dRrS3qiuDJMkwqyfXWCa7+7oA= github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg= github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE= github.com/yargevad/filepathx v1.0.0 h1:SYcT+N3tYGi+NvazubCNlvgIPbzAk7i7y2dwg3I5FYc= @@ -338,20 +306,12 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -359,13 +319,10 @@ golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -396,10 +353,6 @@ golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= @@ -407,34 +360,16 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -453,8 +388,6 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gvisor.dev/gvisor v0.0.0-20240405191320-0878b34101b5 h1:DOUDfNS+CFMM46k18FRF5k/0yz5NhZYMiUQxf4xglIU= gvisor.dev/gvisor v0.0.0-20240405191320-0878b34101b5/go.mod h1:NQHVAzMwvZ+Qe3ElSiHmq9RUm1MdNHpUZ52fiEqvn+0= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM= howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= diff --git a/internal/version/VERSION b/internal/version/VERSION index 41dde217..640b4910 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2504301407 +v5.0.0-beta-2504301431 diff --git a/runner.go b/runner.go index 607b0de4..d0379ebc 100644 --- a/runner.go +++ b/runner.go @@ -28,7 +28,7 @@ import ( "github.com/httprunner/httprunner/v5/internal/sdk" "github.com/httprunner/httprunner/v5/internal/version" "github.com/httprunner/httprunner/v5/uixt" - "github.com/httprunner/httprunner/v5/uixt/ai" + "github.com/httprunner/httprunner/v5/uixt/option" ) // Run starts to run testcase with default configs. @@ -419,15 +419,15 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) { r.parametersIterator = parametersIterator // ai options - aiOpts := []ai.AIServiceOption{} + aiOpts := []option.AIServiceOption{} if parsedConfig.LLMService != "" { - aiOpts = append(aiOpts, ai.WithLLMService(parsedConfig.LLMService)) + aiOpts = append(aiOpts, option.WithLLMService(option.LLMServiceType(parsedConfig.LLMService))) } if parsedConfig.CVService == "" { // default to vedem - parsedConfig.CVService = ai.CVServiceTypeVEDEM + parsedConfig.CVService = option.CVServiceTypeVEDEM } - aiOpts = append(aiOpts, ai.WithCVService(parsedConfig.CVService)) + aiOpts = append(aiOpts, option.WithCVService(parsedConfig.CVService)) // parse android devices config for _, androidDeviceOptions := range parsedConfig.Android { @@ -446,7 +446,10 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) { return nil, errors.Wrap(err, "init android driver failed") } - driverExt := uixt.NewXTDriver(driver, aiOpts...) + driverExt, err := uixt.NewXTDriver(driver, aiOpts...) + if err != nil { + return nil, errors.Wrap(err, "init android XTDriver failed") + } r.uixtDrivers[androidDeviceOptions.SerialNumber] = driverExt } // parse iOS devices config @@ -466,7 +469,10 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) { return nil, errors.Wrap(err, "init ios driver failed") } - driverExt := uixt.NewXTDriver(driver, aiOpts...) + driverExt, err := uixt.NewXTDriver(driver, aiOpts...) + if err != nil { + return nil, errors.Wrap(err, "init ios XTDriver failed") + } r.uixtDrivers[iosDeviceOptions.UDID] = driverExt } // parse harmony devices config @@ -486,7 +492,10 @@ func (r *CaseRunner) parseConfig() (parsedConfig *TConfig, err error) { return nil, errors.Wrap(err, "init harmony driver failed") } - driverExt := uixt.NewXTDriver(driver, aiOpts...) + driverExt, err := uixt.NewXTDriver(driver, aiOpts...) + if err != nil { + return nil, errors.Wrap(err, "init harmony XTDriver failed") + } r.uixtDrivers[harmonyDeviceOptions.ConnectKey] = driverExt } diff --git a/server/context.go b/server/context.go index 23d4f175..93467e72 100644 --- a/server/context.go +++ b/server/context.go @@ -10,7 +10,6 @@ import ( "github.com/httprunner/httprunner/v5/code" "github.com/httprunner/httprunner/v5/uixt" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" ) @@ -33,8 +32,12 @@ func (r *Router) GetDriver(c *gin.Context) (driverExt *uixt.XTDriver, err error) return } - driverExt = uixt.NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err = uixt.NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM)) + if err != nil { + RenderErrorInitDriver(c, err) + return + } c.Set("driver", driverExt) return driverExt, nil } diff --git a/uixt/ai/ai_test.go b/uixt/ai/ai_test.go deleted file mode 100644 index 29591ca0..00000000 --- a/uixt/ai/ai_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package ai - -import ( - "testing" -) - -func TestOption(t *testing.T) { - options := NewAIService( - WithCVService(CVServiceTypeOpenCV), - WithLLMService(LLMServiceTypeUITARS), - ) - t.Log(options) -} diff --git a/uixt/ai/asserter.go b/uixt/ai/asserter.go index 2456bd19..678a3d9d 100644 --- a/uixt/ai/asserter.go +++ b/uixt/ai/asserter.go @@ -14,6 +14,7 @@ import ( "github.com/getkin/kin-openapi/openapi3gen" "github.com/httprunner/httprunner/v5/code" "github.com/httprunner/httprunner/v5/internal/json" + "github.com/httprunner/httprunner/v5/uixt/option" "github.com/httprunner/httprunner/v5/uixt/types" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -57,11 +58,11 @@ func NewAsserter(ctx context.Context) (*Asserter, error) { return nil, err } - if strings.Contains(EnvModelUse, string(LLMServiceTypeUITARS)) { + if strings.Contains(EnvModelUse, string(option.LLMServiceTypeUITARS)) { asserter.systemPrompt += "\n\n" + uiTarsAssertionResponseFormat - } else if strings.Contains(EnvModelUse, string(LLMServiceTypeQwenVL)) { + } else if strings.Contains(EnvModelUse, string(option.LLMServiceTypeQwenVL)) { asserter.systemPrompt += "\n\n" + defaultAssertionResponseJsonFormat - } else if strings.Contains(EnvModelUse, string(LLMServiceTypeGPT)) { + } else if strings.Contains(EnvModelUse, string(option.LLMServiceTypeGPT)) { // define output format type OutputFormat struct { Thought string `json:"thought"` diff --git a/uixt/ai/cv.go b/uixt/ai/cv.go index 2fe70839..44001ea4 100644 --- a/uixt/ai/cv.go +++ b/uixt/ai/cv.go @@ -22,6 +22,13 @@ type ICVService interface { ReadFromPath(imagePath string, opts ...option.ActionOption) (*CVResult, error) } +func NewCVService(modelType option.CVServiceType) (ICVService, error) { + if modelType == option.CVServiceTypeVEDEM { + return NewVEDEMImageService() + } + return nil, errors.New("invalid cv service type") +} + type CVResult struct { URL string `json:"url,omitempty"` // image uploaded url OCRResult OCRResults `json:"ocrResult,omitempty"` // OCR texts diff --git a/uixt/ai/cv_vedem_test.go b/uixt/ai/cv_vedem_test.go index 13a70e3c..ee2d2636 100644 --- a/uixt/ai/cv_vedem_test.go +++ b/uixt/ai/cv_vedem_test.go @@ -19,9 +19,8 @@ func TestGetImageFromBuffer(t *testing.T) { buf := new(bytes.Buffer) buf.Read(file) - service := NewAIService( - WithCVService(CVServiceTypeVEDEM), - ) + service, err := NewVEDEMImageService() + require.Nil(t, err) cvResult, err := service.ReadFromBuffer(buf) assert.Nil(t, err) fmt.Println(fmt.Sprintf("cvResult: %v", cvResult)) @@ -29,9 +28,8 @@ func TestGetImageFromBuffer(t *testing.T) { func TestGetImageFromPath(t *testing.T) { imagePath := "/Users/debugtalk/Downloads/s1.png" - service := NewAIService( - WithCVService(CVServiceTypeVEDEM), - ) + service, err := NewVEDEMImageService() + require.Nil(t, err) cvResult, err := service.ReadFromPath(imagePath) assert.Nil(t, err) fmt.Println(fmt.Sprintf("cvResult: %v", cvResult)) diff --git a/uixt/android_test.go b/uixt/android_test.go index 6e8076ad..be2dac5b 100644 --- a/uixt/android_test.go +++ b/uixt/android_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" "github.com/httprunner/httprunner/v5/uixt/types" ) @@ -23,10 +22,12 @@ func setupADBDriverExt(t *testing.T) *XTDriver { device.Options.LogOn = false driver, err := device.NewDriver() require.Nil(t, err) - return NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM), - ai.WithLLMService(ai.LLMServiceTypeUITARS), + driverExt, err := NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM), + option.WithLLMService(option.LLMServiceTypeUITARS), ) + require.Nil(t, err) + return driverExt } func setupUIA2DriverExt(t *testing.T) *XTDriver { @@ -36,8 +37,10 @@ func setupUIA2DriverExt(t *testing.T) *XTDriver { device.Options.LogOn = false driver, err := device.NewDriver() require.Nil(t, err) - return NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err := NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM)) + require.Nil(t, err) + return driverExt } func TestDevice_Android_GetPackageInfo(t *testing.T) { diff --git a/uixt/demo/main_test.go b/uixt/demo/main_test.go index 8cb8ff5d..afbcf15b 100644 --- a/uixt/demo/main_test.go +++ b/uixt/demo/main_test.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/httprunner/httprunner/v5/uixt" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" ) @@ -23,9 +22,10 @@ func TestIOSDemo(t *testing.T) { driver, err := device.NewDriver() assert.Nil(t, err) - driverExt := uixt.NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM), + driverExt, err := uixt.NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM), ) + assert.Nil(t, err) // release session defer func() { diff --git a/uixt/driver.go b/uixt/driver.go index f9557594..e7d16a8d 100644 --- a/uixt/driver.go +++ b/uixt/driver.go @@ -8,6 +8,7 @@ import ( "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" "github.com/httprunner/httprunner/v5/uixt/types" + "github.com/rs/zerolog/log" ) var ( @@ -81,16 +82,31 @@ type IDriver interface { StopCaptureLog() (result interface{}, err error) } -func NewXTDriver(driver IDriver, opts ...ai.AIServiceOption) *XTDriver { - services := ai.NewAIService(opts...) +func NewXTDriver(driver IDriver, opts ...option.AIServiceOption) (*XTDriver, error) { driverExt := &XTDriver{ - IDriver: driver, - CVService: services.ICVService, - LLMService: services.ILLMService, - + IDriver: driver, screenResults: make([]*ScreenResult, 0), } - return driverExt + + services := option.NewAIServiceOptions(opts...) + + var err error + if services.CVService != "" { + driverExt.CVService, err = ai.NewCVService(services.CVService) + if err != nil { + log.Error().Err(err).Msg("init vedem image service failed") + return nil, err + } + } + if services.LLMService != "" { + driverExt.LLMService, err = ai.NewLLMService(services.LLMService) + if err != nil { + log.Error().Err(err).Msg("init llm service failed") + return nil, err + } + } + + return driverExt, nil } // XTDriver = IDriver + AI diff --git a/uixt/driver_ext_test.go b/uixt/driver_ext_test.go index 1ba1646c..7a974099 100644 --- a/uixt/driver_ext_test.go +++ b/uixt/driver_ext_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -17,8 +16,9 @@ func TestDriverExt_NewMethod1(t *testing.T) { require.Nil(t, err) driver, err := device.NewDriver() require.Nil(t, err) - driverExt := NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err := NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM)) + require.Nil(t, err) driverExt.TapByOCR("推荐") } @@ -27,16 +27,18 @@ func TestDriverExt_NewMethod2(t *testing.T) { require.Nil(t, err) driver, err := NewUIA2Driver(device) require.Nil(t, err) - driverExt := NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err := NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM)) + require.Nil(t, err) driverExt.TapByOCR("推荐") } func TestDriverExt(t *testing.T) { device, _ := NewAndroidDevice() driver, _ := NewADBDriver(device) - driverExt := NewXTDriver(driver, - ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err := NewXTDriver(driver, + option.WithCVService(option.CVServiceTypeVEDEM)) + require.Nil(t, err) // call IDriver methods driverExt.TapXY(0.2, 0.5) @@ -50,7 +52,7 @@ func TestDriverExt(t *testing.T) { textRect, _ := driverExt.FindScreenText("hello") t.Log(textRect) - err := driverExt.TapByCV( + err = driverExt.TapByCV( option.WithScreenShotUITypes("deepseek_send"), option.WithScope(0.8, 0.5, 1, 1)) assert.Nil(t, err) diff --git a/uixt/harmony_test.go b/uixt/harmony_test.go index f3a5bfc0..2f2ac440 100644 --- a/uixt/harmony_test.go +++ b/uixt/harmony_test.go @@ -6,7 +6,7 @@ import ( "fmt" "testing" - "github.com/httprunner/httprunner/v5/uixt/ai" + "github.com/httprunner/httprunner/v5/uixt/option" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -16,7 +16,9 @@ func setupHDCDriverExt(t *testing.T) *XTDriver { require.Nil(t, err) hdcDriver, err := NewHDCDriver(device) require.Nil(t, err) - return NewXTDriver(hdcDriver, ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err := NewXTDriver(hdcDriver, option.WithCVService(option.CVServiceTypeVEDEM)) + require.Nil(t, err) + return driverExt } func TestWindowSize(t *testing.T) { diff --git a/uixt/ios_test.go b/uixt/ios_test.go index 8a731caa..cd4b7b3b 100644 --- a/uixt/ios_test.go +++ b/uixt/ios_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/httprunner/httprunner/v5/uixt/ai" "github.com/httprunner/httprunner/v5/uixt/option" "github.com/httprunner/httprunner/v5/uixt/types" ) @@ -23,7 +22,9 @@ func setupWDADriverExt(t *testing.T) *XTDriver { require.Nil(t, err) driver, err := device.NewDriver() require.Nil(t, err) - return NewXTDriver(driver, ai.WithCVService(ai.CVServiceTypeVEDEM)) + driverExt, err := NewXTDriver(driver, option.WithCVService(option.CVServiceTypeVEDEM)) + require.Nil(t, err) + return driverExt } func TestDevice_IOS_Install(t *testing.T) { diff --git a/uixt/option/ai.go b/uixt/option/ai.go new file mode 100644 index 00000000..cfcab5d1 --- /dev/null +++ b/uixt/option/ai.go @@ -0,0 +1,43 @@ +package option + +func NewAIServiceOptions(opts ...AIServiceOption) *AIServiceOptions { + services := &AIServiceOptions{} + for _, option := range opts { + option(services) + } + return services +} + +type AIServiceOptions struct { + CVService CVServiceType + LLMService LLMServiceType +} + +type AIServiceOption func(*AIServiceOptions) + +type CVServiceType string + +const ( + CVServiceTypeVEDEM CVServiceType = "vedem" + CVServiceTypeOpenCV CVServiceType = "opencv" +) + +func WithCVService(service CVServiceType) AIServiceOption { + return func(opts *AIServiceOptions) { + opts.CVService = service + } +} + +type LLMServiceType string + +const ( + LLMServiceTypeUITARS LLMServiceType = "ui-tars" + LLMServiceTypeGPT LLMServiceType = "gpt" + LLMServiceTypeQwenVL LLMServiceType = "qwen-vl" +) + +func WithLLMService(modelType LLMServiceType) AIServiceOption { + return func(opts *AIServiceOptions) { + opts.LLMService = modelType + } +}