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

Support function calls? #21

Open
seoker opened this issue Jun 29, 2023 · 3 comments
Open

Support function calls? #21

seoker opened this issue Jun 29, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@seoker
Copy link

seoker commented Jun 29, 2023

As you may know, function calls are now supported by OpenAI, and the function call tokens will be taken into account.
With some googling, I found the calculation here.

It will be great if the library could also calculate the required tokens when using with function calls. 🙏🏼

@chuanqisun
Copy link

chuanqisun commented Jul 24, 2023

One related issue is the type signature of ChatMessage. Depending on whether there is functional calling, the ChatMessage may have either the content field or the function_call field, but not both. The current typing in gpt-tokenizer/src/GptEncoding.ts will need an update.

@NatoBoram
Copy link

I saw that https://github.com/hmarr/openai-chat-tokens already does it - would it be fine to import that package here to provide that functionality?

@niieani
Copy link
Owner

niieani commented Jul 18, 2024

PRs welcome! I would prefer not to pull in an external dependency, and it looks like the code isn't too complex.

@niieani niieani added the help wanted Extra attention is needed label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants