diff --git a/.gitignore b/.gitignore index 4e7361d..c05c12f 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,5 @@ Untitled*.ipynb lcov.info ops.ipynb + +.jupyter_ystore.db diff --git a/chatlab/builtins/__init__.py b/chatlab/builtins/__init__.py index 5d4a2da..40bd6d9 100644 --- a/chatlab/builtins/__init__.py +++ b/chatlab/builtins/__init__.py @@ -2,9 +2,11 @@ from deprecation import deprecated -from .files import chat_functions as file_functions -from .python import get_python_docs, run_python -from .shell import chat_functions as shell_functions +from ..tools import run_python, get_python_docs, file_functions, shell_functions + +# TODO: Deprecate extra namespace +# compose all the file, shell, and python functions into one list for ease of use +os_functions = file_functions + shell_functions + [run_python, get_python_docs] # To prevent naming confusion, the builtin that isn't really running a cell # is deprecated. @@ -14,8 +16,6 @@ details="run_cell is deprecated. Use run_python instead for same-session execution.", )(run_python) -# compose all the file, shell, and python functions into one list for ease of use -os_functions = file_functions + shell_functions + [run_python, get_python_docs] __all__ = [ "run_python", diff --git a/chatlab/tools/__init__.py b/chatlab/tools/__init__.py new file mode 100644 index 0000000..c884756 --- /dev/null +++ b/chatlab/tools/__init__.py @@ -0,0 +1,11 @@ +from .files import chat_functions as file_functions +from .python import get_python_docs, run_python +from .shell import chat_functions as shell_functions + +__all__ = [ + "file_functions", + "get_python_docs", + "run_python", + "shell_functions", +] + diff --git a/chatlab/builtins/_mediatypes.py b/chatlab/tools/_mediatypes.py similarity index 100% rename from chatlab/builtins/_mediatypes.py rename to chatlab/tools/_mediatypes.py diff --git a/chatlab/builtins/colors.py b/chatlab/tools/colors.py similarity index 100% rename from chatlab/builtins/colors.py rename to chatlab/tools/colors.py diff --git a/chatlab/builtins/files.py b/chatlab/tools/files.py similarity index 100% rename from chatlab/builtins/files.py rename to chatlab/tools/files.py diff --git a/chatlab/builtins/python.py b/chatlab/tools/python.py similarity index 100% rename from chatlab/builtins/python.py rename to chatlab/tools/python.py diff --git a/chatlab/builtins/shell.py b/chatlab/tools/shell.py similarity index 100% rename from chatlab/builtins/shell.py rename to chatlab/tools/shell.py diff --git a/notebooks/basics.ipynb b/notebooks/basics.ipynb index ab662c5..a334434 100644 --- a/notebooks/basics.ipynb +++ b/notebooks/basics.ipynb @@ -639,7 +639,7 @@ ], "metadata": { "kernelspec": { - "display_name": "chatlab-0EWIBOuo-py3.11", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, diff --git a/notebooks/color-picker.ipynb b/notebooks/color-picker.ipynb index 83889ee..7c57a71 100644 --- a/notebooks/color-picker.ipynb +++ b/notebooks/color-picker.ipynb @@ -4,10 +4,19 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/kylekelley/.pyenv/versions/3.11.7/lib/python3.11/site-packages/pydantic/main.py:1455: RuntimeWarning: fields may not start with an underscore, ignoring \"__required__\"\n", + " warnings.warn(f'fields may not start with an underscore, ignoring \"{f_name}\"', RuntimeWarning)\n" + ] + } + ], "source": [ "from chatlab import Chat, models, system\n", - "from chatlab.builtins.colors import show_colors\n", + "from chatlab.tools.colors import show_colors\n", "\n", "chat = Chat(\n", " system(\"Format responses in markdown,. You are a skilled designer.\"),\n", @@ -68,7 +77,7 @@ ] }, "metadata": { - "role": "assistant" + "role": "assistant" }, "output_type": "display_data" } @@ -146,7 +155,7 @@ ], "metadata": { "kernelspec": { - "display_name": "chatlab-3kMKfU-i-py3.11", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, diff --git a/notebooks/streaming-updates.ipynb b/notebooks/streaming-updates.ipynb index 8ec730e..a53a458 100644 --- a/notebooks/streaming-updates.ipynb +++ b/notebooks/streaming-updates.ipynb @@ -2,9 +2,17 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/kylekelley/Library/Caches/pypoetry/virtualenvs/chatlab-0EWIBOuo-py3.11/lib/python3.11/site-packages/pydantic/main.py:1455: RuntimeWarning: fields may not start with an underscore, ignoring \"__required__\"\n", + " warnings.warn(f'fields may not start with an underscore, ignoring \"{f_name}\"', RuntimeWarning)\n" + ] + }, { "data": { "application/vdom.v1+json": { @@ -76,7 +84,7 @@ } }, "children": [ - "25" + "19" ], "tagName": "span" } @@ -104,7 +112,7 @@ } }, "children": [ - "Sole Survivor" + "Protagonist" ], "tagName": "span" } @@ -132,7 +140,7 @@ } }, "children": [ - "Vault-Tec Corporation" + "Vault 13" ], "tagName": "span" } @@ -162,7 +170,7 @@ } }, "children": [ - "Lone Wanderer" + "Dogmeat" ], "tagName": "h1" }, @@ -187,7 +195,7 @@ } }, "children": [ - "21" + "5" ], "tagName": "span" } @@ -215,7 +223,7 @@ } }, "children": [ - "Wasteland Wanderer" + "Companion" ], "tagName": "span" } @@ -243,7 +251,7 @@ } }, "children": [ - "Brotherhood of Steel" + "Lone Wanderer" ], "tagName": "span" } @@ -273,7 +281,7 @@ } }, "children": [ - "Courier" + "Preston Garvey" ], "tagName": "h1" }, @@ -298,7 +306,7 @@ } }, "children": [ - "30" + "26" ], "tagName": "span" } @@ -326,7 +334,7 @@ } }, "children": [ - "Delivery Person" + "Companion" ], "tagName": "span" } @@ -354,7 +362,7 @@ } }, "children": [ - "New California Republic" + "Minutemen" ], "tagName": "span" } @@ -384,7 +392,7 @@ } }, "children": [ - "Sole Survivor" + "Nick Valentine" ], "tagName": "h1" }, @@ -409,7 +417,7 @@ } }, "children": [ - "35" + "100" ], "tagName": "span" } @@ -437,7 +445,7 @@ } }, "children": [ - "Survivor" + "Companion" ], "tagName": "span" } @@ -465,7 +473,7 @@ } }, "children": [ - "Minutemen" + "Detective Agency" ], "tagName": "span" } @@ -495,7 +503,7 @@ } }, "children": [ - "Chosen One" + "Piper Wright" ], "tagName": "h1" }, @@ -520,7 +528,7 @@ } }, "children": [ - "28" + "23" ], "tagName": "span" } @@ -548,7 +556,7 @@ } }, "children": [ - "Savior of Arroyo" + "Companion" ], "tagName": "span" } @@ -576,7 +584,7 @@ } }, "children": [ - "Arroyo Tribe" + "Publick Occurrences" ], "tagName": "span" } @@ -606,7 +614,7 @@ } }, "children": [ - "Sole Survivor" + "Cait" ], "tagName": "h1" }, @@ -631,7 +639,7 @@ } }, "children": [ - "40" + "26" ], "tagName": "span" } @@ -659,7 +667,7 @@ } }, "children": [ - "Parent searching for their child" + "Companion" ], "tagName": "span" } @@ -687,7 +695,7 @@ } }, "children": [ - "Railroad" + "Combat Zone" ], "tagName": "span" } @@ -717,7 +725,7 @@ } }, "children": [ - "Sole Survivor" + "Codsworth" ], "tagName": "h1" }, @@ -742,7 +750,7 @@ } }, "children": [ - "32" + "200" ], "tagName": "span" } @@ -770,7 +778,7 @@ } }, "children": [ - "Mercenary" + "Companion" ], "tagName": "span" } @@ -798,7 +806,7 @@ } }, "children": [ - "The Institute" + "Sole Survivor" ], "tagName": "span" } @@ -828,7 +836,7 @@ } }, "children": [ - "Sole Survivor" + "Deacon" ], "tagName": "h1" }, @@ -853,7 +861,7 @@ } }, "children": [ - "27" + "35" ], "tagName": "span" } @@ -881,7 +889,7 @@ } }, "children": [ - "Explorer" + "Companion" ], "tagName": "span" } @@ -909,7 +917,7 @@ } }, "children": [ - "The Railroad" + "Railroad" ], "tagName": "span" } @@ -939,7 +947,7 @@ } }, "children": [ - "Sole Survivor" + "John Hancock" ], "tagName": "h1" }, @@ -964,7 +972,7 @@ } }, "children": [ - "33" + "250" ], "tagName": "span" } @@ -992,7 +1000,7 @@ } }, "children": [ - "Settler" + "Companion" ], "tagName": "span" } @@ -1020,7 +1028,7 @@ } }, "children": [ - "Commonwealth Minutemen" + "Goodneighbor" ], "tagName": "span" } @@ -1050,7 +1058,7 @@ } }, "children": [ - "Sole Survivor" + "Robert MacCready" ], "tagName": "h1" }, @@ -1075,7 +1083,7 @@ } }, "children": [ - "29" + "22" ], "tagName": "span" } @@ -1103,7 +1111,7 @@ } }, "children": [ - "Scavenger" + "Companion" ], "tagName": "span" } @@ -1131,7 +1139,7 @@ } }, "children": [ - "The Enclave" + "Gunners" ], "tagName": "span" } @@ -1161,7 +1169,7 @@ } }, "children": [ - "Sole Survivor" + "Paladin Danse" ], "tagName": "h1" }, @@ -1186,7 +1194,7 @@ } }, "children": [ - "31" + "35" ], "tagName": "span" } @@ -1214,7 +1222,7 @@ } }, "children": [ - "Trader" + "Companion" ], "tagName": "span" } @@ -1242,7 +1250,7 @@ } }, "children": [ - "The Pitt Raiders" + "Brotherhood of Steel" ], "tagName": "span" } @@ -1272,7 +1280,7 @@ } }, "children": [ - "Sole Survivor" + "Strong" ], "tagName": "h1" }, @@ -1297,7 +1305,7 @@ } }, "children": [ - "26" + "10" ], "tagName": "span" } @@ -1325,7 +1333,7 @@ } }, "children": [ - "Gunslinger" + "Companion" ], "tagName": "span" } @@ -1353,7 +1361,7 @@ } }, "children": [ - "The Kings" + "Super Mutants" ], "tagName": "span" } @@ -1370,10 +1378,10 @@ "tagName": "div" }, "text/html": [ - "

