From 3dc9fe529b6b7ea48bb7dce618e05332e92cf341 Mon Sep 17 00:00:00 2001 From: Rain-0x01-39 <83620631+Rain-0x01-39@users.noreply.github.com> Date: Sat, 1 Aug 2026 16:37:27 +0800 Subject: [PATCH 1/2] fix: validate bool config values and add reasoning field schema --- astrbot/core/config/default.py | 5 +++++ astrbot/dashboard/services/config_service.py | 16 +++++++++++++--- .../locales/en-US/features/config-metadata.json | 4 ++++ .../locales/ru-RU/features/config-metadata.json | 4 ++++ .../locales/zh-CN/features/config-metadata.json | 4 ++++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 52e7036320..e06a7c98d0 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -2731,6 +2731,11 @@ "type": "int", "hint": "模型最大上下文 Token 大小。如果为 0,则会自动从模型元数据填充(如有)", }, + "reasoning": { + "description": "推理能力", + "type": "bool", + "hint": "标记该模型是否支持推理/思考能力。此项为元数据标记,不影响实际 API 调用。", + }, "dify_api_key": { "description": "API Key", "type": "string", diff --git a/astrbot/dashboard/services/config_service.py b/astrbot/dashboard/services/config_service.py index a35dda8610..abe360c187 100644 --- a/astrbot/dashboard/services/config_service.py +++ b/astrbot/dashboard/services/config_service.py @@ -59,6 +59,13 @@ def try_cast(value: Any, type_: str): return float(value) except (ValueError, TypeError): return None + elif type_ == "bool" and isinstance(value, str): + lowered = value.strip().lower() + if lowered in ("true", "1"): + return True + if lowered in ("false", "0"): + return False + return None def _expect_type(value, expected_type, path_key, errors, expected_name=None) -> bool: @@ -276,9 +283,12 @@ def validate(data: dict, metadata: dict = schema, path="") -> None: ) data[key] = casted elif meta["type"] == "bool" and not isinstance(value, bool): - errors.append( - f"错误的类型 {path}{key}: 期望是 bool, 得到了 {type(value).__name__}", - ) + casted = try_cast(value, "bool") + if casted is None: + errors.append( + f"错误的类型 {path}{key}: 期望是 bool, 得到了 {type(value).__name__}", + ) + data[key] = casted elif meta["type"] in ["string", "text"] and not isinstance(value, str): errors.append( f"错误的类型 {path}{key}: 期望是 string, 得到了 {type(value).__name__}", diff --git a/dashboard/src/i18n/locales/en-US/features/config-metadata.json b/dashboard/src/i18n/locales/en-US/features/config-metadata.json index 979be4fed4..49632367c9 100644 --- a/dashboard/src/i18n/locales/en-US/features/config-metadata.json +++ b/dashboard/src/i18n/locales/en-US/features/config-metadata.json @@ -1700,6 +1700,10 @@ "description": "Model context window size", "hint": "Maximum context tokens. If 0, it auto-fills from model metadata (if available); you can also edit manually." }, + "reasoning": { + "description": "Reasoning capability", + "hint": "Whether this model supports reasoning/thinking capabilities. This is a metadata flag and does not affect actual API calls." + }, "dify_api_key": { "description": "API Key", "hint": "Dify API Key. This field is required." diff --git a/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json b/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json index be0731079a..c351c80fec 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json +++ b/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json @@ -1697,6 +1697,10 @@ "description": "Размер окна контекста модели", "hint": "Максимальное количество токенов контекста. Если 0 — автозаполнение." }, + "reasoning": { + "description": "Способность к рассуждениям", + "hint": "Поддерживает ли модель рассуждения/мышление. Это метаданные, не влияет на вызовы API." + }, "dify_api_key": { "description": "Базовый URL для Coze API. По умолчанию: https://api.coze.cn", "hint": "API-ключ Dify (обязательно)." diff --git a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json index 5036a51606..f3409badd5 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json +++ b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json @@ -1702,6 +1702,10 @@ "description": "模型上下文窗口大小", "hint": "模型最大上下文 Token 大小。如果为 0,则会自动从模型元数据填充(如有)。" }, + "reasoning": { + "description": "推理能力", + "hint": "标记该模型是否支持推理/思考能力。此项为元数据标记,不影响实际 API 调用。" + }, "dify_api_key": { "description": "API Key", "hint": "Dify API Key。此项必填。" From 4cb62f8b5dbb879d8bce5ee85efb7c6def742713 Mon Sep 17 00:00:00 2001 From: Rain-0x01-39 <83620631+Rain-0x01-39@users.noreply.github.com> Date: Sat, 15 Aug 2026 00:39:28 +0800 Subject: [PATCH 2/2] fix: rename reasoning field description --- astrbot/core/config/default.py | 2 +- dashboard/src/i18n/locales/en-US/features/config-metadata.json | 2 +- dashboard/src/i18n/locales/ru-RU/features/config-metadata.json | 2 +- dashboard/src/i18n/locales/zh-CN/features/config-metadata.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index e06a7c98d0..cf6b8bd65b 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -2732,7 +2732,7 @@ "hint": "模型最大上下文 Token 大小。如果为 0,则会自动从模型元数据填充(如有)", }, "reasoning": { - "description": "推理能力", + "description": "支持推理能力", "type": "bool", "hint": "标记该模型是否支持推理/思考能力。此项为元数据标记,不影响实际 API 调用。", }, diff --git a/dashboard/src/i18n/locales/en-US/features/config-metadata.json b/dashboard/src/i18n/locales/en-US/features/config-metadata.json index 49632367c9..bd9a317c9d 100644 --- a/dashboard/src/i18n/locales/en-US/features/config-metadata.json +++ b/dashboard/src/i18n/locales/en-US/features/config-metadata.json @@ -1701,7 +1701,7 @@ "hint": "Maximum context tokens. If 0, it auto-fills from model metadata (if available); you can also edit manually." }, "reasoning": { - "description": "Reasoning capability", + "description": "Supports reasoning", "hint": "Whether this model supports reasoning/thinking capabilities. This is a metadata flag and does not affect actual API calls." }, "dify_api_key": { diff --git a/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json b/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json index c351c80fec..3ded61764b 100644 --- a/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json +++ b/dashboard/src/i18n/locales/ru-RU/features/config-metadata.json @@ -1698,7 +1698,7 @@ "hint": "Максимальное количество токенов контекста. Если 0 — автозаполнение." }, "reasoning": { - "description": "Способность к рассуждениям", + "description": "Поддерживает рассуждения", "hint": "Поддерживает ли модель рассуждения/мышление. Это метаданные, не влияет на вызовы API." }, "dify_api_key": { diff --git a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json index f3409badd5..4fb45809d6 100644 --- a/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json +++ b/dashboard/src/i18n/locales/zh-CN/features/config-metadata.json @@ -1703,7 +1703,7 @@ "hint": "模型最大上下文 Token 大小。如果为 0,则会自动从模型元数据填充(如有)。" }, "reasoning": { - "description": "推理能力", + "description": "支持推理能力", "hint": "标记该模型是否支持推理/思考能力。此项为元数据标记,不影响实际 API 调用。" }, "dify_api_key": {