mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
Litellm dev 12 28 2024 p2 (#7458)
* docs(sidebar.js): docs for support model access groups for wildcard routes * feat(key_management_endpoints.py): add check if user is premium_user when adding model access group for wildcard route * refactor(docs/): make control model access a root-level doc in proxy sidebar easier to discover how to control model access on litellm * docs: more cleanup * feat(fireworks_ai/): add document inlining support Enables user to call non-vision models with images/pdfs/etc. * test(test_fireworks_ai_translation.py): add unit testing for fireworks ai transform inline helper util * docs(docs/): add document inlining details to fireworks ai docs * feat(fireworks_ai/): allow user to dynamically disable auto add transform inline allows client-side disabling of this feature for proxy users * feat(fireworks_ai/): return 'supports_vision' and 'supports_pdf_input' true on all fireworks ai models now true as fireworks ai supports document inlining * test: fix tests * fix(router.py): add unit testing for _is_model_access_group_for_wildcard_route
This commit is contained in:
parent
14324639a9
commit
9150722a00
19 changed files with 832 additions and 305 deletions
|
@ -4713,10 +4713,14 @@ class Router:
|
|||
return None
|
||||
|
||||
def get_model_access_groups(
|
||||
self, model_name: Optional[str] = None
|
||||
self, model_name: Optional[str] = None, model_access_group: Optional[str] = None
|
||||
) -> Dict[str, List[str]]:
|
||||
"""
|
||||
If model_name is provided, only return access groups for that model.
|
||||
|
||||
Parameters:
|
||||
- model_name: Optional[str] - the received model name from the user (can be a wildcard route). If set, will only return access groups for that model.
|
||||
- model_access_group: Optional[str] - the received model access group from the user. If set, will only return models for that access group.
|
||||
"""
|
||||
from collections import defaultdict
|
||||
|
||||
|
@ -4726,11 +4730,39 @@ class Router:
|
|||
if model_list:
|
||||
for m in model_list:
|
||||
for group in m.get("model_info", {}).get("access_groups", []):
|
||||
model_name = m["model_name"]
|
||||
access_groups[group].append(model_name)
|
||||
if model_access_group is not None:
|
||||
if group == model_access_group:
|
||||
model_name = m["model_name"]
|
||||
access_groups[group].append(model_name)
|
||||
else:
|
||||
model_name = m["model_name"]
|
||||
access_groups[group].append(model_name)
|
||||
|
||||
return access_groups
|
||||
|
||||
def _is_model_access_group_for_wildcard_route(
|
||||
self, model_access_group: str
|
||||
) -> bool:
|
||||
"""
|
||||
Return True if model access group is a wildcard route
|
||||
"""
|
||||
# GET ACCESS GROUPS
|
||||
access_groups = self.get_model_access_groups(
|
||||
model_access_group=model_access_group
|
||||
)
|
||||
|
||||
if len(access_groups) == 0:
|
||||
return False
|
||||
|
||||
models = access_groups.get(model_access_group, [])
|
||||
|
||||
for model in models:
|
||||
# CHECK IF MODEL ACCESS GROUP IS A WILDCARD ROUTE
|
||||
if self.pattern_router.route(request=model) is not None:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_settings(self):
|
||||
"""
|
||||
Get router settings method, returns a dictionary of the settings and their values.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue