fix(webui): fix missing imports and create toml_utils module

- Create src/common/toml_utils.py with TOML utility functions
- Fix APIAdapterConfig → ModelConfig in config.py (4 locations)
- Fix git_mirror_service import path in plugin.py
- Fix emoji.py type annotations and unused imports
- Fix jargon.py comment (ChatStreams → ChatSession)
- All routers now import successfully
- Zero Peewee remnants verified across src/webui/
This commit is contained in:
DrSmoothl
2026-02-17 20:19:37 +08:00
parent f97c24bf9e
commit f66e25b1a7
5 changed files with 101 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ from typing import Any, Annotated, Optional
from src.common.logger import get_logger
from src.webui.core import verify_auth_token_from_cookie_or_header
from src.common.toml_utils import save_toml_with_format, _update_toml_doc
from src.config.config import Config, APIAdapterConfig, CONFIG_DIR, PROJECT_ROOT
from src.config.config import Config, ModelConfig, CONFIG_DIR, PROJECT_ROOT
from src.config.official_configs import (
BotConfig,
PersonalityConfig,
@@ -77,7 +77,7 @@ async def get_bot_config_schema(_auth: bool = Depends(require_auth)):
async def get_model_config_schema(_auth: bool = Depends(require_auth)):
"""获取模型配置架构(包含提供商和模型任务配置)"""
try:
schema = ConfigSchemaGenerator.generate_config_schema(APIAdapterConfig)
schema = ConfigSchemaGenerator.generate_config_schema(ModelConfig)
return {"success": True, "schema": schema}
except Exception as e:
logger.error(f"获取模型配置架构失败: {e}")
@@ -227,7 +227,7 @@ async def update_model_config(config_data: ConfigBody, _auth: bool = Depends(req
try:
# 验证配置数据
try:
APIAdapterConfig.from_dict(config_data)
ModelConfig.from_dict(config_data)
except Exception as e:
raise HTTPException(status_code=400, detail=f"配置数据验证失败: {str(e)}") from e
@@ -377,7 +377,7 @@ async def update_model_config_section(
# 验证完整配置
try:
APIAdapterConfig.from_dict(config_data)
ModelConfig.from_dict(config_data)
except Exception as e:
logger.error(f"配置数据验证失败,详细错误: {str(e)}")
# 特殊处理:如果是更新 api_providers检查是否有模型引用了已删除的provider