Skip to content

Commit

Permalink
add LLInterpreter.has_pending_stop()
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Oct 30, 2024
1 parent 16c789f commit e9cfc18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions parser/src/constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ impl Constraint {
Ok(())
}

pub fn has_pending_stop(&self) -> bool {
self.delayed_stop
}

/// This computes token sampling mask.
/// It typically takes up to a millisecond for a 100k tokenizer.
/// It will return an error when the order of calls is violated.
Expand Down
4 changes: 4 additions & 0 deletions python/llguidance/_lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,7 @@ class LLInterpreter:
This is experimental and breaks tests when used instead of post_process().
"""

def has_pending_stop(self) -> bool:
"""
If true, next mid_process() call will return stop
"""
4 changes: 4 additions & 0 deletions rust/src/py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ impl LLInterpreter {
fn post_process(&mut self, sampled_token: Option<TokenId>) -> PyResult<(u32, Vec<TokenId>)> {
self.advance_parser(sampled_token)
}

fn has_pending_stop(&self) -> bool {
self.inner.has_pending_stop()
}
}

#[derive(Serialize, Deserialize)]
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# installing guidance for deps
pip install pytest guidance huggingface_hub tokenizers jsonschema maturin[zig] \
torch transformers bitsandbytes
torch transformers bitsandbytes ipython
pip uninstall -y guidance

0 comments on commit e9cfc18

Please sign in to comment.