diff --git a/chatlab/builtins/__init__.py b/chatlab/builtins/__init__.py index 40bd6d9..365c83a 100644 --- a/chatlab/builtins/__init__.py +++ b/chatlab/builtins/__init__.py @@ -1,4 +1,4 @@ -"""Builtins for ChatLab.""" +"""Simple tools for any LLM to use.""" from deprecation import deprecated diff --git a/chatlab/chat.py b/chatlab/chat.py index 2d1267e..36e1b47 100644 --- a/chatlab/chat.py +++ b/chatlab/chat.py @@ -109,9 +109,9 @@ def __init__( if function_registry is None: if allow_hallucinated_python and python_hallucination_function is None: - from .builtins import run_cell + from .tools import run_python - python_hallucination_function = run_cell + python_hallucination_function = run_python self.function_registry = FunctionRegistry(python_hallucination_function=python_hallucination_function) else: diff --git a/notebooks/color-picker.ipynb b/notebooks/color-picker.ipynb index 7c57a71..7952ba8 100644 --- a/notebooks/color-picker.ipynb +++ b/notebooks/color-picker.ipynb @@ -4,16 +4,7 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "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" - ] - } - ], + "outputs": [], "source": [ "from chatlab import Chat, models, system\n", "from chatlab.tools.colors import show_colors\n", @@ -32,11 +23,153 @@ "outputs": [ { "data": { + "application/vdom.v1+json": { + "attributes": {}, + "children": [ + { + "attributes": {}, + "children": [ + ".chatlab-chat-details summary > * { display: inline; color: #27374D; }" + ], + "tagName": "style" + }, + { + "attributes": { + "className": "chatlab-chat-details", + "style": { + "background": "#DDE6ED", + "borderRadius": "5px", + "padding": ".5rem 1rem" + } + }, + "children": [ + { + "attributes": { + "style": { + "color": "#27374D", + "cursor": "pointer" + } + }, + "children": [ + { + "attributes": { + "style": { + "color": "#9DB2BF", + "paddingLeft": "5px", + "paddingRight": "5px" + } + }, + "children": [ + "𝑓" + ], + "tagName": "span" + }, + { + "attributes": { + "style": { + "color": "#27374D", + "paddingLeft": "5px", + "paddingRight": "5px" + } + }, + "children": [ + "Ran" + ], + "tagName": "span" + }, + { + "attributes": { + "style": { + "fontFamily": "monospace", + "unicodeBidi": "embed", + "whiteSpace": "pre" + } + }, + "children": [ + "show_colors" + ], + "tagName": "span" + }, + { + "attributes": { + "style": { + "fontFamily": "monospace", + "unicodeBidi": "embed", + "whiteSpace": "pre" + } + }, + "children": [ + "..." + ], + "tagName": "span" + } + ], + "tagName": "summary" + }, + { + "attributes": { + "style": { + "marginLeft": "10px", + "marginTop": "10px" + } + }, + "children": [ + { + "attributes": {}, + "children": [ + { + "attributes": { + "style": { + "color": "#27374D", + "fontWeight": "500", + "marginBottom": "5px" + } + }, + "children": [ + "Input:" + ], + "tagName": "div" + }, + { + "attributes": { + "style": { + "background": "#F7F9FA", + "color": "#27374D", + "fontFamily": "monospace", + "marginBottom": "10px", + "overflowX": "auto", + "padding": "10px", + "unicodeBidi": "embed", + "whiteSpace": "pre" + } + }, + "children": [ + "{\"colors\":[\"#1A1A1A\",\"#333333\",\"#4F5D75\",\"#EF8354\",\"#2D3142\"]}" + ], + "tagName": "div" + } + ], + "tagName": "div" + }, + { + "attributes": {}, + "children": [], + "tagName": "div" + } + ], + "tagName": "div" + } + ], + "tagName": "details" + } + ], + "tagName": "div" + }, "text/html": [ - "
𝑓Ranshow_colors...
Input:
{"colors":["#1C1C1E","#2C2C2E","#3A3A3C","#48484A","#9DA5B4","#6366F1","#8B5CF6","#EC4899","#F43F5E","#10B981"]}
" + "
𝑓Ranshow_colors...
Input:
{"colors":["#1A1A1A","#333333","#4F5D75","#EF8354","#2D3142"]}
" ], "text/plain": [ - "ToolArguments(display_id='3d787da0-d2cf-4988-9126-8aee8e8f32db', id='TBD', name='show_colors', arguments='{\"colors\":[\"#1C1C1E\",\"#2C2C2E\",\"#3A3A3C\",\"#48484A\",\"#9DA5B4\",\"#6366F1\",\"#8B5CF6\",\"#EC4899\",\"#F43F5E\",\"#10B981\"]}', verbage='Ran', finished=True)" + "
𝑓Ranshow_colors...
Input:
{"colors":["#1A1A1A","#333333","#4F5D75","#EF8354","#2D3142"]}
" ] }, "metadata": {}, @@ -45,10 +178,10 @@ { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ - "Palette(['#1C1C1E', '#2C2C2E', '#3A3A3C', '#48484A', '#9DA5B4', '#6366F1', '#8B5CF6', '#EC4899', '#F43F5E', '#10B981'], palette-6b614434498c16afb361f78a67dd1ded75a67cc8)" + "Palette(['#1A1A1A', '#333333', '#4F5D75', '#EF8354', '#2D3142'], None)" ] }, "metadata": {}, @@ -57,28 +190,22 @@ { "data": { "text/markdown": [ - "Here is a dark-themed color palette suitable for a portfolio website:\n", + "For your portfolio site with a dark theme, I've created a color palette that balances dark tones with accent colors to provide visual interest and highlight key elements. Here's the palette:\n", "\n", - "1. **Primary Background**: `#1C1C1E` - A deep, dark gray that serves as a strong base for the dark theme.\n", - "2. **Secondary Background**: `#2C2C2E` - Slightly lighter than the primary background, for sections or card backgrounds.\n", - "3. **Tertiary Background**: `#3A3A3C` - Even lighter, for subtle differentiation of UI elements like sidebars or modals.\n", - "4. **Accent Background**: `#48484A` - A medium-dark gray that can be used for hover states or to highlight active elements.\n", - "5. **Neutral Text**: `#9DA5B4` - A muted blue-gray for body text that contrasts well against the dark backgrounds.\n", - "6. **Primary Accent**: `#6366F1` - A vibrant indigo for call-to-action buttons and links to stand out.\n", - "7. **Secondary Accent**: `#8B5CF6` - A purple accent for secondary buttons or interactive elements.\n", - "8. **Tertiary Accent**: `#EC4899` - A pink accent for highlights, icons, or progress bars.\n", - "9. **Quaternary Accent**: `#F43F5E` - A red accent for important warnings or errors.\n", - "10. **Highlight Accent**: `#10B981` - A fresh green for success messages or to denote active statuses.\n", + "1. **Background Color**: `#1A1A1A` - A deep, dark gray that will serve as a sleek and professional background for your portfolio.\n", + "2. **Secondary Background Color**: `#333333` - A slightly lighter shade of dark gray to create subtle contrasts for elements like sidebars or footer.\n", + "3. **Accent Color**: `#EF8354` - A vibrant, warm coral tone that can be used for call-to-action buttons, links, or to highlight important content.\n", + "4. **Primary Text Color**: `#FFFFFF` (not shown) - A clean white for the main text, ensuring readability against the dark background.\n", + "5. **Secondary Text/Element Color**: `#4F5D75` - A muted blue-gray that complements the dark theme and can be used for secondary text or less prominent elements.\n", + "6. **Highlight Color**: `#2D3142` - A dark blue-gray that can be used to highlight sections of the site or for hover states on interactive elements.\n", "\n", - "This palette combines a range of dark grays to create depth and layering in the UI, with pops of color to draw attention to important elements and actions. The use of indigo, purple, pink, red, and green as accent colors adds vibrancy and visual interest to the dark theme, ensuring that the portfolio remains engaging and easy to navigate." + "This palette provides a modern and sophisticated look, with enough contrast to ensure that content is easily readable and interactive elements are noticeable. Remember to maintain accessibility by ensuring sufficient contrast ratios between text and background colors." ], "text/plain": [ - "AssistantMessageView(display_id='a80ad66d-dfb5-4349-881f-c46050acb576', content='Here is a dark-themed color palette suitable for a portfolio website:\\n\\n1. **Primary Background**: `#1C1C1E` - A deep, dark gray that serves as a strong base for the dark theme.\\n2. **Secondary Background**: `#2C2C2E` - Slightly lighter than the primary background, for sections or card backgrounds.\\n3. **Tertiary Background**: `#3A3A3C` - Even lighter, for subtle differentiation of UI elements like sidebars or modals.\\n4. **Accent Background**: `#48484A` - A medium-dark gray that can be used for hover states or to highlight active elements.\\n5. **Neutral Text**: `#9DA5B4` - A muted blue-gray for body text that contrasts well against the dark backgrounds.\\n6. **Primary Accent**: `#6366F1` - A vibrant indigo for call-to-action buttons and links to stand out.\\n7. **Secondary Accent**: `#8B5CF6` - A purple accent for secondary buttons or interactive elements.\\n8. **Tertiary Accent**: `#EC4899` - A pink accent for highlights, icons, or progress bars.\\n9. **Quaternary Accent**: `#F43F5E` - A red accent for important warnings or errors.\\n10. **Highlight Accent**: `#10B981` - A fresh green for success messages or to denote active statuses.\\n\\nThis palette combines a range of dark grays to create depth and layering in the UI, with pops of color to draw attention to important elements and actions. The use of indigo, purple, pink, red, and green as accent colors adds vibrancy and visual interest to the dark theme, ensuring that the portfolio remains engaging and easy to navigate.', finished=False, has_displayed=True)" + "AssistantMessageView(display_id='38c55ab5-bd90-410d-9a4e-4bf2e46f73b4', content=\"For your portfolio site with a dark theme, I've created a color palette that balances dark tones with accent colors to provide visual interest and highlight key elements. Here's the palette:\\n\\n1. **Background Color**: `#1A1A1A` - A deep, dark gray that will serve as a sleek and professional background for your portfolio.\\n2. **Secondary Background Color**: `#333333` - A slightly lighter shade of dark gray to create subtle contrasts for elements like sidebars or footer.\\n3. **Accent Color**: `#EF8354` - A vibrant, warm coral tone that can be used for call-to-action buttons, links, or to highlight important content.\\n4. **Primary Text Color**: `#FFFFFF` (not shown) - A clean white for the main text, ensuring readability against the dark background.\\n5. **Secondary Text/Element Color**: `#4F5D75` - A muted blue-gray that complements the dark theme and can be used for secondary text or less prominent elements.\\n6. **Highlight Color**: `#2D3142` - A dark blue-gray that can be used to highlight sections of the site or for hover states on interactive elements.\\n\\nThis palette provides a modern and sophisticated look, with enough contrast to ensure that content is easily readable and interactive elements are noticeable. Remember to maintain accessibility by ensuring sufficient contrast ratios between text and background colors.\", finished=False, has_displayed=True)" ] }, - "metadata": { - "role": "assistant" - }, + "metadata": {}, "output_type": "display_data" } ], @@ -93,11 +220,153 @@ "outputs": [ { "data": { + "application/vdom.v1+json": { + "attributes": {}, + "children": [ + { + "attributes": {}, + "children": [ + ".chatlab-chat-details summary > * { display: inline; color: #27374D; }" + ], + "tagName": "style" + }, + { + "attributes": { + "className": "chatlab-chat-details", + "style": { + "background": "#DDE6ED", + "borderRadius": "5px", + "padding": ".5rem 1rem" + } + }, + "children": [ + { + "attributes": { + "style": { + "color": "#27374D", + "cursor": "pointer" + } + }, + "children": [ + { + "attributes": { + "style": { + "color": "#9DB2BF", + "paddingLeft": "5px", + "paddingRight": "5px" + } + }, + "children": [ + "𝑓" + ], + "tagName": "span" + }, + { + "attributes": { + "style": { + "color": "#27374D", + "paddingLeft": "5px", + "paddingRight": "5px" + } + }, + "children": [ + "Ran" + ], + "tagName": "span" + }, + { + "attributes": { + "style": { + "fontFamily": "monospace", + "unicodeBidi": "embed", + "whiteSpace": "pre" + } + }, + "children": [ + "show_colors" + ], + "tagName": "span" + }, + { + "attributes": { + "style": { + "fontFamily": "monospace", + "unicodeBidi": "embed", + "whiteSpace": "pre" + } + }, + "children": [ + "..." + ], + "tagName": "span" + } + ], + "tagName": "summary" + }, + { + "attributes": { + "style": { + "marginLeft": "10px", + "marginTop": "10px" + } + }, + "children": [ + { + "attributes": {}, + "children": [ + { + "attributes": { + "style": { + "color": "#27374D", + "fontWeight": "500", + "marginBottom": "5px" + } + }, + "children": [ + "Input:" + ], + "tagName": "div" + }, + { + "attributes": { + "style": { + "background": "#F7F9FA", + "color": "#27374D", + "fontFamily": "monospace", + "marginBottom": "10px", + "overflowX": "auto", + "padding": "10px", + "unicodeBidi": "embed", + "whiteSpace": "pre" + } + }, + "children": [ + "{\"colors\":[\"#0F0F0F\",\"#212121\",\"#08F7FE\",\"#FE53BB\",\"#F5D300\"]}" + ], + "tagName": "div" + } + ], + "tagName": "div" + }, + { + "attributes": {}, + "children": [], + "tagName": "div" + } + ], + "tagName": "div" + } + ], + "tagName": "details" + } + ], + "tagName": "div" + }, "text/html": [ - "
𝑓Ranshow_colors...
Input:
{"colors":["#101010","#212121","#333333","#454545","#BBBBBB","#32CD32","#00FFFF","#FFD700","#FF1493","#4B0082"]}
" + "
𝑓Ranshow_colors...
Input:
{"colors":["#0F0F0F","#212121","#08F7FE","#FE53BB","#F5D300"]}
" ], "text/plain": [ - "ToolArguments(display_id='ca8566b7-af21-4bf2-b341-c01910d11d5a', id='TBD', name='show_colors', arguments='{\"colors\":[\"#101010\",\"#212121\",\"#333333\",\"#454545\",\"#BBBBBB\",\"#32CD32\",\"#00FFFF\",\"#FFD700\",\"#FF1493\",\"#4B0082\"]}', verbage='Ran', finished=True)" + "
𝑓Ranshow_colors...
Input:
{"colors":["#0F0F0F","#212121","#08F7FE","#FE53BB","#F5D300"]}
" ] }, "metadata": {}, @@ -106,10 +375,10 @@ { "data": { "text/html": [ - "
" + "
" ], "text/plain": [ - "Palette(['#101010', '#212121', '#333333', '#454545', '#BBBBBB', '#32CD32', '#00FFFF', '#FFD700', '#FF1493', '#4B0082'], palette-35c93757e18f3ad74a4ddbbf1965519d5a6dc7b1)" + "Palette(['#0F0F0F', '#212121', '#08F7FE', '#FE53BB', '#F5D300'], None)" ] }, "metadata": {}, @@ -118,23 +387,18 @@ { "data": { "text/markdown": [ - "Here is a neon-themed color palette suitable for a portfolio website with a dark theme:\n", + "For a neon-themed portfolio site, I've selected a palette that combines dark backgrounds with bright, neon colors to create a striking and energetic visual experience. Here's the neon palette:\n", "\n", - "1. **Primary Background**: `#101010` - A very dark, almost black color to make the neon colors pop.\n", - "2. **Secondary Background**: `#212121` - A slightly lighter shade of dark gray for section backgrounds or cards.\n", - "3. **Tertiary Background**: `#333333` - A medium dark gray for differentiating UI elements like sidebars or modals.\n", - "4. **Accent Background**: `#454545` - A dark gray that can be used for hover states or to highlight active elements.\n", - "5. **Neutral Text**: `#BBBBBB` - A bright gray for text, providing high contrast against the dark backgrounds.\n", - "6. **Primary Neon Accent**: `#32CD32` - A bright neon green for primary call-to-action buttons and links.\n", - "7. **Secondary Neon Accent**: `#00FFFF` - A neon cyan for secondary buttons or interactive elements.\n", - "8. **Tertiary Neon Accent**: `#FFD700` - A neon yellow for highlights, icons, or progress bars.\n", - "9. **Quaternary Neon Accent**: `#FF1493` - A neon pink for important warnings or errors.\n", - "10. **Highlight Neon Accent**: `#4B0082` - A neon indigo for success messages or to denote active statuses.\n", + "1. **Background Color**: `#0F0F0F` - A very dark gray, almost black, to allow the neon colors to pop and create a high contrast.\n", + "2. **Secondary Background Color**: `#212121` - A slightly lighter dark gray to differentiate sections or elements without detracting from the neon effect.\n", + "3. **Neon Accent Color 1**: `#08F7FE` - A bright neon cyan for a futuristic feel, perfect for highlighting important elements like buttons and icons.\n", + "4. **Neon Accent Color 2**: `#FE53BB` - A vivid neon pink to add a playful and dynamic touch, suitable for calls to action and active navigation items.\n", + "5. **Neon Highlight Color**: `#F5D300` - A neon yellow that stands out against the dark background, great for alerts, badges, or key information.\n", "\n", - "This neon palette is designed to stand out dramatically against the dark background, with bright and vibrant colors that give the portfolio a dynamic and modern feel. The neon accents are intended to draw the user's attention to key elements and actions, while the range of dark grays allows for depth and layering in the UI design." + "This neon palette will give your portfolio a bold and modern edge, ensuring it captures attention. The dark backgrounds will enhance the glow of the neon colors, making your site memorable. As with any design, be mindful of the usage of these bright colors to maintain readability and avoid visual fatigue for your site visitors." ], "text/plain": [ - "AssistantMessageView(display_id='24026821-cf04-43c9-8337-13cd4d7abdfa', content=\"Here is a neon-themed color palette suitable for a portfolio website with a dark theme:\\n\\n1. **Primary Background**: `#101010` - A very dark, almost black color to make the neon colors pop.\\n2. **Secondary Background**: `#212121` - A slightly lighter shade of dark gray for section backgrounds or cards.\\n3. **Tertiary Background**: `#333333` - A medium dark gray for differentiating UI elements like sidebars or modals.\\n4. **Accent Background**: `#454545` - A dark gray that can be used for hover states or to highlight active elements.\\n5. **Neutral Text**: `#BBBBBB` - A bright gray for text, providing high contrast against the dark backgrounds.\\n6. **Primary Neon Accent**: `#32CD32` - A bright neon green for primary call-to-action buttons and links.\\n7. **Secondary Neon Accent**: `#00FFFF` - A neon cyan for secondary buttons or interactive elements.\\n8. **Tertiary Neon Accent**: `#FFD700` - A neon yellow for highlights, icons, or progress bars.\\n9. **Quaternary Neon Accent**: `#FF1493` - A neon pink for important warnings or errors.\\n10. **Highlight Neon Accent**: `#4B0082` - A neon indigo for success messages or to denote active statuses.\\n\\nThis neon palette is designed to stand out dramatically against the dark background, with bright and vibrant colors that give the portfolio a dynamic and modern feel. The neon accents are intended to draw the user's attention to key elements and actions, while the range of dark grays allows for depth and layering in the UI design.\", finished=False, has_displayed=True)" + "AssistantMessageView(display_id='169dd512-6948-4c22-a8c2-0ac3c1cc57eb', content=\"For a neon-themed portfolio site, I've selected a palette that combines dark backgrounds with bright, neon colors to create a striking and energetic visual experience. Here's the neon palette:\\n\\n1. **Background Color**: `#0F0F0F` - A very dark gray, almost black, to allow the neon colors to pop and create a high contrast.\\n2. **Secondary Background Color**: `#212121` - A slightly lighter dark gray to differentiate sections or elements without detracting from the neon effect.\\n3. **Neon Accent Color 1**: `#08F7FE` - A bright neon cyan for a futuristic feel, perfect for highlighting important elements like buttons and icons.\\n4. **Neon Accent Color 2**: `#FE53BB` - A vivid neon pink to add a playful and dynamic touch, suitable for calls to action and active navigation items.\\n5. **Neon Highlight Color**: `#F5D300` - A neon yellow that stands out against the dark background, great for alerts, badges, or key information.\\n\\nThis neon palette will give your portfolio a bold and modern edge, ensuring it captures attention. The dark backgrounds will enhance the glow of the neon colors, making your site memorable. As with any design, be mindful of the usage of these bright colors to maintain readability and avoid visual fatigue for your site visitors.\", finished=False, has_displayed=True)" ] }, "metadata": {}, diff --git a/notebooks/cooking.ipynb b/notebooks/cooking.ipynb index 9499db1..106782a 100644 --- a/notebooks/cooking.ipynb +++ b/notebooks/cooking.ipynb @@ -541,7 +541,7 @@ ], "metadata": { "kernelspec": { - "display_name": "chatlab-0EWIBOuo-py3.11", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, diff --git a/notebooks/function-registry.ipynb b/notebooks/function-registry.ipynb index 10e7265..e7c1b9d 100644 --- a/notebooks/function-registry.ipynb +++ b/notebooks/function-registry.ipynb @@ -1122,7 +1122,7 @@ ], "metadata": { "kernelspec": { - "display_name": "chatlab-3kMKfU-i-py3.11", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -1136,9 +1136,8 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" - }, - "orig_nbformat": 4 + "version": "3.11.7" + } }, "nbformat": 4, "nbformat_minor": 2 diff --git a/tests/test_builtins.py b/tests/test_builtins.py index f92fc7b..f959dee 100644 --- a/tests/test_builtins.py +++ b/tests/test_builtins.py @@ -3,7 +3,7 @@ from chatlab import FunctionRegistry from chatlab.builtins import os_functions -from chatlab.builtins.files import ( +from chatlab.tools.files import ( get_file_size, is_directory, is_file, @@ -11,7 +11,7 @@ read_file, write_file, ) -from chatlab.builtins.shell import run_shell_command +from chatlab.tools.shell import run_shell_command def test_chat_function_adherence(): @@ -39,7 +39,7 @@ async def test_run_shell_command(): @pytest.mark.asyncio async def test_list_files(): - directory = "chatlab/builtins" + directory = "chatlab/tools" files = await list_files(directory) assert isinstance(files, list) assert len(files) > 0 @@ -47,7 +47,7 @@ async def test_list_files(): @pytest.mark.asyncio async def test_get_file_size(): - file_path = "chatlab/builtins/files.py" + file_path = "chatlab/tools/files.py" size = await get_file_size(file_path) assert isinstance(size, int) assert size > 0 @@ -55,13 +55,13 @@ async def test_get_file_size(): @pytest.mark.asyncio async def test_is_file(): - file_path = "chatlab/builtins/files.py" + file_path = "chatlab/tools/files.py" assert await is_file(file_path) @pytest.mark.asyncio async def test_is_directory(): - directory = "chatlab/builtins" + directory = "chatlab/tools" assert await is_directory(directory) diff --git a/website/docs/examples/color-picker.mdx b/website/docs/examples/color-picker.mdx index 9f3d94c..3374522 100644 --- a/website/docs/examples/color-picker.mdx +++ b/website/docs/examples/color-picker.mdx @@ -15,7 +15,7 @@ The IPython-provided `display()` uses your object's `_repr_html_()` to show HTML ```python cell count=1 from chatlab import Chat, models, system -from chatlab.builtins.colors import show_colors +from chatlab.tools.colors import show_colors chat = Chat( system("Format responses in markdown,. You are a skilled designer."), diff --git a/website/docs/interpreter.mdx b/website/docs/interpreter.mdx index 43dea15..480dd05 100644 --- a/website/docs/interpreter.mdx +++ b/website/docs/interpreter.mdx @@ -12,17 +12,17 @@ There is a builtin code interpreter that lets the assistant run code. It's not e ```python cell count=1 from chatlab import Chat -from chatlab.builtins import run_cell +from chatlab.tools import run_python chat = Chat() -chat.register(run_cell) +chat.register(run_python) await chat("Please calculate sin(793.1)") ``` @@ -37,7 +37,7 @@ You can let ChatGPT take on a data persona with a `system` message and then have ```python from chatlab import Chat, system -from chatlab.builtins import run_cell +from chatlab.tools import run_python import pandas as pd # The Chicago Public Library location dataset @@ -49,22 +49,22 @@ chat = Chat( "collaborating with a data engineer." ), ) -chat.register(run_cell) +chat.register(run_python) await chat("Please tell me about what's in `df`") ``` ## The hidden `python` hallucination -Sometimes GPT models will hallucinate a `python` tool that accepts a single string rather than the proper JSON object that `run_cell` requests. You can include it in your `Chat` to handle these cases. +Sometimes GPT models will hallucinate a `python` tool that accepts a single string rather than the proper JSON object that `run_python` requests. You can include it in your `Chat` to handle these cases. ```python cell count=1 from chatlab import Chat -from chatlab.builtins import run_cell +from chatlab.tools import run_python chat = Chat( allow_hallucinated_python=True ) -chat.register(run_cell) +chat.register(run_python) await chat("Please calculate sin(793.1)") ```