diff --git a/notebooks/getting-started.ipynb b/notebooks/getting-started.ipynb index f36ded6..c36b1ac 100644 --- a/notebooks/getting-started.ipynb +++ b/notebooks/getting-started.ipynb @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "42d67f40-462b-43ba-a63f-fdd9e126a423", "metadata": {}, "outputs": [], @@ -78,42 +78,30 @@ "id": "b93d0cb3-9844-4b3d-8778-360ec07b20ac", "metadata": {}, "source": [ - "# 3. Recreate example from Readme\n", - "\n", - "https://github.com/jupyterlab/jupyter-ai shows this example: https://github.com/jupyterlab/jupyter-ai/blob/main/docs/source/_static/sample-html-math.png" + "# 3. Test the models" ] }, { "cell_type": "code", - "execution_count": 7, - "id": "9ae14480-b195-4686-9c80-70654bccfd24", + "execution_count": 8, + "id": "af16e864-8beb-4ea2-93d0-c74b6b595f85", "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/me/jaanli/language-model-notebooks/.venv/lib/python3.12/site-packages/langchain_anthropic/llms.py:164: UserWarning: This Anthropic LLM is deprecated. Please use `from langchain_anthropic import ChatAnthropic` instead\n", - " warnings.warn(\n" - ] - }, { "data": { "text/html": [ - " \n", - " \n", - "" + "AI generated code inserted below ⬇️" ], "text/plain": [ "" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": { "text/html": { "jupyter_ai": { - "model_id": "claude-v1.2", - "provider_id": "anthropic" + "model_id": "claude-3-opus-20240229", + "provider_id": "anthropic-chat" } } }, @@ -121,8 +109,118 @@ } ], "source": [ - "%%ai anthropic:claude-v1.2 -f html\n", - "Create a square using SVG with a black border and white fill." + "%%ai anthropic-chat:claude-3-opus-20240229 --format code \n", + "Create and visualize an interactive plot of the world's population using python and the altair library." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "a5320525-d508-4de0-abce-e4c776db0d54", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + "
\n", + "" + ], + "text/plain": [ + "alt.Chart(...)" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import altair as alt\n", + "from vega_datasets import data\n", + "\n", + "# Load the population data\n", + "pop_data = data.population.url\n", + "\n", + "# Create the interactive plot\n", + "plot = alt.Chart(pop_data).mark_line().encode(\n", + " x='year:O',\n", + " y='sum(people):Q',\n", + " color='age:N',\n", + " tooltip=['year:O', 'sum(people):Q', 'age:N']\n", + ").properties(\n", + " width=600,\n", + " height=400,\n", + " title='World Population by Age Group'\n", + ").transform_filter(\n", + " alt.datum.year >= 1850\n", + ").interactive()\n", + "\n", + "# Display the plot\n", + "plot" ] } ], diff --git a/requirements.in b/requirements.in index c552650..f55d1fc 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,10 @@ jupyter-ai jupyterlab python-dotenv -langchain-anthropic \ No newline at end of file +langchain-anthropic +pandas +ipywidgets +numpy +matplotlib +altair +vega_datasets \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3ad52fd..fc56414 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile @@ -12,6 +12,8 @@ aiosignal==1.3.1 # via aiohttp aiosqlite==0.20.0 # via jupyter-ai +altair==5.3.0 + # via -r requirements.in annotated-types==0.6.0 # via pydantic anthropic==0.25.6 @@ -63,7 +65,13 @@ cloudpickle==3.0.0 # dask # distributed comm==0.2.2 - # via ipykernel + # via + # ipykernel + # ipywidgets +contourpy==1.2.1 + # via matplotlib +cycler==0.12.1 + # via matplotlib dask[distributed]==2024.4.2 # via # distributed @@ -94,6 +102,8 @@ fastjsonschema==2.19.1 # via nbformat filelock==3.13.4 # via huggingface-hub +fonttools==4.51.0 + # via matplotlib fqdn==1.5.1 # via jsonschema frozenlist==1.4.1 @@ -123,7 +133,6 @@ idna==3.7 # yarl importlib-metadata==7.1.0 # via - # dask # jupyter-ai # jupyter-ai-magics ipykernel==6.29.4 @@ -131,13 +140,17 @@ ipykernel==6.29.4 ipython==8.23.0 # via # ipykernel + # ipywidgets # jupyter-ai-magics +ipywidgets==8.1.2 + # via -r requirements.in isoduration==20.11.0 # via jsonschema jedi==0.19.1 # via ipython jinja2==3.1.3 # via + # altair # distributed # jupyter-server # jupyterlab @@ -157,6 +170,7 @@ jsonpointer==2.4 # jsonschema jsonschema[format-nongpl]==4.21.1 # via + # altair # jupyter-events # jupyterlab-server # nbformat @@ -201,6 +215,10 @@ jupyterlab-pygments==0.3.0 # via nbconvert jupyterlab-server==2.27.1 # via jupyterlab +jupyterlab-widgets==3.0.10 + # via ipywidgets +kiwisolver==1.4.5 + # via matplotlib langchain==0.1.16 # via jupyter-ai-magics langchain-anthropic==0.1.11 @@ -230,6 +248,8 @@ markupsafe==2.1.5 # nbconvert marshmallow==3.21.1 # via dataclasses-json +matplotlib==3.8.4 + # via -r requirements.in matplotlib-inline==0.1.7 # via # ipykernel @@ -259,15 +279,21 @@ notebook-shim==0.2.4 # via jupyterlab numpy==1.26.4 # via + # -r requirements.in + # altair + # contourpy # faiss-cpu # langchain # langchain-community + # matplotlib + # pandas orjson==3.10.1 # via langsmith overrides==7.7.0 # via jupyter-server packaging==23.2 # via + # altair # dask # distributed # huggingface-hub @@ -277,7 +303,13 @@ packaging==23.2 # jupyterlab-server # langchain-core # marshmallow + # matplotlib # nbconvert +pandas==2.2.2 + # via + # -r requirements.in + # altair + # vega-datasets pandocfilters==1.5.1 # via nbconvert parso==0.8.4 @@ -286,6 +318,8 @@ partd==1.4.1 # via dask pexpect==4.9.0 # via ipython +pillow==10.3.0 + # via matplotlib platformdirs==4.2.1 # via jupyter-core ply==3.11 @@ -318,14 +352,20 @@ pygments==2.17.2 # via # ipython # nbconvert +pyparsing==3.1.2 + # via matplotlib python-dateutil==2.9.0.post0 # via # arrow # jupyter-client + # matplotlib + # pandas python-dotenv==1.0.1 # via -r requirements.in python-json-logger==2.0.7 # via jupyter-events +pytz==2024.1 + # via pandas pyyaml==6.0.1 # via # dask @@ -404,6 +444,7 @@ tokenizers==0.19.1 # via anthropic toolz==0.12.1 # via + # altair # dask # distributed # partd @@ -422,6 +463,7 @@ traitlets==5.14.3 # comm # ipykernel # ipython + # ipywidgets # jupyter-ai # jupyter-client # jupyter-core @@ -439,7 +481,6 @@ typing-extensions==4.11.0 # aiosqlite # anthropic # huggingface-hub - # ipython # jupyter-ai # jupyter-ai-magics # pydantic @@ -448,12 +489,16 @@ typing-extensions==4.11.0 # typing-inspect typing-inspect==0.9.0 # via dataclasses-json +tzdata==2024.1 + # via pandas uri-template==1.3.0 # via jsonschema urllib3==2.2.1 # via # distributed # requests +vega-datasets==0.9.0 + # via -r requirements.in wcwidth==0.2.13 # via prompt-toolkit webcolors==1.13 @@ -464,6 +509,8 @@ webencodings==0.5.1 # tinycss2 websocket-client==1.8.0 # via jupyter-server +widgetsnbextension==4.0.10 + # via ipywidgets yarl==1.9.4 # via aiohttp zict==3.0.0