refactor(config): 将反截断设置移至模型配置 #真的能算refactor吗
反截断(anti-truncation)功能与特定模型的行为和能力更为相关,而不是任务本身的属性。 此更改将该设置从 `TaskConfig` 移动到 `ModelInfo`,以实现更合理的配置分组和更精细的控制。代码逻辑和配置文件模板也已相应更新。 BREAKING CHANGE: `anti_truncation` 配置项已从 `[model_task_config]` 部分移动到 `[[models]]` 下的具体模型配置中。用户需要更新其配置文件以适配新结构。
This commit is contained in:
@@ -47,6 +47,7 @@ class ModelInfo(ValidatedConfigBase):
|
||||
price_out: float = Field(default=0.0, ge=0, description="每M token输出价格")
|
||||
force_stream_mode: bool = Field(default=False, description="是否强制使用流式输出模式")
|
||||
extra_params: Dict[str, Any] = Field(default_factory=dict, description="额外参数(用于API调用时的额外配置)")
|
||||
anti_truncation: bool = Field(default=False, description="是否启用反截断功能,防止模型输出被截断")
|
||||
|
||||
@field_validator('price_in', 'price_out')
|
||||
@classmethod
|
||||
@@ -83,7 +84,6 @@ class TaskConfig(ValidatedConfigBase):
|
||||
max_tokens: int = Field(default=800, description="任务最大输出token数")
|
||||
temperature: float = Field(default=0.7, description="模型温度")
|
||||
concurrency_count: int = Field(default=1, description="并发请求数量")
|
||||
anti_truncation: bool = Field(default=False, description="是否启用反截断功能,防止模型输出被截断")
|
||||
|
||||
@field_validator('model_list')
|
||||
@classmethod
|
||||
|
||||
@@ -290,12 +290,12 @@ class LLMRequest:
|
||||
model_name = model_info.name
|
||||
|
||||
# 检查是否启用反截断
|
||||
use_anti_truncation = getattr(self.model_for_task, "anti_truncation", False)
|
||||
use_anti_truncation = getattr(api_provider, "anti_truncation", False)
|
||||
|
||||
processed_prompt = prompt
|
||||
if use_anti_truncation:
|
||||
processed_prompt += self.anti_truncation_instruction
|
||||
logger.info(f"任务 '{self.task_name}' 已启用反截断功能")
|
||||
logger.info(f"{api_provider} '{self.task_name}' 已启用反截断功能")
|
||||
|
||||
processed_prompt = self._apply_content_obfuscation(processed_prompt, api_provider)
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ timeout = 30
|
||||
retry_interval = 10
|
||||
enable_content_obfuscation = true # 启用内容混淆功能
|
||||
obfuscation_intensity = 2 # 混淆强度(1-3级,1=低强度,2=中强度,3=高强度)
|
||||
anti_truncation_instruction = true # 防阶段移到了模型配置里
|
||||
|
||||
|
||||
[[models]] # 模型(可以配置多个)
|
||||
@@ -125,7 +126,6 @@ model_list = ["siliconflow-deepseek-v3"] # 使用的模型列表,每个子项
|
||||
temperature = 0.2 # 模型温度,新V3建议0.1-0.3
|
||||
max_tokens = 800 # 最大输出token数
|
||||
#concurrency_count = 2 # 并发请求数量,默认为1(不并发),设置为2或更高启用并发
|
||||
#anti_truncation = true # 启用反截断功能,防止模型输出被截断
|
||||
|
||||
[model_task_config.utils_small] # 在麦麦的一些组件中使用的小模型,消耗量较大,建议使用速度较快的小模型
|
||||
model_list = ["qwen3-8b"]
|
||||
|
||||
Reference in New Issue
Block a user