Open hudson-ai opened 1 week ago
Same with the block
context manager. I know that this may be impossible to implement with the current design for these context managers, but it's worth thinking about.
wow great catch, had no idea these were failing!
@nking-1 and I were deep in the trenches yesterday 😂
@hudson-ai do you remember where the root cause of the bug was? Is it in __add__()
in model.py?
It's sort of inherent to the implementation of context blocks. Opening/closing them just adds/removes something from a class-level dict on Model that affects the __add__
method on Model instances.
The problem is that we never hit that __add__
inside of stateless grammars, because no Model instances ever gets passed to the function. They are "compiled" by passing an empty string in the lm
slot of the signature.
A workaround may be to send an instance of a "fake" Model subclass through rather than the empty string, but I think it may honestly be worth taking this opportunity to rethink the context managers a bit.
The bug Role blocks fail silently inside of stateless grammars -- I think it's okay if they are only supported in stateful contexts, but the user should get an error.
To Reproduce
System info (please complete the following information):
guidance.__version__
): 0.1.15