Running Graph RAG example using Langgraph yields a IndexError
Error
#30414
Replies: 1 comment
-
The To resolve this issue, you should add a check to ensure that the list of properties is not empty before attempting to access its elements. Here's a suggested modification to the relevant part of your for filter in llm_output.filters:
logger.debug(f"Processing filter: {filter}")
properties = [
prop
for prop in graph.structured_schema["node_props"].get(filter.node_label, [])
if prop["property"] == filter.property_key
]
if not properties:
logger.warning(f"No properties found for label {filter.node_label} with key {filter.property_key}")
continue # Skip to the next filter if no properties are found
if properties[0]["type"] != "STRING":
continue
mapping = graph.query(
f"MATCH (n:{filter.node_label}) WHERE toLower(n.`{filter.property_key}`) = toLower($value) RETURN 'yes' LIMIT 1",
{"value": filter.property_value},
)
if not mapping:
logger.warning(
f"Missing value mapping for {filter.node_label} on property {filter.property_key} with value {filter.property_value}"
)
mapping_errors.append(
f"Missing value mapping for {filter.node_label} on property {filter.property_key} with value {filter.property_value}"
) This modification ensures that you only attempt to access the list if it contains elements. If the list is empty, it logs a warning and continues to the next iteration without trying to access an index. This should prevent the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
I am running the example here that builds a querying app over a Neo4j graph: https://python.langchain.com/docs/tutorials/graph/
This is the full code:
When I run this script some questions succeed and some other ones yield this error:
what is causing this error? and how should I solve it?
Beta Was this translation helpful? Give feedback.
All reactions