forked from phoenix/litellm-mirror
fix anthropic json location bug
This commit is contained in:
parent
9ef0ad9e66
commit
e1d0c6096c
4 changed files with 4 additions and 2 deletions
|
@ -8,6 +8,7 @@ import tiktoken
|
|||
import uuid
|
||||
import aiohttp
|
||||
from tokenizers import Tokenizer
|
||||
import pkg_resources
|
||||
encoding = tiktoken.get_encoding("cl100k_base")
|
||||
import importlib.metadata
|
||||
from .integrations.traceloop import TraceloopLogger
|
||||
|
@ -723,7 +724,8 @@ def token_counter(model="", text=None, messages: Optional[List] = None):
|
|||
# anthropic
|
||||
elif model in litellm.anthropic_models:
|
||||
# Read the JSON file
|
||||
with open('../llms/tokenizers/anthropic_tokenizer.json', 'r') as f:
|
||||
filename = pkg_resources.resource_filename(__name__, 'llms/tokenizers/anthropic_tokenizer.json')
|
||||
with open(filename, 'r') as f:
|
||||
json_data = json.load(f)
|
||||
# Decode the JSON data from utf-8
|
||||
json_data_decoded = json.dumps(json_data, ensure_ascii=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue