From b95bdfcb96c514f1ff9f4f1847b3b1065eb9270d Mon Sep 17 00:00:00 2001 From: Roger Yang <80478925+RogerHYang@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:40:29 -0800 Subject: [PATCH 1/2] fix: erroneous if statement --- .../src/openinference/instrumentation/langchain/_tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py b/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py index 0a75a314b..2968e9ac1 100644 --- a/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py +++ b/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py @@ -357,7 +357,7 @@ def _prompt_template(serialized: Optional[Mapping[str, Any]]) -> Iterator[Tuple[ return assert isinstance(kwargs, dict), f"expected dict, found {type(kwargs)}" for obj in kwargs.values(): - if not hasattr(obj, "get") or (id_ := obj.get("id")): + if not hasattr(obj, "get") or (id_ := obj.get("id")) is None: continue # The `id` field of the object is a list indicating the path to the # object's class in the LangChain package, e.g. `PromptTemplate` in From 428eed2b7bc21e1b9648111b7406f210a30c6a68 Mon Sep 17 00:00:00 2001 From: Roger Yang <80478925+RogerHYang@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:56:25 -0800 Subject: [PATCH 2/2] check falsiness instead --- .../src/openinference/instrumentation/langchain/_tracer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py b/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py index 2968e9ac1..abc97e196 100644 --- a/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py +++ b/python/instrumentation/openinference-instrumentation-langchain/src/openinference/instrumentation/langchain/_tracer.py @@ -357,7 +357,7 @@ def _prompt_template(serialized: Optional[Mapping[str, Any]]) -> Iterator[Tuple[ return assert isinstance(kwargs, dict), f"expected dict, found {type(kwargs)}" for obj in kwargs.values(): - if not hasattr(obj, "get") or (id_ := obj.get("id")) is None: + if not hasattr(obj, "get") or not (id_ := obj.get("id")): continue # The `id` field of the object is a list indicating the path to the # object's class in the LangChain package, e.g. `PromptTemplate` in