File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ default = []
1818logging = [" log" , " simple_logger" ]
1919
2020[dependencies ]
21- tiktoken-rs = " 0.9 "
21+ tiktoken-rs = " 0.10.0 "
2222log = { version = " 0.4" , optional = true }
2323simple_logger = { version = " 5.0" , optional = true }
2424libc = " 0.2"
Original file line number Diff line number Diff line change 55[ ![ Ask DeepWiki] ( https://deepwiki.com/badge.svg )] ( https://deepwiki.com/kojix2/tiktoken-c )
66
77- C API for [ Tiktoken] ( https://github.com/openai/tiktoken ) , OpenAI's tokenizer
8- - Compatible with [ tiktoken-rs] ( https://github.com/zurawiki/tiktoken-rs ) 0.9.1
8+ - Compatible with [ tiktoken-rs] ( https://github.com/zurawiki/tiktoken-rs ) 0.10.0
99
1010## Installation
1111
Original file line number Diff line number Diff line change @@ -83,10 +83,10 @@ pub extern "C" fn tiktoken_get_bpe_from_model(model: *const c_char) -> *mut Core
8383 }
8484 }
8585 } ;
86- let bpe = tiktoken_rs:: get_bpe_from_model ( model) ;
86+ let bpe = tiktoken_rs:: bpe_for_model ( model) ;
8787 match bpe {
8888 Ok ( bpe) => {
89- let boxed = Box :: new ( bpe) ;
89+ let boxed = Box :: new ( bpe. clone ( ) ) ;
9090 Box :: into_raw ( boxed)
9191 }
9292 Err ( _) => {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ pub extern "C" fn tiktoken_get_completion_max_tokens(
6161 }
6262 }
6363 } ;
64- match tiktoken_rs:: get_completion_max_tokens ( model, prompt) {
64+ match tiktoken_rs:: get_text_completion_max_tokens ( model, prompt) {
6565 Ok ( max_tokens) => max_tokens,
6666 Err ( _) => {
6767 #[ cfg( feature = "logging" ) ]
@@ -162,6 +162,8 @@ pub extern "C" fn tiktoken_num_tokens_from_messages(
162162 content : content,
163163 name : name,
164164 function_call : function_call,
165+ tool_calls : Vec :: new ( ) ,
166+ refusal : None ,
165167 } ) ;
166168 }
167169 messages_vec
@@ -258,6 +260,8 @@ pub extern "C" fn tiktoken_get_chat_completion_max_tokens(
258260 content : content,
259261 name : name,
260262 function_call : function_call,
263+ tool_calls : Vec :: new ( ) ,
264+ refusal : None ,
261265 } ) ;
262266 }
263267 messages_vec
@@ -425,7 +429,6 @@ pub extern "C" fn tiktoken_corebpe_decode(
425429 return std:: ptr:: null_mut ( ) ;
426430 }
427431 let tokens = unsafe { std:: slice:: from_raw_parts ( tokens, num_tokens) } ;
428- let tokens = tokens. to_vec ( ) ;
429432
430433 let corebpe = unsafe { & mut * ptr } ;
431434 let decoded = corebpe. decode ( tokens) ;
You can’t perform that action at this time.
0 commit comments