From ebd1933cb3945a82a8acfc0071176b82dce92705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Garc=C3=A9s-Erice?= Date: Tue, 22 Oct 2024 05:00:09 +0200 Subject: [PATCH] Check rel type before checking properties (#9) Minor change, but lazy evaluation of the type before checking whether the properties are there saves me a lot of unnecessary exceptions. --- .../langchain_experimental/graph_transformers/llm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/experimental/langchain_experimental/graph_transformers/llm.py b/libs/experimental/langchain_experimental/graph_transformers/llm.py index ae68d32..d4624c1 100644 --- a/libs/experimental/langchain_experimental/graph_transformers/llm.py +++ b/libs/experimental/langchain_experimental/graph_transformers/llm.py @@ -753,7 +753,8 @@ def process_response( for rel in parsed_json: # Check if mandatory properties are there if ( - not rel.get("head") + not isinstance(rel, dict) + or not rel.get("head") or not rel.get("tail") or not rel.get("relation") ):