Add page readiness check before cached actions (#4492)

This commit is contained in:
pedrohsdb
2026-01-19 15:41:15 -08:00
committed by GitHub
parent a795254f45
commit b1cc6de7ed
4 changed files with 211 additions and 7 deletions

View File

@@ -2,10 +2,4 @@ import tiktoken
def count_tokens(text: str) -> int:
"""
tiktoken sends a request to https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken to get the token
"""
try:
return len(tiktoken.encoding_for_model("gpt-4o").encode(text))
except Exception:
return 0
return len(tiktoken.encoding_for_model("gpt-4o").encode(text))