fix: 修复模型权限正则匹配逻辑及相关缓存清除

- 修复 model_mappings 正则匹配不再受 candidate_models 限制
- Provider 启用/禁用/删除时清除 GlobalModel 解析缓存
- 优先级管理对话框中启用的 Provider 排在禁用的前面
- 修复请求时间线 skipped 状态颜色适配主题
This commit is contained in:
fawney19
2026-01-23 16:10:53 +08:00
parent 3963e424f8
commit 6f597a5f54
6 changed files with 77 additions and 26 deletions

View File

@@ -10,6 +10,7 @@ from sqlalchemy.orm import Session
from src.api.base.admin_adapter import AdminApiAdapter
from src.api.base.models_service import invalidate_models_list_cache
from src.services.cache.model_cache import ModelCacheService
from src.api.base.pipeline import ApiRequestPipeline
from src.core.enums import ProviderBillingType
from src.core.exceptions import InvalidRequestException, NotFoundException
@@ -373,6 +374,11 @@ class AdminUpdateProviderAdapter(AdminApiAdapter):
# 清除 /v1/models 列表缓存is_active 变更会影响模型可用性)
await invalidate_models_list_cache()
# 如果更新了 is_active清除 GlobalModel 解析缓存
# Provider 状态变更会影响模型解析结果
if "is_active" in update_data:
await ModelCacheService.invalidate_all_resolve_cache()
# 如果更新了 billing_type清除缓存
if "billing_type" in update_data:
await ProviderCacheService.invalidate_provider_cache(provider.id)
@@ -421,6 +427,9 @@ class AdminDeleteProviderAdapter(AdminApiAdapter):
# 清除 /v1/models 列表缓存
await invalidate_models_list_cache()
# 清除 GlobalModel 解析缓存(删除 Provider 会影响模型解析结果)
await ModelCacheService.invalidate_all_resolve_cache()
return {"message": "提供商已删除"}