Skip to content

Commit ba8ac7a

Browse files
committed
convert lua string to vec u8
1 parent a88b563 commit ba8ac7a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,14 @@ pub fn tiktoken_core(lua: &mlua::Lua) -> LuaResult<LuaTable> {
210210

211211
fn new(
212212
state: &State,
213-
encoder: HashMap<Vec<u8>, usize>,
213+
iencoder: HashMap<LuaString, usize>,
214214
special_tokens_encoder: HashMap<String, usize>,
215215
pattern: String,
216216
) {
217+
let encoder: HashMap<Vec<u8>, usize> = iencoder
218+
.into_iter()
219+
.map(|(k, v)| (k.as_bytes().to_vec(), v))
220+
.collect();
217221
let regex = Regex::new(&pattern)
218222
.map_err(|e| mlua::Error::external(e))
219223
.unwrap();

tiktoken_core-0.1.0-1.rockspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version = "0.1.0-1"
33

44
source = {
55
url = "git+https://github.com/gptlang/lua-tiktoken",
6-
tag = "0.1.0",
6+
-- tag = "0.1.0",
77
}
88

99
description = {

0 commit comments

Comments
 (0)