guidance
guidance copied to clipboard
Raising error in Program execution shouldn't dump to stdout.
At the moment, an error in the executed program dumps the whole traceback to stdout using print
.
https://github.com/microsoft/guidance/blob/d6b855aa625677f806fc51ec7238d2a38df594ea/guidance/_program_executor.py#L104
If you're using a terminal-based program, or handle errors yourself, this is pretty annoying as there is no clean way to suppress the output.
I propose the correct solution is not to print the error or the traceback and simply raise the error. If you must, log the output with a logger or at least print to stderr.
(As an aside, I encounter this when an empty reply from an OpenAI-compatible API returns an empty string, but that's a bug in openai's library, not in guidance.)