From 4c95c99a54badf8d86e1f41d43cad6e876d0b2ea Mon Sep 17 00:00:00 2001 From: ykriger-newrelic <97446848+ykriger-newrelic@users.noreply.github.com> Date: Sun, 10 Sep 2023 12:44:01 +0530 Subject: [PATCH] Fix error str (#23) * Update langchain_callback.py * Update langchain_callback.py --- src/nr_openai_observability/langchain_callback.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/nr_openai_observability/langchain_callback.py b/src/nr_openai_observability/langchain_callback.py index f6bdaa4..0e284ef 100644 --- a/src/nr_openai_observability/langchain_callback.py +++ b/src/nr_openai_observability/langchain_callback.py @@ -139,7 +139,7 @@ def on_chain_error( self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> Any: """Run when chain errors.""" - tags = {error: str(error)} + tags = {"error": str(error)} span = self.spans_stack.pop() assert span["attributes"]["name"] == "LlmChain" self.finish_and_record_span(span, tags) @@ -173,9 +173,7 @@ def on_tool_error( self, error: Union[Exception, KeyboardInterrupt], **kwargs: Any ) -> Any: """Run when tool errors.""" - tags = { - "error": error, - } + tags = {"error": str(error)} span = self.spans_stack.pop() assert span["attributes"]["name"] == "LlmTool" tool_name = kwargs.get("name")