Skip to content

Commit

Permalink
don't accept if there are pending lexer bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Jun 22, 2024
1 parent 78c9b31 commit 91cfe04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions controllers/llguidance_ctrl/run_g.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ def character_maker2(lm, id, description, valid_weapons):

# grm = "Q: 7 * 8\nA: " + gen("text", regex="[0-9]+", max_tokens=20) + "\n"

prompt = "a,b,c,"
grm = one_or_more(byte_range(b"a", b"g")+",")

prompt = ""
grm = one_or_more(byte_range(b"b", b"f"))

max_tokens = 250

serialized = grm.ll_serialize()
Expand Down
5 changes: 4 additions & 1 deletion controllers/llguidance_ctrl/src/earley/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ impl Parser {
}

pub fn is_accepting(&self) -> bool {
if self.curr_row_bytes().len() > 0 {
return false;
}
for pos in self.after_dots() {
let after_dot = self.grammar.sym_idx_at(pos);
if after_dot == CSymIdx::NULL {
Expand Down Expand Up @@ -1021,7 +1024,7 @@ impl Parser {
.as_ref()
.unwrap();
let mut bytes = Vec::new();
let capture_start = item.start_pos() ;
let capture_start = item.start_pos();
if capture_start < curr_idx {
bytes = self.row_infos[capture_start..curr_idx]
.iter()
Expand Down
2 changes: 1 addition & 1 deletion py/guidance
Submodule guidance updated 66 files
+2 −3 .github/workflows/action_gpu_basic_tests.yml
+2 −3 .github/workflows/action_plain_basic_tests.yml
+2 −3 .github/workflows/action_server_tests.yml
+2 −2 .github/workflows/ci_tests.yml
+1 −2 .github/workflows/notebook_tests.yml
+17 −17 .github/workflows/workflow-pr-gate.yml
+24 −15 guidance/_grammar.py
+245 −69 guidance/_parser.py
+127 −63 guidance/library/_json.py
+8 −3 guidance/models/_azure_guidance.py
+19 −10 guidance/models/_model.py
+28 −19 guidance/models/llama_cpp/_llama_cpp.py
+1 −1 guidance/models/transformers/__init__.py
+78 −71 guidance/models/transformers/_transformers.py
+1 −7 pyproject.toml
+46 −0 tests/ReadMe.md
+0 −12 tests/library/test_set_attribute.py
+0 −0 tests/model_integration/__init__.py
+1 −7 tests/model_integration/library/test_commit_point.py
+6 −144 tests/model_integration/library/test_gen.py
+8 −0 tests/model_integration/library/test_substring.py
+8 −0 tests/model_integration/test_grammar.py
+4 −14 tests/model_integration/test_greedy.py
+0 −21 tests/model_integration/test_model.py
+0 −0 tests/model_specific/__init__.py
+0 −0 tests/model_specific/common_chat_testing.py
+27 −10 tests/model_specific/test_llama_cpp.py
+0 −0 tests/model_specific/test_transformers.py
+0 −0 tests/need_credentials/__init__.py
+0 −0 tests/need_credentials/test_anthropic.py
+0 −0 tests/need_credentials/test_azure_guidance.py
+1 −9 tests/need_credentials/test_azureai_openai.py
+4 −9 tests/need_credentials/test_azureai_studio.py
+1 −2 tests/need_credentials/test_chat_templates.py
+0 −0 tests/need_credentials/test_cohere.py
+0 −0 tests/need_credentials/test_googleai.py
+0 −0 tests/need_credentials/test_lite_llm.py
+0 −0 tests/need_credentials/test_openai.py
+0 −0 tests/need_credentials/test_togetherai.py
+0 −0 tests/need_credentials/test_vertexai.py
+0 −0 tests/notebooks/__init__.py
+0 −10 tests/notebooks/test_notebooks.py
+0 −0 tests/server/__init__.py
+0 −4 tests/server/test_server.py
+0 −133 tests/test_parser.py
+0 −0 tests/unit/__init__.py
+0 −0 tests/unit/library/__init__.py
+0 −0 tests/unit/library/test_any_char.py
+0 −0 tests/unit/library/test_any_char_but.py
+0 −0 tests/unit/library/test_block.py
+0 −2 tests/unit/library/test_capture.py
+0 −0 tests/unit/library/test_char_set.py
+7 −0 tests/unit/library/test_commit_point.py
+139 −0 tests/unit/library/test_gen.py
+278 −17 tests/unit/library/test_json.py
+0 −0 tests/unit/library/test_one_or_more.py
+1 −1 tests/unit/library/test_pydantic.py
+1 −1 tests/unit/library/test_regex.py
+10 −0 tests/unit/library/test_set_attribute.py
+1 −3 tests/unit/library/test_silent.py
+1 −8 tests/unit/library/test_substring.py
+0 −7 tests/unit/test_grammar.py
+23 −0 tests/unit/test_model.py
+132 −0 tests/unit/test_parser.py
+0 −0 tests/unit/test_utils.py
+3 −2 tests/utils.py

0 comments on commit 91cfe04

Please sign in to comment.