Fallout Characters

Vault Dweller

Age: 25

Role: Sole Survivor

Affiliation: Vault-Tec Corporation

Lone Wanderer

Age: 21

Role: Wasteland Wanderer

Affiliation: Brotherhood of Steel

Courier

Age: 30

Role: Delivery Person

Affiliation: New California Republic

Sole Survivor

Age: 35

Role: Survivor

Affiliation: Minutemen

Chosen One

Age: 28

Role: Savior of Arroyo

Affiliation: Arroyo Tribe

Sole Survivor

Age: 40

Role: Parent searching for their child

Affiliation: Railroad

Sole Survivor

Age: 32

Role: Mercenary

Affiliation: The Institute

Sole Survivor

Age: 27

Role: Explorer

Affiliation: The Railroad

Sole Survivor

Age: 33

Role: Settler

Affiliation: Commonwealth Minutemen

Sole Survivor

Age: 29

Role: Scavenger

Affiliation: The Enclave

Sole Survivor

Age: 31

Role: Trader

Affiliation: The Pitt Raiders

Sole Survivor

Age: 26

Role: Gunslinger

Affiliation: The Kings

" + "

Fallout Characters

Vault Dweller

Age: 19

Role: Protagonist

Affiliation: Vault 13

Dogmeat

Age: 5

