diff --git a/posts.html b/posts.html index a53eea9..030fd00 100644 --- a/posts.html +++ b/posts.html @@ -263,7 +263,7 @@

Posts

-
+ -
+ -
+ -
+ -
+

diff --git a/search.json b/search.json index 174003b..6ce75de 100644 --- a/search.json +++ b/search.json @@ -260,7 +260,7 @@ "href": "tutorials/python.html#setup-the-bot", "title": "Tutorial: Python", "section": "Setup the bot", - "text": "Setup the bot\nFirst, import relevant modules:\n\nimport ibis\n\nfrom ibis_birdbrain import Bot\n\nSet Ibis interactive mode:\n\nibis.options.interactive = True\n\n\nCreate an Ibis connection\nCreate an Ibis connection to your database:\n\n\n\n\n\n\nWarning\n\n\n\nWe’ll create a demo database for this tutorial.\n\n\n\ncon = ibis.connect(\"duckdb://penguins.ddb\")\ncon.create_table(\n \"penguins\", ibis.examples.penguins.fetch().to_pyarrow(), overwrite=True\n)\ncon = ibis.connect(\"duckdb://penguins.ddb\")\ncon.list_tables()\n\nINFO:pins.cache:cache file: /Users/cody/Library/Caches/pins-py/gcs_332a30997e141da0e08f15fbfae8b3c3ec90463922d117a96fa3b1bef85a2a4c/penguins/20230905T090411Z-9aae2/data.txt\nINFO:pins.cache:cache file: /Users/cody/Library/Caches/pins-py/gcs_332a30997e141da0e08f15fbfae8b3c3ec90463922d117a96fa3b1bef85a2a4c/penguins/20230905T090411Z-9aae2/penguins.csv.gz\n\n\n['penguins']\n\n\n\n\nCreate the bot\nYou’ll create the bot by passing in the connection:\n\n\n\n\n\n\nTip\n\n\n\nFor increased accuracy, you should also pass in a data_description containing information about the dataset. This could be fetched from the database itself, manually created, or otherwise obtained.\nYou should not include table names and schemas – this will be inferred automatically.\n\n\n\nbot = Bot(con=con, data_description=\"the Palmer Penguins dataset\")\nbot\n\nINFO:root:Bot birdbrain initialized...\n\n\n<ibis_birdbrain.bot.Bot at 0x111bf95d0>\n\n\n\n\nTest the bot\nYou can ask the bot questions:\n\nres = bot(\"\"\"give me the counts of penguins by species and island from highest\nto lowest\"\"\")\nres\n\nINFO:root:Bot birdbrain called with text: give me the counts of penguins by species and island from highest\nto lowest\nINFO:root:Selected flow: data\nINFO:root:Executing the data flow\nINFO:root:Text to SQL task\nINFO:httpx:HTTP Request: POST https://birdbrain-eh.openai.azure.com/openai/deployments/gpt-4-turbo/chat/completions?api-version=2023-12-01-preview \"HTTP/1.1 200 OK\"\nINFO:root:Executing the SQL task\n\n\n\n\n\n\n\n\n\nTo: user\nFrom: birdbrain\nSubject: give me the counts of pengu...\nSent at: 2024-03-05 11:23:48.370476\nMessage: a6dff0f1-8fa5-4fe6-a14d-7576736d88e3\nIbis Birdbrain has attached the results.\nAttachments:\nCodeAttachment\n **guid**: 3a358f68-357b-44a2-800e-4d96fb3b9a10\n **time**: 2024-03-05 11:23:48.368303\n **name**: None\n **desc**: None\n **language**: sql\n **code**:\nSELECT species, island, COUNT(*) AS count FROM penguins GROUP BY species, island ORDER BY count DESC\nTableAttachment\n **guid**: d1345277-18aa-46d7-ab71-f026d71cfb19\n **time**: 2024-03-05 11:23:48.370386\n **name**: None\n **desc**: \nibis.Schema {\n species string\n island string\n count int64\n}\n **table**:\n┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓\n┃ species ┃ island ┃ count ┃\n┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩\n│ string │ string │ int64 │\n├───────────┼───────────┼───────┤\n│ Gentoo │ Biscoe │ 124 │\n│ Chinstrap │ Dream │ 68 │\n│ Adelie │ Dream │ 56 │\n│ Adelie │ Torgersen │ 52 │\n│ Adelie │ Biscoe │ 44 │\n└───────────┴───────────┴───────┘\n\n\n\n\n\nGet attachments\nYou can get the table attachment back:\n\nt = res.attachments[-1].open()\nt\n\n┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓\n┃ species ┃ island ┃ count ┃\n┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩\n│ string │ string │ int64 │\n├───────────┼───────────┼───────┤\n│ Gentoo │ Biscoe │ 124 │\n│ Chinstrap │ Dream │ 68 │\n│ Adelie │ Dream │ 56 │\n│ Adelie │ Torgersen │ 52 │\n│ Adelie │ Biscoe │ 44 │\n└───────────┴───────────┴───────┘", + "text": "Setup the bot\nFirst, import relevant modules:\n\nimport ibis\n\nfrom ibis_birdbrain import Bot\n\nSet Ibis interactive mode:\n\nibis.options.interactive = True\n\n\nCreate an Ibis connection\nCreate an Ibis connection to your database:\n\n\n\n\n\n\nWarning\n\n\n\nWe’ll create a demo database for this tutorial.\n\n\n\ncon = ibis.connect(\"duckdb://penguins.ddb\")\ncon.create_table(\n \"penguins\", ibis.examples.penguins.fetch().to_pyarrow(), overwrite=True\n)\ncon = ibis.connect(\"duckdb://penguins.ddb\")\ncon.list_tables()\n\nINFO:pins.cache:cache file: /Users/cody/Library/Caches/pins-py/gcs_332a30997e141da0e08f15fbfae8b3c3ec90463922d117a96fa3b1bef85a2a4c/penguins/20230905T090411Z-9aae2/data.txt\nINFO:pins.cache:cache file: /Users/cody/Library/Caches/pins-py/gcs_332a30997e141da0e08f15fbfae8b3c3ec90463922d117a96fa3b1bef85a2a4c/penguins/20230905T090411Z-9aae2/penguins.csv.gz\n\n\n['penguins']\n\n\n\n\nCreate the bot\nYou’ll create the bot by passing in the connection:\n\n\n\n\n\n\nTip\n\n\n\nFor increased accuracy, you should also pass in a data_description containing information about the dataset. This could be fetched from the database itself, manually created, or otherwise obtained.\nYou should not include table names and schemas – this will be inferred automatically.\n\n\n\nbot = Bot(con=con, data_description=\"the Palmer Penguins dataset\")\nbot\n\nINFO:root:Bot birdbrain initialized...\n\n\n<ibis_birdbrain.bot.Bot at 0x282385090>\n\n\n\n\nTest the bot\nYou can ask the bot questions:\n\nres = bot(\"\"\"give me the counts of penguins by species and island from highest\nto lowest\"\"\")\nres\n\nINFO:root:Bot birdbrain called with text: give me the counts of penguins by species and island from highest\nto lowest\nINFO:root:Selected flow: data\nINFO:root:Executing the data flow\nINFO:root:Text to SQL task\nINFO:httpx:HTTP Request: POST https://birdbrain-eh.openai.azure.com/openai/deployments/gpt-4-turbo/chat/completions?api-version=2023-12-01-preview \"HTTP/1.1 200 OK\"\nINFO:root:Executing the SQL task\n\n\n\n\n\n\n\n\n\nTo: user\nFrom: birdbrain\nSubject: give me the counts of pengu...\nSent at: 2024-03-05 11:31:58.342810\nMessage: 0da2fb4c-30f7-4c2d-a646-ed500e3f99a6\nIbis Birdbrain has attached the results.\nAttachments:\nCodeAttachment\n **guid**: 14125164-2a86-479b-ba97-9847e894d7a7\n **time**: 2024-03-05 11:31:58.340826\n **name**: None\n **desc**: None\n **language**: sql\n **code**:\nSELECT species, island, COUNT(*) AS count \nFROM penguins \nGROUP BY species, island \nORDER BY count DESC\nTableAttachment\n **guid**: 537a8847-568d-45c8-b306-4f5363ad5ca1\n **time**: 2024-03-05 11:31:58.342725\n **name**: None\n **desc**: \nibis.Schema {\n species string\n island string\n count int64\n}\n **table**:\n┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓\n┃ species ┃ island ┃ count ┃\n┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩\n│ string │ string │ int64 │\n├───────────┼───────────┼───────┤\n│ Gentoo │ Biscoe │ 124 │\n│ Chinstrap │ Dream │ 68 │\n│ Adelie │ Dream │ 56 │\n│ Adelie │ Torgersen │ 52 │\n│ Adelie │ Biscoe │ 44 │\n└───────────┴───────────┴───────┘\n\n\n\n\n\nGet attachments\nYou can get the table from the attachment:\n\nt = res.attachments[-1].open()\nt\n\n┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓\n┃ species ┃ island ┃ count ┃\n┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩\n│ string │ string │ int64 │\n├───────────┼───────────┼───────┤\n│ Gentoo │ Biscoe │ 124 │\n│ Chinstrap │ Dream │ 68 │\n│ Adelie │ Dream │ 56 │\n│ Adelie │ Torgersen │ 52 │\n│ Adelie │ Biscoe │ 44 │\n└───────────┴───────────┴───────┘\n\n\n\nAnd do whatever you want with it:\n\nt.order_by(ibis._[\"count\"].asc())\n\n┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓\n┃ species ┃ island ┃ count ┃\n┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩\n│ string │ string │ int64 │\n├───────────┼───────────┼───────┤\n│ Adelie │ Biscoe │ 44 │\n│ Adelie │ Torgersen │ 52 │\n│ Adelie │ Dream │ 56 │\n│ Chinstrap │ Dream │ 68 │\n│ Gentoo │ Biscoe │ 124 │\n└───────────┴───────────┴───────┘", "crumbs": [ "Tutorial: Python" ] diff --git a/sitemap.xml b/sitemap.xml index 21c9519..8b57731 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,98 +2,98 @@ https://ibis-project.github.io/install.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.988Z https://ibis-project.github.io/posts/llms-and-data-pt4/index.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/posts/llms-and-data-pt1/index.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/posts/llms-and-data-pt3/index.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/demo.html - 2024-03-05T16:29:22.199Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/contribute/contributing.html - 2024-03-05T16:29:22.199Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/tutorials/python.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/concepts/archive/user-interfaces.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/archive/platforms.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/attachments.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/messages.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/flows.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/why.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/concepts/tasks.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/bots.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/archive/ops.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/concepts/archive/llms.html - 2024-03-05T16:29:22.195Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/index.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.988Z https://ibis-project.github.io/tutorials/cli.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/how-to/input-output/basics.html - 2024-03-05T16:29:22.199Z + 2024-03-05T16:32:47.976Z https://ibis-project.github.io/posts.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.988Z https://ibis-project.github.io/posts/llms-and-data-pt2/index.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z https://ibis-project.github.io/posts/llms-and-data-pt0/index.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.988Z https://ibis-project.github.io/release_notes.html - 2024-03-05T16:29:22.211Z + 2024-03-05T16:32:47.992Z diff --git a/tutorials/python.html b/tutorials/python.html index 3bcb29a..17b9bde 100644 --- a/tutorials/python.html +++ b/tutorials/python.html @@ -297,13 +297,13 @@

