mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: 修复CVService为空报错
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
package option
|
package option
|
||||||
|
|
||||||
func NewAIServiceOptions(opts ...AIServiceOption) *AIServiceOptions {
|
func NewAIServiceOptions(opts ...AIServiceOption) *AIServiceOptions {
|
||||||
services := &AIServiceOptions{
|
services := &AIServiceOptions{}
|
||||||
Enable: true,
|
|
||||||
}
|
|
||||||
for _, option := range opts {
|
for _, option := range opts {
|
||||||
option(services)
|
option(services)
|
||||||
}
|
}
|
||||||
@@ -11,7 +9,6 @@ func NewAIServiceOptions(opts ...AIServiceOption) *AIServiceOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AIServiceOptions struct {
|
type AIServiceOptions struct {
|
||||||
Enable bool `json:"enable,omitempty" yaml:"enable,omitempty"`
|
|
||||||
CVService CVServiceType `json:"cv_service,omitempty" yaml:"cv_service,omitempty"`
|
CVService CVServiceType `json:"cv_service,omitempty" yaml:"cv_service,omitempty"`
|
||||||
LLMService LLMServiceType `json:"llm_service,omitempty" yaml:"llm_service,omitempty"`
|
LLMService LLMServiceType `json:"llm_service,omitempty" yaml:"llm_service,omitempty"`
|
||||||
LLMConfig *LLMServiceConfig `json:"llm_config,omitempty" yaml:"llm_config,omitempty"` // advanced LLM configuration
|
LLMConfig *LLMServiceConfig `json:"llm_config,omitempty" yaml:"llm_config,omitempty"` // advanced LLM configuration
|
||||||
|
|||||||
19
uixt/sdk.go
19
uixt/sdk.go
@@ -5,12 +5,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v5/uixt/ai"
|
|
||||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
|
||||||
"github.com/mark3labs/mcp-go/client"
|
"github.com/mark3labs/mcp-go/client"
|
||||||
"github.com/mark3labs/mcp-go/mcp"
|
"github.com/mark3labs/mcp-go/mcp"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v5/uixt/ai"
|
||||||
|
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewXTDriver(driver IDriver, opts ...option.AIServiceOption) (*XTDriver, error) {
|
func NewXTDriver(driver IDriver, opts ...option.AIServiceOption) (*XTDriver, error) {
|
||||||
@@ -30,11 +31,12 @@ func NewXTDriver(driver IDriver, opts ...option.AIServiceOption) (*XTDriver, err
|
|||||||
if services.CVService == "" {
|
if services.CVService == "" {
|
||||||
log.Warn().Msg("no CV service config provided, use default vedem")
|
log.Warn().Msg("no CV service config provided, use default vedem")
|
||||||
services.CVService = option.CVServiceTypeVEDEM
|
services.CVService = option.CVServiceTypeVEDEM
|
||||||
}
|
} else {
|
||||||
driverExt.CVService, err = ai.NewCVService(services.CVService)
|
driverExt.CVService, err = ai.NewCVService(services.CVService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("init vedem image service failed")
|
log.Error().Err(err).Msg("init vedem image service failed")
|
||||||
return nil, err
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle LLM service initialization
|
// Handle LLM service initialization
|
||||||
@@ -200,7 +202,8 @@ func (dExt *XTDriver) GetMCPClient(serverName string) (client.MCPClient, bool) {
|
|||||||
|
|
||||||
// CallMCPTool calls the specified MCP tool
|
// CallMCPTool calls the specified MCP tool
|
||||||
func (dExt *XTDriver) CallMCPTool(ctx context.Context,
|
func (dExt *XTDriver) CallMCPTool(ctx context.Context,
|
||||||
serverName, toolName string, arguments map[string]any) (result *mcp.CallToolResult, err error) {
|
serverName, toolName string, arguments map[string]any,
|
||||||
|
) (result *mcp.CallToolResult, err error) {
|
||||||
// Get MCP client
|
// Get MCP client
|
||||||
|
|
||||||
mcpClient, exists := dExt.GetMCPClient(serverName)
|
mcpClient, exists := dExt.GetMCPClient(serverName)
|
||||||
|
|||||||
Reference in New Issue
Block a user