diff --git a/litellm/utils.py b/litellm/utils.py index 97a5aa5e5..d76245bf2 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -44,6 +44,7 @@ user_logger_fn = None additional_details: Optional[Dict[str, str]] = {} local_cache: Optional[Dict[str, str]] = {} last_fetched_at = None +last_fetched_at_keys = None ######## Model Response ######################### # All liteLLM Model responses will be in this format, Follows the OpenAI Format # https://docs.litellm.ai/docs/completion/output @@ -1131,19 +1132,19 @@ def modify_integration(integration_name, integration_params): def get_all_keys(llm_provider=None): try: - global last_fetched_at + global last_fetched_at_keys # if user is using hosted product -> instantiate their env with their hosted api keys - refresh every 5 minutes print_verbose(f"Reaches get all keys, llm_provider: {llm_provider}") user_email = os.getenv("LITELLM_EMAIL") or litellm.email or litellm.token or os.getenv("LITELLM_TOKEN") if user_email: time_delta = 0 - if last_fetched_at != None: + if last_fetched_at_keys != None: current_time = time.time() - time_delta = current_time - last_fetched_at - if time_delta > 300 or last_fetched_at == None or llm_provider: # if the llm provider is passed in , assume this happening due to an AuthError for that provider + time_delta = current_time - last_fetched_at_keys + if time_delta > 300 or last_fetched_at_keys == None or llm_provider: # if the llm provider is passed in , assume this happening due to an AuthError for that provider # make the api call - last_fetched_at = time.time() - print(f"last_fetched_at: {last_fetched_at}") + last_fetched_at_keys = time.time() + print_verbose(f"last_fetched_at_keys: {last_fetched_at_keys}") response = requests.post(url="http://api.litellm.ai/get_all_keys", headers={"content-type": "application/json"}, data=json.dumps({"user_email": user_email})) print_verbose(f"get model key response: {response.text}") data = response.json() @@ -1174,7 +1175,6 @@ def get_model_list(): data = response.json() # update model list model_list = data["model_list"] - get_all_keys() return model_list return [] # return empty list by default except: diff --git a/pyproject.toml b/pyproject.toml index 852ee0993..ecc41e925 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.480" +version = "0.1.481" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"