Skip to content
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)