31 lines
825 B
Python
31 lines
825 B
Python
"""平台适配器注册表:新增平台 = 加一个文件 + 在这里登记。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from app.providers.base import BalanceProvider
|
|
from app.providers.deepseek import DeepSeekProvider
|
|
from app.providers.openrouter import OpenRouterProvider
|
|
|
|
PROVIDERS: dict[str, type[BalanceProvider]] = {
|
|
"deepseek": DeepSeekProvider,
|
|
"openrouter": OpenRouterProvider,
|
|
}
|
|
|
|
|
|
def get_provider(provider_id: str) -> BalanceProvider | None:
|
|
cls = PROVIDERS.get(provider_id)
|
|
return cls() if cls else None
|
|
|
|
|
|
def list_providers() -> list[dict]:
|
|
return [
|
|
{
|
|
"id": p.id,
|
|
"name": p.name,
|
|
"currency": p.currency,
|
|
"icon": p.icon,
|
|
"description": p.description,
|
|
}
|
|
for p in (cls() for cls in PROVIDERS.values())
|
|
]
|