mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
always fetch latest models
This commit is contained in:
parent
d183dc8269
commit
9d1c6eec3d
1 changed files with 16 additions and 16 deletions
|
@ -1135,24 +1135,24 @@ def get_all_keys(llm_provider=None):
|
||||||
def get_model_list():
|
def get_model_list():
|
||||||
global last_fetched_at
|
global last_fetched_at
|
||||||
try:
|
try:
|
||||||
# if user is using hosted product -> get their updated model list - refresh every 5 minutes
|
# if user is using hosted product -> get their updated model list
|
||||||
user_email = os.getenv("LITELLM_EMAIL") or litellm.email
|
user_email = os.getenv("LITELLM_EMAIL") or litellm.email
|
||||||
if user_email:
|
if user_email:
|
||||||
time_delta = 0
|
# Commented out the section checking time delta
|
||||||
if last_fetched_at != None:
|
# time_delta = 0
|
||||||
current_time = time.time()
|
# if last_fetched_at != None:
|
||||||
time_delta = current_time - last_fetched_at
|
# current_time = time.time()
|
||||||
if time_delta > 300 or last_fetched_at == None:
|
# time_delta = current_time - last_fetched_at
|
||||||
# make the api call
|
# if time_delta > 300 or last_fetched_at == None:
|
||||||
last_fetched_at = time.time()
|
# make the api call
|
||||||
print(f"last_fetched_at: {last_fetched_at}")
|
last_fetched_at = time.time()
|
||||||
response = requests.post(url="http://api.litellm.ai/get_model_list", headers={"content-type": "application/json"}, data=json.dumps({"user_email": user_email}))
|
print(f"last_fetched_at: {last_fetched_at}")
|
||||||
print_verbose(f"get_model_list response: {response.text}")
|
response = requests.post(url="http://api.litellm.ai/get_model_list", headers={"content-type": "application/json"}, data=json.dumps({"user_email": user_email}))
|
||||||
data = response.json()
|
print_verbose(f"get_model_list response: {response.text}")
|
||||||
# update model list
|
data = response.json()
|
||||||
model_list = data["model_list"]
|
# update model list
|
||||||
return model_list
|
model_list = data["model_list"]
|
||||||
return None
|
return model_list
|
||||||
return None # return None by default
|
return None # return None by default
|
||||||
except:
|
except:
|
||||||
print_verbose(f"[Non-Blocking Error] get_all_keys error - {traceback.format_exc()}")
|
print_verbose(f"[Non-Blocking Error] get_all_keys error - {traceback.format_exc()}")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue