Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to count tokens for functions defined in the prompt? #78

Open
vrde opened this issue Oct 21, 2023 · 1 comment
Open

How to count tokens for functions defined in the prompt? #78

vrde opened this issue Oct 21, 2023 · 1 comment

Comments

@vrde
Copy link

vrde commented Oct 21, 2023

I use functions in addition to a custom prompt, and a history of messages, to my chatCompletion calls.

I need to calculate the amount of tokens in my calls, to avoid hitting the token limit of the model.

I know how to calculate the amount of tokens for my prompt, but how do I to do it for the functions? Should I just tokenize the JSON describing the functions?

@waptik
Copy link

waptik commented Oct 26, 2023

You can consider checking out this package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants