guidance icon indicating copy to clipboard operation
guidance copied to clipboard

Raising error in Program execution shouldn't dump to stdout.

Open atisharma opened this issue 1 year ago • 0 comments

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.)

atisharma avatar Jun 11 '23 11:06 atisharma