From c8130f9fe06b89e1aba4a125ff65645d5ff0ca7a Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Tue, 22 Aug 2023 07:21:24 -0700 Subject: [PATCH] cache the model list response --- litellm/__pycache__/utils.cpython-311.pyc | Bin 57955 -> 58207 bytes litellm/tests/test_get_model_list.py | 5 ++++- litellm/utils.py | 3 ++- pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/litellm/__pycache__/utils.cpython-311.pyc b/litellm/__pycache__/utils.cpython-311.pyc index 89d8eddd5015192f4bc15c325115268a78e15459..81e6034e2b846061efae8d1ef5c175326fe5f711 100644 GIT binary patch delta 667 zcmYjLUr1A76#ve>cW%z_?$4cB!lrji1m_4LXiM-VA|Xhr9(obBv2W6yGh<$Z>{=Gl zpNB#8#n^075m{)2^{IprVfKe!Vv8j~Nrd@O^v9PTdIZNi@QK{`cF(psBeV&0Yo-%E(_@*T`n$UPcU%UM47iMlNw*+Ge>AzNd<4_q znP!Pp=@#1PZfvx#SrJNb)BiOyv5;yFbQg7mYeU3pAPvR=p-G-)+^HECdC#+q5mDc` zRwG2PAto^Oy4{i?UaO`~*>{4-^%cX2WJtPHX;HZH^LjN=QTL-3TUY8VUq}g@v;hBO z*rOd9)JR;79@f-YG@0C@>RNwXCGn&lZC8hDRYOfi2la4oT#p@$*OPEm=dyF1R+cDa zFMy3+%=*PtC!%xNGtF)M{wVrcg}hsr5aB`^3c`ob#(7o49sk1Y#9L4T>c4ISNtK9_+tEfVLw(Fw@{s3eA Bzdir} delta 423 zcmcbAjQQ~qX1?XTyj%=Gu=3!Ol;dwU@+nVa-o?l;neU3^WZ!AJjO!*>Pb+0EF5#X$ zag)+y&*^-Vvn9DWQdm-0Q`j;YCo7&6vq)jDVaQ}$#>l|18i*la4aYKOARmY!pq9Br z6vk#?Na3tu&f=b|C?msC!@PiFvLLULO$wJJTtO{M4NEXX2@70+A&Upb4rb8g_A6=! za*LRNM5YeV&dK{{Okm`l957RBa{bH}rtb`sS!XFSbF<1#)|_R<{ZvkAPUg()IoTcl zlb6nFVilIXz#}_ZZ*~(S>*kHKA2Tv?O`baU5F^Lth_zSB#AEn_~{WVP@3a?0IYxBhx>Y&3}*QGBG-B&OX)2${4!&>-jm%jOCjr dT^43xtlzxsdM_8hAfwy|1~{R%+3AriBLK+reaip< diff --git a/litellm/tests/test_get_model_list.py b/litellm/tests/test_get_model_list.py index 570a0e207e..af91715e43 100644 --- a/litellm/tests/test_get_model_list.py +++ b/litellm/tests/test_get_model_list.py @@ -3,6 +3,9 @@ import os, sys, traceback sys.path.insert( 0, os.path.abspath("../..") ) # Adds the parent directory to the system path +import litellm from litellm import get_model_list -print(get_model_list()) \ No newline at end of file +print(get_model_list()) +print(get_model_list()) +# print(litellm.model_list) \ No newline at end of file diff --git a/litellm/utils.py b/litellm/utils.py index ad6af63c45..b532ba7d5b 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1019,10 +1019,11 @@ def get_model_list(): if time_delta > 300 or last_fetched_at == None: # make the api call 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})) print_verbose(f"get_model_list response: {response.text}") 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 diff --git a/pyproject.toml b/pyproject.toml index 43d85c9600..3563989edf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "litellm" -version = "0.1.449" +version = "0.1.450" description = "Library to easily interface with LLM API providers" authors = ["BerriAI"] license = "MIT License"