fix(files): list alias and routing-group storage uploads on their provider

This commit is contained in:
mateo-berri 2026-10-28 10:00:21 -07:00
parent ddc20ae8c6
commit e6edd7e7fe
2 changed files with 49 additions and 9 deletions

View file

@ -1775,9 +1775,24 @@ def _deployments_on_provider(llm_router: Router | None, custom_llm_provider: str
)
def _pattern_routes_model_name_to_provider(llm_router: Router, custom_llm_provider: str, model_name: str) -> bool:
return model_name not in llm_router.model_names and llm_router.pattern_router.routes_to_provider(
model_name, custom_llm_provider
def _routed_model_name_on_provider(
llm_router: Router, custom_llm_provider: str, provider_model_names: frozenset[str], model_name: str
) -> bool:
if model_name in llm_router.model_names:
return model_name in provider_model_names
return llm_router.pattern_router.routes_to_provider(model_name, custom_llm_provider)
def _stored_model_name_routes_to_provider(
llm_router: Router, custom_llm_provider: str, provider_model_names: frozenset[str], model_name: str
) -> bool:
routing_group: Final = llm_router.get_routing_group(model_name)
routed_model_names: Final = (
tuple(routing_group.models) if routing_group is not None else (llm_router.routable_model_group(model_name),)
)
return any(
_routed_model_name_on_provider(llm_router, custom_llm_provider, provider_model_names, routed_model_name)
for routed_model_name in routed_model_names
)
@ -1787,16 +1802,20 @@ def _files_on_provider(llm_router: Router | None, custom_llm_provider: str) -> _
if custom_llm_provider not in litellm.provider_list:
return _UnscopedFileList(status_code=400, detail=f"Unknown provider '{custom_llm_provider}' for listing files.")
passthrough_model_id: Final = passthrough_file_model_id(custom_llm_provider)
model_mapping_keys: Final = _model_mapping_keys(
_deployments_on_provider(llm_router, custom_llm_provider)
) | frozenset((passthrough_model_id,) if passthrough_model_id is not None else ())
deployments: Final = tuple(_deployments_on_provider(llm_router, custom_llm_provider))
model_mapping_keys: Final = _model_mapping_keys(deployments) | frozenset(
(passthrough_model_id,) if passthrough_model_id is not None else ()
)
if llm_router is None:
return _ListedFiles(FileListModelScope(model_mapping_keys), custom_llm_provider)
return _ListedFiles(
FileListModelScope(
model_mapping_keys,
routes_stored_model_name=functools.partial(
_pattern_routes_model_name_to_provider, llm_router, custom_llm_provider
_stored_model_name_routes_to_provider,
llm_router,
custom_llm_provider,
frozenset(deployment.model_name for deployment in deployments),
),
),
custom_llm_provider,

View file

@ -6410,7 +6410,11 @@ def _router_with_wildcard_and_unprefixed_anthropic_deployments() -> Router:
"litellm_params": {"model": unprefixed_anthropic_model, "api_key": "anthropic_api_key"},
"model_info": {"id": "claude-unprefixed-id"},
},
]
],
model_group_alias={"claude-alias": "claude-unprefixed"},
routing_groups=[
{"group_name": "claude-group", "models": ["claude-unprefixed"], "routing_strategy": "simple-shuffle"}
],
)
@ -6436,6 +6440,16 @@ def _callers_files_on_wildcard_unprefixed_and_passthrough_deployments() -> list[
model_mappings={"anthropic/claude-haiku-5-5": "litellm_db://unified-wildcard-storage"},
storage_backend="litellm_db",
),
_managed_file_row(
"unified-alias-storage",
model_mappings={"claude-alias": "s3://bucket/unified-alias-storage"},
storage_backend="s3",
),
_managed_file_row(
"unified-group-storage",
model_mappings={"claude-group": "s3://bucket/unified-group-storage"},
storage_backend="s3",
),
]
@ -6458,7 +6472,14 @@ def _callers_files_on_wildcard_unprefixed_and_passthrough_deployments() -> list[
"/anthropic/v1/files",
{},
{},
["unified-wildcard", "unified-unprefixed", "unified-storage", "unified-wildcard-storage"],
[
"unified-wildcard",
"unified-unprefixed",
"unified-storage",
"unified-wildcard-storage",
"unified-alias-storage",
"unified-group-storage",
],
),
("/openai/v1/files", {}, {}, ["unified-gpt", "unified-passthrough"]),
("/v1/files", {"target_model_names": "claude-unprefixed"}, {}, ["unified-unprefixed", "unified-storage"]),