From 74e5c242c3934005f124e5497de1172b3283d492 Mon Sep 17 00:00:00 2001 From: Gal Shubeli Date: Sun, 23 Mar 2025 15:25:30 +0200 Subject: [PATCH] node-onj-extraction --- .../langchain_community/chains/graph_qa/falkordb.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/community/langchain_community/chains/graph_qa/falkordb.py b/libs/community/langchain_community/chains/graph_qa/falkordb.py index ebc5896192b..ca58c5ca542 100644 --- a/libs/community/langchain_community/chains/graph_qa/falkordb.py +++ b/libs/community/langchain_community/chains/graph_qa/falkordb.py @@ -4,6 +4,7 @@ from __future__ import annotations import re from typing import Any, Dict, List, Optional +from falkordb.node import Node from langchain.chains.base import Chain from langchain.chains.llm import LLMChain @@ -164,7 +165,12 @@ class FalkorDBQAChain(Chain): intermediate_steps.append({"query": generated_cypher}) # Retrieve and limit the number of results - context = self.graph.query(generated_cypher)[: self.top_k] + context_list = self.graph.query(generated_cypher)[: self.top_k] + # If the context is a list of nodes (object), extract the properties + context = [ + [r.properties if isinstance(r, Node) else r for r in sublist] + for sublist in context_list + ] if self.return_direct: final_result = context