forked from phoenix/litellm-mirror
fix(utils.py): add try-except around the tiktoken local import
This commit is contained in:
parent
4be6d21c65
commit
aa78f55dff
1 changed files with 8 additions and 1 deletions
|
@ -34,7 +34,14 @@ from dataclasses import (
|
||||||
from importlib import resources
|
from importlib import resources
|
||||||
|
|
||||||
# filename = pkg_resources.resource_filename(__name__, "llms/tokenizers")
|
# filename = pkg_resources.resource_filename(__name__, "llms/tokenizers")
|
||||||
filename = str(resources.files(litellm).joinpath("llms/tokenizers"))
|
try:
|
||||||
|
filename = str(
|
||||||
|
resources.files().joinpath("llms/tokenizers") # type: ignore
|
||||||
|
) # for python 3.8 and 3.12
|
||||||
|
except:
|
||||||
|
filename = str(
|
||||||
|
resources.files(litellm).joinpath("llms/tokenizers") # for python 3.10
|
||||||
|
) # for python 3.10+
|
||||||
os.environ[
|
os.environ[
|
||||||
"TIKTOKEN_CACHE_DIR"
|
"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