Open peterwilli opened 3 months ago
@peterwilli thank you for identifying this issue and providing a workaround! It would be nice if we could do this a bit more "automatically" for our users -- I think that the context-manager implementation needs some attention... will continue thinking about this :)
@nking-1 tagging you for interest
Thank you! Yeah! That was exactly where my thoughts went, but I wasn't experienced enough with your source code to make such change to the context manager. I decided to settle for this workaround for now, but of course automating this, so behavior is the same for stream and not stream is much better
The bug
When using roles such as
with assistant():
combined withstream()
, roles are not obeyed and all output is being squished into the last role...To Reproduce Give a full working code snippet that can be pasted into a notebook cell or python file. Make sure to include the LLM load step so we know which model you are using.
What I get:
Note that the output is all under assistant, and that the sentence being written is a completion of what should have been the user() role.
System info (please complete the following information):
guidance.__version__
): 0.1.15(Temporary) workaround
I found a way around this after reading the source code and attempting to fix it (I couldn't find a way to do it without breaking too much things, so I wait for a dev with more experience for a final fix) - it's not the cleanest but it'll do for now:
Note that the token iteration is outside of any roles, this is important for the workaround to work.