JulsdL's picture
Refactored the code for better maintainability in preparation for LangGraph multi-agent implementation
c4eb0c2
raw
history blame
135 Bytes
import tiktoken
def tiktoken_len(text):
tokens = tiktoken.encoding_for_model("gpt-3.5-turbo").encode(text)
return len(tokens)