mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
feat: optimize ILLMService interface to support different models for each component
- Add LLMServiceConfig to support mixed model configuration - Enable Planner, Asserter, Querier to use different optimal models - Provide recommended configurations for various use cases - Maintain backward compatibility with existing API - Update documentation to reflect current state without iteration history - Merge test files and add comprehensive configuration tests - Resolve circular dependency by moving config to option package
This commit is contained in:
+25
-4
@@ -16,21 +16,42 @@ type ILLMService interface {
|
||||
RegisterTools(tools []*schema.ToolInfo) error
|
||||
}
|
||||
|
||||
// NewLLMService creates a new LLM service with the same model for all components (backward compatibility)
|
||||
func NewLLMService(modelType option.LLMServiceType) (ILLMService, error) {
|
||||
modelConfig, err := GetModelConfig(modelType)
|
||||
config := option.NewLLMServiceConfig(modelType)
|
||||
return NewLLMServiceWithOptionConfig(config)
|
||||
}
|
||||
|
||||
// NewLLMServiceWithOptionConfig creates a new LLM service with different models for each component
|
||||
func NewLLMServiceWithOptionConfig(config *option.LLMServiceConfig) (ILLMService, error) {
|
||||
// Get model configs for each component
|
||||
plannerModelConfig, err := GetModelConfig(config.PlannerModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
planner, err := NewPlanner(context.Background(), modelConfig)
|
||||
asserterModelConfig, err := GetModelConfig(config.AsserterModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
asserter, err := NewAsserter(context.Background(), modelConfig)
|
||||
|
||||
querierModelConfig, err := GetModelConfig(config.QuerierModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
querier, err := NewQuerier(context.Background(), modelConfig)
|
||||
|
||||
// Create components with their respective model configs
|
||||
planner, err := NewPlanner(context.Background(), plannerModelConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
asserter, err := NewAsserter(context.Background(), asserterModelConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
querier, err := NewQuerier(context.Background(), querierModelConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user