Merge pull request #1947 from sorokine/main

Update utils.py: switched from pkg_resources to importlib.resources for `filename` stored in the `os.environ(TIKTOKEN_CACHE_DIR)`
This commit is contained in:
Krish Dholakia 2024-02-14 22:02:35 -08:00 committed by GitHub
commit 78bff46d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,9 +29,11 @@ from dataclasses import (
dataclass,
field,
) # for storing API inputs, outputs, and metadata
import pkg_resources
#import pkg_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().joinpath("llms/tokenizers"))
os.environ[
"TIKTOKEN_CACHE_DIR"
] = filename # use local copy of tiktoken b/c of - https://github.com/BerriAI/litellm/issues/1071