trim svg elements when prompt exceeds context window (#2106)

This commit is contained in:
Shuchang Zheng
2025-04-04 22:33:52 -04:00
committed by GitHub
parent 5e427fc401
commit 3c612968ce
8 changed files with 126 additions and 14 deletions

View File

@@ -0,0 +1,5 @@
import tiktoken
def count_tokens(text: str) -> int:
return len(tiktoken.encoding_for_model("gpt-4o").encode(text))