Refactor Phase 2: Split stories.py into Schema/Service/Controller, add missing endpoints, fix async bug
This commit is contained in:
@@ -177,7 +177,7 @@ def _build_config_from_provider(provider: "Provider") -> AdapterConfig:
|
||||
)
|
||||
|
||||
|
||||
def _get_providers_with_config(
|
||||
async def _get_providers_with_config(
|
||||
provider_type: ProviderType,
|
||||
) -> list[tuple[str, AdapterConfig, "Provider | None"]]:
|
||||
"""获取供应商列表及其配置。
|
||||
@@ -185,7 +185,7 @@ def _get_providers_with_config(
|
||||
Returns:
|
||||
[(adapter_name, config, provider_or_none), ...] 按优先级排序
|
||||
"""
|
||||
db_providers = get_providers(provider_type)
|
||||
db_providers = await get_providers(provider_type)
|
||||
|
||||
if db_providers:
|
||||
return [(p.adapter, _build_config_from_provider(p), p) for p in db_providers]
|
||||
@@ -265,7 +265,7 @@ async def _route_with_failover(
|
||||
user_id: 用户 ID(可选,用于成本追踪和预算检查)
|
||||
**kwargs: 传递给适配器的参数
|
||||
"""
|
||||
providers = _get_providers_with_config(provider_type)
|
||||
providers = await _get_providers_with_config(provider_type)
|
||||
|
||||
if not providers:
|
||||
raise ValueError(f"No {provider_type} providers configured.")
|
||||
|
||||
Reference in New Issue
Block a user