mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: 自适应 RPM 未学习时不限制,改为碰壁学习策略
- 移除自适应模式的默认初始限制(RPMDefaults.INITIAL_LIMIT) - 未学习到边界前不限制 RPM,让系统自由运行直到遇到 429 - 前端自适应 Key 显示学习到的值或"探测中"状态 - 批量余额查询改为并行执行,提升性能
This commit is contained in:
@@ -18,7 +18,6 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from src.api.base.admin_adapter import AdminApiAdapter
|
||||
from src.api.base.pipeline import ApiRequestPipeline
|
||||
from src.config.constants import RPMDefaults
|
||||
from src.core.exceptions import InvalidRequestException, translate_pydantic_error
|
||||
from src.database import get_db
|
||||
from src.models.database import ProviderAPIKey
|
||||
@@ -226,7 +225,7 @@ class ListAdaptiveKeysAdapter(AdminApiAdapter):
|
||||
is_adaptive=key.rpm_limit is None,
|
||||
rpm_limit=key.rpm_limit,
|
||||
effective_limit=(
|
||||
(key.learned_rpm_limit if key.learned_rpm_limit is not None else RPMDefaults.INITIAL_LIMIT)
|
||||
key.learned_rpm_limit # 自适应模式:使用学习值,未学习时为 None(不限制)
|
||||
if key.rpm_limit is None
|
||||
else key.rpm_limit
|
||||
),
|
||||
@@ -279,7 +278,7 @@ class ToggleAdaptiveModeAdapter(AdminApiAdapter):
|
||||
"is_adaptive": is_adaptive,
|
||||
"rpm_limit": key.rpm_limit,
|
||||
"effective_limit": (
|
||||
(key.learned_rpm_limit if key.learned_rpm_limit is not None else RPMDefaults.INITIAL_LIMIT)
|
||||
key.learned_rpm_limit # 自适应模式:使用学习值,未学习时为 None(不限制)
|
||||
if is_adaptive
|
||||
else key.rpm_limit
|
||||
),
|
||||
|
||||
@@ -13,7 +13,6 @@ 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.api.base.pipeline import ApiRequestPipeline
|
||||
from src.config.constants import RPMDefaults
|
||||
from src.core.crypto import crypto_service
|
||||
from src.core.exceptions import InvalidRequestException, NotFoundException
|
||||
from src.core.key_capabilities import get_capability
|
||||
@@ -539,11 +538,7 @@ def _build_key_response(
|
||||
"avg_response_time_ms": round(avg_response_time_ms, 2),
|
||||
"is_adaptive": is_adaptive,
|
||||
"effective_limit": (
|
||||
(
|
||||
key.learned_rpm_limit
|
||||
if key.learned_rpm_limit is not None
|
||||
else RPMDefaults.INITIAL_LIMIT
|
||||
)
|
||||
key.learned_rpm_limit # 自适应模式:使用学习值,未学习时为 None(不限制)
|
||||
if is_adaptive
|
||||
else key.rpm_limit
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user