def count_tokens(text="", model="gpt-4"):
"""
Count the number of tokens in a string
"""
# Fix bug where models starting with openai/ for example can't find tokenizer
if '/' in model:
model = model.split('/')[-1]
# At least give an estimate if we can't find the tokenizer
try:
encoder = tiktoken.encoding_for_model(model)
except KeyError:
print(f"Could not find tokenizer for {model}. Defaulting to gpt-4 tokenizer.")
encoder = tiktoken.encoding_for_model("gpt-4")
return len(encoder.encode(text))
This code in count_tokens.py cause interpreter to crash when using interpreter offline with local models without ever running using gpt-4.
Reproduce
Delete cache
install interpreter
disconnect internet
run using local model
Describe the bug
This code in
count_tokens.py
cause interpreter to crash when using interpreter offline with local models without ever running using gpt-4.Reproduce
Delete cache install interpreter disconnect internet run using local model
Expected behavior
Interpreter should work offline
Screenshots
No response
Open Interpreter version
0.1.17
Python version
3.11.6
Operating System name and version
Windows 11
Additional context
No response