tiktoken icon indicating copy to clipboard operation
tiktoken copied to clipboard

How to count tokens for functions defined in the prompt?

Open vrde opened this issue 2 years ago • 1 comments

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?

vrde avatar Oct 21 '23 15:10 vrde

You can consider checking out this package

waptik avatar Oct 26 '23 23:10 waptik