hit-cxf
2026-06-02 6f5bcb60d0a71678c79c1450e5cc81eb8ee757bd
Modify front-end settings and add bilingual explanations in Chinese and English
5 files modified
130 ■■■■■ changed files
video-claw/video-claw/backend/api/logging_config.py 24 ●●●●● patch | view | raw | blame | history
video-claw/video-claw/backend/api/routers/configuration.py 3 ●●●●● patch | view | raw | blame | history
video-claw/video-claw/backend/config.py 23 ●●●●● patch | view | raw | blame | history
video-claw/video-claw/backend/config.yaml.example 2 ●●●●● patch | view | raw | blame | history
video-claw/video-claw/frontend/app/settings/page.tsx 78 ●●●●● patch | view | raw | blame | history
video-claw/video-claw/backend/api/logging_config.py
@@ -12,6 +12,26 @@
    logging.getLogger("uvicorn.access").disabled = not Config.ACCESS_LOG
def _managed_log_level() -> int:
    level_name = str(getattr(Config, "LOG_LEVEL", "INFO") or "INFO").upper()
    return getattr(logging, level_name, logging.INFO)
def apply_log_level_setting():
    """Apply the runtime log-level setting to the queue logger and known noisy loggers."""
    level = _managed_log_level()
    root_logger = logging.getLogger()
    root_logger.setLevel(level)
    for handler in root_logger.handlers:
        handler.setLevel(level)
    if _listener is not None:
        for handler in getattr(_listener, "handlers", []):
            handler.setLevel(level)
    for name in ("uvicorn", "uvicorn.error", "uvicorn.access", "httpx", "httpcore"):
        logger = logging.getLogger(name)
        logger.setLevel(logging.WARNING if name in {"httpx", "httpcore"} else level)
class AIGCFormatter(logging.Formatter):
    """Custom log formatter that adds level icons for better readability."""
@@ -52,8 +72,7 @@
    if _listener is not None:
        return _listener
    level_name = "DEBUG" if Config.DEBUG else "INFO"
    level = getattr(logging, level_name, logging.INFO)
    level = _managed_log_level()
    log_queue = queue.Queue(-1)
    console_handler = logging.StreamHandler(sys.stdout)
@@ -78,6 +97,7 @@
        logger.handlers.clear()
        logger.propagate = True
        logger.setLevel(logging.WARNING if name in {"httpx", "httpcore"} else level)
    apply_log_level_setting()
    apply_access_log_setting()
    _listener = listener
