Skyvern/skyvern/utils/token_counter.py
Shuchang Zheng 3c612968ce
Some checks failed
Run tests and pre-commit / test (push) Failing after 23s
Publish Fern Docs / run (push) Failing after 46s
Run tests and pre-commit / fe-lint-build (push) Successful in 1m12s
Sync to skyvern-cloud / sync (push) Failing after 2s
Build Skyvern SDK and publish to PyPI / check-version-change (push) Successful in 12s
Build Skyvern SDK and publish to PyPI / run-ci (push) Has been skipped
Build Skyvern SDK and publish to PyPI / build-sdk (push) Has been skipped
trim svg elements when prompt exceeds context window (#2106)
2025-04-04 22:33:52 -04:00

5 lines
121 B
Python

import tiktoken
def count_tokens(text: str) -> int:
return len(tiktoken.encoding_for_model("gpt-4o").encode(text))