mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
Bug Fix - Address deprecation of open_text (#10208)
* Update utils.py (#10201) * fixes importlib --------- Co-authored-by: Nathan Brake <33383515+njbrake@users.noreply.github.com>
This commit is contained in:
parent
868cdd0226
commit
b96d2ea422
1 changed files with 12 additions and 4 deletions
|
@ -180,10 +180,18 @@ from litellm.types.utils import (
|
|||
all_litellm_params,
|
||||
)
|
||||
|
||||
with resources.open_text(
|
||||
"litellm.litellm_core_utils.tokenizers", "anthropic_tokenizer.json"
|
||||
) as f:
|
||||
json_data = json.load(f)
|
||||
try:
|
||||
# Python 3.9+
|
||||
with resources.files("litellm.litellm_core_utils.tokenizers").joinpath(
|
||||
"anthropic_tokenizer.json"
|
||||
).open("r") as f:
|
||||
json_data = json.load(f)
|
||||
except (ImportError, AttributeError, TypeError):
|
||||
with resources.open_text(
|
||||
"litellm.litellm_core_utils.tokenizers", "anthropic_tokenizer.json"
|
||||
) as f:
|
||||
json_data = json.load(f)
|
||||
|
||||
# Convert to str (if necessary)
|
||||
claude_json_str = json.dumps(json_data)
|
||||
import importlib.metadata
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue