From 3c919cbbe7b340a44f466c4d12e117d3918ed67f Mon Sep 17 00:00:00 2001 From: Alexandre Sorokine Date: Fri, 16 Feb 2024 15:52:39 -0500 Subject: [PATCH] fix for importllib compatibility issue for python 3.8 was tested for python versions 3.8, 3.9, 3.10, 3.11, 3.12 --- litellm/utils.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 2e54b5e4465..7fadb577fb4 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -31,16 +31,17 @@ from dataclasses import ( field, ) # for storing API inputs, outputs, and metadata -# import pkg_resources -from importlib import resources - -# filename = pkg_resources.resource_filename(__name__, "llms/tokenizers") - try: - filename = str( - resources.files().joinpath("llms/tokenizers") # type: ignore - ) # for python 3.8 and 3.12 + # this works in python 3.8 + import pkg_resources + filename = pkg_resources.resource_filename(__name__, "llms/tokenizers") +# try: +# filename = str( +# resources.files().joinpath("llms/tokenizers") # type: ignore +# ) # for python 3.8 and 3.12 except: + # this works in python 3.9+ + from importlib import resources filename = str( resources.files(litellm).joinpath("llms/tokenizers") # for python 3.10 ) # for python 3.10+