Skip to content

Add WASM/JS bindings#50

Open
dqbd wants to merge 269 commits intoopenai:mainfrom
dqbd:main
Open

Add WASM/JS bindings#50
dqbd wants to merge 269 commits intoopenai:mainfrom
dqbd:main

Conversation

@dqbd
Copy link

@dqbd dqbd commented Mar 6, 2023

This PR builds on top of #40, which introduces both Java bindings and a split Rust core.

dqbd and others added 30 commits February 2, 2025 22:11
feat: add missing o3-mini, o1 models
feat: add missing gpt-4o-2024-11-20 models and fix o3-mini on wasm
feat: add o3, o4, gpt-4.1 and missing specialised / pro models
The `tiktoken-js` library includes a very helpful function,
`getEncodingNameForModel()`. This function is buried in the
implementation of `encoding_for_model()` in the rust based
`tiktoken` package.

This function is very useful when implementing an encoding cache based
on the model used. In this case, having a mapping from model ->
encoding and then caching based on the encoding name conserves
resources since so many models re-use the same encoding.

I've exposed a new `get_encoding_name_for_model()` function
that behaves similarly to the one in the `tiktoken-js` package, and used
it inside of `encoding_for_model()`.

Finally, I've also added a test to ensure that this function can be
called properly from typescript code, and that it properly throws
exceptions in the case of invalid model names.

Fixes: #123
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

Successfully merging this pull request may close these issues.