Skip to content

Commit f169fdc

Browse files
committed
Fix list append bug
1 parent 03a8bae commit f169fdc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

guidance/_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def _record_captures_from_root(self, initial_item, data, log_prob_data):
447447
# if we are at a capture group node then we save the matched bytes range
448448
# note that we record this after calling our children so that we save the outermost version of self-recursive calls
449449
cname = item.node.capture_name
450-
if cname is not None and cname not in used_names:
450+
if cname is not None and cname not in used_names and not item.node.hidden:
451451

452452
# see if we are doing a list append
453453
if cname.startswith("__LIST_APPEND:"):

guidance/models/_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,10 @@ def __call__(self, grammar, max_tokens=1000000, n=1, top_p=1, temperature=0.0, e
971971
# yeild the snippet of text created by the next token
972972
out = new_bytes[hidden_count:]
973973
if len(out) > 0:
974-
# capture the named groups from the (partial) parse tree,
975-
new_captured_data, new_captured_log_prob_data = parser.get_captures()
976-
captured_data.update(new_captured_data)
977-
captured_log_prob_data.update(new_captured_log_prob_data)
974+
# capture the named groups from the (partial) parse tree, # TODO: disabled for now until we handle list_append correctly
975+
# new_captured_data, new_captured_log_prob_data = parser.get_captures()
976+
# captured_data.update(new_captured_data)
977+
# captured_log_prob_data.update(new_captured_log_prob_data)
978978
yield out, is_generated, new_bytes_prob, captured_data, captured_log_prob_data, token_count - last_token_count # note that we don't capture groups until a complete parse right now...
979979
last_token_count = token_count
980980
hidden_count = 0

0 commit comments

Comments
 (0)