mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
Merge pull request #3602 from msabramo/msabramo/fix_pkg_resources_warning
Fix `pkg_resources` warning
This commit is contained in:
commit
5b390b6512
1 changed files with 9 additions and 12 deletions
|
@ -40,21 +40,18 @@ from litellm.caching import DualCache
|
||||||
oidc_cache = DualCache()
|
oidc_cache = DualCache()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# this works in python 3.8
|
# New and recommended way to access resources
|
||||||
import pkg_resources # type: ignore
|
|
||||||
|
|
||||||
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
|
from importlib import resources
|
||||||
|
|
||||||
filename = str(
|
filename = str(
|
||||||
resources.files(litellm).joinpath("llms/tokenizers") # for python 3.10
|
resources.files(litellm).joinpath("llms/tokenizers")
|
||||||
) # for python 3.10+
|
)
|
||||||
|
except ImportError:
|
||||||
|
# Old way to access resources, which setuptools deprecated some time ago
|
||||||
|
import pkg_resources # type: ignore
|
||||||
|
|
||||||
|
filename = pkg_resources.resource_filename(__name__, "llms/tokenizers")
|
||||||
|
|
||||||
os.environ["TIKTOKEN_CACHE_DIR"] = (
|
os.environ["TIKTOKEN_CACHE_DIR"] = (
|
||||||
filename # use local copy of tiktoken b/c of - https://github.com/BerriAI/litellm/issues/1071
|
filename # use local copy of tiktoken b/c of - https://github.com/BerriAI/litellm/issues/1071
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue