Skip to content

Commit

Permalink
Make sure JS builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed Mar 1, 2023
1 parent 4d8f9af commit ef77b1a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
members = [
"core",
"python",
"js",
"jni",
]

Expand Down
4 changes: 4 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ use fancy_regex::Regex;
use rustc_hash::FxHashMap as HashMap;

mod util;
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
mod load;

#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
pub mod openai_public;

#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
#[macro_use]
extern crate lazy_static;

Expand Down
3 changes: 0 additions & 3 deletions js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ regex = "1.7.0"
rustc-hash = "1.1.0"
bstr = "1.0.1"
wasm-bindgen = "0.2.83"
js-sys = "0.3.61"
anyhow = "1.0.69"
base64 = "0.21.0"
gloo-utils = { version = "0.1", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
reqwest = { version = "0.11.14", features = ["blocking"] }

[features]
default = ["inline"]
Expand Down
6 changes: 3 additions & 3 deletions js/scripts/override_any.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const project = new Project();
project.addSourceFilesAtPaths("./dist/**/*.ts");

for (const filename of [
"./dist/bundler/_tiktoken.d.ts",
"./dist/node/_tiktoken.d.ts",
"./dist/web/_tiktoken.d.ts",
"./dist/bundler/_tiktoken_js.d.ts",
"./dist/node/_tiktoken_js.d.ts",
"./dist/web/_tiktoken_js.d.ts",
]) {
const sourceFile = project.getSourceFileOrThrow(filename);
const cls = sourceFile.getFirstDescendantByKindOrThrow(
Expand Down
5 changes: 0 additions & 5 deletions js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ impl Tiktoken {
self.bpe.encode_single_token(&bytes).unwrap_throw()
}

#[wasm_bindgen(skip_typescript)]
pub fn _encode_single_piece(&self, bytes: &[u8]) -> Vec<usize> {
self.bpe.encode_single_piece(&bytes)
}

pub fn decode(&self, tokens: Vec<usize>) -> Vec<u8> {
self.bpe._decode_native(&tokens)
}
Expand Down

0 comments on commit ef77b1a

Please sign in to comment.