mod compile_misc;
mod compile_tools;
mod engine;
mod mask_cache;
mod prewarm;
mod schema;
mod state;
#[cfg(test)]
pub(crate) mod tests;
pub use engine::{GrammarEngine, GrammarError};
pub use mask_cache::PrewarmHook;
pub use schema::augment_schema_with_tafc_think;
pub use state::{GrammarState, grammar_blocks_stop};
pub fn extract_ordered_vocab(tokenizer: &tokenizers::Tokenizer) -> Vec<String> {
let vocab = tokenizer.get_vocab(true);
let max_id = vocab.values().copied().max().unwrap_or(0) as usize;
let size = vocab.len().max(max_id + 1);
let mut ordered = vec![String::new(); size];
for (token, id) in vocab {
let idx = id as usize;
if idx < size {
ordered[idx] = token;
}
}
ordered
}