-
Notifications
You must be signed in to change notification settings - Fork 898
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
Enhancement: Add convenience token-counting functions to this package #250
Comments
It will be great to have a cost calculator or at least a token calculator within tiktoken for prompt as well as for messages in chatCompletion |
I agree, it seems like it's constantly changing. |
@stephenasuncionDEV I'm curious, have you seen a change in the logic needed for the calculation I pu above? Just want to make sure I didn't miss an announcement. |
For now, since I have a need to use this functionality across multiple projects, I've put it in a small package: For example-
Will happily move to tiktoken or openAI if the functionality gets moved to one of those packages, though. |
I think it would be great to have an interface within tiktoken to calculate the tokens not just in a string but also in a conversation i.e. list of multimodal messages given how far we have come from the original/legacy completions endpoint. HNY and thanks @pamelafox for starting this. Throwing in my support for the same! |
We have implemented a lot of logic around token counting for ChatCompletion requests, and it feels like the logic should go in a separate package. I'm wondering if tiktoken would be an appropriate spot, given the logic all depends on tiktoken?
Specifically, I'm thinking of this sort of code, which is based off cookbooks:
We also have full tests for that code.
Would that be appropriate for tiktoken, or is it already in a separate package? It seems like it'd be helpful to be packaged up for easier community re-use. Thanks!
The text was updated successfully, but these errors were encountered: