This commit is contained in:
Xi Yan 2025-03-13 19:30:47 -07:00
parent 194d86a232
commit a715debcb8
4 changed files with 9 additions and 25 deletions

View file

@ -2159,14 +2159,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/ProviderInfo"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/ProviderInfo"
}
}
}

View file

@ -1452,9 +1452,7 @@ paths:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/ProviderInfo'
- type: 'null'
$ref: '#/components/schemas/ProviderInfo'
'400':
$ref: '#/components/responses/BadRequest400'
'429':

View file

@ -33,4 +33,4 @@ class Providers(Protocol):
async def list_providers(self) -> ListProvidersResponse: ...
@webmethod(route="/providers/{provider_id}", method="GET")
async def inspect_provider(self, provider_id: str) -> Optional[ProviderInfo]: ...
async def inspect_provider(self, provider_id: str) -> ProviderInfo: ...

View file

@ -51,17 +51,10 @@ class ProviderImpl(Providers):
return ListProvidersResponse(data=ret)
async def inspect_provider(self, provider_id: str) -> Optional[ProviderInfo]:
run_config = self.config.run_config
safe_config = StackRunConfig(**redact_sensitive_fields(run_config.model_dump()))
for api, providers in safe_config.providers.items():
for p in providers:
if p.provider_id == provider_id:
return ProviderInfo(
api=api,
provider_id=p.provider_id,
provider_type=p.provider_type,
config=p.config,
)
async def inspect_provider(self, provider_id: str) -> ProviderInfo:
all_providers = await self.list_providers()
for p in all_providers.data:
if p.provider_id == provider_id:
return p
return None
raise ValueError(f"Provider {provider_id} not found")