guidance icon indicating copy to clipboard operation
guidance copied to clipboard

IPython.core.display.HTML object

Open michael-conrad opened this issue 11 months ago • 15 comments

The bug Running from console environment results in multiple logged messages of <IPython...>. Why is the library doing IPython stuff while running gen() in a non-Jupyter run?

<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>
<IPython.core.display.HTML object>

Version: 0.1.12

michael-conrad avatar Mar 21 '24 03:03 michael-conrad

How do I turn off this seizure inducing flickering display cause by the IPython HTML object madness?

michael-conrad avatar Mar 21 '24 11:03 michael-conrad

@michael-conrad sorry about that! You can disable this by setting echo=False in the init of the guidance.models object at initialization time.

I'll think about how to improve this out-of-the-box -- perhaps we can auto-detect if we're in an IPython environment and only echo in those cases?

Harsha-Nori avatar Mar 22 '24 00:03 Harsha-Nori

You can also set it later, e.g. model.echo = False

Harsha-Nori avatar Mar 22 '24 00:03 Harsha-Nori

Much thanks. Seems like a bad default to have true.

How about provide an option for a streaming call-back and not have it at all? This way one could set a streaming call back and then determine how to display streamed results based on the needs of the project. Would also allow streaming to the console.

michael-conrad avatar Mar 22 '24 02:03 michael-conrad

How can I get my console to display the echo? Instead of showing as html objects.

ryanpeach avatar Mar 31 '24 23:03 ryanpeach

When I set "echo=False", I see nothing output in console. Please kindly advise how I can print readable text on terminal, instead of <IPython.core.display.HTML object>

eliranwong avatar Apr 18 '24 10:04 eliranwong

Have you updated? My referenced pr should have fixed it but I unfortunately never tested that particular change.

ryanpeach avatar Apr 18 '24 14:04 ryanpeach

When I set "echo=False", I see nothing output in console. Please kindly advise how I can print readable text on terminal, instead of <IPython.core.display.HTML object>

I mean how to print the streaming output, which is readable instead of ipython object, on terminal as the result streams?

eliranwong avatar Apr 18 '24 16:04 eliranwong

https://github.com/ryanpeach/guidance/blob/9546946eddd7d4960daa17086316f1a4dd061bcb/guidance/models/_model.py#L877

This should have fixed the fact it was printing a readable object instead of a string when you ran outside of jupyter. Yes echo needs to be True

ryanpeach avatar Apr 18 '24 17:04 ryanpeach

https://github.com/ryanpeach/guidance/blob/9546946eddd7d4960daa17086316f1a4dd061bcb/guidance/models/_model.py#L2

Of note, be sure that you dont have iPython installed in your environment. Or it will import it and then it will print the html block instead.

ryanpeach avatar Apr 18 '24 17:04 ryanpeach

I have installed the latest pip package of guidance installed. I also check that ipython is installed in the same environment. However, I read a lot of <IPython.core.display.HTML object> <IPython.core.display.HTML object> <IPython.core.display.HTML object> <IPython.core.display.HTML object>

Bty, I am running guidance on Ubuntu

eliranwong avatar Apr 19 '24 08:04 eliranwong

I found the answer from https://guidance.readthedocs.io/ Thanks for your good work.

eliranwong avatar Apr 19 '24 22:04 eliranwong

I found the answer from https://guidance.readthedocs.io/ Thanks for your good work.

What was the answer?

I'm concerned my PR didn't fix it.

ryanpeach avatar Apr 20 '24 16:04 ryanpeach

Basically, echo have to be False.

Otherwise, the program generates and displays lots of <IPython.core.display.HTML object>

I need to use the streaming with instruction available at: https://guidance.readthedocs.io/en/latest/example_notebooks/tutorials/intro_to_guidance.html#Streaming

eliranwong avatar Apr 24 '24 08:04 eliranwong

It seems to be still an issue, using guidance 0.1.15. Setting echo=False at model initialization works.

maxencealluin avatar May 23 '24 11:05 maxencealluin