llm生成参数
This commit is contained in:
@@ -225,13 +225,22 @@ class BaseAPIStage:
|
||||
apis_in_group: List[Union[YAPIEndpoint, SwaggerEndpoint]], # MODIFIED TYPE HINT
|
||||
llm_service: Optional[LLMService] = None,
|
||||
global_api_spec: Optional[ParsedAPISpec] = None, # <--- 修改类型注解
|
||||
operation_keywords: Optional[Dict[str, List[str]]] = None):
|
||||
operation_keywords: Optional[Dict[str, List[str]]] = None,
|
||||
stage_llm_config: Optional[Dict[str, bool]] = None):
|
||||
self.logger = logging.getLogger(f"{__name__}.{self.__class__.__name__}")
|
||||
self.current_api_group_metadata = api_group_metadata
|
||||
self.api_group_metadata = api_group_metadata # Let's ensure this common name is also available.
|
||||
self.apis_in_group = apis_in_group # CORRECTED attribute name
|
||||
self.global_api_spec: ParsedAPISpec = global_api_spec
|
||||
self.llm_service = llm_service
|
||||
|
||||
# Stage专用的LLM配置
|
||||
self.stage_llm_config = stage_llm_config or {
|
||||
"use_llm_for_request_body": False,
|
||||
"use_llm_for_path_params": False,
|
||||
"use_llm_for_query_params": False,
|
||||
"use_llm_for_headers": False,
|
||||
}
|
||||
|
||||
self._operation_keywords = operation_keywords if operation_keywords is not None else {} # CORRECTED assignment
|
||||
self._matched_endpoints: Dict[str, Dict[str, Any]] = {} # 存储按操作类型匹配到的端点定义
|
||||
|
||||
@@ -435,6 +435,7 @@ class APITestOrchestrator:
|
||||
use_llm_for_path_params: bool = False,
|
||||
use_llm_for_query_params: bool = False,
|
||||
use_llm_for_headers: bool = False,
|
||||
stage_llm_config: Optional[Dict[str, bool]] = None,
|
||||
output_dir: Optional[str] = None,
|
||||
strictness_level: Optional[str] = None,
|
||||
ignore_ssl: bool = False
|
||||
@@ -468,6 +469,7 @@ class APITestOrchestrator:
|
||||
self.stage_registry: Optional[StageRegistry] = None
|
||||
|
||||
self.llm_service: Optional[LLMService] = None
|
||||
# 普通测试用例的LLM配置
|
||||
self.llm_config = {
|
||||
"use_for_request_body": use_llm_for_request_body,
|
||||
"use_for_path_params": use_llm_for_path_params,
|
||||
@@ -475,6 +477,14 @@ class APITestOrchestrator:
|
||||
"use_for_headers": use_llm_for_headers,
|
||||
}
|
||||
|
||||
# Stage专用的LLM配置
|
||||
self.stage_llm_config = stage_llm_config or {
|
||||
"use_llm_for_request_body": False,
|
||||
"use_llm_for_path_params": False,
|
||||
"use_llm_for_query_params": False,
|
||||
"use_llm_for_headers": False,
|
||||
}
|
||||
|
||||
if llm_api_key and llm_base_url and LLMService: # <-- MODIFIED: Added check for llm_base_url
|
||||
try:
|
||||
self.llm_service = LLMService(api_key=llm_api_key, base_url=llm_base_url, model_name=llm_model_name)
|
||||
@@ -2469,9 +2479,10 @@ class APITestOrchestrator:
|
||||
# This template instance doesn't need full group-specific data yet.
|
||||
template_stage_instance_check = stage_class_to_init(
|
||||
api_group_metadata={"name": "_template_check", "description": "用于预检查的模板实例"}, # Provide a default dict
|
||||
apis_in_group=[],
|
||||
apis_in_group=[],
|
||||
global_api_spec=parsed_spec,
|
||||
llm_service=self.llm_service
|
||||
llm_service=self.llm_service,
|
||||
stage_llm_config=self.stage_llm_config
|
||||
)
|
||||
|
||||
for current_api_group_name in api_groups_to_iterate:
|
||||
@@ -2545,9 +2556,10 @@ class APITestOrchestrator:
|
||||
|
||||
stage_instance_for_execution = stage_class_to_init(
|
||||
api_group_metadata=current_group_metadata,
|
||||
apis_in_group=current_apis_in_group_for_stage,
|
||||
apis_in_group=current_apis_in_group_for_stage,
|
||||
global_api_spec=parsed_spec,
|
||||
llm_service=self.llm_service
|
||||
llm_service=self.llm_service,
|
||||
stage_llm_config=self.stage_llm_config
|
||||
)
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user