Refactor config system to use Pydantic validation

Refactored configuration classes to inherit from a new ValidatedConfigBase using Pydantic for robust validation and error reporting. Updated api_ada_configs.py, config.py, config_base.py, and official_configs.py to replace dataclasses with Pydantic models, add field validation, and improve error messages. This change enhances configuration reliability and developer feedback for misconfigurations. Also includes minor code cleanups and removal of unused variables in other modules.
This commit is contained in:
雅诺狐
2025-08-19 15:33:43 +08:00
parent 1b2c5393e5
commit 1405b50d5a
19 changed files with 710 additions and 1224 deletions

View File

@@ -2,7 +2,7 @@
"""
让框架能够发现并加载子目录中的组件。
"""
from .plugin import MaiZoneRefactoredPlugin
from .actions.send_feed_action import SendFeedAction
from .actions.read_feed_action import ReadFeedAction
from .commands.send_feed_command import SendFeedCommand
from .plugin import MaiZoneRefactoredPlugin as MaiZoneRefactoredPlugin
from .actions.send_feed_action import SendFeedAction as SendFeedAction
from .actions.read_feed_action import ReadFeedAction as ReadFeedAction
from .commands.send_feed_command import SendFeedCommand as SendFeedCommand

View File

@@ -165,7 +165,8 @@ class ContentService:
models = llm_api.get_available_models()
text_model = str(self.get_config("models.text_model", "replyer_1"))
model_config = models.get(text_model)
if not model_config: return ""
if not model_config:
return ""
bot_personality = config_api.get_global_config("personality.personality_core", "一个机器人")
bot_expression = config_api.get_global_config("expression.expression_style", "内容积极向上")