video-claw/video-claw/backend/api/routers/configuration.py
@@ -3,7 +3,7 @@
from fastapi import APIRouter
from pydantic import BaseModel, Field
from api.logging_config import apply_access_log_setting
from api.logging_config import apply_access_log_setting, apply_log_level_setting
from config import Config, CONFIG_PATH
router = APIRouter(tags=["Configuration"])
@@ -24,6 +24,7 @@
@router.put("/api/config")
async def update_config(req: ConfigUpdateRequest):
    config = Config.update_config(req.values)
    apply_log_level_setting()
    apply_access_log_setting()
    return {
        "config": config,
video-claw/video-claw/backend/config.py
@@ -17,7 +17,7 @@
    "server": {
        "host": "127.0.0.1",
        "port": 8000,
        "debug": False,
        "log_level": "INFO",
        "access_log": False,
    },
    "api_providers": {
@@ -95,6 +95,7 @@
def _coerce_config(data: Dict[str, Any]) -> Dict[str, Any]:
    clean = _deep_merge(DEFAULT_CONFIG, data)
    clean.pop("llm", None)
    raw_server = data.get("server", {}) if isinstance(data, dict) else {}
    legacy_models = data.get("models", {}) if isinstance(data, dict) else {}
    if isinstance(legacy_models, dict):
@@ -109,7 +110,11 @@
        server["port"] = int(server.get("port"))
    except (TypeError, ValueError):
        server["port"] = DEFAULT_CONFIG["server"]["port"]
    server["debug"] = _as_bool(server.get("debug"))
    server["log_level"] = _normalize_log_level(
        server.get("log_level") if isinstance(raw_server, dict) and "log_level" in raw_server else None,
        server.get("debug"),
    )
    server.pop("debug", None)
    server["access_log"] = _as_bool(server.get("access_log"))
    server.pop("admin_password", None)
@@ -150,6 +155,14 @@
    return str(value).strip().lower() in {"1", "true", "yes", "on"}
def _normalize_log_level(value: Any, legacy_debug: Any = None) -> str:
    allowed = {"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
    if legacy_debug is not None and (value is None or str(value).strip() == ""):
        return "DEBUG" if _as_bool(legacy_debug) else "INFO"
    normalized = str(value or DEFAULT_CONFIG["server"]["log_level"]).strip().upper()
    return normalized if normalized in allowed else DEFAULT_CONFIG["server"]["log_level"]
def load_config() -> Dict[str, Any]:
    if not CONFIG_PATH.exists():
        source = CONFIG_EXAMPLE_PATH if CONFIG_EXAMPLE_PATH.exists() else None
@@ -181,7 +194,8 @@
    HOST = _get(CONFIG, "server.host")
    PORT = _get(CONFIG, "server.port")
    DEBUG = _get(CONFIG, "server.debug")
    LOG_LEVEL = _get(CONFIG, "server.log_level")
    DEBUG = LOG_LEVEL == "DEBUG"
    ACCESS_LOG = _get(CONFIG, "server.access_log")
    PRINT_MODEL_INPUT = _get(CONFIG, "api_providers.common.print_model_input")
@@ -252,7 +266,8 @@
        cls.HOST = _get(clean, "server.host")
        cls.PORT = _get(clean, "server.port")
        cls.DEBUG = _get(clean, "server.debug")
        cls.LOG_LEVEL = _get(clean, "server.log_level")
        cls.DEBUG = cls.LOG_LEVEL == "DEBUG"
        cls.ACCESS_LOG = _get(clean, "server.access_log")
        cls.PRINT_MODEL_INPUT = _get(clean, "api_providers.common.print_model_input")
video-claw/video-claw/backend/config.yaml.example
@@ -2,7 +2,7 @@
server:
  host: 127.0.0.1
  port: 8000
  debug: false
  log_level: INFO
  access_log: false
api_providers:
  common:
video-claw/video-claw/frontend/app/settings/page.tsx
@@ -31,99 +31,107 @@
  eval: [],
};
const LOG_LEVEL_OPTIONS = [
  { id: 'DEBUG', label: 'DEBUG - 最详细' },
  { id: 'INFO', label: 'INFO - 常规' },
  { id: 'WARNING', label: 'WARNING - 仅警告及错误' },
  { id: 'ERROR', label: 'ERROR - 仅错误' },
  { id: 'CRITICAL', label: 'CRITICAL - 严重错误' },
];
const GROUPS: Array<{ title: string; description: string; fields: Field[] }> = [
  {
    title: 'API Server',
    description: '服务启动与调试配置。host / port 保存后需要重启后端完全生效。',
    description: '服务启动与日志配置。host / port 保存后需要重启后端完全生效。',
    fields: [
      { path: 'server.host', label: 'host' },
      { path: 'server.port', label: 'port', type: 'number' },
      { path: 'server.debug', label: 'debug', type: 'boolean' },
      { path: 'server.access_log', label: 'access_log', type: 'boolean' },
      { path: 'server.host', label: 'host 主机地址' },
      { path: 'server.port', label: 'port 端口', type: 'number' },
      { path: 'server.log_level', label: 'log_level 日志层级', type: 'select', options: LOG_LEVEL_OPTIONS },
      { path: 'server.access_log', label: 'access_log 请求访问日志', type: 'boolean' },
    ],
  },
  {
    title: 'Common Provider Settings',
    description: '模型调用公共配置和代理设置。',
    fields: [
      { path: 'api_providers.common.print_model_input', label: 'print_model_input', type: 'boolean' },
      { path: 'api_providers.common.proxy', label: 'proxy' },
      { path: 'api_providers.common.print_model_input', label: 'print_model_input 打印模型输入', type: 'boolean' },
      { path: 'api_providers.common.proxy', label: 'proxy 代理地址' },
    ],
  },
  {
    title: 'OpenAI',
    description: 'OpenAI / 兼容 OpenAI 接口配置。',
    fields: [
      { path: 'api_providers.openai.api_key', label: 'api_key', type: 'password' },
      { path: 'api_providers.openai.base_url', label: 'base_url' },
      { path: 'api_providers.openai.enable_proxy', label: 'enable_proxy', type: 'boolean' },
      { path: 'api_providers.openai.api_key', label: 'api_key API 密钥', type: 'password' },
      { path: 'api_providers.openai.base_url', label: 'base_url 接口地址' },
      { path: 'api_providers.openai.enable_proxy', label: 'enable_proxy 启用代理', type: 'boolean' },
    ],
  },
  {
    title: 'Gemini',
    description: 'Gemini 及兼容接口配置。',
    fields: [
      { path: 'api_providers.gemini.api_key', label: 'api_key', type: 'password' },
      { path: 'api_providers.gemini.base_url', label: 'base_url' },
      { path: 'api_providers.gemini.enable_proxy', label: 'enable_proxy', type: 'boolean' },
      { path: 'api_providers.gemini.api_key', label: 'api_key API 密钥', type: 'password' },
      { path: 'api_providers.gemini.base_url', label: 'base_url 接口地址' },
      { path: 'api_providers.gemini.enable_proxy', label: 'enable_proxy 启用代理', type: 'boolean' },
    ],
  },
  {
    title: 'DeepSeek',
    description: 'DeepSeek 接口配置。',
    fields: [
      { path: 'api_providers.deepseek.api_key', label: 'api_key', type: 'password' },
      { path: 'api_providers.deepseek.base_url', label: 'base_url' },
      { path: 'api_providers.deepseek.enable_proxy', label: 'enable_proxy', type: 'boolean' },
      { path: 'api_providers.deepseek.api_key', label: 'api_key API 密钥', type: 'password' },
      { path: 'api_providers.deepseek.base_url', label: 'base_url 接口地址' },
      { path: 'api_providers.deepseek.enable_proxy', label: 'enable_proxy 启用代理', type: 'boolean' },
    ],
  },
  {
    title: 'DashScope',
    description: '通义千问、通义万相等 DashScope 服务配置。',
    fields: [
      { path: 'api_providers.dashscope.api_key', label: 'api_key', type: 'password' },
      { path: 'api_providers.dashscope.base_url', label: 'base_url' },
      { path: 'api_providers.dashscope.enable_proxy', label: 'enable_proxy', type: 'boolean' },
      { path: 'api_providers.dashscope.api_key', label: 'api_key API 密钥', type: 'password' },
      { path: 'api_providers.dashscope.base_url', label: 'base_url 接口地址' },
      { path: 'api_providers.dashscope.enable_proxy', label: 'enable_proxy 启用代理', type: 'boolean' },
    ],
  },
  {
    title: 'ARK',
    description: 'Seedream / Seedance 使用的火山方舟配置。',
    fields: [
      { path: 'api_providers.ark.api_key', label: 'api_key', type: 'password' },
      { path: 'api_providers.ark.base_url', label: 'base_url' },
      { path: 'api_providers.ark.enable_proxy', label: 'enable_proxy', type: 'boolean' },
      { path: 'api_providers.ark.api_key', label: 'api_key API 密钥', type: 'password' },
      { path: 'api_providers.ark.base_url', label: 'base_url 接口地址' },
      { path: 'api_providers.ark.enable_proxy', label: 'enable_proxy 启用代理', type: 'boolean' },
    ],
  },
  {
    title: 'Kling',
    description: '可灵视频生成接口配置。',
    fields: [
      { path: 'api_providers.kling.base_url', label: 'base_url' },
      { path: 'api_providers.kling.access_key', label: 'access_key', type: 'password' },
      { path: 'api_providers.kling.secret_key', label: 'secret_key', type: 'password' },
      { path: 'api_providers.kling.enable_proxy', label: 'enable_proxy', type: 'boolean' },
      { path: 'api_providers.kling.base_url', label: 'base_url 接口地址' },
      { path: 'api_providers.kling.access_key', label: 'access_key 访问密钥', type: 'password' },
      { path: 'api_providers.kling.secret_key', label: 'secret_key 私密密钥', type: 'password' },
      { path: 'api_providers.kling.enable_proxy', label: 'enable_proxy 启用代理', type: 'boolean' },
    ],
  },
  {
    title: 'Default Models',
    description: '主流程和 Pipeline 使用的默认模型。',
    fields: [
      { path: 'models.llm', label: 'llm', type: 'select', options: [] },
      { path: 'models.vlm', label: 'vlm', type: 'select', options: [] },
      { path: 'models.image_it2i', label: 'image_it2i', type: 'select', options: [] },
      { path: 'models.image_t2i', label: 'image_t2i', type: 'select', options: [] },
      { path: 'models.video', label: 'video', type: 'select', options: [] },
      { path: 'models.eval', label: 'eval', type: 'select', options: [] },
      { path: 'models.llm', label: 'llm 文本模型', type: 'select', options: [] },
      { path: 'models.vlm', label: 'vlm 视觉语言模型', type: 'select', options: [] },
      { path: 'models.image_it2i', label: 'image_it2i 图生图模型', type: 'select', options: [] },
      { path: 'models.image_t2i', label: 'image_t2i 文生图模型', type: 'select', options: [] },
      { path: 'models.video', label: 'video 视频模型', type: 'select', options: [] },
      { path: 'models.eval', label: 'eval 评估模型', type: 'select', options: [] },
    ],
  },
  {
    title: '视频生成配置',
    description: '只对主流程生效:风格、画幅比例和视频分辨率。',
    fields: [
      { path: 'generation.style', label: '风格', type: 'select', options: STYLES },
      { path: 'generation.video_ratio', label: '视频长宽比', type: 'select', options: VIDEO_RATIOS },
      { path: 'generation.video_resolution', label: '视频分辨率', type: 'select', options: VIDEO_RESOLUTIONS },
      { path: 'generation.style', label: 'style 风格', type: 'select', options: STYLES },
      { path: 'generation.video_ratio', label: 'video_ratio 视频长宽比', type: 'select', options: VIDEO_RATIOS },
      { path: 'generation.video_resolution', label: 'video_resolution 视频分辨率', type: 'select', options: VIDEO_RESOLUTIONS },
    ],
  },
];