mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-14 22:52:39 +00:00
feat: Add allow_listing_models
• Add allow_listing_models configuration flag to VLLM provider to control model listing behavior • Implement allow_listing_models() method across all providers with default implementations in base classes • Prevent HTTP requests to /v1/models endpoint when allow_listing_models=false for improved security and performance • Fix unit tests to include allow_listing_models method in test classes and mock objects
This commit is contained in:
parent
188a56af5c
commit
e9214f9004
15 changed files with 143 additions and 25 deletions
|
|
@ -43,6 +43,12 @@ class ModelsRoutingTable(CommonRoutingTableImpl, Models):
|
|||
await self.update_registered_models(provider_id, models)
|
||||
|
||||
async def list_models(self) -> ListModelsResponse:
|
||||
# Check if providers allow listing models before returning models
|
||||
for provider_id, provider in self.impls_by_provider_id.items():
|
||||
allow_listing_models = await provider.allow_listing_models()
|
||||
logger.debug(f"Provider {provider_id}: allow_listing_models={allow_listing_models}")
|
||||
if not allow_listing_models:
|
||||
logger.debug(f"Provider {provider_id} has allow_listing_models disabled")
|
||||
return ListModelsResponse(data=await self.get_all_with_type("model"))
|
||||
|
||||
async def openai_list_models(self) -> OpenAIListModelsResponse:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue