feat: 将LLM配置主存储迁移到MySQL

变更项: 1) 新增 t_llm_config 数据访问层与建表逻辑。 2) Robot 启动时自动初始化并在空库时从 YAML 导入。 3) 后台 system LLM API 改为读写 MySQL。 4) LLMRegistry 改为优先 MySQL 读取并回退 YAML。 5) DashboardServer 挂载 llm_config_db 提供后台访问。
This commit is contained in:
liuwei
2026-04-20 14:51:43 +08:00
parent ef49588485
commit 1446bf5f39
5 changed files with 287 additions and 24 deletions

View File

@@ -18,6 +18,7 @@ from configuration import Config
from db.connection import DBConnectionManager
from db.contacts_db import ContactsDBOperator
from db.group_plugin_config_db import GroupPluginConfigDBOperator
from db.llm_config_db import LLMConfigDBOperator
from db.plugin_schedule_db import PluginScheduleDBOperator
from db.system_job_db import SystemJobDBOperator
from utils.system_jobs import SystemJobLoader
@@ -71,9 +72,16 @@ class Robot:
self.contacts_db = ContactsDBOperator(self.db_manager)
self.group_plugin_config_db = GroupPluginConfigDBOperator(self.db_manager)
self.llm_config_db = LLMConfigDBOperator(self.db_manager)
self.plugin_schedule_db = PluginScheduleDBOperator(self.db_manager)
self.system_job_db = SystemJobDBOperator(self.db_manager)
self.group_plugin_config_db.init_tables()
# LLM 配置迁移到 MySQL
# 1. 先确保表存在;
# 2. 若库里没有配置,则从 config.yaml 的 llm 节点导入一次;
# 3. 后续运行时以数据库为准YAML 仅作为初始导入来源与兜底。
self.llm_config_db.init_tables()
self.llm_config_db.bootstrap_from_yaml_if_empty(self.config.llm)
self.group_plugin_config_service = GroupPluginConfigService(
db_operator=self.group_plugin_config_db,
redis_client=self.db_manager.get_redis_connection(),