Role: Companion

Affiliation: Lone Wanderer

Preston Garvey

Age: 26

Role: Companion

Affiliation: Minutemen

Nick Valentine

Age: 100

Role: Companion

Affiliation: Detective Agency

Piper Wright

Age: 23

Role: Companion

Affiliation: Publick Occurrences

Cait

Age: 26

Role: Companion

Affiliation: Combat Zone

Codsworth

Age: 200

Role: Companion

Affiliation: Sole Survivor

Deacon

Age: 35

Role: Companion

Affiliation: Railroad

John Hancock

Age: 250

Role: Companion

Affiliation: Goodneighbor

Robert MacCready

Age: 22

Role: Companion

Affiliation: Gunners

Paladin Danse

Age: 35

Role: Companion

Affiliation: Brotherhood of Steel

Strong

Age: 10

Role: Companion

Affiliation: Super Mutants

" ], "text/plain": [ - "

Fallout Characters

Vault Dweller

Age: 25

Role: Sole Survivor

Affiliation: Vault-Tec Corporation

Lone Wanderer

Age: 21

Role: Wasteland Wanderer

Affiliation: Brotherhood of Steel

Courier

Age: 30

Role: Delivery Person

Affiliation: New California Republic

Sole Survivor

Age: 35

Role: Survivor

Affiliation: Minutemen

Chosen One

Age: 28

Role: Savior of Arroyo

Affiliation: Arroyo Tribe

Sole Survivor

Age: 40

Role: Parent searching for their child

Affiliation: Railroad

Sole Survivor

Age: 32

Role: Mercenary

Affiliation: The Institute

Sole Survivor

Age: 27

Role: Explorer

Affiliation: The Railroad

Sole Survivor

Age: 33

Role: Settler

Affiliation: Commonwealth Minutemen

Sole Survivor

Age: 29

Role: Scavenger

Affiliation: The Enclave

Sole Survivor

