From 7e323e3d0f2a17f144e4e42f3116a0d876bbdefb Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Sat, 15 Nov 2025 21:08:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(prompt):=20=E9=BB=98=E8=AE=A4=E5=90=AF?= =?UTF-8?q?=E7=94=A8=E6=8A=97=E5=AE=A1=E6=9F=A5=E6=8C=87=E4=BB=A4=E5=B9=B6?= =?UTF-8?q?=E7=AE=80=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为了简化用户配置并默认提高模型的抗审查能力,本次更新移除了 `prepend_noise_instruction` 配置选项。 现在,抗审查指令将作为默认行为,在处理所有提示词时自动添加,不再需要用户手动开启。同时,更新了模板文件中的注释,使其更清晰易懂。 --- src/config/api_ada_configs.py | 2 -- src/llm_models/utils_model.py | 3 +-- template/model_config_template.toml | 11 ++++++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/config/api_ada_configs.py b/src/config/api_ada_configs.py index 157692919..d5478f8b4 100644 --- a/src/config/api_ada_configs.py +++ b/src/config/api_ada_configs.py @@ -76,8 +76,6 @@ class ModelInfo(ValidatedConfigBase): default="light", description="扰动强度(light/medium/heavy)" ) enable_semantic_variants: bool = Field(default=False, description="是否启用语义变体作为扰动策略") - - prepend_noise_instruction: bool = Field(default=False, description="是否在提示词前部添加抗审查指令") @classmethod def validate_prices(cls, v): """验证价格必须为非负数""" diff --git a/src/llm_models/utils_model.py b/src/llm_models/utils_model.py index c26bb752d..c3f4dc567 100644 --- a/src/llm_models/utils_model.py +++ b/src/llm_models/utils_model.py @@ -501,8 +501,7 @@ class _PromptProcessor: user_prompt = prompt # 步骤 A: (可选) 添加抗审查指令 - if getattr(model_info, "prepend_noise_instruction", False): - final_prompt_parts.append(self.noise_instruction) + final_prompt_parts.append(self.noise_instruction) # 步骤 B: (可选) 应用统一的提示词扰动 if getattr(model_info, "enable_prompt_perturbation", False): diff --git a/template/model_config_template.toml b/template/model_config_template.toml index c1c84087a..527ede4a3 100644 --- a/template/model_config_template.toml +++ b/template/model_config_template.toml @@ -1,5 +1,5 @@ [inner] -version = "1.3.8" +version = "1.3.9" # 配置文件版本号迭代规则同bot_config.toml @@ -37,10 +37,11 @@ name = "deepseek-v3" # 模型名称(可随意命名,在后面 api_provider = "DeepSeek" # API服务商名称(对应在api_providers中配置的服务商名称) price_in = 2.0 # 输入价格(用于API调用统计,单位:元/ M token)(可选,若无该字段,默认值为0) price_out = 8.0 # 输出价格(用于API调用统计,单位:元/ M token)(可选,若无该字段,默认值为0) -#force_stream_mode = true # 强制流式输出模式(若模型不支持非流式输出,请取消该注释,启用强制流式输出,若无该字段,默认值为false) -#use_anti_truncation = true # [可选] 启用反截断功能。当模型输出不完整时,系统会自动重试。建议只为有需要的模型(如Gemini)开启。 -#enable_content_obfuscation = true # [可选] 启用内容混淆功能,用于特定场景下的内容处理(例如某些内容审查比较严的模型和稀疏注意模型) -#obfuscation_intensity = 2 # 混淆强度(1-3级,1=低强度,2=中强度,3=高强度) +#force_stream_mode = false # [可选] 强制流式输出模式。如果模型不支持非流式输出,请取消注释以启用。默认为 false。 +#anti_truncation = false # [可选] 启用反截断功能。当模型输出不完整时,系统会自动重试。建议只为需要的模型(如Gemini)开启。默认为 false。 +#enable_prompt_perturbation = false # [可选] 启用提示词扰动。此功能整合了内容混淆和注意力优化,默认为 false。 +#perturbation_strength = "light" # [可选] 扰动强度。仅在 enable_prompt_perturbation 为 true 时生效。可选值为 "light", "medium", "heavy"。默认为 "light"。 +#enable_semantic_variants = false # [可选] 启用语义变体。作为一种扰动策略,生成语义上相似但表达不同的提示。默认为 false。 [[models]] model_identifier = "deepseek-ai/DeepSeek-V3.2-Exp"