diff --git a/litellm/proxy/openai_files_endpoints/files_endpoints.py b/litellm/proxy/openai_files_endpoints/files_endpoints.py index e2c221b9e72..7d2cebbe3f7 100644 --- a/litellm/proxy/openai_files_endpoints/files_endpoints.py +++ b/litellm/proxy/openai_files_endpoints/files_endpoints.py @@ -1750,6 +1750,12 @@ def _model_mapping_keys(deployments: Iterable[Deployment]) -> frozenset[str]: return frozenset(itertools.chain.from_iterable(map(_deployment_model_mapping_keys, deployments))) +def _team_public_model_names(deployments: Iterable[Deployment]) -> frozenset[str]: + return frozenset( + name for deployment in deployments if (name := deployment.model_info.team_public_model_name) is not None + ) + + def _deployments_serving_model(llm_router: Router, model: str, team_id: str | None) -> tuple[Deployment, ...]: deployment: Final = llm_router.registry().deployment(model) if llm_router.registry().has_deployment(model) else None if deployment is not None: @@ -1831,7 +1837,8 @@ def _files_serving_model(llm_router: Router, model: str, team_id: str | None) -> deployments: Final = _deployments_serving_model(llm_router, model, team_id) providers: Final = frozenset(map(_resolved_deployment_provider, deployments)) return _ListedFiles( - FileListModelScope(_model_mapping_keys(deployments)), next(iter(providers)) if len(providers) == 1 else None + FileListModelScope(_model_mapping_keys(deployments) | _team_public_model_names(deployments)), + next(iter(providers)) if len(providers) == 1 else None, ) diff --git a/tests/unit/proxy/openai_files_endpoint/test_files_endpoint.py b/tests/unit/proxy/openai_files_endpoint/test_files_endpoint.py index 528a03a56d5..f6dd5636f81 100644 --- a/tests/unit/proxy/openai_files_endpoint/test_files_endpoint.py +++ b/tests/unit/proxy/openai_files_endpoint/test_files_endpoint.py @@ -6432,6 +6432,12 @@ def test_require_managed_files_lists_the_callers_files_on_its_team_model_by_publ _router_with_two_teams_sharing_a_public_model_name(), [ _managed_file_row("unified-team-a", team_id="team-a", model_mappings={"team-a-gpt-id": "f-1"}), + _managed_file_row( + "unified-team-a-stored", + team_id="team-a", + model_mappings={"team-gpt": "storage-f-4"}, + storage_backend="azure_storage", + ), _managed_file_row("unified-global", team_id="team-a", model_mappings={"gpt-3.5-turbo-id": "f-2"}), _managed_file_row("unified-team-b", team_id="team-b", model_mappings={"team-b-gpt-id": "f-3"}), ], @@ -6444,7 +6450,7 @@ def test_require_managed_files_lists_the_callers_files_on_its_team_model_by_publ response: Final = _list_files_as_test_user("/v1/files", params, headers) assert response.status_code == 200, response.text - assert [file["id"] for file in response.json()["data"]] == ["unified-team-a"] + assert [file["id"] for file in response.json()["data"]] == ["unified-team-a", "unified-team-a-stored"]