mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-13 08:52:02 +00:00
fix(proxy): keep storage-backed files in a team model's managed file list
Files a team stores itself are keyed by the team model's public name, so the managed file list scope for a team deployment now includes that name next to the deployment's internal name and id
This commit is contained in:
parent
a1329da503
commit
2e181246bb
2 changed files with 15 additions and 2 deletions
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue