Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.
Python aiburrchatbot-frameworkdagsgenerative-aigraphshacktoberfestllmopsllmsmlopspersistent-data-structurestate-machinestate-managementvisibility
Changes everything to use demo_ instead of demo: -- this is a cleaner way of doing it
elijahbenizzy3c3c25dce7e5
diff --git a/burr/cli/__main__.py b/burr/cli/__main__.pyindex ac33b0a8..085e6ca1 100644--- a/burr/cli/__main__.py+++ b/burr/cli/__main__.py@@ -9,7 +9,7 @@ import webbrowserfrom contextlib import contextmanagerfrom importlib.resources import files-from burr import telemetry+from burr import system, telemetryfrom burr.core.persistence import PersistedStateDatafrom burr.integrations.base import require_plugin@@ -24,8 +24,6 @@ except ImportError as e:"start",)-IS_WINDOWS = os.name == "nt"-# TODO -- add this as a general callback to the CLIdef _telemetry_if_enabled(event: str):@@ -117,7 +115,7 @@ def _run_server(port: int, dev_mode: bool, no_open: bool, no_copy_demo_data: boofor top_level in os.listdir(demo_data_path):if not os.path.exists(f"{base_dir}/{top_level}"):# this is purely for legacy -- we used to name with `demo_`- if not IS_WINDOWS and os.path.exists(+ if not system.IS_WINDOWS and os.path.exists(f"{base_dir}/{top_level.replace('demo_', 'demo:')}"):# in this case we don't need to copy it over, it already exists in the right place...diff --git a/burr/system.py b/burr/system.pynew file mode 100644index 00000000..4e17099e--- /dev/null+++ b/burr/system.py@@ -0,0 +1,3 @@+import os++IS_WINDOWS = os.name == "nt"diff --git a/burr/tracking/client.py b/burr/tracking/client.pyindex b74c17de..97fda069 100644--- a/burr/tracking/client.py+++ b/burr/tracking/client.py@@ -15,6 +15,7 @@ from burr.lifecycle import (PreRunStepHook,PreStartSpanHook,)+from burr.system import IS_WINDOWSfrom burr.tracking.common.models import (ApplicationMetadataModel,ApplicationModel,@@ -80,15 +81,16 @@ class LocalTrackingClient("""self.f = None+ if ":" in project and IS_WINDOWS:+ raise ValueError(+ "Project name cannot contain ':' -- this is purely as we're using the filesystem as a storage utility."+ )self.storage_dir = LocalTrackingClient.get_storage_path(project, storage_dir)self.project_id = project@classmethoddef get_storage_path(cls, project, storage_dir) -> str:- # need to replace `:` with `_` for the project_id; it becomes part of the path and characters- # need to work on windows, etc.- sanitized_project_id = project.replace(":", "_")- return os.path.join(os.path.expanduser(storage_dir), sanitized_project_id)+ return str(os.path.join(os.path.expanduser(storage_dir), project))@classmethoddef app_log_exists(diff --git a/burr/tracking/server/backend.py b/burr/tracking/server/backend.pyindex 1dcdbec1..40d5ae62 100644--- a/burr/tracking/server/backend.py+++ b/burr/tracking/server/backend.py@@ -60,10 +60,10 @@ class BackendBase(abc.ABC):def get_uri(project_id: str) -> str:project_id_map = {- "demo:counter": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/hello-world-counter",- "demo:tracing": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/tracing-and-spans/application.py",- "demo:chatbot": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/multi-modal-chatbot",- "demo:conversational-rag": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/conversational-rag",+ "demo_counter": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/hello-world-counter",+ "demo_tracing": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/tracing-and-spans/application.py",+ "demo_chatbot": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/multi-modal-chatbot",+ "demo_conversational-rag": "https://github.com/DAGWorks-Inc/burr/tree/main/examples/conversational-rag",}return project_id_map.get(project_id, "")diff --git a/docs/concepts/tracking.rst b/docs/concepts/tracking.rstindex f3be5a7f..94de4e31 100644--- a/docs/concepts/tracking.rst+++ b/docs/concepts/tracking.rst@@ -56,7 +56,7 @@ For example, as you initialize the Burr Application, you'd have some control flofrom burr.tracking import client- project_name = "demo:hamilton-multi-agent"+ project_name = "demo_hamilton-multi-agent"if app_instance_id:initial_state, entry_point = client.LocalTrackingClient.load_state(project_name, app_instance_iddiff --git a/docs/getting_started/up-next.rst b/docs/getting_started/up-next.rstindex 45fbe226..53764d04 100644--- a/docs/getting_started/up-next.rst+++ b/docs/getting_started/up-next.rst@@ -9,7 +9,7 @@ All of the following are pre-populated in the UI under ``projects/``. You can stburr-Telemetry UI chatbot demo ``demo:chatbot``+Telemetry UI chatbot demo ``demo_chatbot``------------------------------------------You'll need the env variable ``OPENAI_API_KEY`` set to your api key for this to work. If you don't@@ -39,7 +39,7 @@ For the next examples you'll need the repository cloned:git clone https://github.com/dagworks-inc/burr && cd burr--------------------------------Simple Counter ``demo:counter``+Simple Counter ``demo_counter``-------------------------------.. code-block:: bash@@ -48,7 +48,7 @@ Simple Counter ``demo:counter``python application.py--------------------------------------------Interactive RAG ``demo:conversational-rag``+Interactive RAG ``demo_conversational-rag``-------------------------------------------This is a toy interactive RAG example. You'll ask questions in the terminal about information it already has...diff --git a/examples/conversational-rag/application.py b/examples/conversational-rag/application.pyindex 69e707d7..1f798c49 100644--- a/examples/conversational-rag/application.py+++ b/examples/conversational-rag/application.py@@ -107,7 +107,7 @@ def application(("human_converse", "ai_converse", default),).with_entrypoint("human_converse")- .with_tracker(project="demo:conversational-rag", params={"storage_dir": storage_dir})+ .with_tracker(project="demo_conversational-rag", params={"storage_dir": storage_dir}).with_identifiers(app_id=app_id, partition_key="sample_user").with_hooks(*hooks if hooks else []).build()diff --git a/examples/conversational-rag/notebook.ipynb b/examples/conversational-rag/notebook.ipynbindex b7799cb8..c880910f 100644--- a/examples/conversational-rag/notebook.ipynb+++ b/examples/conversational-rag/notebook.ipynb@@ -457,7 +457,7 @@" # add a hook to print the steps -- optional but shows that Burr is pluggable\n"," .with_hooks(PrintStepHook())\n"," # add tracking -- this will show up in the BURR UI.\n",- " .with_tracker(project=\"demo:conversational-rag\")\n",+ " .with_tracker(project=\"demo_conversational-rag\")\n"," # build the application\n"," .build()\n",")"@@ -851,7 +851,7 @@"rewind_to_sequence_id = last_sequence_id - 2\n","new_app_id = str(uuid.uuid4())\n","\n",- "project_name = \"demo:conversational-rag\"\n",+ "project_name = \"demo_conversational-rag\"\n","# we use the tracking client here to get the state of the application at a prior sequence_id\n","tracker = LocalTrackingClient(project=project_name)\n","persisted_state = tracker.load(partition_key=\"sample_user\", \n",@@ -1018,7 +1018,7 @@"prior_app_id = app_id\n","new_app_id = str(uuid.uuid4())\n","\n",- "project_name = \"demo:conversational-rag\"\n",+ "project_name = \"demo_conversational-rag\"\n","# we use the tracking client here to get the state of the application at a prior sequence_id\n","tracker = LocalTrackingClient(project=project_name)\n","pick_up_where_we_left_off_app = (\n",diff --git a/examples/email-assistant/application.py b/examples/email-assistant/application.pyindex 2726699f..9b5caaf3 100644--- a/examples/email-assistant/application.py+++ b/examples/email-assistant/application.py@@ -148,7 +148,7 @@ def final_result(state: State) -> Tuple[dict, State]:def application(- app_id: str = None, project: str = "demo:email_assistant", username: str = None+ app_id: str = None, project: str = "demo_email_assistant", username: str = None) -> Application:tracker = LocalTrackingClient(project=project)builder = (diff --git a/examples/email-assistant/notebook.ipynb b/examples/email-assistant/notebook.ipynbindex 6a68b72c..4e8d1476 100644--- a/examples/email-assistant/notebook.ipynb+++ b/examples/email-assistant/notebook.ipynb@@ -89,7 +89,7 @@"outputs": [],"source": ["from IPython.display import Markdown\n",- "url = f\"[Link to UI](http://localhost:7241/project/demo:email_assistant/{app.uid})\"\n",+ "url = f\"[Link to UI](http://localhost:7241/project/demo_email_assistant/{app.uid})\"\n","Markdown(url)"]},diff --git a/examples/hello-world-counter/application.py b/examples/hello-world-counter/application.pyindex 48d9eb5c..3cba6d26 100644--- a/examples/hello-world-counter/application.py+++ b/examples/hello-world-counter/application.py@@ -44,7 +44,7 @@ def application(default_entrypoint="counter",).with_state_persister(persister)- .with_tracker(project="demo:counter", params={"storage_dir": storage_dir})+ .with_tracker(project="demo_counter", params={"storage_dir": storage_dir}).with_hooks(*hooks if hooks else []).build())diff --git a/examples/hello-world-counter/notebook.ipynb b/examples/hello-world-counter/notebook.ipynbindex 2fa6d25a..89123b9b 100644--- a/examples/hello-world-counter/notebook.ipynb+++ b/examples/hello-world-counter/notebook.ipynb@@ -156,7 +156,7 @@" default_entrypoint=\"counter\",\n"," )\n"," .with_state_persister(persister)\n",- " .with_tracker(project=\"demo:counter\", params={\"storage_dir\": storage_dir})\n",+ " .with_tracker(project=\"demo_counter\", params={\"storage_dir\": storage_dir})\n"," .with_hooks(*hooks if hooks else [])\n"," .build()\n",")\n",diff --git a/examples/llm-adventure-game/application.py b/examples/llm-adventure-game/application.pyindex 5a5b96e6..a4d4deea 100644--- a/examples/llm-adventure-game/application.py+++ b/examples/llm-adventure-game/application.py@@ -125,7 +125,7 @@ def application(("maybe_progress", "prompt_for_challenge", default),).with_entrypoint("start")- .with_tracker(project="demo:corgi_adventure", params={"storage_dir": storage_dir})+ .with_tracker(project="demo_corgi_adventure", params={"storage_dir": storage_dir}).with_identifiers(app_id=app_id).build())diff --git a/examples/multi-agent-collaboration/hamilton/alternative_implementation.py b/examples/multi-agent-collaboration/hamilton/alternative_implementation.pyindex 52c728bd..ba4bf7c0 100644--- a/examples/multi-agent-collaboration/hamilton/alternative_implementation.py+++ b/examples/multi-agent-collaboration/hamilton/alternative_implementation.py@@ -134,7 +134,7 @@ def default_state_and_entry_point() -> tuple[dict, str]:def application(app_instance_id: Optional[str] = None):- project_name = "demo:hamilton-multi-agent"+ project_name = "demo_hamilton-multi-agent"# TODO -- use the new persistence APIif app_instance_id:state, entry_point = burr_tclient.LocalTrackingClient.load_state(diff --git a/examples/multi-agent-collaboration/hamilton/application.py b/examples/multi-agent-collaboration/hamilton/application.pyindex b16dc891..0fde32bd 100644--- a/examples/multi-agent-collaboration/hamilton/application.py+++ b/examples/multi-agent-collaboration/hamilton/application.py@@ -235,7 +235,7 @@ def main(query: str = None, app_instance_id: str = None, sequence_number: int =:param sequence_number: a prior sequence number to restart from.:return:"""- project_name = "demo:hamilton-multi-agent-v1"+ project_name = "demo_hamilton-multi-agent-v1"if app_instance_id:tracker = burr_tclient.LocalTrackingClient(project_name)persisted_state = tracker.load("demo", app_id=app_instance_id, sequence_no=sequence_number)diff --git a/examples/multi-agent-collaboration/hamilton/notebook.ipynb b/examples/multi-agent-collaboration/hamilton/notebook.ipynbindex f51f6273..e0977df8 100644--- a/examples/multi-agent-collaboration/hamilton/notebook.ipynb+++ b/examples/multi-agent-collaboration/hamilton/notebook.ipynb@@ -847,7 +847,7 @@"# Adjust these if you want to load a prior execution\n","app_instance_id = None\n","sequence_id = None\n",- "project_name = \"demo:hamilton-multi-agent-v1\"\n",+ "project_name = \"demo_hamilton-multi-agent-v1\"\n","\n","# CHANGE THIS IF YOU WANT SOMETHING DIFFERENT!\n","default_query = (\"Fetch the UK's GDP over the past 5 years, then draw a line graph of it. \"\n",diff --git a/examples/multi-agent-collaboration/lcel/application.py b/examples/multi-agent-collaboration/lcel/application.pyindex a764cfce..96f86399 100644--- a/examples/multi-agent-collaboration/lcel/application.py+++ b/examples/multi-agent-collaboration/lcel/application.py@@ -221,7 +221,7 @@ def main(query: str = None, app_instance_id: str = None, sequence_id: int = NonePass in an app_instance_id to restart from a previous run.Pass in an sequence_id to restart from a previous run and a specific position in it."""- project_name = "demo:lcel-multi-agent"+ project_name = "demo_lcel-multi-agent"if app_instance_id:tracker = burr_tclient.LocalTrackingClient(project_name)persisted_state = tracker.load("demo", app_id=app_instance_id, sequence_no=sequence_id)diff --git a/examples/multi-agent-collaboration/lcel/notebook.ipynb b/examples/multi-agent-collaboration/lcel/notebook.ipynbindex 77a66cf1..01413f8f 100644--- a/examples/multi-agent-collaboration/lcel/notebook.ipynb+++ b/examples/multi-agent-collaboration/lcel/notebook.ipynb@@ -362,7 +362,7 @@"# Adjust these if you want to load a prior execution\n","app_instance_id = None\n","sequence_id = None\n",- "project_name = \"demo:lcel-multi-agent\"\n",+ "project_name = \"demo_lcel-multi-agent\"\n","\n","# CHANGE THIS IF YOU WANT SOMETHING DIFFERENT!\n","default_query = (\"Fetch the UK's GDP over the past 5 years, then draw a line graph of it. \"\n",diff --git a/examples/multi-modal-chatbot/application.py b/examples/multi-modal-chatbot/application.pyindex 19a71fb7..aa5914c9 100644--- a/examples/multi-modal-chatbot/application.py+++ b/examples/multi-modal-chatbot/application.py@@ -200,7 +200,7 @@ def base_application(def application(app_id: Optional[str] = None,- project_id: str = "demo:chatbot",+ project_id: str = "demo_chatbot",storage_dir: Optional[str] = "~/.burr",hooks: Optional[List[LifecycleAdapter]] = None,) -> Application:diff --git a/examples/multi-modal-chatbot/notebook.ipynb b/examples/multi-modal-chatbot/notebook.ipynbindex a4592748..d5fd937d 100644--- a/examples/multi-modal-chatbot/notebook.ipynb+++ b/examples/multi-modal-chatbot/notebook.ipynb@@ -79,7 +79,7 @@"outputs": [],"source": ["from IPython.display import Markdown\n",- "url = f\"[Link to UI](http://localhost:7241/project/demo:chatbot/{app.uid})\"\n",+ "url = f\"[Link to UI](http://localhost:7241/project/demo_chatbot/{app.uid})\"\n","Markdown(url)"]}diff --git a/examples/simple-chatbot-intro/application.py b/examples/simple-chatbot-intro/application.pyindex b7a4808c..418524a3 100644--- a/examples/simple-chatbot-intro/application.py+++ b/examples/simple-chatbot-intro/application.py@@ -70,7 +70,7 @@ def application():).with_state(chat_history=[]).with_entrypoint("human_input")- .with_tracker("local", project="demo:getting_started")+ .with_tracker("local", project="demo_getting_started").build())diff --git a/examples/simple-chatbot-intro/notebook.ipynb b/examples/simple-chatbot-intro/notebook.ipynbindex 82cae4de..641ef57e 100644--- a/examples/simple-chatbot-intro/notebook.ipynb+++ b/examples/simple-chatbot-intro/notebook.ipynb@@ -262,7 +262,7 @@" ).with_state(chat_history=[])\n"," .with_entrypoint(\"human_input\")\n"," .with_tracker(\n",- " \"local\", project=\"demo:getting_started\"\n",+ " \"local\", project=\"demo_getting_started\"\n"," ).build()\n",")"]@@ -318,7 +318,7 @@"outputs": [],"source": ["from IPython.display import Markdown\n",- "url = f\"[Link to UI](http://localhost:7241/project/demo:getting_started/{app_with_tracker.uid})\"\n",+ "url = f\"[Link to UI](http://localhost:7241/project/demo_getting_started/{app_with_tracker.uid})\"\n","Markdown(url)"]},@@ -335,7 +335,7 @@"get_ipython().system = os.system\n","!burr --no-open > /dev/null 2>&1 &\n","time.sleep(3) # quick trick to wait for the server to start\n",- "url = f\"http://localhost:7241/project/demo:getting_started/{app_with_tracker.uid}\"\n",+ "url = f\"http://localhost:7241/project/demo_getting_started/{app_with_tracker.uid}\"\n","iframe = f'<iframe src=\"{url}\" width=\"100%\" height=\"1000px\"></iframe>'\n","display(HTML(iframe))"]@@ -400,7 +400,7 @@" ).with_state_persister(sqllite_persister)\n"," .with_identifiers(app_id=app_id, partition_key=partition_key)\n"," .with_tracker(\n",- " \"local\", project=\"demo:getting_started\"\n",+ " \"local\", project=\"demo_getting_started\"\n"," ).build()\n"," )"]diff --git a/examples/streaming-overview/application.py b/examples/streaming-overview/application.pyindex c10dca68..dc531395 100644--- a/examples/streaming-overview/application.py+++ b/examples/streaming-overview/application.py@@ -165,7 +165,7 @@ def application(app_id: Optional[str] = None):"prompt",),)- .with_tracker(project="demo:chatbot_streaming")+ .with_tracker(project="demo_chatbot_streaming").with_identifiers(app_id=app_id).build())diff --git a/examples/tracing-and-spans/application.py b/examples/tracing-and-spans/application.pyindex 42a85531..d3bb8244 100644--- a/examples/tracing-and-spans/application.py+++ b/examples/tracing-and-spans/application.py@@ -182,7 +182,7 @@ def application(),("response", "prompt", default),)- .with_tracker(project="demo:tracing", params={"storage_dir": storage_dir})+ .with_tracker(project="demo_tracing", params={"storage_dir": storage_dir}).with_identifiers(app_id=app_id).build())diff --git a/examples/tracing-and-spans/notebook.ipynb b/examples/tracing-and-spans/notebook.ipynbindex ac7d74ed..bb69850e 100644--- a/examples/tracing-and-spans/notebook.ipynb+++ b/examples/tracing-and-spans/notebook.ipynb@@ -315,7 +315,7 @@{"data": {"text/markdown": [- "[Link to UI](http://localhost:7241/project/demo:tracing/d50acb12-080d-499c-b1d5-719862b8ae58)"+ "[Link to UI](http://localhost:7241/project/demo_tracing/d50acb12-080d-499c-b1d5-719862b8ae58)"],"text/plain": ["<IPython.core.display.Markdown object>"@@ -328,7 +328,7 @@],"source": ["from IPython.display import Markdown\n",- "url = f\"[Link to UI](http://localhost:7241/project/demo:tracing/{app.uid})\"\n",+ "url = f\"[Link to UI](http://localhost:7241/project/demo_tracing/{app.uid})\"\n","Markdown(url)"]}diff --git a/telemetry/ui/src/examples/Chatbot.tsx b/telemetry/ui/src/examples/Chatbot.tsxindex e5e8d86e..cbb586e7 100644--- a/telemetry/ui/src/examples/Chatbot.tsx+++ b/telemetry/ui/src/examples/Chatbot.tsx@@ -301,7 +301,7 @@ export const ChatbotAppSelector = (props: {};export const ChatbotWithTelemetry = () => {- const currentProject = 'demo:chatbot';+ const currentProject = 'demo_chatbot';const [currentApp, setCurrentApp] = useState<ApplicationSummary | undefined>(undefined);return (diff --git a/telemetry/ui/src/examples/EmailAssistant.tsx b/telemetry/ui/src/examples/EmailAssistant.tsxindex fe527f6f..e9c4a325 100644--- a/telemetry/ui/src/examples/EmailAssistant.tsx+++ b/telemetry/ui/src/examples/EmailAssistant.tsx@@ -436,7 +436,7 @@ export const EmailAssistantAppSelector = (props: {};export const EmailAssistantWithTelemetry = () => {- const currentProject = 'demo:email-assistant';+ const currentProject = 'demo_email-assistant';const [currentApp, setCurrentApp] = useState<ApplicationSummary | undefined>(undefined);return (