We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 868cdd0 commit b96d2eaCopy full SHA for b96d2ea
litellm/utils.py
@@ -180,10 +180,18 @@
180
all_litellm_params,
181
)
182
183
-with resources.open_text(
184
- "litellm.litellm_core_utils.tokenizers", "anthropic_tokenizer.json"
185
-) as f:
186
- json_data = json.load(f)
+try:
+ # Python 3.9+
+ with resources.files("litellm.litellm_core_utils.tokenizers").joinpath(
+ "anthropic_tokenizer.json"
187
+ ).open("r") as f:
188
+ json_data = json.load(f)
189
+except (ImportError, AttributeError, TypeError):
190
+ with resources.open_text(
191
+ "litellm.litellm_core_utils.tokenizers", "anthropic_tokenizer.json"
192
+ ) as f:
193
194
+
195
# Convert to str (if necessary)
196
claude_json_str = json.dumps(json_data)
197
import importlib.metadata
0 commit comments