Overview

Setup the bot

First, import relevant modules:

-
+
import ibis
 
 from ibis_birdbrain import Bot

Set Ibis interactive mode:

-
+
ibis.options.interactive = True
@@ -322,7 +322,7 @@

Create an Ibis c

We’ll create a demo database for this tutorial.

-
+
con = ibis.connect("duckdb://penguins.ddb")
 con.create_table(
     "penguins", ibis.examples.penguins.fetch().to_pyarrow(), overwrite=True
@@ -355,21 +355,21 @@ 

Create the bot

You should not include table names and schemas – this will be inferred automatically.

-
+
bot = Bot(con=con, data_description="the Palmer Penguins dataset")
 bot
INFO:root:Bot birdbrain initialized...
-
<ibis_birdbrain.bot.Bot at 0x111bf95d0>
+
<ibis_birdbrain.bot.Bot at 0x282385090>

Test the bot

You can ask the bot questions:

-
+
res = bot("""give me the counts of penguins by species and island from highest
 to lowest""")
 res
@@ -393,21 +393,24 @@

Test the bot

To: user
 From: birdbrain
 Subject: give me the counts of pengu...
-Sent at: 2024-03-05 11:23:48.370476
-Message: a6dff0f1-8fa5-4fe6-a14d-7576736d88e3
+Sent at: 2024-03-05 11:31:58.342810
+Message: 0da2fb4c-30f7-4c2d-a646-ed500e3f99a6
 Ibis Birdbrain has attached the results.
 Attachments:
 CodeAttachment
-    **guid**: 3a358f68-357b-44a2-800e-4d96fb3b9a10
-    **time**: 2024-03-05 11:23:48.368303
+    **guid**: 14125164-2a86-479b-ba97-9847e894d7a7
+    **time**: 2024-03-05 11:31:58.340826
     **name**: None
     **desc**: None
     **language**: sql
     **code**:
-SELECT species, island, COUNT(*) AS count FROM penguins GROUP BY species, island ORDER BY count DESC
+SELECT species, island, COUNT(*) AS count 
+FROM penguins 
+GROUP BY species, island 
+ORDER BY count DESC
 TableAttachment
-    **guid**: d1345277-18aa-46d7-ab71-f026d71cfb19
-    **time**: 2024-03-05 11:23:48.370386
+    **guid**: 537a8847-568d-45c8-b306-4f5363ad5ca1
+    **time**: 2024-03-05 11:31:58.342725
     **name**: None
     **desc**: 
 ibis.Schema {
@@ -433,8 +436,8 @@ 

Test the bot

Get attachments

-

You can get the table attachment back:

-
+

You can get the table from the attachment:

+
t = res.attachments[-1].open()
 t
@@ -452,6 +455,24 @@

Get attachments

+

And do whatever you want with it:

+
+
t.order_by(ibis._["count"].asc())
+
+
┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┓
+┃ species    island     count ┃
+┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━┩
+│ stringstringint64 │
+├───────────┼───────────┼───────┤
+│ Adelie   Biscoe   44 │
+│ Adelie   Torgersen52 │
+│ Adelie   Dream    56 │
+│ ChinstrapDream    68 │
+│ Gentoo   Biscoe   124 │
+└───────────┴───────────┴───────┘
+
+
+