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.

updated section about persistence and added links

zilto5e3fb81c605a
diff --git a/examples/youtube-to-social-media-post/README.md b/examples/youtube-to-social-media-post/README.md
index cd09ce15..99542c14 100644
--- a/examples/youtube-to-social-media-post/README.md
+++ b/examples/youtube-to-social-media-post/README.md
@@ -2,11 +2,11 @@
The challenge with large language models (LLMs) is handling the 5% of the time they say crazy things. Being able to debug why an output is bad and having tools for fixing are critical requirements for making LLM features / agents trustworthy and available to users.
-In this example, you'll learn how `instructor` can make LLM reliability produce structured outputs, and `burr` helps you introspect and debug your application.
+In this example, you'll learn how `instructor` can make LLM reliability produce structured outputs, and `burr` helps you introspect, debug, and create tests for your application.
-In a few lines of code, you can query an LLM API and can create powerful productivity utilities. However, user-facing features deserve much more scrutiny, which requires tooling and solving complex engineering problems.
+While a LLM/agent demo takes a few lines of code, production user-facing features aren't as simple. To build trust, they need to work as intended consistently, requiring much more scrutiny and the right instrumentation. You're agent won't be perfect from the start, and tools should help you improve it iteratively and ship updates with confidence.
Building our app with Burr provides several benefits that we'll detail next:
- **Observability**: monitor in real-time and log the execution of your `Application` and view it in Burr's web user interface.
-- **Persistence**: At any point, you can save the application `State`. This allows to create user sessions (e.g., the conversation history menu in ChatGPT), which helps developers investigate bugs and test potential solutions.
+- **Persistence**: At any point, you can save the application `State`. This allows to create user sessions (e.g., the conversation history menu in ChatGPT), which helps developers investigate bugs, iterate over possible code paths, and test potential solutions in an integrated manner.
- **Portability**: your `Application` can run in a notebook, as a script, as a web service, or anywhere Python runs. We'll show how to use Burr with [FastAPI](https://fastapi.tiangolo.com/).
diff --git a/examples/youtube-to-social-media-post/notebook.ipynb b/examples/youtube-to-social-media-post/notebook.ipynb
index 1491e5c9..d6431740 100644
--- a/examples/youtube-to-social-media-post/notebook.ipynb
+++ b/examples/youtube-to-social-media-post/notebook.ipynb
@@ -136,7 +136,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -160,7 +160,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -186,7 +186,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -194,7 +194,7 @@
"output_type": "stream",
"text": [
"<class '__main__.SocialMediaPost'>\n",
- "{'topic': 'Agent Development and Debugging', 'hook': 'Ever faced challenges while developing AI agents? Fixing bugs can be a nightmare!', 'body': 'Join us in our latest video where we dive into the tools and techniques that can streamline your agent development, especially when things go off the rails. Discover the functionalities of Burr, a framework designed to help debug your agent applications without starting from scratch. From creating flowcharts to tracking your state, learn how to build and monitor your agent’s performance effectively!', 'concepts': [{'term': 'Burr Framework', 'definition': 'A framework that helps in building and debugging agent applications by modeling actions and states in a graph structure.', 'timestamp': 83.0}, {'term': 'Local Tracker', 'definition': 'A feature that allows you to initialize from a previous state and track or introspect the running application.', 'timestamp': 260.0}, {'term': 'Graph Structure', 'definition': 'A representation in which agents can model their actions and states, allowing for efficient debugging and flow control.', 'timestamp': 105.0}], 'key_takeaways': ['Streamline your AI agent debugging process.', 'Utilize the Burr framework to manage states and actions effectively.', \"Learn to visualize and control your agent's behavior through graph structures.\"], 'youtube_url': None}\n"
+ "{'topic': 'Understanding B: A Powerful Tool for Agent Applications', 'hook': '🚀 Debug with ease using B!', 'body': 'Ever faced frustrating issues while building agent applications? Dive into our latest video where we unveil the capabilities of B, a framework designed to enhance observability and debugging. Learn how to fix bugs without restarting your entire agent and explore B’s unique graph-building capabilities for a seamless coding experience. Perfect for developers looking to streamline their coding processes!', 'concepts': [{'term': 'Agent Applications', 'definition': 'Applications that utilize AI agents to perform tasks or make decisions based on input and graphs of actions.', 'timestamp': 108.0}, {'term': 'Graph Building', 'definition': 'Creating a flowchart-like structure of actions and states for better process management in applications.', 'timestamp': 179.0}, {'term': 'Local Tracker', 'definition': 'A feature within B that allows interaction with the application state for tracking and debugging purposes.', 'timestamp': 260.0}], 'key_takeaways': ['B enables easy bug fixing without restarting your agent.', 'Graph-based modeling simplifies the coding process.', 'Integrate local tracking for comprehensive observability in applications.'], 'youtube_url': None}\n"
]
}
],
@@ -212,25 +212,25 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "TOPIC: Agent Development and Debugging\n",
+ "TOPIC: Understanding B: A Powerful Tool for Agent Applications\n",
"\n",
- "Ever faced challenges while developing AI agents? Fixing bugs can be a nightmare!\n",
+ "🚀 Debug with ease using B!\n",
"\n",
- "Join us in our latest video where we dive into the tools and techniques that can streamline your agent development, especially when things go off the rails. Discover the functionalities of Burr, a framework designed to help debug your agent applications without starting from scratch. From creating flowcharts to tracking your state, learn how to build and monitor your agent’s performance effectively!\n",
+ "Ever faced frustrating issues while building agent applications? Dive into our latest video where we unveil the capabilities of B, a framework designed to enhance observability and debugging. Learn how to fix bugs without restarting your entire agent and explore B’s unique graph-building capabilities for a seamless coding experience. Perfect for developers looking to streamline their coding processes!\n",
"\n",
- "Streamline your AI agent debugging process. Utilize the Burr framework to manage states and actions effectively. Learn to visualize and control your agent's behavior through graph structures.\n",
+ "B enables easy bug fixing without restarting your agent. Graph-based modeling simplifies the coding process. Integrate local tracking for comprehensive observability in applications.\n",
"\n",
"CONCEPTS\n",
- "1:23 - Burr Framework: A framework that helps in building and debugging agent applications by modeling actions and states in a graph structure.\n",
- "4:20 - Local Tracker: A feature that allows you to initialize from a previous state and track or introspect the running application.\n",
- "1:45 - Graph Structure: A representation in which agents can model their actions and states, allowing for efficient debugging and flow control.\n"
+ "1:48 - Agent Applications: Applications that utilize AI agents to perform tasks or make decisions based on input and graphs of actions.\n",
+ "2:59 - Graph Building: Creating a flowchart-like structure of actions and states for better process management in applications.\n",
+ "4:20 - Local Tracker: A feature within B that allows interaction with the application state for tracking and debugging purposes.\n"
]
}
],
@@ -259,7 +259,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -317,7 +317,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"outputs": [
{
@@ -368,10 +368,10 @@
"</svg>\n"
],
"text/plain": [
- "<graphviz.graphs.Digraph at 0x7fb343313b80>"
+ "<graphviz.graphs.Digraph at 0x7f94ead0d270>"
]
},
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -405,27 +405,27 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
- "TOPIC: Burr Framework for Agent Applications\n",
+ "TOPIC: Debugging with Burr and Graph States\n",
"\n",
- "Unlock the potential of your AI agents with Burr!\n",
+ "Ever struggled with debugging your AI agents?\n",
"\n",
- "Ever faced frustrating failures when building your AI agent applications? Explore how the Burr framework provides robust observability and state management that lets you debug effectively and even revisit previous states. Learn how you can create dynamic action graphs that not only streamline your Dev Loop but also help you track and fix errors without starting from scratch! Dive into our latest video to see Burr in action and discover how it can revolutionize your agent-building process!\n",
+ "Dive into the world of Burr with our latest video! Learn how to leverage state tracking and condition-based flowcharts to handle failures and streamline debugging like never before. Discover how you can monitor your agents, and even resume operations from a specific point in their execution—without starting over! 🚀 Whether you’re a developer building complex applications or simply curious about AI functionality, this video will enhance your understanding of agent workflows. Don't miss out!\n",
"\n",
- "Burr enables dynamic action modeling and enhances state management. Debugging is simplified by tracking actions over time and allowing state forking. You can run applications seamlessly without starting from scratch after adjustments.\n",
+ "Learn how to handle failures in AI agent applications effectively. Understand the relationship between actions and state in your applications. Discover how to resume operations from a specific state without restarting the entire application.\n",
"\n",
"link: https://www.youtube.com/watch?v=hqutVJyd3TI\n",
"\n",
"CONCEPTS\n",
- "2:25 - State Management: A method to handle state data within applications, crucial for debugging and managing application flow.\n",
- "2:10 - Action Graphs: A representation of various actions and their interdependencies, similar to flowcharts, used for modeling AI behavior.\n",
- "0:42 - Observability: The ability to monitor and understand system state and behavior in real-time, facilitating easier debugging.\n"
+ "10:57 - State Tracking: State tracking allows you to monitor the state of your application at different points in time, making debugging easier.\n",
+ "1:50 - Flowchart: In this context, a flowchart represents the actions and their dependencies in your agent application as a directed graph.\n",
+ "3:36 - Modality: The condition that determines which action to take next in the flow of your agent’s tasks.\n"
]
}
],
@@ -515,7 +515,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -547,12 +547,12 @@
"source": [
"By adding the transition `(\"rewrite_post\", \"rewrite_post\")`, we are introducing a graph cycle. Observability and persistence becomes particularly valuable to ensure that the LLM doesn't spiral into non-sense. If that's the case, it could be due to the prompts / instructions in the application code, but also user inputs.\n",
"\n",
- "We also add a `.with_persister()` clause to store our results"
+ "We also add a `.with_persister()` clause to store our results."
]
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 22,
"metadata": {},
"outputs": [
{
@@ -564,79 +564,79 @@
"<!-- Generated by graphviz version 2.43.0 (0)\n",
" -->\n",
"<!-- Title: %3 Pages: 1 -->\n",
- "<svg width=\"409pt\" height=\"239pt\"\n",
- " viewBox=\"0.00 0.00 408.93 239.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
+ "<svg width=\"381pt\" height=\"239pt\"\n",
+ " viewBox=\"0.00 0.00 381.28 239.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 235)\">\n",
"<title>%3</title>\n",
- "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-235 404.93,-235 404.93,4 -4,4\"/>\n",
+ "<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-235 377.28,-235 377.28,4 -4,4\"/>\n",
"<!-- get_youtube_transcript -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>get_youtube_transcript</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M383.74,-166C383.74,-166 225.74,-166 225.74,-166 219.74,-166 213.74,-160 213.74,-154 213.74,-154 213.74,-142 213.74,-142 213.74,-136 219.74,-130 225.74,-130 225.74,-130 383.74,-130 383.74,-130 389.74,-130 395.74,-136 395.74,-142 395.74,-142 395.74,-154 395.74,-154 395.74,-160 389.74,-166 383.74,-166\"/>\n",
- "<text text-anchor=\"middle\" x=\"304.74\" y=\"-144.3\" font-family=\"Times,serif\" font-size=\"14.00\">get_youtube_transcript</text>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M356.09,-166C356.09,-166 198.09,-166 198.09,-166 192.09,-166 186.09,-160 186.09,-154 186.09,-154 186.09,-142 186.09,-142 186.09,-136 192.09,-130 198.09,-130 198.09,-130 356.09,-130 356.09,-130 362.09,-130 368.09,-136 368.09,-142 368.09,-142 368.09,-154 368.09,-154 368.09,-160 362.09,-166 356.09,-166\"/>\n",
+ "<text text-anchor=\"middle\" x=\"277.09\" y=\"-144.3\" font-family=\"Times,serif\" font-size=\"14.00\">get_youtube_transcript</text>\n",
"</g>\n",
"<!-- generate_post -->\n",
"<g id=\"node3\" class=\"node\">\n",
"<title>generate_post</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M351.74,-101C351.74,-101 257.74,-101 257.74,-101 251.74,-101 245.74,-95 245.74,-89 245.74,-89 245.74,-77 245.74,-77 245.74,-71 251.74,-65 257.74,-65 257.74,-65 351.74,-65 351.74,-65 357.74,-65 363.74,-71 363.74,-77 363.74,-77 363.74,-89 363.74,-89 363.74,-95 357.74,-101 351.74,-101\"/>\n",
- "<text text-anchor=\"middle\" x=\"304.74\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">generate_post</text>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M324.09,-101C324.09,-101 230.09,-101 230.09,-101 224.09,-101 218.09,-95 218.09,-89 218.09,-89 218.09,-77 218.09,-77 218.09,-71 224.09,-65 230.09,-65 230.09,-65 324.09,-65 324.09,-65 330.09,-65 336.09,-71 336.09,-77 336.09,-77 336.09,-89 336.09,-89 336.09,-95 330.09,-101 324.09,-101\"/>\n",
+ "<text text-anchor=\"middle\" x=\"277.09\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">generate_post</text>\n",
"</g>\n",
"<!-- get_youtube_transcript&#45;&gt;generate_post -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>get_youtube_transcript&#45;&gt;generate_post</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M304.74,-129.78C304.74,-124.09 304.74,-117.61 304.74,-111.34\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"308.24,-111.19 304.74,-101.19 301.24,-111.19 308.24,-111.19\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M277.09,-129.78C277.09,-124.09 277.09,-117.61 277.09,-111.34\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"280.59,-111.19 277.09,-101.19 273.59,-111.19 280.59,-111.19\"/>\n",
"</g>\n",
"<!-- input__youtube_url -->\n",
"<g id=\"node2\" class=\"node\">\n",
"<title>input__youtube_url</title>\n",
- "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"304.74\" cy=\"-213\" rx=\"96.38\" ry=\"18\"/>\n",
- "<text text-anchor=\"middle\" x=\"304.74\" y=\"-209.3\" font-family=\"Times,serif\" font-size=\"14.00\">input: youtube_url</text>\n",
+ "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"277.09\" cy=\"-213\" rx=\"96.38\" ry=\"18\"/>\n",
+ "<text text-anchor=\"middle\" x=\"277.09\" y=\"-209.3\" font-family=\"Times,serif\" font-size=\"14.00\">input: youtube_url</text>\n",
"</g>\n",
"<!-- input__youtube_url&#45;&gt;get_youtube_transcript -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
"<title>input__youtube_url&#45;&gt;get_youtube_transcript</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M304.74,-194.78C304.74,-189.09 304.74,-182.61 304.74,-176.34\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"308.24,-176.19 304.74,-166.19 301.24,-176.19 308.24,-176.19\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M277.09,-194.78C277.09,-189.09 277.09,-182.61 277.09,-176.34\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"280.59,-176.19 277.09,-166.19 273.59,-176.19 280.59,-176.19\"/>\n",
"</g>\n",
"<!-- rewrite_post -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>rewrite_post</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M250.24,-36C250.24,-36 167.24,-36 167.24,-36 161.24,-36 155.24,-30 155.24,-24 155.24,-24 155.24,-12 155.24,-12 155.24,-6 161.24,0 167.24,0 167.24,0 250.24,0 250.24,0 256.24,0 262.24,-6 262.24,-12 262.24,-12 262.24,-24 262.24,-24 262.24,-30 256.24,-36 250.24,-36\"/>\n",
- "<text text-anchor=\"middle\" x=\"208.74\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">rewrite_post</text>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M229.59,-36C229.59,-36 146.59,-36 146.59,-36 140.59,-36 134.59,-30 134.59,-24 134.59,-24 134.59,-12 134.59,-12 134.59,-6 140.59,0 146.59,0 146.59,0 229.59,0 229.59,0 235.59,0 241.59,-6 241.59,-12 241.59,-12 241.59,-24 241.59,-24 241.59,-30 235.59,-36 229.59,-36\"/>\n",
+ "<text text-anchor=\"middle\" x=\"188.09\" y=\"-14.3\" font-family=\"Times,serif\" font-size=\"14.00\">rewrite_post</text>\n",
"</g>\n",
"<!-- generate_post&#45;&gt;rewrite_post -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>generate_post&#45;&gt;rewrite_post</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M278.76,-64.95C267.88,-57.81 255.06,-49.4 243.39,-41.74\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"245.02,-38.62 234.74,-36.06 241.18,-44.48 245.02,-38.62\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M252.77,-64.78C242.86,-57.77 231.26,-49.56 220.64,-42.04\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"222.57,-39.12 212.38,-36.19 218.52,-44.83 222.57,-39.12\"/>\n",
"</g>\n",
"<!-- rewrite_post&#45;&gt;rewrite_post -->\n",
"<g id=\"edge5\" class=\"edge\">\n",
"<title>rewrite_post&#45;&gt;rewrite_post</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M262.37,-29.47C272.82,-28.13 280.24,-24.31 280.24,-18 280.24,-13.96 277.19,-10.93 272.26,-8.93\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"272.92,-5.49 262.37,-6.53 271.26,-12.29 272.92,-5.49\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M241.72,-29.47C252.17,-28.13 259.59,-24.31 259.59,-18 259.59,-13.96 256.55,-10.93 251.61,-8.93\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"252.27,-5.49 241.72,-6.53 250.62,-12.29 252.27,-5.49\"/>\n",
"</g>\n",
- "<!-- input__rewrite_prompt -->\n",
+ "<!-- input__user_prompt -->\n",
"<g id=\"node5\" class=\"node\">\n",
- "<title>input__rewrite_prompt</title>\n",
- "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"113.74\" cy=\"-83\" rx=\"113.98\" ry=\"18\"/>\n",
- "<text text-anchor=\"middle\" x=\"113.74\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">input: rewrite_prompt</text>\n",
+ "<title>input__user_prompt</title>\n",
+ "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"100.09\" cy=\"-83\" rx=\"100.18\" ry=\"18\"/>\n",
+ "<text text-anchor=\"middle\" x=\"100.09\" y=\"-79.3\" font-family=\"Times,serif\" font-size=\"14.00\">input: user_prompt</text>\n",
"</g>\n",
- "<!-- input__rewrite_prompt&#45;&gt;rewrite_post -->\n",
+ "<!-- input__user_prompt&#45;&gt;rewrite_post -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
- "<title>input__rewrite_prompt&#45;&gt;rewrite_post</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M139.2,-65.12C149.97,-57.97 162.69,-49.54 174.28,-41.85\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"176.48,-44.59 182.88,-36.15 172.61,-38.76 176.48,-44.59\"/>\n",
+ "<title>input__user_prompt&#45;&gt;rewrite_post</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M123.21,-65.45C133.18,-58.31 145,-49.85 155.81,-42.11\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"158.11,-44.77 164.2,-36.1 154.04,-39.08 158.11,-44.77\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
- "<graphviz.graphs.Digraph at 0x7fb318a68c70>"
+ "<graphviz.graphs.Digraph at 0x7f94c0175180>"
]
},
- "execution_count": 26,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -645,6 +645,9 @@
"from burr.core import ApplicationBuilder\n",
"from burr.core.persistence import SQLLitePersister\n",
"\n",
+ "persister = SQLLitePersister(db_path=\".burr.db\", table_name=\"burr_state\")\n",
+ "persister.initialize() # this will create the db and table\n",
+ "\n",
"application = (\n",
" ApplicationBuilder()\n",
" .with_actions(\n",
@@ -657,14 +660,12 @@
" (\"generate_post\", \"rewrite_post\"),\n",
" (\"rewrite_post\", \"rewrite_post\"),\n",
" )\n",
- " .with_state_persister(\n",
- " SQLLitePersister(db_path=\".burr.db\", table_name=\"state\")\n",
- " )\n",
+ " .with_state_persister(persister)\n",
" .with_entrypoint(\"get_youtube_transcript\")\n",
" .with_tracker(project=\"youtube-post\")\n",
" .build()\n",
")\n",
- "application.visualize(output_file_path=\"statemachine.png\")"
+ "application.visualize()"
]
},
{
@@ -678,20 +679,20 @@
"text": [
"LAST ACTION : generate_post: transcript -> post \n",
"\n",
- "TOPIC: Debugging and Observability in Agent Applications with Burr\n",
+ "TOPIC: Enhancing AI Agent Applications with B and Hamilton\n",
"\n",
- "🚀 Struggling to debug your AI agent? Meet Burr!\n",
+ "🚀 Dive into the world of AI agents and discover how to streamline your debugging process with B!\n",
"\n",
- "In this video, we dive into how Burr can transform your debugging experience for AI agents. Discover how it helps you monitor, debug, and handle errors without starting from scratch. With its unique approach to state management and action modeling, Burr simplifies navigating through failures and understanding your code's behavior. Let's explore the power of visualizing your application as a graph and how you can seamlessly fix issues without losing your progress! 🎥✨\n",
+ "Are you tired of constant debugging cycles in your AI projects? In our latest video, we explore B, a framework designed to help you monitor and debug agent applications efficiently. Learn how B allows you to visualize your application’s state, manage complex action flows, and even fork your state at any point to tackle bugs without restarting from scratch. Plus, discover its sister framework, Hamilton, perfect for managing data pipelines! Curious to learn how to simplify your debugging and enhance your application development? 🎥 Watch the full video now!\n",
"\n",
- "Burr offers an innovative way to visualize action flows in AI agents. Debugging becomes easier by allowing developers to fix bugs without restarting the whole application. Explore how using a state object facilitates communication between different actions in your code.\n",
+ "Learn to visualize and debug agent applications effectively with B. Understand how to manage states and actions using a graphical approach. Explore the integration of Hamilton for complex data pipeline processes.\n",
"\n",
"link: https://www.youtube.com/watch?v=hqutVJyd3TI\n",
"\n",
"CONCEPTS\n",
- "2:25 - State Object: A state object is used for reading and writing state, allowing actions within the application to communicate effectively.\n",
- "1:58 - Graph Structure: A representation of the agent's actions and states as nodes and edges, enabling clear visual tracking of the application's flow.\n",
- "4:16 - Local Tracker: A feature that helps to track and introspect your application's state during debugging and monitoring phases.\n"
+ "0:1 - B Framework: A framework for building and debugging AI agent applications, allowing for state tracking and action visualization.\n",
+ "2:25 - State Object: An object that retains the state of an application, enabling actions to read and write within that context.\n",
+ "2:0 - Graph Visualization: A depiction of actions and states in a flowchart-like manner to streamline application behavior and debugging.\n"
]
}
],
@@ -716,18 +717,20 @@
"text": [
"LAST ACTION : rewrite_post: post -> post \n",
"\n",
- "TOPIC: Debugging and Observability in Agent Applications with Burr\n",
+ "TOPIC: Enhancing AI Agent Applications with B and Hamilton\n",
+ "\n",
+ "🚀 Dive into the world of AI agents and discover how to streamline your debugging process with B!\n",
"\n",
- "🚀 Struggling to debug your AI agent? Meet Burr!\n",
+ "Are you encountering challenges with debugging cycles in your AI projects? In our latest video, we explore B, a framework designed for monitoring and debugging agent applications effectively. With B, you can visualize your application’s state, manage complex action flows, and fork your state to tackle bugs without having to restart from scratch. Additionally, we introduce Hamilton, a framework that complements B by simplifying the management of data pipelines. If you are interested in improving your debugging process and application development, we invite you to watch the full video!\n",
"\n",
- "In this informative video, we explore how Burr can enhance your debugging experience for AI agents. Learn about its capabilities in monitoring, debugging, and managing errors without the need to start from scratch. Discover the role of state management and action modeling in simplifying the navigation through failures and understanding your code's behavior. We will also discuss how visualizing your application as a graph can help in seamlessly addressing issues while retaining progress. Click the link to learn more! 🎥✨\n",
+ "Learn to visualize and debug agent applications effectively with B. Understand how to manage states and actions using a graphical approach. Explore the integration of Hamilton for complex data pipeline processes.\n",
"\n",
- "Burr offers an innovative way to visualize action flows in AI agents. Debugging becomes easier by allowing developers to fix bugs without restarting the whole application. Explore how using a state object facilitates communication between different actions in your code.\n",
+ "link: https://www.youtube.com/watch?v=hqutVJyd3TI\n",
"\n",
"CONCEPTS\n",
- "2:25 - State Object: A state object is used for reading and writing state, allowing actions within the application to communicate effectively.\n",
- "1:58 - Graph Structure: A representation of the agent's actions and states as nodes and edges, enabling clear visual tracking of the application's flow.\n",
- "4:16 - Local Tracker: A feature that helps to track and introspect your application's state during debugging and monitoring phases.\n"
+ "0:1 - B Framework: A framework for building and debugging AI agent applications, allowing for state tracking and action visualization.\n",
+ "2:25 - State Object: An object that retains the state of an application, enabling actions to read and write within that context.\n",
+ "2:0 - Graph Visualization: A depiction of actions and states in a flowchart-like manner to streamline application behavior and debugging.\n"
]
}
],
@@ -740,6 +743,65 @@
"print(state[\"post\"].display())"
]
},
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Then, you can retrieve the store app ids and resume from there. This requires adding a `.initialize_from()` with the `persister`. Also, we're getting the `app_id` from storage via `persister.list_app_ids()`. By passing it to the `.with_identifiers(app_id=...)`, this \"reloaded application\" will logged and tracked in succession of the original app (as you can see in the Burr UI).\n",
+ "\n",
+ "Below, we're building a new `Application` from the persisted state. When we print the `State`, we're able to retrieve the previously generated (you can see the matching titles)!"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Enhancing AI Agent Applications with B and Hamilton\n"
+ ]
+ }
+ ],
+ "source": [
+ "app_id = persister.list_app_ids(\"\")[0]\n",
+ "\n",
+ "reloaded_app = (\n",
+ " ApplicationBuilder()\n",
+ " .with_actions(\n",
+ " get_youtube_transcript,\n",
+ " generate_post.bind(llm_client=llm_client),\n",
+ " rewrite_post.bind(llm_client=llm_client),\n",
+ " )\n",
+ " .with_transitions(\n",
+ " (\"get_youtube_transcript\", \"generate_post\"),\n",
+ " (\"generate_post\", \"rewrite_post\"),\n",
+ " (\"rewrite_post\", \"rewrite_post\"),\n",
+ " )\n",
+ " .initialize_from(\n",
+ " persister,\n",
+ " resume_at_next_action=True,\n",
+ " default_state={},\n",
+ " default_entrypoint=\"get_youtube_transcript\",\n",
+ " )\n",
+ " .with_state_persister(persister)\n",
+ " .with_identifiers(app_id=app_id)\n",
+ " .with_tracker(project=\"youtube-post\")\n",
+ " .build()\n",
+ ")\n",
+ "\n",
+ "print(reloaded_app.state[\"post\"].topic)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Persistence is great for iterative development such as tuning your [Instructor model with validators and constraints](https://python.useinstructor.com/concepts/reask_validation/), but it's also a powerful tool for building [test cases and guard rails](https://burr.dagworks.io/examples/creating_tests/). The CLI command `burr-test-case` can generate a `pytest.fixture` to resume your app from a given state."
+ ]
+ },
{
"cell_type": "markdown",
"metadata": {},