diff --git a/controllers/guidance_ctrl/src/earley/parser.rs b/controllers/guidance_ctrl/src/earley/parser.rs index d7bd1520..92dfe392 100644 --- a/controllers/guidance_ctrl/src/earley/parser.rs +++ b/controllers/guidance_ctrl/src/earley/parser.rs @@ -13,7 +13,7 @@ use aici_abi::{ use super::grammar::{CGrammar, CSymIdx, CSymbol, ModelVariable, RuleIdx}; -const DEBUG: bool = true; +const DEBUG: bool = false; const INFO: bool = true; macro_rules! debug { diff --git a/controllers/guidance_ctrl/src/tokenparser.rs b/controllers/guidance_ctrl/src/tokenparser.rs index 1666ebca..e3a5361a 100644 --- a/controllers/guidance_ctrl/src/tokenparser.rs +++ b/controllers/guidance_ctrl/src/tokenparser.rs @@ -48,10 +48,10 @@ impl TokenParser { pub fn bytes_since(&self, mut idx: usize) -> &[u8] { idx += self.grm_prefix.len(); - if idx >= self.llm_bytes.len() { + let endp = std::cmp::min(self.llm_bytes.len(), self.parser.hidden_start()); + if idx >= self.llm_bytes.len() || idx >= endp { return &[]; } - let endp = std::cmp::min(self.llm_bytes.len(), self.parser.hidden_start()); &self.llm_bytes[idx..endp] }