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.

Fixes up tracking -- adds serialization filter + __init__.py file

elijahbenizzyd39db32a323d
diff --git a/burr/tracking/common/__init__.py b/burr/tracking/common/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/burr/tracking/common/models.py b/burr/tracking/common/models.py
index c3438632..75f8f85b 100644
--- a/burr/tracking/common/models.py
+++ b/burr/tracking/common/models.py
@@ -86,6 +86,13 @@ class ApplicationModel(IdentifyingModel):
)
+INPUT_FILTERLIST = {"__tracer"}
+
+
+def _filter_inputs(d: dict) -> dict:
+ return {k: v for k, v in d.items() if k not in INPUT_FILTERLIST}
+
+
class BeginEntryModel(IdentifyingModel):
"""Pydantic model that represents an entry for the beginning of a step"""
@@ -94,6 +101,10 @@ class BeginEntryModel(IdentifyingModel):
inputs: Dict[str, Any]
type: str = "begin_entry"
+ @field_serializer("inputs")
+ def serialize_inputs(self, inputs):
+ return _serialize_object(_filter_inputs(inputs))
+
def _serialize_object(d: object) -> Union[dict, list, object]:
if isinstance(d, list):
@@ -104,8 +115,7 @@ def _serialize_object(d: object) -> Union[dict, list, object]:
return d.model_dump()
elif hasattr(d, "to_json"):
return d.to_json()
- else:
- return d
+ return d
class EndEntryModel(IdentifyingModel):