Skip to content

Commit

Permalink
chore: (dependencies) bump tiktoken version to 0.8.0 and update compa…
Browse files Browse the repository at this point in the history
…tibility in token.py
  • Loading branch information
yufeikang committed Dec 11, 2024
1 parent 78fda0b commit 0ba1e94
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
64 changes: 33 additions & 31 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/ai_cli/bot/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


def get_token_count(text: str, model: str = "gpt-3.5-turbo") -> int:
if model.startswith("o1"):
model = "gpt-4o"
encoding = tiktoken.encoding_for_model(model)
tokens = encoding.encode(text)
return len(tokens)

0 comments on commit 0ba1e94

Please sign in to comment.