From c93ecbb8a68fe2172eb32d9578b31116c83d76f2 Mon Sep 17 00:00:00 2001
From: Alan <41682961+alan-cooney@users.noreply.github.com>
Date: Mon, 23 Oct 2023 08:40:49 +0800
Subject: [PATCH] Add html mime type (#82)
Add html MIME type to the rendered html
---
python/Demonstration.ipynb | 4098 +++++++++--------
python/circuitsvis/utils/render.py | 26 +-
python/circuitsvis/utils/tests/test_render.py | 6 +-
3 files changed, 2074 insertions(+), 2056 deletions(-)
diff --git a/python/Demonstration.ipynb b/python/Demonstration.ipynb
index 52ac7c1..5bf4cc3 100644
--- a/python/Demonstration.ipynb
+++ b/python/Demonstration.ipynb
@@ -20,31 +20,24 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 19,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "The autoreload extension is already loaded. To reload it, use:\n",
- " %reload_ext autoreload\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
- "# Enable python import reloading\n",
- "%load_ext autoreload\n",
- "%autoreload 2\n",
- "\n",
"# Imports\n",
"import numpy as np\n",
"from circuitsvis.attention import attention_patterns, attention_pattern\n",
"from circuitsvis.activations import text_neuron_activations\n",
- "from circuitsvis.examples import hello\n",
"from circuitsvis.tokens import colored_tokens\n",
"from circuitsvis.topk_tokens import topk_tokens\n",
- "from circuitsvis.topk_samples import topk_samples"
+ "from circuitsvis.topk_samples import topk_samples\n",
+ "\n",
+ "# Hot reload (for development only)\n",
+ "from IPython import get_ipython\n",
+ "ip = get_ipython()\n",
+ "if not ip.extension_manager.loaded:\n",
+ " ip.extension_manager.load('autoreload')\n",
+ " %autoreload 2"
]
},
{
@@ -73,62 +66,62 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "
\n",
+ "\n",
" "
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 2,
- "metadata": {},
+ "execution_count": 12,
+ "metadata": {
+ "text/html": {
+ "Content-Type": "text/html"
+ }
+ },
"output_type": "execute_result"
}
],
@@ -4981,62 +4978,62 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "\n",
+ "\n",
" "
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 3,
- "metadata": {},
+ "execution_count": 13,
+ "metadata": {
+ "text/html": {
+ "Content-Type": "text/html"
+ }
+ },
"output_type": "execute_result"
}
],
@@ -9898,62 +9899,62 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "\n",
+ "\n",
" "
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 4,
- "metadata": {},
+ "execution_count": 14,
+ "metadata": {
+ "text/html": {
+ "Content-Type": "text/html"
+ }
+ },
"output_type": "execute_result"
}
],
@@ -14802,62 +14807,62 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "\n",
+ "\n",
" "
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 5,
- "metadata": {},
+ "execution_count": 15,
+ "metadata": {
+ "text/html": {
+ "Content-Type": "text/html"
+ }
+ },
"output_type": "execute_result"
}
],
@@ -19713,62 +19722,62 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "\n",
+ "\n",
" "
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 6,
- "metadata": {},
+ "execution_count": 16,
+ "metadata": {
+ "text/html": {
+ "Content-Type": "text/html"
+ }
+ },
"output_type": "execute_result"
}
],
@@ -24618,62 +24631,62 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "\n",
+ "\n",
" "
],
"text/plain": [
- ""
+ ""
]
},
- "execution_count": 7,
- "metadata": {},
+ "execution_count": 17,
+ "metadata": {
+ "text/html": {
+ "Content-Type": "text/html"
+ }
+ },
"output_type": "execute_result"
}
],
@@ -29532,62 +29549,62 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
- "\n",
+ "\n",
"