Spaces:
Runtime error
Runtime error
File size: 24,055 Bytes
8c8727a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
{
"cells": [
{
"cell_type": "markdown",
"id": "9e833386",
"metadata": {},
"source": [
"# Test Notebook\n",
"\n",
"This tutorial notebook will go through the installation and application of the application."
]
},
{
"cell_type": "markdown",
"id": "aa7f6ac5",
"metadata": {},
"source": [
"## Package Installation\n",
"\n",
"These packages are needed for this application:\n",
"\n",
"+ streamlit\n",
"+ openai\n",
"\n",
"The following code will help to install them locally."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5b2f63cb",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: openai in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (0.15.0)\n",
"Requirement already satisfied: openpyxl>=3.0.7 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from openai) (3.0.9)\n",
"Requirement already satisfied: tqdm in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from openai) (4.63.0)\n",
"Requirement already satisfied: pandas>=1.2.3 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from openai) (1.4.1)\n",
"Requirement already satisfied: requests>=2.20 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from openai) (2.27.1)\n",
"Requirement already satisfied: pandas-stubs>=1.1.0.11 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from openai) (1.2.0.50)\n",
"Requirement already satisfied: et-xmlfile in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from openpyxl>=3.0.7->openai) (1.1.0)\n",
"Requirement already satisfied: python-dateutil>=2.8.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pandas>=1.2.3->openai) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pandas>=1.2.3->openai) (2021.3)\n",
"Requirement already satisfied: numpy>=1.18.5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pandas>=1.2.3->openai) (1.21.5)\n",
"Requirement already satisfied: six>=1.5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from python-dateutil>=2.8.1->pandas>=1.2.3->openai) (1.16.0)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests>=2.20->openai) (2.0.4)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests>=2.20->openai) (1.26.8)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests>=2.20->openai) (2021.10.8)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests>=2.20->openai) (3.3)\n",
"Requirement already satisfied: streamlit in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (1.7.0)\n",
"Requirement already satisfied: importlib-metadata>=1.4 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (4.11.3)\n",
"Requirement already satisfied: gitpython!=3.1.19 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (3.1.27)\n",
"Requirement already satisfied: click>=7.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (8.0.4)\n",
"Requirement already satisfied: astor in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (0.8.1)\n",
"Requirement already satisfied: semver in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (2.13.0)\n",
"Requirement already satisfied: pympler>=0.9 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (1.0.1)\n",
"Requirement already satisfied: pyarrow in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (7.0.0)\n",
"Requirement already satisfied: numpy in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (1.21.5)\n",
"Requirement already satisfied: pillow>=6.2.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (9.0.1)\n",
"Requirement already satisfied: validators in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (0.18.2)\n",
"Requirement already satisfied: toml in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (0.10.2)\n",
"Requirement already satisfied: pandas>=0.21.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (1.4.1)\n",
"Requirement already satisfied: tornado>=5.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (6.1)\n",
"Requirement already satisfied: blinker in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (1.4)\n",
"Requirement already satisfied: cachetools>=4.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (5.0.0)\n",
"Requirement already satisfied: packaging in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (21.3)\n",
"Requirement already satisfied: requests in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (2.27.1)\n",
"Requirement already satisfied: python-dateutil in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (2.8.2)\n",
"Requirement already satisfied: protobuf!=3.11,>=3.6.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (3.19.4)\n",
"Requirement already satisfied: tzlocal in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (4.1)\n",
"Requirement already satisfied: pydeck>=0.1.dev5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (0.7.1)\n",
"Requirement already satisfied: altair>=3.2.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (4.2.0)\n",
"Requirement already satisfied: attrs in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (21.4.0)\n",
"Requirement already satisfied: base58 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from streamlit) (2.1.1)\n",
"Requirement already satisfied: entrypoints in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from altair>=3.2.0->streamlit) (0.3)\n",
"Requirement already satisfied: toolz in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from altair>=3.2.0->streamlit) (0.11.2)\n",
"Requirement already satisfied: jsonschema>=3.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from altair>=3.2.0->streamlit) (3.2.0)\n",
"Requirement already satisfied: jinja2 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from altair>=3.2.0->streamlit) (2.11.3)\n",
"Requirement already satisfied: gitdb<5,>=4.0.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from gitpython!=3.1.19->streamlit) (4.0.9)\n",
"Requirement already satisfied: smmap<6,>=3.0.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from gitdb<5,>=4.0.1->gitpython!=3.1.19->streamlit) (5.0.0)\n",
"Requirement already satisfied: zipp>=0.5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from importlib-metadata>=1.4->streamlit) (3.7.0)\n",
"Requirement already satisfied: six>=1.11.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jsonschema>=3.0->altair>=3.2.0->streamlit) (1.16.0)\n",
"Requirement already satisfied: setuptools in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jsonschema>=3.0->altair>=3.2.0->streamlit) (61.2.0)\n",
"Requirement already satisfied: pyrsistent>=0.14.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jsonschema>=3.0->altair>=3.2.0->streamlit) (0.18.0)\n",
"Requirement already satisfied: pytz>=2020.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pandas>=0.21.0->streamlit) (2021.3)\n",
"Requirement already satisfied: ipykernel>=5.1.2 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pydeck>=0.1.dev5->streamlit) (6.9.1)\n",
"Requirement already satisfied: ipywidgets>=7.0.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pydeck>=0.1.dev5->streamlit) (7.6.5)\n",
"Requirement already satisfied: traitlets>=4.3.2 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pydeck>=0.1.dev5->streamlit) (5.1.1)\n",
"Requirement already satisfied: ipython>=7.23.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (8.2.0)\n",
"Requirement already satisfied: appnope in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.1.2)\n",
"Requirement already satisfied: jupyter-client<8.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (6.1.12)\n",
"Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.1.2)\n",
"Requirement already satisfied: nest-asyncio in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (1.5.1)\n",
"Requirement already satisfied: debugpy<2.0,>=1.0.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (1.5.1)\n",
"Requirement already satisfied: backcall in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.2.0)\n",
"Requirement already satisfied: pygments>=2.4.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (2.11.2)\n",
"Requirement already satisfied: pexpect>4.3 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (4.8.0)\n",
"Requirement already satisfied: pickleshare in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.7.5)\n",
"Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (3.0.20)\n",
"Requirement already satisfied: stack-data in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.2.0)\n",
"Requirement already satisfied: decorator in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (5.1.1)\n",
"Requirement already satisfied: jedi>=0.16 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.18.1)\n",
"Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.0.0)\n",
"Requirement already satisfied: nbformat>=4.2.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (5.1.3)\n",
"Requirement already satisfied: widgetsnbextension~=3.5.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (3.5.2)\n",
"Requirement already satisfied: ipython-genutils~=0.2.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.2.0)\n",
"Requirement already satisfied: parso<0.9.0,>=0.8.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.8.3)\n",
"Requirement already satisfied: MarkupSafe>=0.23 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jinja2->altair>=3.2.0->streamlit) (2.0.1)\n",
"Requirement already satisfied: pyzmq>=13 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (22.3.0)\n",
"Requirement already satisfied: jupyter-core>=4.6.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from jupyter-client<8.0->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (4.9.2)\n",
"Requirement already satisfied: ptyprocess>=0.5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pexpect>4.3->ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.7.0)\n",
"Requirement already satisfied: wcwidth in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.2.5)\n",
"Requirement already satisfied: notebook>=4.4.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (6.4.8)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: argon2-cffi in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (21.3.0)\n",
"Requirement already satisfied: terminado>=0.8.3 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.13.1)\n",
"Requirement already satisfied: prometheus-client in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.13.1)\n",
"Requirement already satisfied: nbconvert in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (6.4.4)\n",
"Requirement already satisfied: Send2Trash>=1.8.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.8.0)\n",
"Requirement already satisfied: argon2-cffi-bindings in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (21.2.0)\n",
"Requirement already satisfied: cffi>=1.0.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from argon2-cffi-bindings->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.15.0)\n",
"Requirement already satisfied: pycparser in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (2.21)\n",
"Requirement already satisfied: defusedxml in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.7.1)\n",
"Requirement already satisfied: bleach in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (4.1.0)\n",
"Requirement already satisfied: testpath in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.5.0)\n",
"Requirement already satisfied: beautifulsoup4 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (4.10.0)\n",
"Requirement already satisfied: pandocfilters>=1.4.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (1.5.0)\n",
"Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.5.11)\n",
"Requirement already satisfied: mistune<2,>=0.8.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.8.4)\n",
"Requirement already satisfied: jupyterlab-pygments in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.1.2)\n",
"Requirement already satisfied: soupsieve>1.2 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from beautifulsoup4->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (2.3.1)\n",
"Requirement already satisfied: webencodings in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from bleach->nbconvert->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7.0.0->pydeck>=0.1.dev5->streamlit) (0.5.1)\n",
"Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from packaging->streamlit) (3.0.4)\n",
"Requirement already satisfied: idna<4,>=2.5 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests->streamlit) (3.3)\n",
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests->streamlit) (1.26.8)\n",
"Requirement already satisfied: charset-normalizer~=2.0.0 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests->streamlit) (2.0.4)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from requests->streamlit) (2021.10.8)\n",
"Requirement already satisfied: asttokens in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from stack-data->ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (2.0.5)\n",
"Requirement already satisfied: executing in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from stack-data->ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.8.3)\n",
"Requirement already satisfied: pure-eval in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from stack-data->ipython>=7.23.1->ipykernel>=5.1.2->pydeck>=0.1.dev5->streamlit) (0.2.2)\n",
"Requirement already satisfied: pytz-deprecation-shim in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from tzlocal->streamlit) (0.1.0.post0)\n",
"Requirement already satisfied: tzdata in /Users/hayashishio/opt/anaconda3/lib/python3.9/site-packages (from pytz-deprecation-shim->tzlocal->streamlit) (2021.5)\n"
]
},
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# install packages\n",
"import os\n",
"os.system('pip install openai')\n",
"os.system('pip install streamlit')"
]
},
{
"cell_type": "markdown",
"id": "ad09d81e",
"metadata": {},
"source": [
"## Run Application\n",
"\n",
"The following code will run the frontend page. Use the stop button in Jupyter Notebook to stop the app."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "abb44562",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-04-18 11:56:08.317 INFO numexpr.utils: NumExpr defaulting to 8 threads.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" You can now view your Streamlit app in your browser.\n",
"\n",
" Local URL: http://localhost:8501\n",
" Network URL: http://10.76.153.53:8501\n",
"\n",
" Stopping...\n"
]
},
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# run\n",
"os.system('streamlit run frontend.py')"
]
},
{
"cell_type": "markdown",
"id": "cbad015b",
"metadata": {},
"source": [
"## Backend Tutorial\n",
"\n",
"This is a tutorial to go throught the backend."
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "360508e4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"API key:路路路路路路路路\n",
"\n",
"\n",
"Hi John Doe,\n",
"\n",
"I am writing to request a referral for an internship. I am a hard-working and motivated individual who is looking for an opportunity to learn and grow in the field of _____. I would be grateful if you could provide me with a referral to _____. Thank you for your time and consideration.\n",
"\n",
"Sincerely,\n",
"\n",
"Your Name\n"
]
}
],
"source": [
"## run source code\n",
"import getpass\n",
"import openai\n",
"\n",
"## get api_key\n",
"openai.api_key = getpass.getpass(\"API key:\")\n",
"\n",
"## source code in backend\n",
"def email(\n",
" start:str = \"Hi, John Doe\",\n",
" len:int = 250,\n",
" draft:str = \"recruiter, give me an referral for internship.\",\n",
" topic:str = 'Request for referral',\n",
" random_state:float = 0.9\n",
" ) -> str:\n",
" \n",
" return openai.Completion.create(\n",
" engine='text-davinci-002',\n",
" prompt=\"Write me a professional style email start with '\" + start + \"' about '\" + topic + \"' and the email should be based on this draft: \\\"\" + draft + \"\\\"\\n\",\n",
" temperature = random_state,\n",
" max_tokens= len,\n",
" top_p=1,\n",
" frequency_penalty=1,\n",
" presence_penalty=1,\n",
" best_of=2\n",
" ).get(\"choices\")[0]['text'].strip()\n",
"\n",
"## print the result\n",
"print('\\n')\n",
"print(email())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "187d2dd4",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|