mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
cache the model list response
This commit is contained in:
parent
4b34eb1414
commit
c8130f9fe0
4 changed files with 7 additions and 3 deletions
Binary file not shown.
|
@ -3,6 +3,9 @@ import os, sys, traceback
|
||||||
sys.path.insert(
|
sys.path.insert(
|
||||||
0, os.path.abspath("../..")
|
0, os.path.abspath("../..")
|
||||||
) # Adds the parent directory to the system path
|
) # Adds the parent directory to the system path
|
||||||
|
import litellm
|
||||||
from litellm import get_model_list
|
from litellm import get_model_list
|
||||||
|
|
||||||
print(get_model_list())
|
print(get_model_list())
|
||||||
|
print(get_model_list())
|
||||||
|
# print(litellm.model_list)
|
|
@ -1019,10 +1019,11 @@ def get_model_list():
|
||||||
if time_delta > 300 or last_fetched_at == None:
|
if time_delta > 300 or last_fetched_at == None:
|
||||||
# make the api call
|
# make the api call
|
||||||
last_fetched_at = time.time()
|
last_fetched_at = time.time()
|
||||||
|
print(f"last_fetched_at: {last_fetched_at}")
|
||||||
response = requests.get(url="http://api.litellm.ai/get_model_list", headers={"content-type": "application/json"}, data=json.dumps({"user_email": user_email}))
|
response = requests.get(url="http://api.litellm.ai/get_model_list", headers={"content-type": "application/json"}, data=json.dumps({"user_email": user_email}))
|
||||||
print_verbose(f"get_model_list response: {response.text}")
|
print_verbose(f"get_model_list response: {response.text}")
|
||||||
model_list = response.json()["model_list"]
|
model_list = response.json()["model_list"]
|
||||||
return model_list
|
litellm.model_list = model_list # update the user's current litellm model list
|
||||||
# return litellm model list by default
|
# return litellm model list by default
|
||||||
return litellm.model_list
|
return litellm.model_list
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "litellm"
|
name = "litellm"
|
||||||
version = "0.1.449"
|
version = "0.1.450"
|
||||||
description = "Library to easily interface with LLM API providers"
|
description = "Library to easily interface with LLM API providers"
|
||||||
authors = ["BerriAI"]
|
authors = ["BerriAI"]
|
||||||
license = "MIT License"
|
license = "MIT License"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue