Skip to content

Commit

Permalink
fix empty "text"
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Jun 24, 2024
1 parent ba9a917 commit 7246614
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 15 additions & 2 deletions controllers/llguidance_ctrl/run_g.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,19 @@ def character_maker2(lm, id, description, valid_weapons):
assert grm.match("null")

grm = guidance.json(
schema={"type": "object", "properties": {"a": {"type": "integer"}}}
"OBJ",
schema={
"type": "object",
"additionalProperties": False,
"properties": {"age": {"type": "integer"}},
}
)
assert grm.match('{"a": 1}')
# assert grm.match('{"a": 1}')
prompt = ""
grm = "Here's some JSON:\n" + grm # + "\nAnd some more:\n" + grm

# g = zero_or_more("a") + "b"
# assert not g.match("b")

max_tokens = 250

Expand All @@ -282,6 +292,9 @@ def character_maker2(lm, id, description, valid_weapons):
print("JSON size:", len(llguidance_arg), "saved to tmp/llguidance_arg.json")
# print(json.dumps(llguidance_json, indent=2))

# with open("tmp/long_json_grammar_req.json", "r") as f:
# llguidance_arg = f.read()

# read current script file
# with open(__file__) as f:
# script = f.read()
Expand Down
4 changes: 3 additions & 1 deletion controllers/llguidance_ctrl/src/tokenparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ impl TokenParser {
idx += self.grm_prefix.len();
let endp = std::cmp::min(
self.llm_bytes.len(),
self.previous_grm_bytes.len() + self.parser.hidden_start(),
self.previous_grm_bytes
.len()
.saturating_add(self.parser.hidden_start()),
);
if idx >= self.llm_bytes.len() || idx >= endp {
return &[];
Expand Down
1 change: 1 addition & 0 deletions py/llguidance/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ find = { where = ["python"] }
target = "llguidance._lib"
binding = "PyO3"
debug = false
# features = ["aici_llguidance_ctrl/logging"]
# See reference for RustExtension in https://setuptools-rust.readthedocs.io/en/latest/reference.html

0 comments on commit 7246614

Please sign in to comment.