Age: 31

Role: Trader

Affiliation: The Pitt Raiders

Sole Survivor

Age: 26

Role: Gunslinger

Affiliation: The Kings

" + "

Fallout Characters

Vault Dweller

Age: 19

Role: Protagonist

Affiliation: Vault 13

Dogmeat

Age: 5

Role: Companion

Affiliation: Lone Wanderer

Preston Garvey

Age: 26

Role: Companion

Affiliation: Minutemen

Nick Valentine

Age: 100

Role: Companion

Affiliation: Detective Agency

Piper Wright

Age: 23

Role: Companion

Affiliation: Publick Occurrences

Cait

Age: 26

Role: Companion

Affiliation: Combat Zone

Codsworth

Age: 200

Role: Companion

Affiliation: Sole Survivor

Deacon

Age: 35

Role: Companion

Affiliation: Railroad

John Hancock

Age: 250

Role: Companion

Affiliation: Goodneighbor

Robert MacCready

Age: 22

Role: Companion

Affiliation: Gunners

Paladin Danse

Age: 35

Role: Companion

Affiliation: Brotherhood of Steel

Strong

Age: 10

Role: Companion

Affiliation: Super Mutants

" ] }, "metadata": {}, @@ -1382,10 +1390,23 @@ { "data": { "text/markdown": [ - "I have created 12 characters from the Fallout Universe. You can see the details in the table above." + "I have created 12 characters from the Fallout Universe. Here they are:\n", + "\n", + "1. **Vault Dweller**: A 19-year-old protagonist affiliated with Vault 13.\n", + "2. **Dogmeat**: A 5-year-old companion of the Lone Wanderer.\n", + "3. **Preston Garvey**: A 26-year-old companion affiliated with the Minutemen.\n", + "4. **Nick Valentine**: A 100-year-old companion affiliated with the Detective Agency.\n", + "5. **Piper Wright**: A 23-year-old companion affiliated with Publick Occurrences.\n", + "6. **Cait**: A 26-year-old companion affiliated with the Combat Zone.\n", + "7. **Codsworth**: A 200-year-old companion affiliated with the Sole Survivor.\n", + "8. **Deacon**: A 35-year-old companion affiliated with the Railroad.\n", + "9. **John Hancock**: A 250-year-old companion affiliated with Goodneighbor.\n", + "10. **Robert MacCready**: A 22-year-old companion affiliated with the Gunners.\n", + "11. **Paladin Danse**: A 35-year-old companion affiliated with the Brotherhood of Steel.\n", + "12. **Strong**: A 10-year-old companion affiliated with the Super Mutants." ], "text/plain": [ - "AssistantMessageView(display_id='b8dc3f0d-69a2-49e1-aec5-7493673974e3', content='I have created 12 characters from the Fallout Universe. You can see the details in the table above.', finished=False, has_displayed=True)" + "AssistantMessageView(display_id='3619dc75-b2f4-4818-8ae6-8aed344bcc03', content='I have created 12 characters from the Fallout Universe. Here they are:\\n\\n1. **Vault Dweller**: A 19-year-old protagonist affiliated with Vault 13.\\n2. **Dogmeat**: A 5-year-old companion of the Lone Wanderer.\\n3. **Preston Garvey**: A 26-year-old companion affiliated with the Minutemen.\\n4. **Nick Valentine**: A 100-year-old companion affiliated with the Detective Agency.\\n5. **Piper Wright**: A 23-year-old companion affiliated with Publick Occurrences.\\n6. **Cait**: A 26-year-old companion affiliated with the Combat Zone.\\n7. **Codsworth**: A 200-year-old companion affiliated with the Sole Survivor.\\n8. **Deacon**: A 35-year-old companion affiliated with the Railroad.\\n9. **John Hancock**: A 250-year-old companion affiliated with Goodneighbor.\\n10. **Robert MacCready**: A 22-year-old companion affiliated with the Gunners.\\n11. **Paladin Danse**: A 35-year-old companion affiliated with the Brotherhood of Steel.\\n12. **Strong**: A 10-year-old companion affiliated with the Super Mutants.', finished=False, has_displayed=True)" ] }, "metadata": {}, @@ -1466,8 +1487,9 @@ " system(\n", " \"You are running inside a jupyter notebook. Your responses appear as markdown in the notebook. Functions you run can produce side effects. Do not repeat input to functions back as text.\"\n", " ),\n", - " model=\"gpt-3.5-turbo\",\n", - " # model=\"gpt-4-turbo-preview\",\n", + " #model=\"gpt-3.5-turbo\",\n", + " #model=\"gpt-4-turbo-preview\",\n", + " model=\"gpt-4\",\n", " chat_functions=[store_characters],\n", ")\n", "\n",