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.

Updates examples for persistence

elijahbenizzy1cacbb3faff0
diff --git a/examples/.DS_Store b/examples/.DS_Store
new file mode 100644
index 00000000..9fb52aab
Binary files /dev/null and b/examples/.DS_Store differ
diff --git a/examples/conversational_rag/application.py b/examples/conversational_rag/application.py
index 0c95042c..cafa0d50 100644
--- a/examples/conversational_rag/application.py
+++ b/examples/conversational_rag/application.py
@@ -94,9 +94,8 @@ def application(
("human_converse", "ai_converse", default),
)
.with_entrypoint("human_converse")
- .with_tracker(
- project="demo:conversational-rag", params={"app_id": app_id, "storage_dir": storage_dir}
- )
+ .with_tracker(project="demo:conversational-rag", params={"storage_dir": storage_dir})
+ .with_identifiers(app_id=app_id)
.with_hooks(*hooks if hooks else [])
.build()
)
diff --git a/examples/corgi_adventure/application.py b/examples/corgi_adventure/application.py
index ece9910c..4a9f7fd7 100644
--- a/examples/corgi_adventure/application.py
+++ b/examples/corgi_adventure/application.py
@@ -127,9 +127,8 @@ def application(
("maybe_progress", "prompt_for_challenge", default),
)
.with_entrypoint("start")
- .with_tracker(
- project="demo:corgi_adventure", params={"app_id": app_id, "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/counter/application.py b/examples/counter/application.py
index 19619ce0..37af7ec9 100644
--- a/examples/counter/application.py
+++ b/examples/counter/application.py
@@ -4,7 +4,7 @@ from typing import List, Optional, Tuple
import burr.core
from burr.core import Application, Result, State, default, expr
from burr.core.action import action
-from burr.core.state import SQLLitePersistence
+from burr.core.state import SQLLitePersister
from burr.lifecycle import LifecycleAdapter
logger = logging.getLogger(__name__)
@@ -13,9 +13,6 @@ logger = logging.getLogger(__name__)
@action(reads=["counter"], writes=["counter"])
def counter(state: State) -> Tuple[dict, State]:
result = {"counter": state["counter"] + 1}
- # import random
- # if random.random() < 0.5:
- # raise ValueError("random error")
print(f"counted to {result['counter']}")
return result, state.update(**result)
@@ -27,7 +24,7 @@ def application(
storage_dir: Optional[str] = "~/.burr",
hooks: Optional[List[LifecycleAdapter]] = None,
) -> Application:
- persister = SQLLitePersistence("demos.db", "counter")
+ persister = SQLLitePersister("demos.db", "counter")
persister.initialize()
logger.info(
f"{partition_key} has these prior invocations: {persister.list_app_ids(partition_key)}"
@@ -44,7 +41,7 @@ def application(
persister,
resume_at_next_action=True,
default_state={"counter": 0},
- default_entry_point="counter",
+ default_entrypoint="counter",
)
.with_state_persister(persister)
.with_tracker(project="demo:counter", params={"storage_dir": storage_dir})
diff --git a/examples/gpt/.DS_Store b/examples/gpt/.DS_Store
new file mode 100644
index 00000000..bd2ca2d0
Binary files /dev/null and b/examples/gpt/.DS_Store differ
diff --git a/examples/gpt/application.py b/examples/gpt/application.py
index 130b81ee..144fb267 100644
--- a/examples/gpt/application.py
+++ b/examples/gpt/application.py
@@ -165,7 +165,8 @@ def base_application(hooks: List[LifecycleAdapter], app_id: str, storage_dir: st
("response", "prompt", default),
)
.with_hooks(*hooks)
- .with_tracker(project="demo:chatbot", params={"app_id": app_id, "storage_dir": storage_dir})
+ .with_tracker(project="demo:chatbot", params={"storage_dir": storage_dir})
+ .with_identifiers(app_id=app_id)
.build()
)
@@ -231,7 +232,8 @@ def hamilton_application(hooks: List[LifecycleAdapter], app_id: str, storage_dir
("response", "prompt", default),
)
.with_hooks(*hooks)
- .with_tracker(project="demo:chatbot", params={"app_id": app_id, "storage_dir": storage_dir})
+ .with_tracker(project="demo:chatbot", params={"storage_dir": storage_dir})
+ .with_identifiers(app_id=app_id)
.build()
)
return application
diff --git a/examples/gpt/application_with_traces.py b/examples/gpt/application_with_traces.py
index f8f5ee91..2c39b54b 100644
--- a/examples/gpt/application_with_traces.py
+++ b/examples/gpt/application_with_traces.py
@@ -190,7 +190,8 @@ def base_application(hooks: List[LifecycleAdapter], app_id: str, storage_dir: st
("response", "prompt", default),
)
.with_hooks(*hooks)
- .with_tracker(project="demo:tracing", params={"app_id": app_id, "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/multi-agent-collaboration/func_agent.py b/examples/multi-agent-collaboration/func_agent.py
index d8e38596..8d95e04b 100644
--- a/examples/multi-agent-collaboration/func_agent.py
+++ b/examples/multi-agent-collaboration/func_agent.py
@@ -166,7 +166,7 @@ def llm_function_message(
"content": None,
"tool_calls": [
{
- "id": t.id,
+ "id": t.uid,
"type": "function",
"function": {"name": t.function.name, "arguments": t.function.arguments},
}
@@ -193,7 +193,7 @@ def parsed_tool_calls(
if tool_calls:
for tool_call in tool_calls:
func_call = {
- "id": tool_call.id,
+ "id": tool_call.uid,
"function_name": tool_call.function.name,
"function_args": tool_call.function.arguments,
}
diff --git a/examples/multi-agent-collaboration/hamilton_application.py b/examples/multi-agent-collaboration/hamilton_application.py
index 4370765e..73faf0e1 100644
--- a/examples/multi-agent-collaboration/hamilton_application.py
+++ b/examples/multi-agent-collaboration/hamilton_application.py
@@ -2,7 +2,8 @@ import json
from typing import Any, Dict, Optional
import func_agent
-from hamilton import driver, lifecycle
+from hamilton import driver
+from hamilton import lifecycle as h_lifecycle
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_experimental.utilities import PythonREPL
@@ -13,7 +14,7 @@ from burr.tracking import client as burr_tclient
from burr.visibility import ActionSpanTracer, TracerFactory
-class SimpleTracer(lifecycle.NodeExecutionHook):
+class SimpleTracer(h_lifecycle.NodeExecutionHook):
"""Simple Hamilton Tracer"""
def __init__(self, tracer: TracerFactory):
diff --git a/examples/streaming_chatbot/application.py b/examples/streaming_chatbot/application.py
index cc4a6dd5..fa7f5c58 100644
--- a/examples/streaming_chatbot/application.py
+++ b/examples/streaming_chatbot/application.py
@@ -169,7 +169,8 @@ def application(hooks: List[LifecycleAdapter], app_id: Optional[str] = None):
),
)
.with_hooks(*hooks)
- .with_tracker(project="demo:chatbot_streaming", params={"app_id": app_id})
+ .with_tracker(project="demo:chatbot_streaming")
+ .with_identifiers(app_id=app_id)
.build()
)