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

Add calculate tokens helper #47

Open
jodendaal opened this issue Mar 19, 2023 · 2 comments
Open

Add calculate tokens helper #47

jodendaal opened this issue Mar 19, 2023 · 2 comments

Comments

@jodendaal
Copy link
Owner

jodendaal commented Mar 19, 2023

Add method that will calculate tokens a request will use for text completion and chat API.

This is useful when consuming the library in an application and needing to truncate prompt.

Help avoid each implementation using a different calculation.

@Alumniminium
Copy link

That would be very helpful. I keep getting exceptions because the input size + the maxtokens param exceed the models max token count.

@LyleRolleman-plst
Copy link

Bit late to the party, but you can use TikTokenSharp for this (port of the tiktoken python library)

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

3 participants