Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added Marimo support for echo=True #981

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions guidance/models/_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
ipython_is_imported = True
except ImportError:
ipython_is_imported = False
try:
import torch

torch_is_imported = True
except ImportError:
torch_is_imported = False
try:
import marimo
marimo_is_imported = True
except ImportError:
marimo_is_imported = False

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -357,6 +368,8 @@ def _update_display(self, throttle=True):
if ipython_is_imported:
clear_output(wait=True)
display(HTML(self._html()))
elif marimo_is_imported:
marimo.output.replace(marimo.Html(self._html()))
else:
pprint(self._state)

Expand Down Expand Up @@ -907,3 +920,4 @@ def __init__(self, *args, **kwargs):
self.prompt = kwargs.pop("prompt", None)
self.data = kwargs.pop("data", None)
super().__init__(*args, **kwargs)

Loading