Skip to content

Commit

Permalink
[Python] Handoff Bugs (#753)
Browse files Browse the repository at this point in the history
1. from_runnable_config doesn't lbyl to see if the parent is in the
order_map. Should fix
2. events are null by default here but are populated in langchain,
meaning run trees cant be treated as interchangeable in the base tracer.
  • Loading branch information
hinthornw authored May 31, 2024
1 parent 2ad492b commit 4863cf8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion python/langsmith/run_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def infer_defaults(cls, values: dict) -> dict:
else:
values["trace_id"] = values["id"]
cast(dict, values.setdefault("extra", {}))
if values.get("events") is None:
values["events"] = []
return values

@root_validator(pre=False)
Expand Down Expand Up @@ -335,7 +337,7 @@ def from_runnable_config(
)
)
):
if hasattr(tracer, "order_map"):
if hasattr(tracer, "order_map") and cb.parent_run_id in tracer.order_map:
dotted_order = tracer.order_map[cb.parent_run_id][1]
elif (
run := tracer.run_map.get(str(cb.parent_run_id))
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.1.65"
version = "0.1.66"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <support@langchain.dev>"]
license = "MIT"
Expand Down
12 changes: 12 additions & 0 deletions python/tests/unit_tests/test_run_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,15 @@ def test_run_tree_accepts_tpe() -> None:
)
def test_parse_dotted_order(inputs, expected):
assert run_trees._parse_dotted_order(inputs) == expected


def test_run_tree_events_not_null():
mock_client = MagicMock(spec=Client)
run_tree = run_trees.RunTree(
name="My Chat Bot",
inputs={"text": "Summarize this morning's meetings."},
client=mock_client,
executor=ThreadPoolExecutor(),
events=None,
)
assert run_tree.events == []

0 comments on commit 4863cf8

Please sign in to comment.