refactor(proxy_server.py): fix linting issues

This commit is contained in:
Krrish Dholakia 2023-11-30 09:24:51 -08:00
parent cbc358ef77
commit 062ede96e3

View file

@ -854,34 +854,35 @@ async def info_key_fn(key: str = fastapi.Query(..., description="Key in the requ
#### MODEL MANAGEMENT #### #### MODEL MANAGEMENT ####
#### [BETA] - This is a beta endpoint, format might change based on user feedback. - https://github.com/BerriAI/litellm/issues/933 #### [BETA] - This is a beta endpoint, format might change based on user feedback. - https://github.com/BerriAI/litellm/issues/933
@router.get("/model/info", description="Provides more info about each model in /models, including config.yaml descriptions", tags=["model management"], dependencies=[Depends(user_api_key_auth)]) @router.get("/model/info", description="Provides more info about each model in /models, including config.yaml descriptions (except api key and api base)", tags=["model management"], dependencies=[Depends(user_api_key_auth)])
async def model_info(request: Request): async def model_info(request: Request):
global llm_model_list, general_settings global llm_model_list, general_settings
all_models = [] all_models = []
for m in llm_model_list: if llm_model_list is not None:
model_dict = {} for m in llm_model_list:
model_name = m["model_name"] model_dict = {}
model_params = {} model_name = m["model_name"]
for k,v in m["litellm_params"].items(): model_params = {}
if k == "api_key" or k == "api_base": # don't send the api key or api base for k,v in m["litellm_params"].items():
continue if k == "api_key" or k == "api_base": # don't send the api key or api base
continue
if k == "model":
########## remove -ModelID-XXXX from model ############## if k == "model":
original_model_string = v ########## remove -ModelID-XXXX from model ##############
# Find the index of "ModelID" in the string original_model_string = v
index_of_model_id = original_model_string.find("-ModelID") # Find the index of "ModelID" in the string
# Remove everything after "-ModelID" if it exists index_of_model_id = original_model_string.find("-ModelID")
if index_of_model_id != -1: # Remove everything after "-ModelID" if it exists
v = original_model_string[:index_of_model_id] if index_of_model_id != -1:
else: v = original_model_string[:index_of_model_id]
v = original_model_string else:
v = original_model_string
model_params[k] = v
model_params[k] = v
model_dict["model_name"] = model_name model_dict["model_name"] = model_name
model_dict["model_params"] = model_params model_dict["model_params"] = model_params
all_models.append(model_dict) all_models.append(model_dict)
# all_models = list(set([m["model_name"] for m in llm_model_list])) # all_models = list(set([m["model_name"] for m in llm_model_list]))
print_verbose(f"all_models: {all_models}") print_verbose(f"all_models: {all_models}")
return dict( return dict(