Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Adds video link to demo notebook

Stefan Krawczyk43cadb641925
diff --git a/examples/multi-modal-chatbot/README.md b/examples/multi-modal-chatbot/README.md
index 9e680641..e25822e9 100644
--- a/examples/multi-modal-chatbot/README.md
+++ b/examples/multi-modal-chatbot/README.md
@@ -53,3 +53,9 @@ can build a more sophisticated UI around the Burr application.
## Tracing
To see a tracing example see this [example](../tracing-and-spans).
+
+
+## Burr Demo Notebook showing state persistence & time travel
+
+`burr_demo.ipynb` is a notebook demonstrating persistence and time travel with Burr using a
+multi-modal agent example. Watch [this video](https://youtu.be/hqutVJyd3TI) for a guided walkthrough.
diff --git a/examples/multi-modal-chatbot/burr_demo.ipynb b/examples/multi-modal-chatbot/burr_demo.ipynb
index 080e65f4..cc21de00 100644
--- a/examples/multi-modal-chatbot/burr_demo.ipynb
+++ b/examples/multi-modal-chatbot/burr_demo.ipynb
@@ -3,11 +3,10 @@
{
"cell_type": "markdown",
"id": "f63df3e4b8d4fdba",
- "metadata": {
- "jp-MarkdownHeadingCollapsed": true
- },
+ "metadata": {},
"source": [
- "# Burr Demo - observing state & traveling back in time!\n",
+ "# Burr Demo - observing state \n",
+ "# & traveling back in time!\n",
"\n",
"\n",
"<img src=\"https://github.com/user-attachments/assets/2ab9b499-7ca2-4ae9-af72-ccc775f30b4e\" width=\"100\" align=\"left\" /> + \n",
@@ -19,7 +18,7 @@
"\n",
" - high level what is Burr\n",
" - what you can do with Burr (observing state & being able to debug a particular point in time)\n",
- " - there's a limited amount of stickers at the back"
+ " - watch a walkthrough of this [notebook here](https://youtu.be/hqutVJyd3TI)."
]
},
{
@@ -52,7 +51,9 @@
{
"cell_type": "markdown",
"id": "92cea7b3-1d27-4820-90b5-7aba9026fdfe",
- "metadata": {},
+ "metadata": {
+ "jp-MarkdownHeadingCollapsed": true
+ },
"source": [
"## Well but ... monitoring doesn't help you debug & complete your dev loop\n",
"\n",
@@ -83,11 +84,12 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 13,
"id": "7953fe759ae0f510",
"metadata": {
- "jupyter": {
- "is_executing": true
+ "ExecuteTime": {
+ "end_time": "2024-08-05T19:18:03.050318Z",
+ "start_time": "2024-08-05T19:18:01.630987Z"
}
},
"outputs": [],
@@ -204,7 +206,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 14,
"id": "add99d139d3d72a0",
"metadata": {
"ExecuteTime": {
@@ -219,7 +221,7 @@
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
- "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
+ "<!-- Generated by graphviz version 12.0.0 (20240704.0754)\n",
" -->\n",
"<!-- Pages: 1 -->\n",
"<svg width=\"497pt\" height=\"304pt\"\n",
@@ -368,10 +370,10 @@
"</svg>\n"
],
"text/plain": [
- "<graphviz.graphs.Digraph at 0x10acab8e0>"
+ "<graphviz.graphs.Digraph at 0x12b8d55d0>"
]
},
- "execution_count": 2,
+ "execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
@@ -422,7 +424,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 11,
"id": "4f0bf205944272ff",
"metadata": {
"ExecuteTime": {
@@ -437,7 +439,7 @@
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
- "<!-- Generated by graphviz version 10.0.1 (20240210.2158)\n",
+ "<!-- Generated by graphviz version 12.0.0 (20240704.0754)\n",
" -->\n",
"<!-- Pages: 1 -->\n",
"<svg width=\"576pt\" height=\"328pt\"\n",
@@ -511,7 +513,7 @@
"<title>decide_mode&#45;&gt;answer_question</title>\n",
"<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M397.41,-149.12C393.38,-139.74 388.05,-128.04 382.52,-118 381.59,-116.32 380.61,-114.61 379.59,-112.9\"/>\n",
"<polygon fill=\"black\" stroke=\"black\" points=\"382.65,-111.2 374.38,-104.59 376.72,-114.92 382.65,-111.2\"/>\n",
- "<text text-anchor=\"middle\" x=\"455.39\" y=\"-121.2\" font-family=\"Times,serif\" font-size=\"14.00\">mode=answer_question</text>\n",
+ "<text text-anchor=\"middle\" x=\"454.39\" y=\"-121.2\" font-family=\"Times,serif\" font-size=\"14.00\">mode=answer_question</text>\n",
"</g>\n",
"<!-- prompt_for_more -->\n",
"<g id=\"node8\" class=\"node\">\n",
@@ -522,8 +524,8 @@
"<!-- decide_mode&#45;&gt;prompt_for_more -->\n",
"<g id=\"edge9\" class=\"edge\">\n",
"<title>decide_mode&#45;&gt;prompt_for_more</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M449.16,-160.34C479.29,-155.16 515.19,-146.64 524.52,-134.5 530.15,-127.16 527.63,-119.05 521.93,-111.6\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"524.52,-109.25 515.13,-104.35 519.41,-114.04 524.52,-109.25\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M449.11,-160.23C478.92,-155.02 514.31,-146.51 523.52,-134.5 529.09,-127.23 526.67,-119.14 521.13,-111.69\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"523.84,-109.47 514.52,-104.43 518.67,-114.18 523.84,-109.47\"/>\n",
"</g>\n",
"<!-- response -->\n",
"<g id=\"node9\" class=\"node\">\n",
@@ -589,10 +591,10 @@
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x10ac728c0>"
+ "<burr.core.application.Application at 0x12afc6b90>"
]
},
- "execution_count": 3,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -625,7 +627,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 12,
"id": "48745f4c04b9d28d",
"metadata": {},
"outputs": [
@@ -633,54 +635,94 @@
"name": "stdin",
"output_type": "stream",
"text": [
- "Hi, how can I help? What is the capital of California?\n"
+ "Hi, how can I help? what is the capital of France?\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
- "πŸ€–: The capital of California is Sacramento.\n"
+ "πŸ€–: The capital of France is Paris.\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
- "Hi, how can I help? What countries are next to Poland?\n"
+ "Hi, how can I help? write hello world in java\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
- "πŸ€–: The countries that border Poland are Germany, Czech Republic, Slovakia, Ukraine, Belarus, Lithuania, and Russia.\n"
+ "πŸ€–: ```\n",
+ "public class HelloWorld {\n",
+ " public static void main(String[] args) {\n",
+ " System.out.println(\"Hello, World!\");\n",
+ " }\n",
+ "}\n",
+ "```\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
- "Hi, how can I help? Draw me a cat\n"
+ "Hi, how can I help? draw a pen\n"
]
},
{
- "data": {
- "text/html": [
- "<img src=\"https://oaidalleapiprodscus.blob.core.windows.net/private/org-UENfV68Ccazb3rdeYDLRWmoF/user-KU9L39oZGkNLkg6ZfSLMc4AV/img-u2wxhoIjZ3q1dPicxGfMoYMR.png?st=2024-07-30T18%3A42%3A01Z&se=2024-07-30T20%3A42%3A01Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-07-30T00%3A39%3A33Z&ske=2024-07-31T00%3A39%3A33Z&sks=b&skv=2023-11-03&sig=YC8/S%2BU80orlOTwlvJg9KR/zVOr6b0vh9nNy7qh0Wbk%3D\"/>"
- ],
- "text/plain": [
- "<IPython.core.display.Image object>"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "name": "stdin",
+ "name": "stderr",
"output_type": "stream",
"text": [
- "Hi, how can I help? quit\n"
+ "\n",
+ "********************************************************************************\n",
+ "-------------------------------------------------------------------\n",
+ "Oh no an error! Need help with Burr?\n",
+ "Join our discord and ask for help! https://discord.gg/4FxBMyzW5n\n",
+ "-------------------------------------------------------------------\n",
+ "> Action: `generate_image` encountered an error!<\n",
+ "> State (at time of action):\n",
+ "{'__PRIOR_STEP': 'decide_mode',\n",
+ " '__SEQUENCE_ID': 10,\n",
+ " 'chat_history': \"[{'role': 'user', 'content': 'what is the capital ...\",\n",
+ " 'mode': 'generate_image',\n",
+ " 'prompt': 'draw a pen',\n",
+ " 'response': \"{'content': '```\\\\npublic class HelloWorld {\\\\n p...\"}\n",
+ "> Inputs (at time of action):\n",
+ "{'prompt': 'draw a pen'}\n",
+ "********************************************************************************\n",
+ "Traceback (most recent call last):\n",
+ " File \"/Users/stefankrawczyk/dagworks/burr/burr/core/application.py\", line 534, in _step\n",
+ " result, new_state = _run_single_step_action(\n",
+ " File \"/Users/stefankrawczyk/dagworks/burr/burr/core/application.py\", line 233, in _run_single_step_action\n",
+ " action.run_and_update(state, **inputs), action.name\n",
+ " File \"/Users/stefankrawczyk/dagworks/burr/burr/core/action.py\", line 533, in run_and_update\n",
+ " return self._fn(state, **self._bound_params, **run_kwargs)\n",
+ " File \"/var/folders/gv/q39lb_1s26x7gbyyypqc3dkm0000gn/T/ipykernel_43564/1354917547.py\", line 94, in image_response\n",
+ " raise ValueError(\"Demo error\")\n",
+ "ValueError: Demo error\n"
+ ]
+ },
+ {
+ "ename": "ValueError",
+ "evalue": "Demo error",
+ "output_type": "error",
+ "traceback": [
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
+ "Cell \u001b[0;32mIn[12], line 5\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mquit\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m==\u001b[39m user_input\u001b[38;5;241m.\u001b[39mlower():\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[0;32m----> 5\u001b[0m last_action, action_result, app_state \u001b[38;5;241m=\u001b[39m \u001b[43mapp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mhalt_after\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mresponse\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mprompt\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43muser_input\u001b[49m\u001b[43m}\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 9\u001b[0m last_message \u001b[38;5;241m=\u001b[39m app_state[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mchat_history\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m last_message[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtype\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mimage\u001b[39m\u001b[38;5;124m'\u001b[39m:\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/telemetry.py:273\u001b[0m, in \u001b[0;36mcapture_function_usage.<locals>.wrapped_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 270\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(call_fn)\n\u001b[1;32m 271\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapped_fn\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 272\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 273\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcall_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 274\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 275\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_telemetry_enabled():\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/application.py:878\u001b[0m, in \u001b[0;36mApplication.run\u001b[0;34m(self, halt_before, halt_after, inputs)\u001b[0m\n\u001b[1;32m 876\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m 877\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 878\u001b[0m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mgen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 879\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 880\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m e\u001b[38;5;241m.\u001b[39mvalue\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/application.py:823\u001b[0m, in \u001b[0;36mApplication.iterate\u001b[0;34m(self, halt_before, halt_after, inputs)\u001b[0m\n\u001b[1;32m 820\u001b[0m prior_action: Optional[Action] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 821\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhas_next_action():\n\u001b[1;32m 822\u001b[0m \u001b[38;5;66;03m# self.step will only return None if there is no next action, so we can rely on tuple unpacking\u001b[39;00m\n\u001b[0;32m--> 823\u001b[0m prior_action, result, state \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstep\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 824\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m prior_action, result, state\n\u001b[1;32m 825\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_should_halt_iterate(halt_before, halt_after, prior_action):\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/application.py:495\u001b[0m, in \u001b[0;36mApplication.step\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m 492\u001b[0m \u001b[38;5;66;03m# we need to increment the sequence before we start computing\u001b[39;00m\n\u001b[1;32m 493\u001b[0m \u001b[38;5;66;03m# that way if we're replaying from state, we don't get stuck\u001b[39;00m\n\u001b[1;32m 494\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_increment_sequence_id()\n\u001b[0;32m--> 495\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_step\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m_run_hooks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 496\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m out\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/application.py:548\u001b[0m, in \u001b[0;36mApplication._step\u001b[0;34m(self, inputs, _run_hooks)\u001b[0m\n\u001b[1;32m 546\u001b[0m exc \u001b[38;5;241m=\u001b[39m e\n\u001b[1;32m 547\u001b[0m logger\u001b[38;5;241m.\u001b[39mexception(_format_BASE_ERROR_MESSAGE(next_action, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_state, inputs))\n\u001b[0;32m--> 548\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 549\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 550\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m _run_hooks:\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/application.py:534\u001b[0m, in \u001b[0;36mApplication._step\u001b[0;34m(self, inputs, _run_hooks)\u001b[0m\n\u001b[1;32m 532\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 533\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m next_action\u001b[38;5;241m.\u001b[39msingle_step:\n\u001b[0;32m--> 534\u001b[0m result, new_state \u001b[38;5;241m=\u001b[39m \u001b[43m_run_single_step_action\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 535\u001b[0m \u001b[43m \u001b[49m\u001b[43mnext_action\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_state\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maction_inputs\u001b[49m\n\u001b[1;32m 536\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 537\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 538\u001b[0m result \u001b[38;5;241m=\u001b[39m _run_function(\n\u001b[1;32m 539\u001b[0m next_action, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_state, action_inputs, name\u001b[38;5;241m=\u001b[39mnext_action\u001b[38;5;241m.\u001b[39mname\n\u001b[1;32m 540\u001b[0m )\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/application.py:233\u001b[0m, in \u001b[0;36m_run_single_step_action\u001b[0;34m(action, state, inputs)\u001b[0m\n\u001b[1;32m 230\u001b[0m \u001b[38;5;66;03m# TODO -- guard all reads/writes with a subset of the state\u001b[39;00m\n\u001b[1;32m 231\u001b[0m action\u001b[38;5;241m.\u001b[39mvalidate_inputs(inputs)\n\u001b[1;32m 232\u001b[0m result, new_state \u001b[38;5;241m=\u001b[39m _adjust_single_step_output(\n\u001b[0;32m--> 233\u001b[0m \u001b[43maction\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_and_update\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m)\u001b[49m, action\u001b[38;5;241m.\u001b[39mname\n\u001b[1;32m 234\u001b[0m )\n\u001b[1;32m 235\u001b[0m _validate_result(result, action\u001b[38;5;241m.\u001b[39mname)\n\u001b[1;32m 236\u001b[0m out \u001b[38;5;241m=\u001b[39m result, _state_update(state, new_state)\n",
+ "File \u001b[0;32m~/dagworks/burr/burr/core/action.py:533\u001b[0m, in \u001b[0;36mFunctionBasedAction.run_and_update\u001b[0;34m(self, state, **run_kwargs)\u001b[0m\n\u001b[1;32m 532\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mrun_and_update\u001b[39m(\u001b[38;5;28mself\u001b[39m, state: State, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mrun_kwargs) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mtuple\u001b[39m[\u001b[38;5;28mdict\u001b[39m, State]:\n\u001b[0;32m--> 533\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_bound_params\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mrun_kwargs\u001b[49m\u001b[43m)\u001b[49m\n",
+ "Cell \u001b[0;32mIn[8], line 94\u001b[0m, in \u001b[0;36mimage_response\u001b[0;34m(state, model)\u001b[0m\n\u001b[1;32m 91\u001b[0m \u001b[38;5;129m@action\u001b[39m(reads\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprompt\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mchat_history\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmode\u001b[39m\u001b[38;5;124m\"\u001b[39m], writes\u001b[38;5;241m=\u001b[39m[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mresponse\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 92\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mimage_response\u001b[39m(state: State, model: \u001b[38;5;28mstr\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdall-e-2\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m State:\n\u001b[1;32m 93\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Generates an image response to the prompt. Optional save function to save the image to a URL.\"\"\"\u001b[39;00m\n\u001b[0;32m---> 94\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDemo error\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 95\u001b[0m client \u001b[38;5;241m=\u001b[39m openai\u001b[38;5;241m.\u001b[39mClient()\n\u001b[1;32m 96\u001b[0m result \u001b[38;5;241m=\u001b[39m client\u001b[38;5;241m.\u001b[39mimages\u001b[38;5;241m.\u001b[39mgenerate(\n\u001b[1;32m 97\u001b[0m model\u001b[38;5;241m=\u001b[39mmodel, prompt\u001b[38;5;241m=\u001b[39mstate[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprompt\u001b[39m\u001b[38;5;124m\"\u001b[39m], size\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m1024x1024\u001b[39m\u001b[38;5;124m\"\u001b[39m, quality\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstandard\u001b[39m\u001b[38;5;124m\"\u001b[39m, n\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m\n\u001b[1;32m 98\u001b[0m )\n",
+ "\u001b[0;31mValueError\u001b[0m: Demo error"
]
}
],
@@ -722,17 +764,17 @@
},
{
"cell_type": "code",
- "execution_count": 46,
+ "execution_count": 15,
"id": "f5588457208604d4",
"metadata": {},
"outputs": [],
"source": [
- "app_id = \"40f03bd6-a6bc-48a8-8e2b-dd865a629351\""
+ "app_id = \"a6d74912-9ad6-42f0-9a18-bc17c5e77eaf\""
]
},
{
"cell_type": "code",
- "execution_count": 47,
+ "execution_count": 16,
"id": "b4abab5aa575628d",
"metadata": {},
"outputs": [],
@@ -754,39 +796,25 @@
},
{
"cell_type": "code",
- "execution_count": 48,
+ "execution_count": 17,
"id": "4b21ade9-051c-453d-b3fd-f191f970c7b4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "[{'role': 'user',\n",
- " 'content': 'write hello world in python please.',\n",
- " 'type': 'text'},\n",
- " {'content': 'print(\"Hello World\")', 'type': 'code', 'role': 'assistant'},\n",
- " {'role': 'user',\n",
- " 'content': 'what about hello world in javascript?',\n",
- " 'type': 'text'},\n",
- " {'content': 'console.log(\"Hello World\");',\n",
- " 'type': 'code',\n",
- " 'role': 'assistant'},\n",
- " {'role': 'user',\n",
- " 'content': 'this is some gibberish asdfasdfads fsdasfadsdfadsfasd',\n",
- " 'type': 'text'},\n",
- " {'content': 'None of the response modes I support apply to your question. Please clarify?',\n",
+ "[{'role': 'user', 'content': 'what is the capital of France?', 'type': 'text'},\n",
+ " {'content': 'The capital of France is Paris.',\n",
" 'type': 'text',\n",
" 'role': 'assistant'},\n",
- " {'role': 'user', 'content': 'what was my last question?', 'type': 'text'},\n",
- " {'content': 'Your last question was: \"what about hello world in javascript?\"',\n",
- " 'type': 'text',\n",
+ " {'role': 'user', 'content': 'write hello world in java', 'type': 'text'},\n",
+ " {'content': '```\\npublic class HelloWorld {\\n public static void main(String[] args) {\\n System.out.println(\"Hello, World!\");\\n }\\n}\\n```',\n",
+ " 'type': 'code',\n",
" 'role': 'assistant'},\n",
- " {'role': 'user',\n",
- " 'content': 'draw me a picture of a kiwi bird',\n",
- " 'type': 'text'}]"
+ " {'role': 'user', 'content': 'draw a pen', 'type': 'text'}]"
]
},
- "execution_count": 48,
+ "execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -797,7 +825,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"id": "2186ef09eaff58d9",
"metadata": {},
"outputs": [
@@ -811,7 +839,7 @@
{
"data": {
"text/html": [
- "<img src=\"https://oaidalleapiprodscus.blob.core.windows.net/private/org-UENfV68Ccazb3rdeYDLRWmoF/user-KU9L39oZGkNLkg6ZfSLMc4AV/img-Zj7BIgqg2t4ck37Y3LvQnQ4w.png?st=2024-07-17T01%3A15%3A03Z&se=2024-07-17T03%3A15%3A03Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-07-17T00%3A31%3A59Z&ske=2024-07-18T00%3A31%3A59Z&sks=b&skv=2023-11-03&sig=x6i9a5IenxUGCogYsOAKhvqv6bCtPbUiDhz2h57Mt%2BE%3D\"/>"
+ "<img src=\"https://oaidalleapiprodscus.blob.core.windows.net/private/org-UENfV68Ccazb3rdeYDLRWmoF/user-KU9L39oZGkNLkg6ZfSLMc4AV/img-nONYcLQepD3jBslMG4staoEb.png?st=2024-08-05T20%3A52%3A15Z&se=2024-08-05T22%3A52%3A15Z&sp=r&sv=2023-11-03&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2024-08-05T12%3A52%3A48Z&ske=2024-08-06T12%3A52%3A48Z&sks=b&skv=2023-11-03&sig=qsXqOHTMZhItTdL35Nd4Zic1/Q4LHaDg%2BlFG05rExkw%3D\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
@@ -819,6 +847,27 @@
},
"metadata": {},
"output_type": "display_data"
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Hi, how can I help? what is the capital of England?\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "πŸ€–: The capital of England is London.\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "Hi, how can I help? quit\n"
+ ]
}
],
"source": [
@@ -849,7 +898,7 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 19,
"id": "c008089be309c098",
"metadata": {
"ExecuteTime": {
@@ -859,14 +908,14 @@
},
"outputs": [],
"source": [
- "app_id = \"337d0bba-528f-4bde-8358-f87f1ae7f1c9\"\n",
+ "app_id = \"a6d74912-9ad6-42f0-9a18-bc17c5e77eaf\"\n",
"sequence_id = 4\n",
"# partition_key = \"\""
]
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 20,
"id": "a8c5631cfebe8e48",
"metadata": {},
"outputs": [],
@@ -890,7 +939,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 21,
"id": "2a725130e0532f0c",
"metadata": {
"ExecuteTime": {
@@ -902,18 +951,14 @@
{
"data": {
"text/plain": [
- "[{'role': 'user',\n",
- " 'content': 'What is the capital of Australia?',\n",
- " 'type': 'text'},\n",
- " {'content': 'The capital of Australia is Canberra.',\n",
+ "[{'role': 'user', 'content': 'what is the capital of France?', 'type': 'text'},\n",
+ " {'content': 'The capital of France is Paris.',\n",
" 'type': 'text',\n",
" 'role': 'assistant'},\n",
- " {'role': 'user',\n",
- " 'content': 'What ocean is San Francisco next to?',\n",
- " 'type': 'text'}]"
+ " {'role': 'user', 'content': 'write hello world in java', 'type': 'text'}]"
]
},
- "execution_count": 23,
+ "execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
@@ -925,7 +970,7 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": null,
"id": "e27a17968c62aa98",
"metadata": {},
"outputs": [
@@ -940,31 +985,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "πŸ€–: San Francisco is next to the Pacific Ocean.\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "Hi, how can I help? Write a hello world agent\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "πŸ€–: ```python\n",
- "print(\"Hello, World!\")\n",
+ "πŸ€–: ```java\n",
+ "public class HelloWorld {\n",
+ " public static void main(String[] args) {\n",
+ " System.out.println(\"Hello, World!\");\n",
+ " }\n",
+ "}\n",
"```\n"
]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "Hi, how can I help? quit\n"
- ]
}
],
"source": [
@@ -990,7 +1018,7 @@
"source": [
"# Want to know more?\n",
"\n",
+ "[Link to video walking through this notebook](https://youtu.be/hqutVJyd3TI).\n",
"\n",
"[https://github.com/dagworks-inc/burr](https://github.com/dagworks-inc/burr)\n",
"<img src=\"burr_qrcode.png\" width=\"125\"/>\n",
@@ -1010,6 +1038,7 @@
"\n",
"Follow on Twitter & LinkedIn:\n",
"\n",
+ "- https://x.com/burr_framework\n",
"- https://x.com/dagworks\n",
"- https://x.com/stefkrawczyk\n",
"- https://www.linkedin.com/in/skrawczyk/"