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

feat: support o200k_base #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tiktoken-node"
version = "0.0.6"
version = "0.0.8"
edition = "2021"

[lib]
Expand All @@ -10,7 +10,7 @@ crate-type = ["cdylib"]
rayon = "1.7.0"
napi = "2"
napi-derive = "2"
tiktoken-rs = "0.5.8"
tiktoken-rs = "0.5.9"

[build-dependencies]
napi-build = "2"
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function getEncoding(encoding: 'gpt2' | 'r50k_base' | 'p50k_base' | 'p50k_edit' | 'cl100k_base'): Encoding
export function getEncoding(encoding: 'gpt2' | 'r50k_base' | 'p50k_base' | 'p50k_edit' | 'cl100k_base' | 'o200k_base'): Encoding
export function encodingForModel(modelName: string): Encoding
export class Encoding {
encode(text: string): Array<number>
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tiktoken-node",
"version": "0.0.7",
"version": "0.0.8",
"types": "index.d.ts",
"main": "index.cjs",
"napi": {
Expand Down Expand Up @@ -29,8 +29,8 @@
],
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "2.18.0",
"typescript": "5.3.3"
"@napi-rs/cli": "2.18.3",
"typescript": "5.4.5"
},
"engines": {
"node": ">= 14"
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Encoding {

#[napi]
pub fn get_encoding(
#[napi(ts_arg_type = "'gpt2' | 'r50k_base' | 'p50k_base' | 'p50k_edit' | 'cl100k_base'")]
#[napi(ts_arg_type = "'gpt2' | 'r50k_base' | 'p50k_base' | 'p50k_edit' | 'cl100k_base' | 'o200k_base'")]
encoding: String,
) -> Result<Encoding, Error> {
let encoding: Result<tiktoken_rs::CoreBPE, Error> = match encoding.as_str() {
Expand All @@ -55,6 +55,7 @@ pub fn get_encoding(
"p50k_base" => Ok(tiktoken_rs::p50k_base().unwrap()),
"p50k_edit" => Ok(tiktoken_rs::p50k_edit().unwrap()),
"cl100k_base" => Ok(tiktoken_rs::cl100k_base().unwrap()),
"o200k_base" => Ok(tiktoken_rs::o200k_base().unwrap()),
_ => Err(Error::from_reason("Invalid encoding")),
};

Expand Down