Spaces:
Runtime error
Runtime error
Delete Langchain_QA_Panel.ipynb
Browse files- Langchain_QA_Panel.ipynb +0 -835
Langchain_QA_Panel.ipynb
DELETED
|
@@ -1,835 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"cells": [
|
| 3 |
-
{
|
| 4 |
-
"cell_type": "code",
|
| 5 |
-
"execution_count": 1,
|
| 6 |
-
"id": "a54a31ac-281b-499f-b0c5-0a2b7e33a78e",
|
| 7 |
-
"metadata": {
|
| 8 |
-
"tags": []
|
| 9 |
-
},
|
| 10 |
-
"outputs": [
|
| 11 |
-
{
|
| 12 |
-
"name": "stdout",
|
| 13 |
-
"output_type": "stream",
|
| 14 |
-
"text": [
|
| 15 |
-
"Requirement already satisfied: langchain in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (0.0.173)\n",
|
| 16 |
-
"Requirement already satisfied: openai in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (0.27.6)\n",
|
| 17 |
-
"Requirement already satisfied: chromadb in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (0.3.23)\n",
|
| 18 |
-
"Requirement already satisfied: tiktoken in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (0.4.0)\n",
|
| 19 |
-
"Requirement already satisfied: pypdf in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (3.8.1)\n",
|
| 20 |
-
"Requirement already satisfied: panel in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (0.13.1)\n",
|
| 21 |
-
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (3.8.4)\n",
|
| 22 |
-
"Requirement already satisfied: dataclasses-json<0.6.0,>=0.5.7 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (0.5.7)\n",
|
| 23 |
-
"Requirement already satisfied: requests<3,>=2 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (2.28.1)\n",
|
| 24 |
-
"Requirement already satisfied: openapi-schema-pydantic<2.0,>=1.2 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (1.2.4)\n",
|
| 25 |
-
"Requirement already satisfied: async-timeout<5.0.0,>=4.0.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (4.0.2)\n",
|
| 26 |
-
"Requirement already satisfied: tenacity<9.0.0,>=8.1.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (8.2.2)\n",
|
| 27 |
-
"Requirement already satisfied: pydantic<2,>=1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (1.10.7)\n",
|
| 28 |
-
"Requirement already satisfied: SQLAlchemy<3,>=1.4 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (1.4.39)\n",
|
| 29 |
-
"Requirement already satisfied: numexpr<3.0.0,>=2.8.4 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (2.8.4)\n",
|
| 30 |
-
"Requirement already satisfied: numpy<2,>=1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (1.24.3)\n",
|
| 31 |
-
"Requirement already satisfied: PyYAML>=5.4.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from langchain) (6.0)\n",
|
| 32 |
-
"Requirement already satisfied: tqdm in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from openai) (4.64.1)\n",
|
| 33 |
-
"Requirement already satisfied: uvicorn[standard]>=0.18.3 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (0.22.0)\n",
|
| 34 |
-
"Requirement already satisfied: sentence-transformers>=2.2.2 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (2.2.2)\n",
|
| 35 |
-
"Requirement already satisfied: duckdb>=0.7.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (0.8.0)\n",
|
| 36 |
-
"Requirement already satisfied: clickhouse-connect>=0.5.7 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (0.5.24)\n",
|
| 37 |
-
"Requirement already satisfied: fastapi>=0.85.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (0.95.2)\n",
|
| 38 |
-
"Requirement already satisfied: posthog>=2.4.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (3.0.1)\n",
|
| 39 |
-
"Requirement already satisfied: pandas>=1.3 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (1.4.4)\n",
|
| 40 |
-
"Requirement already satisfied: hnswlib>=0.7 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (0.7.0)\n",
|
| 41 |
-
"Requirement already satisfied: typing-extensions>=4.5.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from chromadb) (4.5.0)\n",
|
| 42 |
-
"Requirement already satisfied: regex>=2022.1.18 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from tiktoken) (2022.7.9)\n",
|
| 43 |
-
"Requirement already satisfied: pyviz-comms>=0.7.4 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (2.0.2)\n",
|
| 44 |
-
"Requirement already satisfied: bokeh<2.5.0,>=2.4.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (2.4.3)\n",
|
| 45 |
-
"Requirement already satisfied: setuptools in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (63.4.1)\n",
|
| 46 |
-
"Requirement already satisfied: bleach in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (4.1.0)\n",
|
| 47 |
-
"Requirement already satisfied: pyct>=0.4.4 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (0.4.8)\n",
|
| 48 |
-
"Requirement already satisfied: markdown in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (3.3.4)\n",
|
| 49 |
-
"Requirement already satisfied: param>=1.12.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from panel) (1.12.0)\n",
|
| 50 |
-
"Requirement already satisfied: aiosignal>=1.1.2 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.1)\n",
|
| 51 |
-
"Requirement already satisfied: attrs>=17.3.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (21.4.0)\n",
|
| 52 |
-
"Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (2.0.4)\n",
|
| 53 |
-
"Requirement already satisfied: frozenlist>=1.1.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.3.3)\n",
|
| 54 |
-
"Requirement already satisfied: yarl<2.0,>=1.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (1.9.2)\n",
|
| 55 |
-
"Requirement already satisfied: multidict<7.0,>=4.5 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from aiohttp<4.0.0,>=3.8.3->langchain) (6.0.4)\n",
|
| 56 |
-
"Requirement already satisfied: Jinja2>=2.9 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from bokeh<2.5.0,>=2.4.0->panel) (2.11.3)\n",
|
| 57 |
-
"Requirement already satisfied: packaging>=16.8 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from bokeh<2.5.0,>=2.4.0->panel) (21.3)\n",
|
| 58 |
-
"Requirement already satisfied: pillow>=7.1.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from bokeh<2.5.0,>=2.4.0->panel) (9.2.0)\n",
|
| 59 |
-
"Requirement already satisfied: tornado>=5.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from bokeh<2.5.0,>=2.4.0->panel) (6.1)\n",
|
| 60 |
-
"Requirement already satisfied: zstandard in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from clickhouse-connect>=0.5.7->chromadb) (0.21.0)\n",
|
| 61 |
-
"Requirement already satisfied: urllib3>=1.26 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from clickhouse-connect>=0.5.7->chromadb) (1.26.11)\n",
|
| 62 |
-
"Requirement already satisfied: certifi in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from clickhouse-connect>=0.5.7->chromadb) (2022.9.24)\n",
|
| 63 |
-
"Requirement already satisfied: lz4 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from clickhouse-connect>=0.5.7->chromadb) (3.1.3)\n",
|
| 64 |
-
"Requirement already satisfied: pytz in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from clickhouse-connect>=0.5.7->chromadb) (2022.1)\n",
|
| 65 |
-
"Requirement already satisfied: typing-inspect>=0.4.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (0.8.0)\n",
|
| 66 |
-
"Requirement already satisfied: marshmallow<4.0.0,>=3.3.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (3.19.0)\n",
|
| 67 |
-
"Requirement already satisfied: marshmallow-enum<2.0.0,>=1.5.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from dataclasses-json<0.6.0,>=0.5.7->langchain) (1.5.1)\n",
|
| 68 |
-
"Requirement already satisfied: starlette<0.28.0,>=0.27.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from fastapi>=0.85.1->chromadb) (0.27.0)\n",
|
| 69 |
-
"Requirement already satisfied: python-dateutil>=2.8.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from pandas>=1.3->chromadb) (2.8.2)\n",
|
| 70 |
-
"Requirement already satisfied: six>=1.5 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from posthog>=2.4.0->chromadb) (1.16.0)\n",
|
| 71 |
-
"Requirement already satisfied: backoff>=1.10.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from posthog>=2.4.0->chromadb) (2.2.1)\n",
|
| 72 |
-
"Requirement already satisfied: monotonic>=1.5 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from posthog>=2.4.0->chromadb) (1.6)\n",
|
| 73 |
-
"Requirement already satisfied: idna<4,>=2.5 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from requests<3,>=2->langchain) (3.3)\n",
|
| 74 |
-
"Requirement already satisfied: transformers<5.0.0,>=4.6.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (4.29.2)\n",
|
| 75 |
-
"Requirement already satisfied: nltk in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (3.7)\n",
|
| 76 |
-
"Requirement already satisfied: torchvision in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (0.14.1)\n",
|
| 77 |
-
"Requirement already satisfied: huggingface-hub>=0.4.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (0.14.1)\n",
|
| 78 |
-
"Requirement already satisfied: sentencepiece in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (0.1.99)\n",
|
| 79 |
-
"Requirement already satisfied: scipy in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (1.9.1)\n",
|
| 80 |
-
"Requirement already satisfied: torch>=1.6.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (1.13.1)\n",
|
| 81 |
-
"Requirement already satisfied: scikit-learn in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from sentence-transformers>=2.2.2->chromadb) (1.0.2)\n",
|
| 82 |
-
"Requirement already satisfied: greenlet!=0.4.17 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from SQLAlchemy<3,>=1.4->langchain) (1.1.1)\n",
|
| 83 |
-
"Requirement already satisfied: click>=7.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (8.0.4)\n",
|
| 84 |
-
"Requirement already satisfied: h11>=0.8 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.14.0)\n",
|
| 85 |
-
"Requirement already satisfied: uvloop!=0.15.0,!=0.15.1,>=0.14.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.17.0)\n",
|
| 86 |
-
"Requirement already satisfied: websockets>=10.4 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (11.0.3)\n",
|
| 87 |
-
"Requirement already satisfied: httptools>=0.5.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.5.0)\n",
|
| 88 |
-
"Requirement already satisfied: python-dotenv>=0.13 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (1.0.0)\n",
|
| 89 |
-
"Requirement already satisfied: watchfiles>=0.13 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from uvicorn[standard]>=0.18.3->chromadb) (0.19.0)\n",
|
| 90 |
-
"Requirement already satisfied: webencodings in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from bleach->panel) (0.5.1)\n",
|
| 91 |
-
"Requirement already satisfied: fsspec in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from huggingface-hub>=0.4.0->sentence-transformers>=2.2.2->chromadb) (2022.7.1)\n",
|
| 92 |
-
"Requirement already satisfied: filelock in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from huggingface-hub>=0.4.0->sentence-transformers>=2.2.2->chromadb) (3.6.0)\n",
|
| 93 |
-
"Requirement already satisfied: MarkupSafe>=0.23 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from Jinja2>=2.9->bokeh<2.5.0,>=2.4.0->panel) (2.0.1)\n",
|
| 94 |
-
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from packaging>=16.8->bokeh<2.5.0,>=2.4.0->panel) (3.0.9)\n",
|
| 95 |
-
"Requirement already satisfied: anyio<5,>=3.4.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from starlette<0.28.0,>=0.27.0->fastapi>=0.85.1->chromadb) (3.5.0)\n",
|
| 96 |
-
"Requirement already satisfied: tokenizers!=0.11.3,<0.14,>=0.11.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from transformers<5.0.0,>=4.6.0->sentence-transformers>=2.2.2->chromadb) (0.13.3)\n",
|
| 97 |
-
"Requirement already satisfied: mypy-extensions>=0.3.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from typing-inspect>=0.4.0->dataclasses-json<0.6.0,>=0.5.7->langchain) (0.4.3)\n",
|
| 98 |
-
"Requirement already satisfied: joblib in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from nltk->sentence-transformers>=2.2.2->chromadb) (1.1.0)\n",
|
| 99 |
-
"Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from scikit-learn->sentence-transformers>=2.2.2->chromadb) (2.2.0)\n",
|
| 100 |
-
"Requirement already satisfied: sniffio>=1.1 in /Users/maraksa/opt/anaconda3/lib/python3.9/site-packages (from anyio<5,>=3.4.0->starlette<0.28.0,>=0.27.0->fastapi>=0.85.1->chromadb) (1.2.0)\n"
|
| 101 |
-
]
|
| 102 |
-
}
|
| 103 |
-
],
|
| 104 |
-
"source": [
|
| 105 |
-
"!pip install langchain openai chromadb tiktoken pypdf panel"
|
| 106 |
-
]
|
| 107 |
-
},
|
| 108 |
-
{
|
| 109 |
-
"cell_type": "code",
|
| 110 |
-
"execution_count": 27,
|
| 111 |
-
"id": "863cb54e-071e-4a79-a453-e8b7026127ae",
|
| 112 |
-
"metadata": {},
|
| 113 |
-
"outputs": [],
|
| 114 |
-
"source": [
|
| 115 |
-
"import os \n",
|
| 116 |
-
"from langchain.chains import RetrievalQA\n",
|
| 117 |
-
"from langchain.llms import OpenAI\n",
|
| 118 |
-
"from langchain.document_loaders import TextLoader\n",
|
| 119 |
-
"from langchain.document_loaders import PyPDFLoader\n",
|
| 120 |
-
"from langchain.indexes import VectorstoreIndexCreator\n",
|
| 121 |
-
"from langchain.text_splitter import CharacterTextSplitter\n",
|
| 122 |
-
"from langchain.embeddings import OpenAIEmbeddings\n",
|
| 123 |
-
"from langchain.vectorstores import Chroma\n",
|
| 124 |
-
"import panel as pn\n",
|
| 125 |
-
"import tempfile"
|
| 126 |
-
]
|
| 127 |
-
},
|
| 128 |
-
{
|
| 129 |
-
"cell_type": "code",
|
| 130 |
-
"execution_count": 28,
|
| 131 |
-
"id": "c08a624a-171f-4334-993c-c516d67cd46b",
|
| 132 |
-
"metadata": {},
|
| 133 |
-
"outputs": [
|
| 134 |
-
{
|
| 135 |
-
"data": {
|
| 136 |
-
"application/javascript": [
|
| 137 |
-
"(function(root) {\n",
|
| 138 |
-
" function now() {\n",
|
| 139 |
-
" return new Date();\n",
|
| 140 |
-
" }\n",
|
| 141 |
-
"\n",
|
| 142 |
-
" var force = true;\n",
|
| 143 |
-
"\n",
|
| 144 |
-
" if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n",
|
| 145 |
-
" root._bokeh_onload_callbacks = [];\n",
|
| 146 |
-
" root._bokeh_is_loading = undefined;\n",
|
| 147 |
-
" }\n",
|
| 148 |
-
"\n",
|
| 149 |
-
" if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
|
| 150 |
-
" root._bokeh_timeout = Date.now() + 5000;\n",
|
| 151 |
-
" root._bokeh_failed_load = false;\n",
|
| 152 |
-
" }\n",
|
| 153 |
-
"\n",
|
| 154 |
-
" function run_callbacks() {\n",
|
| 155 |
-
" try {\n",
|
| 156 |
-
" root._bokeh_onload_callbacks.forEach(function(callback) {\n",
|
| 157 |
-
" if (callback != null)\n",
|
| 158 |
-
" callback();\n",
|
| 159 |
-
" });\n",
|
| 160 |
-
" } finally {\n",
|
| 161 |
-
" delete root._bokeh_onload_callbacks\n",
|
| 162 |
-
" }\n",
|
| 163 |
-
" console.debug(\"Bokeh: all callbacks have finished\");\n",
|
| 164 |
-
" }\n",
|
| 165 |
-
"\n",
|
| 166 |
-
" function load_libs(css_urls, js_urls, js_modules, callback) {\n",
|
| 167 |
-
" if (css_urls == null) css_urls = [];\n",
|
| 168 |
-
" if (js_urls == null) js_urls = [];\n",
|
| 169 |
-
" if (js_modules == null) js_modules = [];\n",
|
| 170 |
-
"\n",
|
| 171 |
-
" root._bokeh_onload_callbacks.push(callback);\n",
|
| 172 |
-
" if (root._bokeh_is_loading > 0) {\n",
|
| 173 |
-
" console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
|
| 174 |
-
" return null;\n",
|
| 175 |
-
" }\n",
|
| 176 |
-
" if (js_urls.length === 0 && js_modules.length === 0) {\n",
|
| 177 |
-
" run_callbacks();\n",
|
| 178 |
-
" return null;\n",
|
| 179 |
-
" }\n",
|
| 180 |
-
" console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
|
| 181 |
-
"\n",
|
| 182 |
-
" function on_load() {\n",
|
| 183 |
-
" root._bokeh_is_loading--;\n",
|
| 184 |
-
" if (root._bokeh_is_loading === 0) {\n",
|
| 185 |
-
" console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n",
|
| 186 |
-
" run_callbacks()\n",
|
| 187 |
-
" }\n",
|
| 188 |
-
" }\n",
|
| 189 |
-
"\n",
|
| 190 |
-
" function on_error() {\n",
|
| 191 |
-
" console.error(\"failed to load \" + url);\n",
|
| 192 |
-
" }\n",
|
| 193 |
-
"\n",
|
| 194 |
-
" for (var i = 0; i < css_urls.length; i++) {\n",
|
| 195 |
-
" var url = css_urls[i];\n",
|
| 196 |
-
" const element = document.createElement(\"link\");\n",
|
| 197 |
-
" element.onload = on_load;\n",
|
| 198 |
-
" element.onerror = on_error;\n",
|
| 199 |
-
" element.rel = \"stylesheet\";\n",
|
| 200 |
-
" element.type = \"text/css\";\n",
|
| 201 |
-
" element.href = url;\n",
|
| 202 |
-
" console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n",
|
| 203 |
-
" document.body.appendChild(element);\n",
|
| 204 |
-
" }\n",
|
| 205 |
-
"\n",
|
| 206 |
-
" var skip = [];\n",
|
| 207 |
-
" if (window.requirejs) {\n",
|
| 208 |
-
" window.requirejs.config({'packages': {}, 'paths': {'Quill': 'https://cdn.quilljs.com/1.3.6/quill', 'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'gridstack': {'exports': 'GridStack'}}});\n",
|
| 209 |
-
" require([\"Quill\"], function(Quill) {\n",
|
| 210 |
-
"\twindow.Quill = Quill\n",
|
| 211 |
-
"\ton_load()\n",
|
| 212 |
-
" })\n",
|
| 213 |
-
" require([\"gridstack\"], function(GridStack) {\n",
|
| 214 |
-
"\twindow.GridStack = GridStack\n",
|
| 215 |
-
"\ton_load()\n",
|
| 216 |
-
" })\n",
|
| 217 |
-
" require([\"notyf\"], function() {\n",
|
| 218 |
-
"\ton_load()\n",
|
| 219 |
-
" })\n",
|
| 220 |
-
" root._bokeh_is_loading = css_urls.length + 3;\n",
|
| 221 |
-
" } else {\n",
|
| 222 |
-
" root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n",
|
| 223 |
-
" } if (((window['Quill'] !== undefined) && (!(window['Quill'] instanceof HTMLElement))) || window.requirejs) {\n",
|
| 224 |
-
" var urls = ['https://cdn.quilljs.com/1.3.6/quill.js'];\n",
|
| 225 |
-
" for (var i = 0; i < urls.length; i++) {\n",
|
| 226 |
-
" skip.push(urls[i])\n",
|
| 227 |
-
" }\n",
|
| 228 |
-
" } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n",
|
| 229 |
-
" var urls = ['https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5.js'];\n",
|
| 230 |
-
" for (var i = 0; i < urls.length; i++) {\n",
|
| 231 |
-
" skip.push(urls[i])\n",
|
| 232 |
-
" }\n",
|
| 233 |
-
" } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n",
|
| 234 |
-
" var urls = ['https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js'];\n",
|
| 235 |
-
" for (var i = 0; i < urls.length; i++) {\n",
|
| 236 |
-
" skip.push(urls[i])\n",
|
| 237 |
-
" }\n",
|
| 238 |
-
" } for (var i = 0; i < js_urls.length; i++) {\n",
|
| 239 |
-
" var url = js_urls[i];\n",
|
| 240 |
-
" if (skip.indexOf(url) >= 0) {\n",
|
| 241 |
-
"\tif (!window.requirejs) {\n",
|
| 242 |
-
"\t on_load();\n",
|
| 243 |
-
"\t}\n",
|
| 244 |
-
"\tcontinue;\n",
|
| 245 |
-
" }\n",
|
| 246 |
-
" var element = document.createElement('script');\n",
|
| 247 |
-
" element.onload = on_load;\n",
|
| 248 |
-
" element.onerror = on_error;\n",
|
| 249 |
-
" element.async = false;\n",
|
| 250 |
-
" element.src = url;\n",
|
| 251 |
-
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
|
| 252 |
-
" document.head.appendChild(element);\n",
|
| 253 |
-
" }\n",
|
| 254 |
-
" for (var i = 0; i < js_modules.length; i++) {\n",
|
| 255 |
-
" var url = js_modules[i];\n",
|
| 256 |
-
" if (skip.indexOf(url) >= 0) {\n",
|
| 257 |
-
"\tif (!window.requirejs) {\n",
|
| 258 |
-
"\t on_load();\n",
|
| 259 |
-
"\t}\n",
|
| 260 |
-
"\tcontinue;\n",
|
| 261 |
-
" }\n",
|
| 262 |
-
" var element = document.createElement('script');\n",
|
| 263 |
-
" element.onload = on_load;\n",
|
| 264 |
-
" element.onerror = on_error;\n",
|
| 265 |
-
" element.async = false;\n",
|
| 266 |
-
" element.src = url;\n",
|
| 267 |
-
" element.type = \"module\";\n",
|
| 268 |
-
" console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
|
| 269 |
-
" document.head.appendChild(element);\n",
|
| 270 |
-
" }\n",
|
| 271 |
-
" if (!js_urls.length && !js_modules.length) {\n",
|
| 272 |
-
" on_load()\n",
|
| 273 |
-
" }\n",
|
| 274 |
-
" };\n",
|
| 275 |
-
"\n",
|
| 276 |
-
" function inject_raw_css(css) {\n",
|
| 277 |
-
" const element = document.createElement(\"style\");\n",
|
| 278 |
-
" element.appendChild(document.createTextNode(css));\n",
|
| 279 |
-
" document.body.appendChild(element);\n",
|
| 280 |
-
" }\n",
|
| 281 |
-
"\n",
|
| 282 |
-
" var js_urls = [\"https://cdn.quilljs.com/1.3.6/quill.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\", \"https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/panel.min.js\"];\n",
|
| 283 |
-
" var js_modules = [];\n",
|
| 284 |
-
" var css_urls = [\"https://cdn.quilljs.com/1.3.6/quill.bubble.css\", \"https://cdn.quilljs.com/1.3.6/quill.snow.css\", \"https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css\", \"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/debugger.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/alerts.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/card.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/widgets.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/markdown.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/json.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/loading.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/dataframe.css\"];\n",
|
| 285 |
-
" var inline_js = [ function(Bokeh) {\n",
|
| 286 |
-
" inject_raw_css(\"\\n .bk.pn-loading.arcs:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBzdHlsZT0ibWFyZ2luOiBhdXRvOyBiYWNrZ3JvdW5kOiBub25lOyBkaXNwbGF5OiBibG9jazsgc2hhcGUtcmVuZGVyaW5nOiBhdXRvOyIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4gIDxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjMyIiBzdHJva2Utd2lkdGg9IjgiIHN0cm9rZT0iI2MzYzNjMyIgc3Ryb2tlLWRhc2hhcnJheT0iNTAuMjY1NDgyNDU3NDM2NjkgNTAuMjY1NDgyNDU3NDM2NjkiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+ICAgIDxhbmltYXRlVHJhbnNmb3JtIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSIgdHlwZT0icm90YXRlIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgZHVyPSIxcyIga2V5VGltZXM9IjA7MSIgdmFsdWVzPSIwIDUwIDUwOzM2MCA1MCA1MCI+PC9hbmltYXRlVHJhbnNmb3JtPiAgPC9jaXJjbGU+PC9zdmc+\\\");\\n background-size: auto calc(min(50%, 400px));\\n }\\n \");\n",
|
| 287 |
-
" }, function(Bokeh) {\n",
|
| 288 |
-
" Bokeh.set_log_level(\"info\");\n",
|
| 289 |
-
" },\n",
|
| 290 |
-
"function(Bokeh) {} // ensure no trailing comma for IE\n",
|
| 291 |
-
" ];\n",
|
| 292 |
-
"\n",
|
| 293 |
-
" function run_inline_js() {\n",
|
| 294 |
-
" if ((root.Bokeh !== undefined) || (force === true)) {\n",
|
| 295 |
-
" for (var i = 0; i < inline_js.length; i++) {\n",
|
| 296 |
-
" inline_js[i].call(root, root.Bokeh);\n",
|
| 297 |
-
" }} else if (Date.now() < root._bokeh_timeout) {\n",
|
| 298 |
-
" setTimeout(run_inline_js, 100);\n",
|
| 299 |
-
" } else if (!root._bokeh_failed_load) {\n",
|
| 300 |
-
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
|
| 301 |
-
" root._bokeh_failed_load = true;\n",
|
| 302 |
-
" }\n",
|
| 303 |
-
" }\n",
|
| 304 |
-
"\n",
|
| 305 |
-
" if (root._bokeh_is_loading === 0) {\n",
|
| 306 |
-
" console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
|
| 307 |
-
" run_inline_js();\n",
|
| 308 |
-
" } else {\n",
|
| 309 |
-
" load_libs(css_urls, js_urls, js_modules, function() {\n",
|
| 310 |
-
" console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n",
|
| 311 |
-
" run_inline_js();\n",
|
| 312 |
-
" });\n",
|
| 313 |
-
" }\n",
|
| 314 |
-
"}(window));"
|
| 315 |
-
],
|
| 316 |
-
"application/vnd.holoviews_load.v0+json": "(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, js_modules, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n if (js_modules == null) js_modules = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls.length === 0 && js_modules.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n var skip = [];\n if (window.requirejs) {\n window.requirejs.config({'packages': {}, 'paths': {'Quill': 'https://cdn.quilljs.com/1.3.6/quill', 'gridstack': 'https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5', 'notyf': 'https://cdn.jsdelivr.net/npm/notyf@3/notyf.min'}, 'shim': {'gridstack': {'exports': 'GridStack'}}});\n require([\"Quill\"], function(Quill) {\n\twindow.Quill = Quill\n\ton_load()\n })\n require([\"gridstack\"], function(GridStack) {\n\twindow.GridStack = GridStack\n\ton_load()\n })\n require([\"notyf\"], function() {\n\ton_load()\n })\n root._bokeh_is_loading = css_urls.length + 3;\n } else {\n root._bokeh_is_loading = css_urls.length + js_urls.length + js_modules.length;\n } if (((window['Quill'] !== undefined) && (!(window['Quill'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.quilljs.com/1.3.6/quill.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['GridStack'] !== undefined) && (!(window['GridStack'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.jsdelivr.net/npm/gridstack@4.2.5/dist/gridstack-h5.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } if (((window['Notyf'] !== undefined) && (!(window['Notyf'] instanceof HTMLElement))) || window.requirejs) {\n var urls = ['https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js'];\n for (var i = 0; i < urls.length; i++) {\n skip.push(urls[i])\n }\n } for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n if (skip.indexOf(url) >= 0) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n for (var i = 0; i < js_modules.length; i++) {\n var url = js_modules[i];\n if (skip.indexOf(url) >= 0) {\n\tif (!window.requirejs) {\n\t on_load();\n\t}\n\tcontinue;\n }\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n element.type = \"module\";\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n if (!js_urls.length && !js_modules.length) {\n on_load()\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n var js_urls = [\"https://cdn.quilljs.com/1.3.6/quill.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-2.4.3.min.js\", \"https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/panel.min.js\"];\n var js_modules = [];\n var css_urls = [\"https://cdn.quilljs.com/1.3.6/quill.bubble.css\", \"https://cdn.quilljs.com/1.3.6/quill.snow.css\", \"https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css\", \"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/debugger.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/alerts.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/card.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/widgets.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/markdown.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/json.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/loading.css\", \"https://unpkg.com/@holoviz/panel@0.13.1/dist/css/dataframe.css\"];\n var inline_js = [ function(Bokeh) {\n inject_raw_css(\"\\n .bk.pn-loading.arcs:before {\\n background-image: url(\\\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBzdHlsZT0ibWFyZ2luOiBhdXRvOyBiYWNrZ3JvdW5kOiBub25lOyBkaXNwbGF5OiBibG9jazsgc2hhcGUtcmVuZGVyaW5nOiBhdXRvOyIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89InhNaWRZTWlkIj4gIDxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjMyIiBzdHJva2Utd2lkdGg9IjgiIHN0cm9rZT0iI2MzYzNjMyIgc3Ryb2tlLWRhc2hhcnJheT0iNTAuMjY1NDgyNDU3NDM2NjkgNTAuMjY1NDgyNDU3NDM2NjkiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+ICAgIDxhbmltYXRlVHJhbnNmb3JtIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSIgdHlwZT0icm90YXRlIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgZHVyPSIxcyIga2V5VGltZXM9IjA7MSIgdmFsdWVzPSIwIDUwIDUwOzM2MCA1MCA1MCI+PC9hbmltYXRlVHJhbnNmb3JtPiAgPC9jaXJjbGU+PC9zdmc+\\\");\\n background-size: auto calc(min(50%, 400px));\\n }\\n \");\n }, function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {} // ensure no trailing comma for IE\n ];\n\n function run_inline_js() {\n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, js_modules, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
|
| 317 |
-
},
|
| 318 |
-
"metadata": {},
|
| 319 |
-
"output_type": "display_data"
|
| 320 |
-
},
|
| 321 |
-
{
|
| 322 |
-
"data": {
|
| 323 |
-
"application/javascript": [
|
| 324 |
-
"\n",
|
| 325 |
-
"if ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n",
|
| 326 |
-
" window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n",
|
| 327 |
-
"}\n",
|
| 328 |
-
"\n",
|
| 329 |
-
"\n",
|
| 330 |
-
" function JupyterCommManager() {\n",
|
| 331 |
-
" }\n",
|
| 332 |
-
"\n",
|
| 333 |
-
" JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n",
|
| 334 |
-
" if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n",
|
| 335 |
-
" var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n",
|
| 336 |
-
" comm_manager.register_target(comm_id, function(comm) {\n",
|
| 337 |
-
" comm.on_msg(msg_handler);\n",
|
| 338 |
-
" });\n",
|
| 339 |
-
" } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n",
|
| 340 |
-
" window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n",
|
| 341 |
-
" comm.onMsg = msg_handler;\n",
|
| 342 |
-
" });\n",
|
| 343 |
-
" } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n",
|
| 344 |
-
" google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n",
|
| 345 |
-
" var messages = comm.messages[Symbol.asyncIterator]();\n",
|
| 346 |
-
" function processIteratorResult(result) {\n",
|
| 347 |
-
" var message = result.value;\n",
|
| 348 |
-
" console.log(message)\n",
|
| 349 |
-
" var content = {data: message.data, comm_id};\n",
|
| 350 |
-
" var buffers = []\n",
|
| 351 |
-
" for (var buffer of message.buffers || []) {\n",
|
| 352 |
-
" buffers.push(new DataView(buffer))\n",
|
| 353 |
-
" }\n",
|
| 354 |
-
" var metadata = message.metadata || {};\n",
|
| 355 |
-
" var msg = {content, buffers, metadata}\n",
|
| 356 |
-
" msg_handler(msg);\n",
|
| 357 |
-
" return messages.next().then(processIteratorResult);\n",
|
| 358 |
-
" }\n",
|
| 359 |
-
" return messages.next().then(processIteratorResult);\n",
|
| 360 |
-
" })\n",
|
| 361 |
-
" }\n",
|
| 362 |
-
" }\n",
|
| 363 |
-
"\n",
|
| 364 |
-
" JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n",
|
| 365 |
-
" if (comm_id in window.PyViz.comms) {\n",
|
| 366 |
-
" return window.PyViz.comms[comm_id];\n",
|
| 367 |
-
" } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n",
|
| 368 |
-
" var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n",
|
| 369 |
-
" var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n",
|
| 370 |
-
" if (msg_handler) {\n",
|
| 371 |
-
" comm.on_msg(msg_handler);\n",
|
| 372 |
-
" }\n",
|
| 373 |
-
" } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n",
|
| 374 |
-
" var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n",
|
| 375 |
-
" comm.open();\n",
|
| 376 |
-
" if (msg_handler) {\n",
|
| 377 |
-
" comm.onMsg = msg_handler;\n",
|
| 378 |
-
" }\n",
|
| 379 |
-
" } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n",
|
| 380 |
-
" var comm_promise = google.colab.kernel.comms.open(comm_id)\n",
|
| 381 |
-
" comm_promise.then((comm) => {\n",
|
| 382 |
-
" window.PyViz.comms[comm_id] = comm;\n",
|
| 383 |
-
" if (msg_handler) {\n",
|
| 384 |
-
" var messages = comm.messages[Symbol.asyncIterator]();\n",
|
| 385 |
-
" function processIteratorResult(result) {\n",
|
| 386 |
-
" var message = result.value;\n",
|
| 387 |
-
" var content = {data: message.data};\n",
|
| 388 |
-
" var metadata = message.metadata || {comm_id};\n",
|
| 389 |
-
" var msg = {content, metadata}\n",
|
| 390 |
-
" msg_handler(msg);\n",
|
| 391 |
-
" return messages.next().then(processIteratorResult);\n",
|
| 392 |
-
" }\n",
|
| 393 |
-
" return messages.next().then(processIteratorResult);\n",
|
| 394 |
-
" }\n",
|
| 395 |
-
" }) \n",
|
| 396 |
-
" var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n",
|
| 397 |
-
" return comm_promise.then((comm) => {\n",
|
| 398 |
-
" comm.send(data, metadata, buffers, disposeOnDone);\n",
|
| 399 |
-
" });\n",
|
| 400 |
-
" };\n",
|
| 401 |
-
" var comm = {\n",
|
| 402 |
-
" send: sendClosure\n",
|
| 403 |
-
" };\n",
|
| 404 |
-
" }\n",
|
| 405 |
-
" window.PyViz.comms[comm_id] = comm;\n",
|
| 406 |
-
" return comm;\n",
|
| 407 |
-
" }\n",
|
| 408 |
-
" window.PyViz.comm_manager = new JupyterCommManager();\n",
|
| 409 |
-
" \n",
|
| 410 |
-
"\n",
|
| 411 |
-
"\n",
|
| 412 |
-
"var JS_MIME_TYPE = 'application/javascript';\n",
|
| 413 |
-
"var HTML_MIME_TYPE = 'text/html';\n",
|
| 414 |
-
"var EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\n",
|
| 415 |
-
"var CLASS_NAME = 'output';\n",
|
| 416 |
-
"\n",
|
| 417 |
-
"/**\n",
|
| 418 |
-
" * Render data to the DOM node\n",
|
| 419 |
-
" */\n",
|
| 420 |
-
"function render(props, node) {\n",
|
| 421 |
-
" var div = document.createElement(\"div\");\n",
|
| 422 |
-
" var script = document.createElement(\"script\");\n",
|
| 423 |
-
" node.appendChild(div);\n",
|
| 424 |
-
" node.appendChild(script);\n",
|
| 425 |
-
"}\n",
|
| 426 |
-
"\n",
|
| 427 |
-
"/**\n",
|
| 428 |
-
" * Handle when a new output is added\n",
|
| 429 |
-
" */\n",
|
| 430 |
-
"function handle_add_output(event, handle) {\n",
|
| 431 |
-
" var output_area = handle.output_area;\n",
|
| 432 |
-
" var output = handle.output;\n",
|
| 433 |
-
" if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
|
| 434 |
-
" return\n",
|
| 435 |
-
" }\n",
|
| 436 |
-
" var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
|
| 437 |
-
" var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n",
|
| 438 |
-
" if (id !== undefined) {\n",
|
| 439 |
-
" var nchildren = toinsert.length;\n",
|
| 440 |
-
" var html_node = toinsert[nchildren-1].children[0];\n",
|
| 441 |
-
" html_node.innerHTML = output.data[HTML_MIME_TYPE];\n",
|
| 442 |
-
" var scripts = [];\n",
|
| 443 |
-
" var nodelist = html_node.querySelectorAll(\"script\");\n",
|
| 444 |
-
" for (var i in nodelist) {\n",
|
| 445 |
-
" if (nodelist.hasOwnProperty(i)) {\n",
|
| 446 |
-
" scripts.push(nodelist[i])\n",
|
| 447 |
-
" }\n",
|
| 448 |
-
" }\n",
|
| 449 |
-
"\n",
|
| 450 |
-
" scripts.forEach( function (oldScript) {\n",
|
| 451 |
-
" var newScript = document.createElement(\"script\");\n",
|
| 452 |
-
" var attrs = [];\n",
|
| 453 |
-
" var nodemap = oldScript.attributes;\n",
|
| 454 |
-
" for (var j in nodemap) {\n",
|
| 455 |
-
" if (nodemap.hasOwnProperty(j)) {\n",
|
| 456 |
-
" attrs.push(nodemap[j])\n",
|
| 457 |
-
" }\n",
|
| 458 |
-
" }\n",
|
| 459 |
-
" attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n",
|
| 460 |
-
" newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n",
|
| 461 |
-
" oldScript.parentNode.replaceChild(newScript, oldScript);\n",
|
| 462 |
-
" });\n",
|
| 463 |
-
" if (JS_MIME_TYPE in output.data) {\n",
|
| 464 |
-
" toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n",
|
| 465 |
-
" }\n",
|
| 466 |
-
" output_area._hv_plot_id = id;\n",
|
| 467 |
-
" if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n",
|
| 468 |
-
" window.PyViz.plot_index[id] = Bokeh.index[id];\n",
|
| 469 |
-
" } else {\n",
|
| 470 |
-
" window.PyViz.plot_index[id] = null;\n",
|
| 471 |
-
" }\n",
|
| 472 |
-
" } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
|
| 473 |
-
" var bk_div = document.createElement(\"div\");\n",
|
| 474 |
-
" bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
|
| 475 |
-
" var script_attrs = bk_div.children[0].attributes;\n",
|
| 476 |
-
" for (var i = 0; i < script_attrs.length; i++) {\n",
|
| 477 |
-
" toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
|
| 478 |
-
" }\n",
|
| 479 |
-
" // store reference to server id on output_area\n",
|
| 480 |
-
" output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
|
| 481 |
-
" }\n",
|
| 482 |
-
"}\n",
|
| 483 |
-
"\n",
|
| 484 |
-
"/**\n",
|
| 485 |
-
" * Handle when an output is cleared or removed\n",
|
| 486 |
-
" */\n",
|
| 487 |
-
"function handle_clear_output(event, handle) {\n",
|
| 488 |
-
" var id = handle.cell.output_area._hv_plot_id;\n",
|
| 489 |
-
" var server_id = handle.cell.output_area._bokeh_server_id;\n",
|
| 490 |
-
" if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n",
|
| 491 |
-
" var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n",
|
| 492 |
-
" if (server_id !== null) {\n",
|
| 493 |
-
" comm.send({event_type: 'server_delete', 'id': server_id});\n",
|
| 494 |
-
" return;\n",
|
| 495 |
-
" } else if (comm !== null) {\n",
|
| 496 |
-
" comm.send({event_type: 'delete', 'id': id});\n",
|
| 497 |
-
" }\n",
|
| 498 |
-
" delete PyViz.plot_index[id];\n",
|
| 499 |
-
" if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n",
|
| 500 |
-
" var doc = window.Bokeh.index[id].model.document\n",
|
| 501 |
-
" doc.clear();\n",
|
| 502 |
-
" const i = window.Bokeh.documents.indexOf(doc);\n",
|
| 503 |
-
" if (i > -1) {\n",
|
| 504 |
-
" window.Bokeh.documents.splice(i, 1);\n",
|
| 505 |
-
" }\n",
|
| 506 |
-
" }\n",
|
| 507 |
-
"}\n",
|
| 508 |
-
"\n",
|
| 509 |
-
"/**\n",
|
| 510 |
-
" * Handle kernel restart event\n",
|
| 511 |
-
" */\n",
|
| 512 |
-
"function handle_kernel_cleanup(event, handle) {\n",
|
| 513 |
-
" delete PyViz.comms[\"hv-extension-comm\"];\n",
|
| 514 |
-
" window.PyViz.plot_index = {}\n",
|
| 515 |
-
"}\n",
|
| 516 |
-
"\n",
|
| 517 |
-
"/**\n",
|
| 518 |
-
" * Handle update_display_data messages\n",
|
| 519 |
-
" */\n",
|
| 520 |
-
"function handle_update_output(event, handle) {\n",
|
| 521 |
-
" handle_clear_output(event, {cell: {output_area: handle.output_area}})\n",
|
| 522 |
-
" handle_add_output(event, handle)\n",
|
| 523 |
-
"}\n",
|
| 524 |
-
"\n",
|
| 525 |
-
"function register_renderer(events, OutputArea) {\n",
|
| 526 |
-
" function append_mime(data, metadata, element) {\n",
|
| 527 |
-
" // create a DOM node to render to\n",
|
| 528 |
-
" var toinsert = this.create_output_subarea(\n",
|
| 529 |
-
" metadata,\n",
|
| 530 |
-
" CLASS_NAME,\n",
|
| 531 |
-
" EXEC_MIME_TYPE\n",
|
| 532 |
-
" );\n",
|
| 533 |
-
" this.keyboard_manager.register_events(toinsert);\n",
|
| 534 |
-
" // Render to node\n",
|
| 535 |
-
" var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
|
| 536 |
-
" render(props, toinsert[0]);\n",
|
| 537 |
-
" element.append(toinsert);\n",
|
| 538 |
-
" return toinsert\n",
|
| 539 |
-
" }\n",
|
| 540 |
-
"\n",
|
| 541 |
-
" events.on('output_added.OutputArea', handle_add_output);\n",
|
| 542 |
-
" events.on('output_updated.OutputArea', handle_update_output);\n",
|
| 543 |
-
" events.on('clear_output.CodeCell', handle_clear_output);\n",
|
| 544 |
-
" events.on('delete.Cell', handle_clear_output);\n",
|
| 545 |
-
" events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n",
|
| 546 |
-
"\n",
|
| 547 |
-
" OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
|
| 548 |
-
" safe: true,\n",
|
| 549 |
-
" index: 0\n",
|
| 550 |
-
" });\n",
|
| 551 |
-
"}\n",
|
| 552 |
-
"\n",
|
| 553 |
-
"if (window.Jupyter !== undefined) {\n",
|
| 554 |
-
" try {\n",
|
| 555 |
-
" var events = require('base/js/events');\n",
|
| 556 |
-
" var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
|
| 557 |
-
" if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
|
| 558 |
-
" register_renderer(events, OutputArea);\n",
|
| 559 |
-
" }\n",
|
| 560 |
-
" } catch(err) {\n",
|
| 561 |
-
" }\n",
|
| 562 |
-
"}\n"
|
| 563 |
-
],
|
| 564 |
-
"application/vnd.holoviews_load.v0+json": "\nif ((window.PyViz === undefined) || (window.PyViz instanceof HTMLElement)) {\n window.PyViz = {comms: {}, comm_status:{}, kernels:{}, receivers: {}, plot_index: []}\n}\n\n\n function JupyterCommManager() {\n }\n\n JupyterCommManager.prototype.register_target = function(plot_id, comm_id, msg_handler) {\n if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n comm_manager.register_target(comm_id, function(comm) {\n comm.on_msg(msg_handler);\n });\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n window.PyViz.kernels[plot_id].registerCommTarget(comm_id, function(comm) {\n comm.onMsg = msg_handler;\n });\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n google.colab.kernel.comms.registerTarget(comm_id, (comm) => {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n console.log(message)\n var content = {data: message.data, comm_id};\n var buffers = []\n for (var buffer of message.buffers || []) {\n buffers.push(new DataView(buffer))\n }\n var metadata = message.metadata || {};\n var msg = {content, buffers, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n })\n }\n }\n\n JupyterCommManager.prototype.get_client_comm = function(plot_id, comm_id, msg_handler) {\n if (comm_id in window.PyViz.comms) {\n return window.PyViz.comms[comm_id];\n } else if (window.comm_manager || ((window.Jupyter !== undefined) && (Jupyter.notebook.kernel != null))) {\n var comm_manager = window.comm_manager || Jupyter.notebook.kernel.comm_manager;\n var comm = comm_manager.new_comm(comm_id, {}, {}, {}, comm_id);\n if (msg_handler) {\n comm.on_msg(msg_handler);\n }\n } else if ((plot_id in window.PyViz.kernels) && (window.PyViz.kernels[plot_id])) {\n var comm = window.PyViz.kernels[plot_id].connectToComm(comm_id);\n comm.open();\n if (msg_handler) {\n comm.onMsg = msg_handler;\n }\n } else if (typeof google != 'undefined' && google.colab.kernel != null) {\n var comm_promise = google.colab.kernel.comms.open(comm_id)\n comm_promise.then((comm) => {\n window.PyViz.comms[comm_id] = comm;\n if (msg_handler) {\n var messages = comm.messages[Symbol.asyncIterator]();\n function processIteratorResult(result) {\n var message = result.value;\n var content = {data: message.data};\n var metadata = message.metadata || {comm_id};\n var msg = {content, metadata}\n msg_handler(msg);\n return messages.next().then(processIteratorResult);\n }\n return messages.next().then(processIteratorResult);\n }\n }) \n var sendClosure = (data, metadata, buffers, disposeOnDone) => {\n return comm_promise.then((comm) => {\n comm.send(data, metadata, buffers, disposeOnDone);\n });\n };\n var comm = {\n send: sendClosure\n };\n }\n window.PyViz.comms[comm_id] = comm;\n return comm;\n }\n window.PyViz.comm_manager = new JupyterCommManager();\n \n\n\nvar JS_MIME_TYPE = 'application/javascript';\nvar HTML_MIME_TYPE = 'text/html';\nvar EXEC_MIME_TYPE = 'application/vnd.holoviews_exec.v0+json';\nvar CLASS_NAME = 'output';\n\n/**\n * Render data to the DOM node\n */\nfunction render(props, node) {\n var div = document.createElement(\"div\");\n var script = document.createElement(\"script\");\n node.appendChild(div);\n node.appendChild(script);\n}\n\n/**\n * Handle when a new output is added\n */\nfunction handle_add_output(event, handle) {\n var output_area = handle.output_area;\n var output = handle.output;\n if ((output.data == undefined) || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n return\n }\n var id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n if (id !== undefined) {\n var nchildren = toinsert.length;\n var html_node = toinsert[nchildren-1].children[0];\n html_node.innerHTML = output.data[HTML_MIME_TYPE];\n var scripts = [];\n var nodelist = html_node.querySelectorAll(\"script\");\n for (var i in nodelist) {\n if (nodelist.hasOwnProperty(i)) {\n scripts.push(nodelist[i])\n }\n }\n\n scripts.forEach( function (oldScript) {\n var newScript = document.createElement(\"script\");\n var attrs = [];\n var nodemap = oldScript.attributes;\n for (var j in nodemap) {\n if (nodemap.hasOwnProperty(j)) {\n attrs.push(nodemap[j])\n }\n }\n attrs.forEach(function(attr) { newScript.setAttribute(attr.name, attr.value) });\n newScript.appendChild(document.createTextNode(oldScript.innerHTML));\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n if (JS_MIME_TYPE in output.data) {\n toinsert[nchildren-1].children[1].textContent = output.data[JS_MIME_TYPE];\n }\n output_area._hv_plot_id = id;\n if ((window.Bokeh !== undefined) && (id in Bokeh.index)) {\n window.PyViz.plot_index[id] = Bokeh.index[id];\n } else {\n window.PyViz.plot_index[id] = null;\n }\n } else if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n var bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n var script_attrs = bk_div.children[0].attributes;\n for (var i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].childNodes[1].setAttribute(script_attrs[i].name, script_attrs[i].value);\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n}\n\n/**\n * Handle when an output is cleared or removed\n */\nfunction handle_clear_output(event, handle) {\n var id = handle.cell.output_area._hv_plot_id;\n var server_id = handle.cell.output_area._bokeh_server_id;\n if (((id === undefined) || !(id in PyViz.plot_index)) && (server_id !== undefined)) { return; }\n var comm = window.PyViz.comm_manager.get_client_comm(\"hv-extension-comm\", \"hv-extension-comm\", function () {});\n if (server_id !== null) {\n comm.send({event_type: 'server_delete', 'id': server_id});\n return;\n } else if (comm !== null) {\n comm.send({event_type: 'delete', 'id': id});\n }\n delete PyViz.plot_index[id];\n if ((window.Bokeh !== undefined) & (id in window.Bokeh.index)) {\n var doc = window.Bokeh.index[id].model.document\n doc.clear();\n const i = window.Bokeh.documents.indexOf(doc);\n if (i > -1) {\n window.Bokeh.documents.splice(i, 1);\n }\n }\n}\n\n/**\n * Handle kernel restart event\n */\nfunction handle_kernel_cleanup(event, handle) {\n delete PyViz.comms[\"hv-extension-comm\"];\n window.PyViz.plot_index = {}\n}\n\n/**\n * Handle update_display_data messages\n */\nfunction handle_update_output(event, handle) {\n handle_clear_output(event, {cell: {output_area: handle.output_area}})\n handle_add_output(event, handle)\n}\n\nfunction register_renderer(events, OutputArea) {\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n var toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[0]);\n element.append(toinsert);\n return toinsert\n }\n\n events.on('output_added.OutputArea', handle_add_output);\n events.on('output_updated.OutputArea', handle_update_output);\n events.on('clear_output.CodeCell', handle_clear_output);\n events.on('delete.Cell', handle_clear_output);\n events.on('kernel_ready.Kernel', handle_kernel_cleanup);\n\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n safe: true,\n index: 0\n });\n}\n\nif (window.Jupyter !== undefined) {\n try {\n var events = require('base/js/events');\n var OutputArea = require('notebook/js/outputarea').OutputArea;\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n } catch(err) {\n }\n}\n"
|
| 565 |
-
},
|
| 566 |
-
"metadata": {},
|
| 567 |
-
"output_type": "display_data"
|
| 568 |
-
},
|
| 569 |
-
{
|
| 570 |
-
"data": {
|
| 571 |
-
"text/html": [
|
| 572 |
-
"<style>.bk-root, .bk-root .bk:before, .bk-root .bk:after {\n",
|
| 573 |
-
" font-family: var(--jp-ui-font-size1);\n",
|
| 574 |
-
" font-size: var(--jp-ui-font-size1);\n",
|
| 575 |
-
" color: var(--jp-ui-font-color1);\n",
|
| 576 |
-
"}\n",
|
| 577 |
-
"</style>"
|
| 578 |
-
]
|
| 579 |
-
},
|
| 580 |
-
"metadata": {},
|
| 581 |
-
"output_type": "display_data"
|
| 582 |
-
}
|
| 583 |
-
],
|
| 584 |
-
"source": [
|
| 585 |
-
"pn.extension('texteditor', template=\"bootstrap\", sizing_mode='stretch_width')\n",
|
| 586 |
-
"pn.state.template.param.update(\n",
|
| 587 |
-
" main_max_width=\"690px\",\n",
|
| 588 |
-
" header_background=\"#eddf15\",\n",
|
| 589 |
-
")"
|
| 590 |
-
]
|
| 591 |
-
},
|
| 592 |
-
{
|
| 593 |
-
"cell_type": "code",
|
| 594 |
-
"execution_count": 29,
|
| 595 |
-
"id": "ac074e46-004b-41e7-b3b6-79ccd92d2051",
|
| 596 |
-
"metadata": {},
|
| 597 |
-
"outputs": [],
|
| 598 |
-
"source": [
|
| 599 |
-
"file_input = pn.widgets.FileInput(width=300)\n",
|
| 600 |
-
"\n",
|
| 601 |
-
"openaikey = pn.widgets.PasswordInput(\n",
|
| 602 |
-
" value=\"\", placeholder=\"Enter your OpenAI API Key here...\", width=300\n",
|
| 603 |
-
")\n",
|
| 604 |
-
"prompt = pn.widgets.TextEditor(\n",
|
| 605 |
-
" value=\"\", placeholder=\"Enter your questions here...\", height=160, toolbar=False\n",
|
| 606 |
-
")\n",
|
| 607 |
-
"run_button = pn.widgets.Button(name=\"Run!\")\n",
|
| 608 |
-
"\n",
|
| 609 |
-
"select_k = pn.widgets.IntSlider(\n",
|
| 610 |
-
" name=\"Number of relevant chunks\", start=1, end=5, step=1, value=2\n",
|
| 611 |
-
")\n",
|
| 612 |
-
"select_chain_type = pn.widgets.RadioButtonGroup(\n",
|
| 613 |
-
" name='Chain type', \n",
|
| 614 |
-
" options=['stuff', 'map_reduce', \"refine\", \"map_rerank\"]\n",
|
| 615 |
-
")\n",
|
| 616 |
-
"\n",
|
| 617 |
-
"widgets = pn.Row(\n",
|
| 618 |
-
" pn.Card(\n",
|
| 619 |
-
" \"Chain type:\",\n",
|
| 620 |
-
" pn.Column(select_chain_type, select_k),\n",
|
| 621 |
-
" title=\"Advanced settings\", margin=10\n",
|
| 622 |
-
" ), \n",
|
| 623 |
-
" pn.Column(prompt, run_button, margin=5),\n",
|
| 624 |
-
" width=600\n",
|
| 625 |
-
")"
|
| 626 |
-
]
|
| 627 |
-
},
|
| 628 |
-
{
|
| 629 |
-
"cell_type": "code",
|
| 630 |
-
"execution_count": 30,
|
| 631 |
-
"id": "43670abb-f7a3-452a-89e4-d335e5d4ae77",
|
| 632 |
-
"metadata": {},
|
| 633 |
-
"outputs": [],
|
| 634 |
-
"source": [
|
| 635 |
-
"def qa(file, query, chain_type, k):\n",
|
| 636 |
-
" # load document\n",
|
| 637 |
-
" loader = PyPDFLoader(file)\n",
|
| 638 |
-
" documents = loader.load()\n",
|
| 639 |
-
" # split the documents into chunks\n",
|
| 640 |
-
" text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)\n",
|
| 641 |
-
" texts = text_splitter.split_documents(documents)\n",
|
| 642 |
-
" # select which embeddings we want to use\n",
|
| 643 |
-
" embeddings = OpenAIEmbeddings()\n",
|
| 644 |
-
" # create the vectorestore to use as the index\n",
|
| 645 |
-
" db = Chroma.from_documents(texts, embeddings)\n",
|
| 646 |
-
" # expose this index in a retriever interface\n",
|
| 647 |
-
" retriever = db.as_retriever(search_type=\"similarity\", search_kwargs={\"k\": k})\n",
|
| 648 |
-
" # create a chain to answer questions \n",
|
| 649 |
-
" qa = RetrievalQA.from_chain_type(\n",
|
| 650 |
-
" llm=OpenAI(), chain_type=chain_type, retriever=retriever, return_source_documents=True)\n",
|
| 651 |
-
" result = qa({\"query\": query})\n",
|
| 652 |
-
" print(result['result'])\n",
|
| 653 |
-
" return result"
|
| 654 |
-
]
|
| 655 |
-
},
|
| 656 |
-
{
|
| 657 |
-
"cell_type": "code",
|
| 658 |
-
"execution_count": 31,
|
| 659 |
-
"id": "f54690e3-81c1-4221-b5b1-9b2acc3f2c40",
|
| 660 |
-
"metadata": {},
|
| 661 |
-
"outputs": [],
|
| 662 |
-
"source": [
|
| 663 |
-
"convos = [] # store all panel objects in a list\n",
|
| 664 |
-
"\n",
|
| 665 |
-
"def qa_result(_):\n",
|
| 666 |
-
" os.environ[\"OPENAI_API_KEY\"] = openaikey.value\n",
|
| 667 |
-
" \n",
|
| 668 |
-
" # save pdf file to a temp file \n",
|
| 669 |
-
" if file_input.value is not None:\n",
|
| 670 |
-
" file_input.save(\"/.cache/temp.pdf\")\n",
|
| 671 |
-
" \n",
|
| 672 |
-
" prompt_text = prompt.value\n",
|
| 673 |
-
" if prompt_text:\n",
|
| 674 |
-
" result = qa(file=\"/.cache/temp.pdf\", query=prompt_text, chain_type=select_chain_type.value, k=select_k.value)\n",
|
| 675 |
-
" convos.extend([\n",
|
| 676 |
-
" pn.Row(\n",
|
| 677 |
-
" pn.panel(\"\\U0001F60A\", width=10),\n",
|
| 678 |
-
" prompt_text,\n",
|
| 679 |
-
" width=600\n",
|
| 680 |
-
" ),\n",
|
| 681 |
-
" pn.Row(\n",
|
| 682 |
-
" pn.panel(\"\\U0001F916\", width=10),\n",
|
| 683 |
-
" pn.Column(\n",
|
| 684 |
-
" result[\"result\"],\n",
|
| 685 |
-
" \"Relevant source text:\",\n",
|
| 686 |
-
" pn.pane.Markdown('\\n--------------------------------------------------------------------\\n'.join(doc.page_content for doc in result[\"source_documents\"]))\n",
|
| 687 |
-
" )\n",
|
| 688 |
-
" )\n",
|
| 689 |
-
" ])\n",
|
| 690 |
-
" #return convos\n",
|
| 691 |
-
" return pn.Column(*convos, margin=15, width=575, min_height=400)\n"
|
| 692 |
-
]
|
| 693 |
-
},
|
| 694 |
-
{
|
| 695 |
-
"cell_type": "code",
|
| 696 |
-
"execution_count": 32,
|
| 697 |
-
"id": "989d5916-427e-4c48-987f-99b7d219b791",
|
| 698 |
-
"metadata": {},
|
| 699 |
-
"outputs": [],
|
| 700 |
-
"source": [
|
| 701 |
-
"qa_interactive = pn.panel(\n",
|
| 702 |
-
" pn.bind(qa_result, run_button),\n",
|
| 703 |
-
" loading_indicator=True,\n",
|
| 704 |
-
")"
|
| 705 |
-
]
|
| 706 |
-
},
|
| 707 |
-
{
|
| 708 |
-
"cell_type": "code",
|
| 709 |
-
"execution_count": 33,
|
| 710 |
-
"id": "b1553e1e-9c6d-4d83-89ef-db3bebfe65e0",
|
| 711 |
-
"metadata": {},
|
| 712 |
-
"outputs": [],
|
| 713 |
-
"source": [
|
| 714 |
-
"output = pn.WidgetBox('*Output will show up here:*', qa_interactive, width=630, scroll=True)"
|
| 715 |
-
]
|
| 716 |
-
},
|
| 717 |
-
{
|
| 718 |
-
"cell_type": "code",
|
| 719 |
-
"execution_count": 34,
|
| 720 |
-
"id": "eec3dc8e-c8d3-4e4c-b250-51331efab1e9",
|
| 721 |
-
"metadata": {},
|
| 722 |
-
"outputs": [
|
| 723 |
-
{
|
| 724 |
-
"data": {},
|
| 725 |
-
"metadata": {},
|
| 726 |
-
"output_type": "display_data"
|
| 727 |
-
},
|
| 728 |
-
{
|
| 729 |
-
"data": {
|
| 730 |
-
"application/vnd.holoviews_exec.v0+json": "",
|
| 731 |
-
"text/html": [
|
| 732 |
-
"<div id='1019'>\n",
|
| 733 |
-
" <div class=\"bk-root\" id=\"00520726-2e22-432c-8740-76645160b036\" data-root-id=\"1019\"></div>\n",
|
| 734 |
-
"</div>\n",
|
| 735 |
-
"<script type=\"application/javascript\">(function(root) {\n",
|
| 736 |
-
" function embed_document(root) {\n",
|
| 737 |
-
" var docs_json = {\"51db6d23-6bd8-4244-b3f0-feb4157753ad\":{\"defs\":[{\"extends\":null,\"module\":null,\"name\":\"ReactiveHTML1\",\"overrides\":[],\"properties\":[]},{\"extends\":null,\"module\":null,\"name\":\"FlexBox1\",\"overrides\":[],\"properties\":[{\"default\":\"flex-start\",\"kind\":null,\"name\":\"align_content\"},{\"default\":\"flex-start\",\"kind\":null,\"name\":\"align_items\"},{\"default\":\"row\",\"kind\":null,\"name\":\"flex_direction\"},{\"default\":\"wrap\",\"kind\":null,\"name\":\"flex_wrap\"},{\"default\":\"flex-start\",\"kind\":null,\"name\":\"justify_content\"}]},{\"extends\":null,\"module\":null,\"name\":\"GridStack1\",\"overrides\":[],\"properties\":[{\"default\":\"warn\",\"kind\":null,\"name\":\"mode\"},{\"default\":null,\"kind\":null,\"name\":\"ncols\"},{\"default\":null,\"kind\":null,\"name\":\"nrows\"},{\"default\":true,\"kind\":null,\"name\":\"allow_resize\"},{\"default\":true,\"kind\":null,\"name\":\"allow_drag\"},{\"default\":[],\"kind\":null,\"name\":\"state\"}]},{\"extends\":null,\"module\":null,\"name\":\"click1\",\"overrides\":[],\"properties\":[{\"default\":\"\",\"kind\":null,\"name\":\"terminal_output\"},{\"default\":\"\",\"kind\":null,\"name\":\"debug_name\"},{\"default\":0,\"kind\":null,\"name\":\"clears\"}]},{\"extends\":null,\"module\":null,\"name\":\"NotificationAreaBase1\",\"overrides\":[],\"properties\":[{\"default\":\"bottom-right\",\"kind\":null,\"name\":\"position\"},{\"default\":0,\"kind\":null,\"name\":\"_clear\"}]},{\"extends\":null,\"module\":null,\"name\":\"NotificationArea1\",\"overrides\":[],\"properties\":[{\"default\":[],\"kind\":null,\"name\":\"notifications\"},{\"default\":\"bottom-right\",\"kind\":null,\"name\":\"position\"},{\"default\":0,\"kind\":null,\"name\":\"_clear\"},{\"default\":[{\"background\":\"#ffc107\",\"icon\":{\"className\":\"fas fa-exclamation-triangle\",\"color\":\"white\",\"tagName\":\"i\"},\"type\":\"warning\"},{\"background\":\"#007bff\",\"icon\":{\"className\":\"fas fa-info-circle\",\"color\":\"white\",\"tagName\":\"i\"},\"type\":\"info\"}],\"kind\":null,\"name\":\"types\"}]},{\"extends\":null,\"module\":null,\"name\":\"Notification\",\"overrides\":[],\"properties\":[{\"default\":null,\"kind\":null,\"name\":\"background\"},{\"default\":3000,\"kind\":null,\"name\":\"duration\"},{\"default\":null,\"kind\":null,\"name\":\"icon\"},{\"default\":\"\",\"kind\":null,\"name\":\"message\"},{\"default\":null,\"kind\":null,\"name\":\"notification_type\"},{\"default\":false,\"kind\":null,\"name\":\"_destroyed\"}]},{\"extends\":null,\"module\":null,\"name\":\"TemplateActions1\",\"overrides\":[],\"properties\":[{\"default\":0,\"kind\":null,\"name\":\"open_modal\"},{\"default\":0,\"kind\":null,\"name\":\"close_modal\"}]},{\"extends\":null,\"module\":null,\"name\":\"MaterialTemplateActions1\",\"overrides\":[],\"properties\":[{\"default\":0,\"kind\":null,\"name\":\"open_modal\"},{\"default\":0,\"kind\":null,\"name\":\"close_modal\"}]}],\"roots\":{\"references\":[{\"attributes\":{\"children\":[{\"id\":\"1025\"},{\"id\":\"1026\"}],\"css_classes\":[\"panel-widget-box\",\"scrollable\"],\"margin\":[5,5,5,5],\"name\":\"WidgetBox00199\",\"sizing_mode\":\"stretch_width\",\"width\":630},\"id\":\"1024\",\"type\":\"Column\"},{\"attributes\":{\"args\":{\"bidirectional\":false,\"properties\":{\"event:button_click\":\"loading\"},\"source\":{\"id\":\"1038\"},\"target\":{\"id\":\"1026\"}},\"code\":\"\\n if ('event:button_click'.startsWith('event:')) {\\n var value = true\\n } else {\\n var value = source['event:button_click'];\\n value = value;\\n }\\n if (typeof value !== 'boolean' || source.labels !== ['Loading']) {\\n value = true\\n }\\n var css_classes = target.css_classes.slice()\\n var loading_css = ['pn-loading', 'arcs']\\n if (value) {\\n for (var css of loading_css) {\\n if (!(css in css_classes)) {\\n css_classes.push(css)\\n }\\n }\\n } else {\\n for (var css of loading_css) {\\n var index = css_classes.indexOf(css)\\n if (index > -1) {\\n css_classes.splice(index, 1)\\n }\\n }\\n }\\n target['css_classes'] = css_classes\\n \",\"tags\":[[140635381546624,[null,\"event:button_click\"],[null,\"loading\"]]]},\"id\":\"1039\",\"type\":\"CustomJS\"},{\"attributes\":{\"icon\":null,\"js_event_callbacks\":{\"button_click\":[{\"id\":\"1039\"}]},\"label\":\"Run!\",\"margin\":[5,10,5,10],\"sizing_mode\":\"stretch_width\",\"subscribed_events\":[\"button_click\"]},\"id\":\"1038\",\"type\":\"Button\"},{\"attributes\":{\"active_header_background\":\"\",\"button_css_classes\":[\"card-button\"],\"children\":[{\"id\":\"1030\"},{\"id\":\"1032\"},{\"id\":\"1033\"}],\"collapsed\":false,\"css_classes\":[\"card\"],\"header_background\":\"\",\"header_color\":\"\",\"header_css_classes\":[\"card-header\"],\"margin\":[10,10,10,10],\"name\":\"Card00184\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1029\",\"type\":\"panel.models.layout.Card\"},{\"attributes\":{\"margin\":[5,10,5,10],\"max_length\":5000,\"placeholder\":\"Enter your OpenAI API Key here...\",\"sizing_mode\":\"stretch_width\",\"width\":300},\"id\":\"1023\",\"type\":\"PasswordInput\"},{\"attributes\":{\"end\":5,\"margin\":[5,10,5,10],\"sizing_mode\":\"stretch_width\",\"start\":1,\"title\":\"Number of relevant chunks\",\"value\":2},\"id\":\"1035\",\"type\":\"Slider\"},{\"attributes\":{\"css_classes\":[\"card-title\"],\"margin\":[5,0,5,0],\"name\":\"HTML00185\",\"sizing_mode\":\"stretch_width\",\"text\":\"Advanced settings\"},\"id\":\"1031\",\"type\":\"panel.models.markup.HTML\"},{\"attributes\":{\"margin\":[15,15,15,15],\"min_height\":400,\"name\":\"Column00195\",\"sizing_mode\":\"stretch_width\",\"width\":575},\"id\":\"1027\",\"type\":\"Column\"},{\"attributes\":{\"children\":[{\"id\":\"1022\"},{\"id\":\"1023\"}],\"margin\":[0,0,0,0],\"name\":\"Row00202\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1021\",\"type\":\"Row\"},{\"attributes\":{\"children\":[{\"id\":\"1020\"},{\"id\":\"1021\"},{\"id\":\"1024\"},{\"id\":\"1028\"}],\"margin\":[0,0,0,0],\"name\":\"Column00203\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1019\",\"type\":\"Column\"},{\"attributes\":{\"margin\":[5,10,5,10],\"sizing_mode\":\"stretch_width\",\"width\":300},\"id\":\"1022\",\"type\":\"FileInput\"},{\"attributes\":{\"height\":160,\"margin\":[5,10,5,10],\"name\":\"\",\"placeholder\":\"Enter your questions here...\",\"sizing_mode\":\"stretch_width\",\"toolbar\":false},\"id\":\"1037\",\"type\":\"panel.models.quill.QuillInput\"},{\"attributes\":{\"css_classes\":[\"markdown\"],\"margin\":[5,5,5,5],\"name\":\"Markdown00197\",\"sizing_mode\":\"stretch_width\",\"text\":\"<p><em>Output will show up here:</em></p>\"},\"id\":\"1025\",\"type\":\"panel.models.markup.HTML\"},{\"attributes\":{\"children\":[{\"id\":\"1034\"},{\"id\":\"1035\"}],\"margin\":[0,0,0,0],\"name\":\"Column00180\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1033\",\"type\":\"Column\"},{\"attributes\":{\"children\":[{\"id\":\"1029\"},{\"id\":\"1036\"}],\"margin\":[0,0,0,0],\"name\":\"Row00188\",\"sizing_mode\":\"stretch_width\",\"width\":600},\"id\":\"1028\",\"type\":\"Row\"},{\"attributes\":{\"children\":[{\"id\":\"1027\"}],\"margin\":[0,0,0,0],\"name\":\"Row00193\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1026\",\"type\":\"Row\"},{\"attributes\":{\"children\":[{\"id\":\"1031\"}],\"css_classes\":[\"card-header-row\"],\"margin\":[0,0,0,0],\"name\":\"Row00181\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1030\",\"type\":\"Row\"},{\"attributes\":{\"active\":0,\"labels\":[\"stuff\",\"map_reduce\",\"refine\",\"map_rerank\"],\"margin\":[5,10,5,10],\"sizing_mode\":\"stretch_width\"},\"id\":\"1034\",\"type\":\"RadioButtonGroup\"},{\"attributes\":{\"client_comm_id\":\"9bd64eb24b244bf48b05c64b3d5e6b2d\",\"comm_id\":\"e85db2cad384443a89302795699f26c3\",\"plot_id\":\"1019\"},\"id\":\"1040\",\"type\":\"panel.models.comm_manager.CommManager\"},{\"attributes\":{\"css_classes\":[\"markdown\"],\"margin\":[5,5,5,5],\"name\":\"Markdown00200\",\"sizing_mode\":\"stretch_width\",\"text\":\"<h2>\\ud83d\\ude0a! Question Answering with your PDF file</h2>\\n<p>1) Upload a PDF. 2) Enter OpenAI API key. This costs $. Set up billing at <a href="https://platform.openai.com/account">OpenAI</a>. 3) Type a question and click &ldquo;Run&rdquo;.</p>\"},\"id\":\"1020\",\"type\":\"panel.models.markup.HTML\"},{\"attributes\":{\"children\":[{\"id\":\"1037\"},{\"id\":\"1038\"}],\"margin\":[5,5,5,5],\"name\":\"Column00187\",\"sizing_mode\":\"stretch_width\"},\"id\":\"1036\",\"type\":\"Column\"},{\"attributes\":{\"css_classes\":[\"markdown\"],\"margin\":[5,5,5,5],\"name\":\"Markdown00182\",\"sizing_mode\":\"stretch_width\",\"text\":\"<p>Chain type:</p>\"},\"id\":\"1032\",\"type\":\"panel.models.markup.HTML\"}],\"root_ids\":[\"1019\",\"1040\"]},\"title\":\"Bokeh Application\",\"version\":\"2.4.3\"}};\n",
|
| 738 |
-
" var render_items = [{\"docid\":\"51db6d23-6bd8-4244-b3f0-feb4157753ad\",\"root_ids\":[\"1019\"],\"roots\":{\"1019\":\"00520726-2e22-432c-8740-76645160b036\"}}];\n",
|
| 739 |
-
" root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n",
|
| 740 |
-
" }\n",
|
| 741 |
-
" if (root.Bokeh !== undefined && root.Bokeh.Panel !== undefined) {\n",
|
| 742 |
-
" embed_document(root);\n",
|
| 743 |
-
" } else {\n",
|
| 744 |
-
" var attempts = 0;\n",
|
| 745 |
-
" var timer = setInterval(function(root) {\n",
|
| 746 |
-
" if (root.Bokeh !== undefined && root.Bokeh.Panel !== undefined) {\n",
|
| 747 |
-
" clearInterval(timer);\n",
|
| 748 |
-
" embed_document(root);\n",
|
| 749 |
-
" } else if (document.readyState == \"complete\") {\n",
|
| 750 |
-
" attempts++;\n",
|
| 751 |
-
" if (attempts > 200) {\n",
|
| 752 |
-
" clearInterval(timer);\n",
|
| 753 |
-
" console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n",
|
| 754 |
-
" }\n",
|
| 755 |
-
" }\n",
|
| 756 |
-
" }, 25, root)\n",
|
| 757 |
-
" }\n",
|
| 758 |
-
"})(window);</script>"
|
| 759 |
-
],
|
| 760 |
-
"text/plain": [
|
| 761 |
-
"Column(sizing_mode='stretch_width')\n",
|
| 762 |
-
" [0] Markdown(str, sizing_mode='stretch_width')\n",
|
| 763 |
-
" [1] Row(sizing_mode='stretch_width')\n",
|
| 764 |
-
" [0] FileInput(sizing_mode='stretch_width', width=300)\n",
|
| 765 |
-
" [1] PasswordInput(placeholder='Enter your OpenAI A..., sizing_mode='stretch_width', width=300)\n",
|
| 766 |
-
" [2] WidgetBox(scroll=True, sizing_mode='stretch_width', width=630)\n",
|
| 767 |
-
" [0] Markdown(str, sizing_mode='stretch_width')\n",
|
| 768 |
-
" [1] ParamFunction(function, loading_indicator=True, sizing_mode='stretch_width')\n",
|
| 769 |
-
" [3] Row(sizing_mode='stretch_width', width=600)\n",
|
| 770 |
-
" [0] Card(margin=10, sizing_mode='stretch_width', title='Advanced settings')\n",
|
| 771 |
-
" [0] Markdown(str, sizing_mode='stretch_width')\n",
|
| 772 |
-
" [1] Column(sizing_mode='stretch_width')\n",
|
| 773 |
-
" [0] RadioButtonGroup(name='Chain type', options=['stuff', 'map_reduce', ...], sizing_mode='stretch_width', value='stuff')\n",
|
| 774 |
-
" [1] IntSlider(end=5, name='Number of relevant c..., sizing_mode='stretch_width', start=1, value=2)\n",
|
| 775 |
-
" [1] Column(margin=5, sizing_mode='stretch_width')\n",
|
| 776 |
-
" [0] TextEditor(height=160, placeholder='Enter your questions h..., sizing_mode='stretch_width', toolbar=False)\n",
|
| 777 |
-
" [1] Button(name='Run!', sizing_mode='stretch_width')"
|
| 778 |
-
]
|
| 779 |
-
},
|
| 780 |
-
"execution_count": 34,
|
| 781 |
-
"metadata": {
|
| 782 |
-
"application/vnd.holoviews_exec.v0+json": {
|
| 783 |
-
"id": "1019"
|
| 784 |
-
}
|
| 785 |
-
},
|
| 786 |
-
"output_type": "execute_result"
|
| 787 |
-
}
|
| 788 |
-
],
|
| 789 |
-
"source": [
|
| 790 |
-
"# layout\n",
|
| 791 |
-
"pn.Column(\n",
|
| 792 |
-
" pn.pane.Markdown(\"\"\"\n",
|
| 793 |
-
" ## \\U0001F60A! Question Answering with your PDF file\n",
|
| 794 |
-
" \n",
|
| 795 |
-
" 1) Upload a PDF. 2) Enter OpenAI API key. This costs $. Set up billing at [OpenAI](https://platform.openai.com/account). 3) Type a question and click \"Run\".\n",
|
| 796 |
-
" \n",
|
| 797 |
-
" \"\"\"),\n",
|
| 798 |
-
" pn.Row(file_input,openaikey),\n",
|
| 799 |
-
" output,\n",
|
| 800 |
-
" widgets\n",
|
| 801 |
-
"\n",
|
| 802 |
-
").servable()"
|
| 803 |
-
]
|
| 804 |
-
},
|
| 805 |
-
{
|
| 806 |
-
"cell_type": "code",
|
| 807 |
-
"execution_count": null,
|
| 808 |
-
"id": "c5ef3d1d-eca6-43d3-900d-823206858927",
|
| 809 |
-
"metadata": {},
|
| 810 |
-
"outputs": [],
|
| 811 |
-
"source": []
|
| 812 |
-
}
|
| 813 |
-
],
|
| 814 |
-
"metadata": {
|
| 815 |
-
"kernelspec": {
|
| 816 |
-
"display_name": "Python 3 (ipykernel)",
|
| 817 |
-
"language": "python",
|
| 818 |
-
"name": "python3"
|
| 819 |
-
},
|
| 820 |
-
"language_info": {
|
| 821 |
-
"codemirror_mode": {
|
| 822 |
-
"name": "ipython",
|
| 823 |
-
"version": 3
|
| 824 |
-
},
|
| 825 |
-
"file_extension": ".py",
|
| 826 |
-
"mimetype": "text/x-python",
|
| 827 |
-
"name": "python",
|
| 828 |
-
"nbconvert_exporter": "python",
|
| 829 |
-
"pygments_lexer": "ipython3",
|
| 830 |
-
"version": "3.9.13"
|
| 831 |
-
}
|
| 832 |
-
},
|
| 833 |
-
"nbformat": 4,
|
| 834 |
-
"nbformat_minor": 5
|
| 835 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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