From 2b7ce74a1a139e90ac8a8f7354037106c8301744 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Wed, 10 Jul 2024 11:20:09 +0200 Subject: [PATCH 01/11] Add ipython display util IFrameFromSrc --- src/penai/utils/ipython.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/penai/utils/ipython.py diff --git a/src/penai/utils/ipython.py b/src/penai/utils/ipython.py new file mode 100644 index 0000000..d9139e9 --- /dev/null +++ b/src/penai/utils/ipython.py @@ -0,0 +1,10 @@ +import base64 + +from IPython.display import IFrame + + +class IFrameFromSrc(IFrame): + def __init__(self, html_content: str, width: int = 800, height: int = 600): + encoded_content = base64.b64encode(html_content.encode()).decode() + data_uri = f"data:text/html;base64,{encoded_content}" + super().__init__(data_uri, width, height) From 0ecf738fdf47436fe564b20f440ca50bd9457e98 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Wed, 10 Jul 2024 11:24:45 +0200 Subject: [PATCH 02/11] InteractiveHTMLHierarchyVisualizer: Use jinja template, allow both path and direct SVG specification --- .../{ => jinja_templates}/hierarchy.html | 14 ++++++-- src/penai/hierarchy_generation/vis.py | 34 ++++++++++++++----- 2 files changed, 37 insertions(+), 11 deletions(-) rename resources/{ => jinja_templates}/hierarchy.html (85%) diff --git a/resources/hierarchy.html b/resources/jinja_templates/hierarchy.html similarity index 85% rename from resources/hierarchy.html rename to resources/jinja_templates/hierarchy.html index 43c1cf3..67077b8 100644 --- a/resources/hierarchy.html +++ b/resources/jinja_templates/hierarchy.html @@ -2,13 +2,15 @@ - $$title + {{ title }}