From dd3df425ee5d3b4111c81685fb70b3bf2b151eec Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 20 Dec 2025 00:06:42 +0800 Subject: [PATCH] feat: add warnings for missing provider IDs in manager and context - Introduced logging warnings in ProviderManager and Context classes when a provider ID is not found, indicating potential issues due to ID modifications. - Updated the ProviderPage.vue to advise against modifying provider IDs, highlighting possible configuration impacts. --- astrbot/core/provider/manager.py | 5 +++++ astrbot/core/star/context.py | 6 ++---- dashboard/src/views/ProviderPage.vue | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/astrbot/core/provider/manager.py b/astrbot/core/provider/manager.py index b23fdf4f5..8e8847f12 100644 --- a/astrbot/core/provider/manager.py +++ b/astrbot/core/provider/manager.py @@ -151,6 +151,7 @@ class ProviderManager: """ provider = None + provider_id = None if umo: provider_id = sp.get( f"provider_perf_{provider_type.value}", @@ -188,6 +189,10 @@ class ProviderManager: ) else: raise ValueError(f"Unknown provider type: {provider_type}") + + if not provider and provider_id: + logger.warning(f"没有找到 ID 为 {provider_id} 的提供商,这可能是由于您修改了提供商(模型)ID 导致的。") + return provider async def initialize(self): diff --git a/astrbot/core/star/context.py b/astrbot/core/star/context.py index 2561762f1..a99376773 100644 --- a/astrbot/core/star/context.py +++ b/astrbot/core/star/context.py @@ -267,6 +267,8 @@ class Context: ): """通过 ID 获取对应的 LLM Provider。""" prov = self.provider_manager.inst_map.get(provider_id) + if provider_id and not prov: + logger.warning(f"没有找到 ID 为 {provider_id} 的提供商,这可能是由于您修改了提供商(模型)ID 导致的。") return prov def get_all_providers(self) -> list[Provider]: @@ -296,10 +298,6 @@ class Context: provider_type=ProviderType.CHAT_COMPLETION, umo=umo, ) - if prov is None: - raise ProviderNotFoundError( - "provider not found, please choose provider first" - ) if not isinstance(prov, Provider): raise ValueError("返回的 Provider 不是 Provider 类型") return prov diff --git a/dashboard/src/views/ProviderPage.vue b/dashboard/src/views/ProviderPage.vue index 0f591b501..8d7e83578 100644 --- a/dashboard/src/views/ProviderPage.vue +++ b/dashboard/src/views/ProviderPage.vue @@ -208,6 +208,7 @@ + 不建议修改 ID,可能会导致指向该模型的相关配置(如默认模型、插件相关配置等)失效。