From e2b7ed887ee1c6397f9489590f6e4b41d88b0a76 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Fri, 1 Dec 2023 09:24:48 -0800 Subject: [PATCH] Update --- libs/core/langchain_core/tracers/base.py | 1 - libs/core/tests/unit_tests/runnables/test_runnable.py | 4 ++-- .../unit_tests/callbacks/tracers/test_base_tracer.py | 8 +++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/core/langchain_core/tracers/base.py b/libs/core/langchain_core/tracers/base.py index 18ec9762c0529..ff42c6b529247 100644 --- a/libs/core/langchain_core/tracers/base.py +++ b/libs/core/langchain_core/tracers/base.py @@ -69,7 +69,6 @@ def _get_stacktrace(error: BaseException) -> str: tb = traceback.format_exception(error) return msg + "\n\n".join(tb).strip() except: # noqa: E722 - breakpoint() return msg def _start_trace(self, run: Run) -> None: diff --git a/libs/core/tests/unit_tests/runnables/test_runnable.py b/libs/core/tests/unit_tests/runnables/test_runnable.py index 564e0f9d82dd0..d3f39072786d1 100644 --- a/libs/core/tests/unit_tests/runnables/test_runnable.py +++ b/libs/core/tests/unit_tests/runnables/test_runnable.py @@ -3938,7 +3938,7 @@ def raise_value_error(x: int) -> int: branch.invoke(1000, config={"callbacks": [tracer]}) assert len(tracer.runs) == 2 - assert "ValueError('x is too large')" in tracer.runs[1].error + assert "ValueError('x is too large')" in str(tracer.runs[1].error) assert tracer.runs[1].outputs is None @@ -3965,7 +3965,7 @@ async def raise_value_error(x: int) -> int: await branch.ainvoke(1000, config={"callbacks": [tracer]}) assert len(tracer.runs) == 2 - assert "ValueError('x is too large')" in tracer.runs[1].error + assert "ValueError('x is too large')" in str(tracer.runs[1].error) assert tracer.runs[1].outputs is None diff --git a/libs/langchain/tests/unit_tests/callbacks/tracers/test_base_tracer.py b/libs/langchain/tests/unit_tests/callbacks/tracers/test_base_tracer.py index f658abe260854..da8b8b7ac1f6d 100644 --- a/libs/langchain/tests/unit_tests/callbacks/tracers/test_base_tracer.py +++ b/libs/langchain/tests/unit_tests/callbacks/tracers/test_base_tracer.py @@ -329,7 +329,13 @@ def test_tracer_llm_run_on_error() -> None: tracer.on_llm_start(serialized=SERIALIZED, prompts=[], run_id=uuid) tracer.on_llm_error(exception, run_id=uuid) - assert tracer.runs == [compare_run] + assert len(tracer.runs) == 1 + received = tracer.runs[0].dict() + received_err = received.pop("error") + expected = compare_run.dict() + expected_err = expected.pop("error") + assert received == expected + assert expected_err in received_err @freeze_time("2023-01-01")