修复代码格式和文件名大小写问题
This commit is contained in:
@@ -10,22 +10,26 @@ class APIProvider(ValidatedConfigBase):
|
||||
name: str = Field(..., min_length=1, description="API提供商名称")
|
||||
base_url: str = Field(..., description="API基础URL")
|
||||
api_key: str = Field(..., min_length=1, description="API密钥")
|
||||
client_type: Literal["openai", "gemini", "aiohttp_gemini"] = Field(default="openai", description="客户端类型(如openai/google等,默认为openai)")
|
||||
client_type: Literal["openai", "gemini", "aiohttp_gemini"] = Field(
|
||||
default="openai", description="客户端类型(如openai/google等,默认为openai)"
|
||||
)
|
||||
max_retry: int = Field(default=2, ge=0, description="最大重试次数(单个模型API调用失败,最多重试的次数)")
|
||||
timeout: int = Field(default=10, ge=1, description="API调用的超时时长(超过这个时长,本次请求将被视为'请求超时',单位:秒)")
|
||||
timeout: int = Field(
|
||||
default=10, ge=1, description="API调用的超时时长(超过这个时长,本次请求将被视为'请求超时',单位:秒)"
|
||||
)
|
||||
retry_interval: int = Field(default=10, ge=0, description="重试间隔(如果API调用失败,重试的间隔时间,单位:秒)")
|
||||
enable_content_obfuscation: bool = Field(default=False, description="是否启用内容混淆(用于特定场景下的内容处理)")
|
||||
obfuscation_intensity: int = Field(default=1, ge=1, le=3, description="混淆强度(1-3级,数值越高混淆程度越强)")
|
||||
|
||||
@field_validator('base_url')
|
||||
@field_validator("base_url")
|
||||
@classmethod
|
||||
def validate_base_url(cls, v):
|
||||
"""验证base_url,确保URL格式正确"""
|
||||
if v and not (v.startswith('http://') or v.startswith('https://')):
|
||||
if v and not (v.startswith("http://") or v.startswith("https://")):
|
||||
raise ValueError("base_url必须以http://或https://开头")
|
||||
return v
|
||||
|
||||
@field_validator('api_key')
|
||||
@field_validator("api_key")
|
||||
@classmethod
|
||||
def validate_api_key(cls, v):
|
||||
"""验证API密钥不能为空"""
|
||||
@@ -49,7 +53,7 @@ class ModelInfo(ValidatedConfigBase):
|
||||
extra_params: Dict[str, Any] = Field(default_factory=dict, description="额外参数(用于API调用时的额外配置)")
|
||||
anti_truncation: bool = Field(default=False, description="是否启用反截断功能,防止模型输出被截断")
|
||||
|
||||
@field_validator('price_in', 'price_out')
|
||||
@field_validator("price_in", "price_out")
|
||||
@classmethod
|
||||
def validate_prices(cls, v):
|
||||
"""验证价格必须为非负数"""
|
||||
@@ -57,18 +61,18 @@ class ModelInfo(ValidatedConfigBase):
|
||||
raise ValueError("价格不能为负数")
|
||||
return v
|
||||
|
||||
@field_validator('model_identifier')
|
||||
@field_validator("model_identifier")
|
||||
@classmethod
|
||||
def validate_model_identifier(cls, v):
|
||||
"""验证模型标识符不能为空且不能包含特殊字符"""
|
||||
if not v or not v.strip():
|
||||
raise ValueError("模型标识符不能为空")
|
||||
# 检查是否包含危险字符
|
||||
if any(char in v for char in [' ', '\n', '\t', '\r']):
|
||||
if any(char in v for char in [" ", "\n", "\t", "\r"]):
|
||||
raise ValueError("模型标识符不能包含空格或换行符")
|
||||
return v
|
||||
|
||||
@field_validator('name')
|
||||
@field_validator("name")
|
||||
@classmethod
|
||||
def validate_name(cls, v):
|
||||
"""验证模型名称不能为空"""
|
||||
@@ -85,7 +89,7 @@ class TaskConfig(ValidatedConfigBase):
|
||||
temperature: float = Field(default=0.7, description="模型温度")
|
||||
concurrency_count: int = Field(default=1, description="并发请求数量")
|
||||
|
||||
@field_validator('model_list')
|
||||
@field_validator("model_list")
|
||||
@classmethod
|
||||
def validate_model_list(cls, v):
|
||||
"""验证模型列表不能为空"""
|
||||
@@ -118,7 +122,7 @@ class ModelTaskConfig(ValidatedConfigBase):
|
||||
monthly_plan_generator: TaskConfig = Field(..., description="月层计划生成模型配置")
|
||||
emoji_vlm: TaskConfig = Field(..., description="表情包识别模型配置")
|
||||
anti_injection: TaskConfig = Field(..., description="反注入检测专用模型配置")
|
||||
|
||||
|
||||
# 处理配置文件中命名不一致的问题
|
||||
utils_video: TaskConfig = Field(..., description="视频分析模型配置(兼容配置文件中的命名)")
|
||||
|
||||
@@ -132,7 +136,7 @@ class ModelTaskConfig(ValidatedConfigBase):
|
||||
# 处理向后兼容性:如果请求video_analysis,返回utils_video
|
||||
if task_name == "video_analysis":
|
||||
task_name = "utils_video"
|
||||
|
||||
|
||||
if hasattr(self, task_name):
|
||||
config = getattr(self, task_name)
|
||||
if config is None:
|
||||
@@ -153,37 +157,37 @@ class APIAdapterConfig(ValidatedConfigBase):
|
||||
self.api_providers_dict = {provider.name: provider for provider in self.api_providers}
|
||||
self.models_dict = {model.name: model for model in self.models}
|
||||
|
||||
@field_validator('models')
|
||||
@field_validator("models")
|
||||
@classmethod
|
||||
def validate_models_list(cls, v):
|
||||
"""验证模型列表"""
|
||||
if not v:
|
||||
raise ValueError("模型列表不能为空,请在配置中设置有效的模型列表。")
|
||||
|
||||
|
||||
# 检查模型名称是否重复
|
||||
model_names = [model.name for model in v]
|
||||
if len(model_names) != len(set(model_names)):
|
||||
raise ValueError("模型名称存在重复,请检查配置文件。")
|
||||
|
||||
|
||||
# 检查模型标识符是否有效
|
||||
for model in v:
|
||||
if not model.model_identifier:
|
||||
raise ValueError(f"模型 '{model.name}' 的 model_identifier 不能为空")
|
||||
|
||||
|
||||
return v
|
||||
|
||||
@field_validator('api_providers')
|
||||
@field_validator("api_providers")
|
||||
@classmethod
|
||||
def validate_api_providers_list(cls, v):
|
||||
"""验证API提供商列表"""
|
||||
if not v:
|
||||
raise ValueError("API提供商列表不能为空,请在配置中设置有效的API提供商列表。")
|
||||
|
||||
|
||||
# 检查API提供商名称是否重复
|
||||
provider_names = [provider.name for provider in v]
|
||||
if len(provider_names) != len(set(provider_names)):
|
||||
raise ValueError("API提供商名称存在重复,请检查配置文件。")
|
||||
|
||||
|
||||
return v
|
||||
|
||||
def get_model_info(self, model_name: str) -> ModelInfo:
|
||||
|
||||
@@ -182,7 +182,7 @@ def _update_dict(target: TOMLDocument | dict | Table, source: TOMLDocument | dic
|
||||
# 跳过version字段的更新
|
||||
if key == "version":
|
||||
continue
|
||||
|
||||
|
||||
if key in target:
|
||||
# 键已存在,更新值
|
||||
target_value = target[key]
|
||||
@@ -396,16 +396,28 @@ class Config(ValidatedConfigBase):
|
||||
schedule: ScheduleConfig = Field(..., description="调度配置")
|
||||
permission: PermissionConfig = Field(..., description="权限配置")
|
||||
command: CommandConfig = Field(..., description="命令系统配置")
|
||||
|
||||
|
||||
# 有默认值的字段放在后面
|
||||
anti_prompt_injection: AntiPromptInjectionConfig = Field(default_factory=lambda: AntiPromptInjectionConfig(), description="反提示注入配置")
|
||||
video_analysis: VideoAnalysisConfig = Field(default_factory=lambda: VideoAnalysisConfig(), description="视频分析配置")
|
||||
dependency_management: DependencyManagementConfig = Field(default_factory=lambda: DependencyManagementConfig(), description="依赖管理配置")
|
||||
anti_prompt_injection: AntiPromptInjectionConfig = Field(
|
||||
default_factory=lambda: AntiPromptInjectionConfig(), description="反提示注入配置"
|
||||
)
|
||||
video_analysis: VideoAnalysisConfig = Field(
|
||||
default_factory=lambda: VideoAnalysisConfig(), description="视频分析配置"
|
||||
)
|
||||
dependency_management: DependencyManagementConfig = Field(
|
||||
default_factory=lambda: DependencyManagementConfig(), description="依赖管理配置"
|
||||
)
|
||||
web_search: WebSearchConfig = Field(default_factory=lambda: WebSearchConfig(), description="网络搜索配置")
|
||||
sleep_system: SleepSystemConfig = Field(default_factory=lambda: SleepSystemConfig(), description="睡眠系统配置")
|
||||
monthly_plan_system: MonthlyPlanSystemConfig = Field(default_factory=lambda: MonthlyPlanSystemConfig(), description="月层计划系统配置")
|
||||
cross_context: CrossContextConfig = Field(default_factory=lambda: CrossContextConfig(), description="跨群聊上下文共享配置")
|
||||
maizone_intercom: MaizoneIntercomConfig = Field(default_factory=lambda: MaizoneIntercomConfig(), description="Maizone互通组配置")
|
||||
monthly_plan_system: MonthlyPlanSystemConfig = Field(
|
||||
default_factory=lambda: MonthlyPlanSystemConfig(), description="月层计划系统配置"
|
||||
)
|
||||
cross_context: CrossContextConfig = Field(
|
||||
default_factory=lambda: CrossContextConfig(), description="跨群聊上下文共享配置"
|
||||
)
|
||||
maizone_intercom: MaizoneIntercomConfig = Field(
|
||||
default_factory=lambda: MaizoneIntercomConfig(), description="Maizone互通组配置"
|
||||
)
|
||||
|
||||
|
||||
class APIAdapterConfig(ValidatedConfigBase):
|
||||
@@ -420,37 +432,37 @@ class APIAdapterConfig(ValidatedConfigBase):
|
||||
self.api_providers_dict = {provider.name: provider for provider in self.api_providers}
|
||||
self.models_dict = {model.name: model for model in self.models}
|
||||
|
||||
@field_validator('models')
|
||||
@field_validator("models")
|
||||
@classmethod
|
||||
def validate_models_list(cls, v):
|
||||
"""验证模型列表"""
|
||||
if not v:
|
||||
raise ValueError("模型列表不能为空,请在配置中设置有效的模型列表。")
|
||||
|
||||
|
||||
# 检查模型名称是否重复
|
||||
model_names = [model.name for model in v]
|
||||
if len(model_names) != len(set(model_names)):
|
||||
raise ValueError("模型名称存在重复,请检查配置文件。")
|
||||
|
||||
|
||||
# 检查模型标识符是否有效
|
||||
for model in v:
|
||||
if not model.model_identifier:
|
||||
raise ValueError(f"模型 '{model.name}' 的 model_identifier 不能为空")
|
||||
|
||||
|
||||
return v
|
||||
|
||||
@field_validator('api_providers')
|
||||
@field_validator("api_providers")
|
||||
@classmethod
|
||||
def validate_api_providers_list(cls, v):
|
||||
"""验证API提供商列表"""
|
||||
if not v:
|
||||
raise ValueError("API提供商列表不能为空,请在配置中设置有效的API提供商列表。")
|
||||
|
||||
|
||||
# 检查API提供商名称是否重复
|
||||
provider_names = [provider.name for provider in v]
|
||||
if len(provider_names) != len(set(provider_names)):
|
||||
raise ValueError("API提供商名称存在重复,请检查配置文件。")
|
||||
|
||||
|
||||
return v
|
||||
|
||||
def get_model_info(self, model_name: str) -> ModelInfo:
|
||||
|
||||
@@ -135,16 +135,17 @@ class ConfigBase:
|
||||
"""返回配置类的字符串表示"""
|
||||
return f"{self.__class__.__name__}({', '.join(f'{f.name}={getattr(self, f.name)}' for f in fields(self))})"
|
||||
|
||||
|
||||
class ValidatedConfigBase(BaseModel):
|
||||
"""带验证的配置基类,继承自Pydantic BaseModel"""
|
||||
|
||||
|
||||
model_config = {
|
||||
"extra": "allow", # 允许额外字段
|
||||
"validate_assignment": True, # 验证赋值
|
||||
"arbitrary_types_allowed": True, # 允许任意类型
|
||||
"strict": True, # 如果设为 True 会完全禁用类型转换
|
||||
}
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, data: dict):
|
||||
"""兼容原有的from_dict方法,增强错误信息"""
|
||||
@@ -152,42 +153,42 @@ class ValidatedConfigBase(BaseModel):
|
||||
return cls.model_validate(data)
|
||||
except ValidationError as e:
|
||||
enhanced_message = cls._create_enhanced_error_message(e, data)
|
||||
|
||||
|
||||
raise ValueError(enhanced_message) from e
|
||||
|
||||
|
||||
@classmethod
|
||||
def _create_enhanced_error_message(cls, e: ValidationError, data: dict) -> str:
|
||||
"""创建增强的错误信息"""
|
||||
enhanced_messages = []
|
||||
|
||||
|
||||
for error in e.errors():
|
||||
error_type = error.get('type', '')
|
||||
field_path = error.get('loc', ())
|
||||
input_value = error.get('input')
|
||||
|
||||
error_type = error.get("type", "")
|
||||
field_path = error.get("loc", ())
|
||||
input_value = error.get("input")
|
||||
|
||||
# 构建字段路径字符串
|
||||
field_path_str = '.'.join(str(p) for p in field_path)
|
||||
|
||||
field_path_str = ".".join(str(p) for p in field_path)
|
||||
|
||||
# 处理字符串类型错误
|
||||
if error_type == 'string_type' and len(field_path) >= 2:
|
||||
if error_type == "string_type" and len(field_path) >= 2:
|
||||
parent_field = field_path[0]
|
||||
element_index = field_path[1]
|
||||
|
||||
|
||||
# 尝试获取父字段的类型信息
|
||||
parent_field_info = cls.model_fields.get(parent_field)
|
||||
|
||||
if parent_field_info and hasattr(parent_field_info, 'annotation'):
|
||||
|
||||
if parent_field_info and hasattr(parent_field_info, "annotation"):
|
||||
expected_type = parent_field_info.annotation
|
||||
|
||||
|
||||
# 获取实际的父字段值
|
||||
actual_parent_value = data.get(parent_field)
|
||||
|
||||
|
||||
# 检查是否是列表类型错误
|
||||
if get_origin(expected_type) is list and isinstance(actual_parent_value, list):
|
||||
list_element_type = get_args(expected_type)[0] if get_args(expected_type) else str
|
||||
actual_item_type = type(input_value).__name__
|
||||
expected_element_name = getattr(list_element_type, '__name__', str(list_element_type))
|
||||
|
||||
expected_element_name = getattr(list_element_type, "__name__", str(list_element_type))
|
||||
|
||||
enhanced_messages.append(
|
||||
f"字段 '{field_path_str}' 类型错误: "
|
||||
f"期待类型 List[{expected_element_name}],"
|
||||
@@ -203,31 +204,30 @@ class ValidatedConfigBase(BaseModel):
|
||||
else:
|
||||
# 回退到原始错误信息
|
||||
enhanced_messages.append(f"字段 '{field_path_str}': {error.get('msg', str(error))}")
|
||||
|
||||
|
||||
# 处理缺失字段错误
|
||||
elif error_type == 'missing':
|
||||
elif error_type == "missing":
|
||||
enhanced_messages.append(f"缺少必需字段: '{field_path_str}'")
|
||||
|
||||
|
||||
# 处理模型类型错误
|
||||
elif error_type in ['model_type', 'dict_type', 'is_instance_of']:
|
||||
field_name = field_path[0] if field_path else 'unknown'
|
||||
elif error_type in ["model_type", "dict_type", "is_instance_of"]:
|
||||
field_name = field_path[0] if field_path else "unknown"
|
||||
field_info = cls.model_fields.get(field_name)
|
||||
|
||||
if field_info and hasattr(field_info, 'annotation'):
|
||||
|
||||
if field_info and hasattr(field_info, "annotation"):
|
||||
expected_type = field_info.annotation
|
||||
expected_name = getattr(expected_type, '__name__', str(expected_type))
|
||||
expected_name = getattr(expected_type, "__name__", str(expected_type))
|
||||
actual_name = type(input_value).__name__
|
||||
|
||||
|
||||
enhanced_messages.append(
|
||||
f"字段 '{field_name}' 类型错误: "
|
||||
f"期待类型 {expected_name},实际类型 {actual_name} (值: {input_value})"
|
||||
)
|
||||
else:
|
||||
enhanced_messages.append(f"字段 '{field_path_str}': {error.get('msg', str(error))}")
|
||||
|
||||
|
||||
# 处理其他类型错误
|
||||
else:
|
||||
enhanced_messages.append(f"字段 '{field_path_str}': {error.get('msg', str(error))}")
|
||||
|
||||
return "配置验证失败:\n" + "\n".join(f" - {msg}" for msg in enhanced_messages)
|
||||
|
||||
return "配置验证失败:\n" + "\n".join(f" - {msg}" for msg in enhanced_messages)
|
||||
|
||||
@@ -12,7 +12,6 @@ from src.config.config_base import ValidatedConfigBase
|
||||
"""
|
||||
|
||||
|
||||
|
||||
class DatabaseConfig(ValidatedConfigBase):
|
||||
"""数据库配置类"""
|
||||
|
||||
@@ -25,7 +24,9 @@ class DatabaseConfig(ValidatedConfigBase):
|
||||
mysql_password: str = Field(default="", description="MySQL密码")
|
||||
mysql_charset: str = Field(default="utf8mb4", description="MySQL字符集")
|
||||
mysql_unix_socket: str = Field(default="", description="MySQL Unix套接字路径")
|
||||
mysql_ssl_mode: Literal["DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY"] = Field(default="DISABLED", description="SSL模式")
|
||||
mysql_ssl_mode: Literal["DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY"] = Field(
|
||||
default="DISABLED", description="SSL模式"
|
||||
)
|
||||
mysql_ssl_ca: str = Field(default="", description="SSL CA证书路径")
|
||||
mysql_ssl_cert: str = Field(default="", description="SSL客户端证书路径")
|
||||
mysql_ssl_key: str = Field(default="", description="SSL客户端密钥路径")
|
||||
@@ -56,7 +57,6 @@ class PersonalityConfig(ValidatedConfigBase):
|
||||
compress_identity: bool = Field(default=True, description="是否压缩身份")
|
||||
|
||||
|
||||
|
||||
class RelationshipConfig(ValidatedConfigBase):
|
||||
"""关系配置类"""
|
||||
|
||||
@@ -64,7 +64,6 @@ class RelationshipConfig(ValidatedConfigBase):
|
||||
relation_frequency: float = Field(default=1.0, description="关系频率")
|
||||
|
||||
|
||||
|
||||
class ChatConfig(ValidatedConfigBase):
|
||||
"""聊天配置类"""
|
||||
|
||||
@@ -78,14 +77,20 @@ class ChatConfig(ValidatedConfigBase):
|
||||
focus_value: float = Field(default=1.0, description="专注值")
|
||||
force_focus_private: bool = Field(default=False, description="强制专注私聊")
|
||||
group_chat_mode: Literal["auto", "normal", "focus"] = Field(default="auto", description="群聊模式")
|
||||
timestamp_display_mode: Literal["normal", "normal_no_YMD", "relative"] = Field(default="normal_no_YMD", description="时间戳显示模式")
|
||||
timestamp_display_mode: Literal["normal", "normal_no_YMD", "relative"] = Field(
|
||||
default="normal_no_YMD", description="时间戳显示模式"
|
||||
)
|
||||
enable_proactive_thinking: bool = Field(default=False, description="启用主动思考")
|
||||
proactive_thinking_interval: int = Field(default=1500, description="主动思考间隔")
|
||||
The_scope_that_proactive_thinking_can_trigger: str = Field(default="all", description="主动思考可以触发的范围")
|
||||
proactive_thinking_in_private: bool = Field(default=True, description="主动思考可以在私聊里面启用")
|
||||
proactive_thinking_in_group: bool = Field(default=True, description="主动思考可以在群聊里面启用")
|
||||
proactive_thinking_enable_in_private: List[str] = Field(default_factory=list, description="启用主动思考的私聊范围,格式:platform:user_id,为空则不限制")
|
||||
proactive_thinking_enable_in_groups: List[str] = Field(default_factory=list, description="启用主动思考的群聊范围,格式:platform:group_id,为空则不限制")
|
||||
proactive_thinking_enable_in_private: List[str] = Field(
|
||||
default_factory=list, description="启用主动思考的私聊范围,格式:platform:user_id,为空则不限制"
|
||||
)
|
||||
proactive_thinking_enable_in_groups: List[str] = Field(
|
||||
default_factory=list, description="启用主动思考的群聊范围,格式:platform:group_id,为空则不限制"
|
||||
)
|
||||
delta_sigma: int = Field(default=120, description="采用正态分布随机时间间隔")
|
||||
|
||||
def get_current_talk_frequency(self, chat_stream_id: Optional[str] = None) -> float:
|
||||
@@ -247,7 +252,6 @@ class ChatConfig(ValidatedConfigBase):
|
||||
return None
|
||||
|
||||
|
||||
|
||||
class MessageReceiveConfig(ValidatedConfigBase):
|
||||
"""消息接收配置类"""
|
||||
|
||||
@@ -255,14 +259,12 @@ class MessageReceiveConfig(ValidatedConfigBase):
|
||||
ban_msgs_regex: List[str] = Field(default_factory=lambda: list(), description="禁用消息正则列表")
|
||||
|
||||
|
||||
|
||||
class NormalChatConfig(ValidatedConfigBase):
|
||||
"""普通聊天配置类"""
|
||||
|
||||
willing_mode: str = Field(default="classical", description="意愿模式")
|
||||
|
||||
|
||||
|
||||
class ExpressionRule(ValidatedConfigBase):
|
||||
"""表达学习规则"""
|
||||
|
||||
@@ -366,13 +368,13 @@ class ToolConfig(ValidatedConfigBase):
|
||||
history: ToolHistoryConfig = Field(default_factory=ToolHistoryConfig)
|
||||
"""工具历史记录配置"""
|
||||
|
||||
|
||||
class VoiceConfig(ValidatedConfigBase):
|
||||
"""语音识别配置类"""
|
||||
|
||||
enable_asr: bool = Field(default=False, description="启用语音识别")
|
||||
|
||||
|
||||
|
||||
class EmojiConfig(ValidatedConfigBase):
|
||||
"""表情包配置类"""
|
||||
|
||||
@@ -387,13 +389,14 @@ class EmojiConfig(ValidatedConfigBase):
|
||||
enable_emotion_analysis: bool = Field(default=True, description="启用情感分析")
|
||||
|
||||
|
||||
|
||||
class MemoryConfig(ValidatedConfigBase):
|
||||
"""记忆配置类"""
|
||||
|
||||
enable_memory: bool = Field(default=True, description="启用记忆")
|
||||
memory_build_interval: int = Field(default=600, description="记忆构建间隔")
|
||||
memory_build_distribution: list[float] = Field(default_factory=lambda: [6.0, 3.0, 0.6, 32.0, 12.0, 0.4], description="记忆构建分布")
|
||||
memory_build_distribution: list[float] = Field(
|
||||
default_factory=lambda: [6.0, 3.0, 0.6, 32.0, 12.0, 0.4], description="记忆构建分布"
|
||||
)
|
||||
memory_build_sample_num: int = Field(default=8, description="记忆构建样本数量")
|
||||
memory_build_sample_length: int = Field(default=40, description="记忆构建样本长度")
|
||||
memory_compress_rate: float = Field(default=0.1, description="记忆压缩率")
|
||||
@@ -403,13 +406,14 @@ class MemoryConfig(ValidatedConfigBase):
|
||||
consolidate_memory_interval: int = Field(default=1000, description="记忆巩固间隔")
|
||||
consolidation_similarity_threshold: float = Field(default=0.7, description="巩固相似性阈值")
|
||||
consolidate_memory_percentage: float = Field(default=0.01, description="巩固记忆百分比")
|
||||
memory_ban_words: list[str] = Field(default_factory=lambda: ["表情包", "图片", "回复", "聊天记录"], description="记忆禁用词")
|
||||
memory_ban_words: list[str] = Field(
|
||||
default_factory=lambda: ["表情包", "图片", "回复", "聊天记录"], description="记忆禁用词"
|
||||
)
|
||||
enable_instant_memory: bool = Field(default=True, description="启用即时记忆")
|
||||
enable_llm_instant_memory: bool = Field(default=True, description="启用基于LLM的瞬时记忆")
|
||||
enable_vector_instant_memory: bool = Field(default=True, description="启用基于向量的瞬时记忆")
|
||||
|
||||
|
||||
|
||||
class MoodConfig(ValidatedConfigBase):
|
||||
"""情绪配置类"""
|
||||
|
||||
@@ -417,7 +421,6 @@ class MoodConfig(ValidatedConfigBase):
|
||||
mood_update_threshold: float = Field(default=1.0, description="情绪更新阈值")
|
||||
|
||||
|
||||
|
||||
class KeywordRuleConfig(ValidatedConfigBase):
|
||||
"""关键词规则配置类"""
|
||||
|
||||
@@ -427,6 +430,7 @@ class KeywordRuleConfig(ValidatedConfigBase):
|
||||
|
||||
def __post_init__(self):
|
||||
import re
|
||||
|
||||
if not self.keywords and not self.regex:
|
||||
raise ValueError("关键词规则必须至少包含keywords或regex中的一个")
|
||||
if not self.reaction:
|
||||
@@ -438,7 +442,6 @@ class KeywordRuleConfig(ValidatedConfigBase):
|
||||
raise ValueError(f"无效的正则表达式 '{pattern}': {str(e)}") from e
|
||||
|
||||
|
||||
|
||||
class KeywordReactionConfig(ValidatedConfigBase):
|
||||
"""关键词配置类"""
|
||||
|
||||
@@ -446,7 +449,6 @@ class KeywordReactionConfig(ValidatedConfigBase):
|
||||
regex_rules: list[KeywordRuleConfig] = Field(default_factory=lambda: [], description="正则表达式规则列表")
|
||||
|
||||
|
||||
|
||||
class CustomPromptConfig(ValidatedConfigBase):
|
||||
"""自定义提示词配置类"""
|
||||
|
||||
@@ -455,7 +457,6 @@ class CustomPromptConfig(ValidatedConfigBase):
|
||||
planner_custom_prompt_content: str = Field(default="", description="规划器自定义提示词内容")
|
||||
|
||||
|
||||
|
||||
class ResponsePostProcessConfig(ValidatedConfigBase):
|
||||
"""回复后处理配置类"""
|
||||
|
||||
@@ -489,6 +490,7 @@ class DebugConfig(ValidatedConfigBase):
|
||||
|
||||
class ExperimentalConfig(ValidatedConfigBase):
|
||||
"""实验功能配置类"""
|
||||
|
||||
pfc_chatting: bool = Field(default=False, description="启用PFC聊天")
|
||||
|
||||
|
||||
@@ -505,7 +507,6 @@ class MaimMessageConfig(ValidatedConfigBase):
|
||||
auth_token: list[str] = Field(default_factory=lambda: [], description="认证令牌列表")
|
||||
|
||||
|
||||
|
||||
class LPMMKnowledgeConfig(ValidatedConfigBase):
|
||||
"""LPMM知识库配置类"""
|
||||
|
||||
@@ -523,7 +524,6 @@ class LPMMKnowledgeConfig(ValidatedConfigBase):
|
||||
embedding_dimension: int = Field(default=1024, description="嵌入维度")
|
||||
|
||||
|
||||
|
||||
class ScheduleConfig(ValidatedConfigBase):
|
||||
"""日程配置类"""
|
||||
|
||||
@@ -540,25 +540,28 @@ class DependencyManagementConfig(ValidatedConfigBase):
|
||||
mirror_url: str = Field(default="", description="镜像URL")
|
||||
use_proxy: bool = Field(default=False, description="使用代理")
|
||||
proxy_url: str = Field(default="", description="代理URL")
|
||||
pip_options: list[str] = Field(default_factory=lambda: ["--no-warn-script-location", "--disable-pip-version-check"], description="Pip选项")
|
||||
pip_options: list[str] = Field(
|
||||
default_factory=lambda: ["--no-warn-script-location", "--disable-pip-version-check"], description="Pip选项"
|
||||
)
|
||||
prompt_before_install: bool = Field(default=False, description="安装前提示")
|
||||
install_log_level: str = Field(default="INFO", description="安装日志级别")
|
||||
|
||||
|
||||
|
||||
class VideoAnalysisConfig(ValidatedConfigBase):
|
||||
"""视频分析配置类"""
|
||||
|
||||
enable: bool = Field(default=True, description="启用")
|
||||
analysis_mode: str = Field(default="batch_frames", description="分析模式")
|
||||
frame_extraction_mode: str = Field(default="keyframe", description="抽帧模式:keyframe(关键帧), fixed_number(固定数量), time_interval(时间间隔)")
|
||||
frame_extraction_mode: str = Field(
|
||||
default="keyframe", description="抽帧模式:keyframe(关键帧), fixed_number(固定数量), time_interval(时间间隔)"
|
||||
)
|
||||
frame_interval_seconds: float = Field(default=2.0, description="抽帧时间间隔")
|
||||
max_frames: int = Field(default=8, description="最大帧数")
|
||||
frame_quality: int = Field(default=85, description="帧质量")
|
||||
max_image_size: int = Field(default=800, description="最大图像大小")
|
||||
enable_frame_timing: bool = Field(default=True, description="启用帧时间")
|
||||
batch_analysis_prompt: str = Field(default="", description="批量分析提示")
|
||||
|
||||
|
||||
# Rust模块相关配置
|
||||
rust_keyframe_threshold: float = Field(default=2.0, description="关键帧检测阈值")
|
||||
rust_use_simd: bool = Field(default=True, description="启用SIMD优化")
|
||||
@@ -575,7 +578,7 @@ class WebSearchConfig(ValidatedConfigBase):
|
||||
tavily_api_keys: list[str] = Field(default_factory=lambda: [], description="Tavily API密钥列表,支持轮询机制")
|
||||
exa_api_keys: list[str] = Field(default_factory=lambda: [], description="exa API密钥列表,支持轮询机制")
|
||||
enabled_engines: list[str] = Field(default_factory=lambda: ["ddg"], description="启用的搜索引擎")
|
||||
search_strategy: Literal["fallback","single","parallel"] = Field(default="single", description="搜索策略")
|
||||
search_strategy: Literal["fallback", "single", "parallel"] = Field(default="single", description="搜索策略")
|
||||
|
||||
|
||||
class AntiPromptInjectionConfig(ValidatedConfigBase):
|
||||
@@ -611,7 +614,9 @@ class SleepSystemConfig(ValidatedConfigBase):
|
||||
decay_interval: float = Field(default=30.0, ge=1.0, description="唤醒度衰减间隔(秒)")
|
||||
angry_duration: float = Field(default=300.0, ge=10.0, description="愤怒状态持续时间(秒)")
|
||||
angry_prompt: str = Field(default="你被人吵醒了非常生气,说话带着怒气", description="被吵醒后的愤怒提示词")
|
||||
re_sleep_delay_minutes: int = Field(default=5, ge=1, description="被唤醒后,如果多久没有新消息则尝试重新入睡(分钟)")
|
||||
re_sleep_delay_minutes: int = Field(
|
||||
default=5, ge=1, description="被唤醒后,如果多久没有新消息则尝试重新入睡(分钟)"
|
||||
)
|
||||
|
||||
# --- 失眠机制相关参数 ---
|
||||
enable_insomnia_system: bool = Field(default=True, description="是否启用失眠系统")
|
||||
@@ -625,11 +630,17 @@ class SleepSystemConfig(ValidatedConfigBase):
|
||||
|
||||
# --- 弹性睡眠与睡前消息 ---
|
||||
enable_flexible_sleep: bool = Field(default=True, description="是否启用弹性睡眠")
|
||||
flexible_sleep_pressure_threshold: float = Field(default=40.0, description="触发弹性睡眠的睡眠压力阈值,低于该值可能延迟入睡")
|
||||
flexible_sleep_pressure_threshold: float = Field(
|
||||
default=40.0, description="触发弹性睡眠的睡眠压力阈值,低于该值可能延迟入睡"
|
||||
)
|
||||
max_sleep_delay_minutes: int = Field(default=60, description="单日最大延迟入睡分钟数")
|
||||
enable_pre_sleep_notification: bool = Field(default=True, description="是否启用睡前消息")
|
||||
pre_sleep_notification_groups: List[str] = Field(default_factory=list, description="接收睡前消息的群号列表, 格式: [\"platform:group_id1\", \"platform:group_id2\"]")
|
||||
pre_sleep_prompt: str = Field(default="我准备睡觉了,请生成一句简短自然的晚安问候。", description="用于生成睡前消息的提示")
|
||||
pre_sleep_notification_groups: List[str] = Field(
|
||||
default_factory=list, description='接收睡前消息的群号列表, 格式: ["platform:group_id1", "platform:group_id2"]'
|
||||
)
|
||||
pre_sleep_prompt: str = Field(
|
||||
default="我准备睡觉了,请生成一句简短自然的晚安问候。", description="用于生成睡前消息的提示"
|
||||
)
|
||||
|
||||
|
||||
class MonthlyPlanSystemConfig(ValidatedConfigBase):
|
||||
@@ -644,30 +655,35 @@ class MonthlyPlanSystemConfig(ValidatedConfigBase):
|
||||
|
||||
class ContextGroup(ValidatedConfigBase):
|
||||
"""上下文共享组配置"""
|
||||
|
||||
name: str = Field(..., description="共享组的名称")
|
||||
chat_ids: List[str] = Field(..., description="属于该组的聊天ID列表")
|
||||
|
||||
|
||||
class CrossContextConfig(ValidatedConfigBase):
|
||||
"""跨群聊上下文共享配置"""
|
||||
|
||||
enable: bool = Field(default=False, description="是否启用跨群聊上下文共享功能")
|
||||
groups: List[ContextGroup] = Field(default_factory=list, description="上下文共享组列表")
|
||||
|
||||
|
||||
class MaizoneIntercomConfig(ValidatedConfigBase):
|
||||
"""Maizone互通组配置"""
|
||||
|
||||
enable: bool = Field(default=False, description="是否启用Maizone互通组功能")
|
||||
groups: List[ContextGroup] = Field(default_factory=list, description="Maizone互通组列表")
|
||||
|
||||
|
||||
class CommandConfig(ValidatedConfigBase):
|
||||
"""命令系统配置类"""
|
||||
|
||||
command_prefixes: List[str] = Field(default_factory=lambda: ['/', '!', '.', '#'], description="支持的命令前缀列表")
|
||||
|
||||
command_prefixes: List[str] = Field(default_factory=lambda: ["/", "!", ".", "#"], description="支持的命令前缀列表")
|
||||
|
||||
|
||||
class PermissionConfig(ValidatedConfigBase):
|
||||
"""权限系统配置类"""
|
||||
|
||||
|
||||
# Master用户配置(拥有最高权限,无视所有权限节点)
|
||||
master_users: List[List[str]] = Field(default_factory=list, description="Master用户列表,格式: [[platform, user_id], ...]")
|
||||
master_users: List[List[str]] = Field(
|
||||
default_factory=list, description="Master用户列表,格式: [[platform, user_id], ...]"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user