Repository navigation
fix(proxy): list key and team model aliases in GET /v1/models #42908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
a3a2a1a
d6ec911
c39356e
f187b8a
8a205fb
470725b
2eb9a1d
579abf4
4a06c64
459bbd3
8e970ce
884653a
2557744
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -422,6 +422,9 @@ def generate_feedback_box(): | |
| from litellm.proxy.common_utils.model_listing_utils import ( | ||
| ClaudeCodeRoutingNames, | ||
| TeamModelNameTranslator, | ||
| alias_listing_entries, | ||
| alias_target, | ||
| caller_alias_maps, | ||
| claude_code_view_ids, | ||
| configured_display_names, | ||
| is_claude_code_client, | ||
|
|
@@ -11172,14 +11175,13 @@ async def model_list( | |
| view_aliases: Final = ( | ||
| view_router_settings.get("model_group_alias") if isinstance(view_router_settings, Mapping) else None | ||
| ) | ||
| caller_aliases: Final = caller_alias_maps( | ||
| user_api_key_dict.aliases, user_api_key_dict.team_model_aliases, user_api_key_dict.team_id, team_id | ||
| ) | ||
| routing_names: Final = ClaudeCodeRoutingNames( | ||
| llm_router, | ||
| team_id or user_api_key_dict.team_id, | ||
| ( | ||
| user_api_key_dict.aliases, | ||
| user_api_key_dict.team_model_aliases, | ||
| view_aliases, | ||
| ), | ||
| (*caller_aliases.rewrite, view_aliases), | ||
| ) | ||
|
|
||
| # Validate scope parameter if provided | ||
|
|
@@ -11307,7 +11309,9 @@ async def model_list( | |
| # The internal routing key drives the metadata/fallback lookup, while the | ||
| # public name is what the client sees as the model id. | ||
| model_data = [] | ||
| entries: Final = TeamModelNameTranslator.listing_entries(all_models, llm_router, settings) | ||
| entries: Final = alias_listing_entries( | ||
| TeamModelNameTranslator.listing_entries(all_models, llm_router, settings), caller_aliases | ||
| ) | ||
| for response_id, lookup_id in entries: | ||
| model_info = create_model_info_response( | ||
| model_id=lookup_id, | ||
|
|
@@ -11391,7 +11395,8 @@ async def model_info( | |
| ) | ||
|
|
||
| # Mirror /v1/models' visibility filter so first-occurrence resolution | ||
| # cannot land on a deployment the listing had hidden. | ||
| # cannot land on a deployment the listing had hidden. Undiscoverable | ||
| # models stay retrievable by id, they only drop out of the alias guard. | ||
| blocked_names: Final = llm_router.get_fully_blocked_model_names() if llm_router is not None else set() | ||
| unhealthy_names: Final = await get_hidden_unhealthy_model_names( | ||
| healthy_only=healthy_only, | ||
|
|
@@ -11401,10 +11406,25 @@ async def model_info( | |
| hidden_names: Final = blocked_names | unhealthy_names | ||
| if hidden_names: | ||
| all_models = [m for m in all_models if m not in hidden_names] | ||
| undiscoverable_names: Final = undiscoverable_model_names( | ||
| all_models, llm_router, user_api_key_dict, team_id or user_api_key_dict.team_id | ||
| ) | ||
|
|
||
| internal_to_public: Final = TeamModelNameTranslator.build_internal_to_public_map(llm_router, settings) | ||
| aliased_model_id: Final = alias_target( | ||
| model_id, | ||
| caller_alias_maps( | ||
| user_api_key_dict.aliases, user_api_key_dict.team_model_aliases, user_api_key_dict.team_id, team_id | ||
| ), | ||
| frozenset( | ||
| response_id | ||
| for response_id, _ in TeamModelNameTranslator.listing_entries( | ||
| [m for m in all_models if m not in undiscoverable_names], llm_router, settings | ||
| ) | ||
| ), | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| ) | ||
| resolved_model_id: Final = TeamModelNameTranslator.resolve_public_name( | ||
| model_id=model_id, | ||
| model_id=aliased_model_id or model_id, | ||
| available_models=all_models, | ||
|
Comment on lines
11426
to
11428
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If an undiscoverable team model and a discoverable model share a public ID,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pre-existing and out of scope:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right — the existing |
||
| llm_router=llm_router, | ||
| general_settings=settings, | ||
|
|
@@ -11434,7 +11454,8 @@ async def model_info( | |
| fallback_type=None, | ||
| llm_router=llm_router, | ||
| ) | ||
| return {**response, "id": internal_to_public.get(resolved_model_id, model_id)} # mutable-ok: response id differs | ||
| response_id: Final = model_id if aliased_model_id else internal_to_public.get(resolved_model_id, model_id) | ||
| return {**response, "id": response_id} # mutable-ok: response id differs | ||
|
|
||
|
|
||
| def _blocked_response_usage(original_response: object | None) -> "litellm.Usage": | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.