forked from phoenix/litellm-mirror
fix(proxy_server.py): fix model list returned for /model/info
when team has restricted access
This commit is contained in:
parent
25a2f00db6
commit
95566dc249
2 changed files with 46 additions and 16 deletions
|
@ -9395,12 +9395,31 @@ async def model_info_v1(
|
|||
status_code=500, detail={"error": "LLM Model List not loaded in"}
|
||||
)
|
||||
|
||||
if len(user_api_key_dict.models) > 0:
|
||||
model_names = user_api_key_dict.models
|
||||
all_models: List[dict] = []
|
||||
## CHECK IF MODEL RESTRICTIONS ARE SET AT KEY/TEAM LEVEL ##
|
||||
if llm_model_list is None:
|
||||
proxy_model_list = []
|
||||
else:
|
||||
proxy_model_list = [m["model_name"] for m in llm_model_list]
|
||||
key_models = get_key_models(
|
||||
user_api_key_dict=user_api_key_dict, proxy_model_list=proxy_model_list
|
||||
)
|
||||
team_models = get_team_models(
|
||||
user_api_key_dict=user_api_key_dict, proxy_model_list=proxy_model_list
|
||||
)
|
||||
all_models_str = get_complete_model_list(
|
||||
key_models=key_models,
|
||||
team_models=team_models,
|
||||
proxy_model_list=proxy_model_list,
|
||||
user_model=user_model,
|
||||
infer_model_from_keys=general_settings.get("infer_model_from_keys", False),
|
||||
)
|
||||
|
||||
if len(all_models_str) > 0:
|
||||
model_names = all_models_str
|
||||
_relevant_models = [m for m in llm_model_list if m["model_name"] in model_names]
|
||||
all_models = copy.deepcopy(_relevant_models)
|
||||
else:
|
||||
all_models = copy.deepcopy(llm_model_list)
|
||||
|
||||
for model in all_models:
|
||||
# provided model_info in config.yaml
|
||||
model_info = model.get("model_info", {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue