Skip to content

Commit bc156c3

Browse files
committed
fix(llama-index): extract rel type from dict in get_rel_map variable-length path
1 parent ac43ad0 commit bc156c3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • llama-index-coordinode/llama_index/graph_stores/coordinode

llama-index-coordinode/llama_index/graph_stores/coordinode/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ def get_rel_map(
147147
dst_data = row.get("m", {})
148148
src_id = str(row.get("_src_id", ""))
149149
dst_id = str(row.get("_dst_id", ""))
150-
# Variable-length path r returns a list; take first rel type as label.
150+
# Variable-length path [r*1..N] returns a list of relationship dicts.
151151
rels = row.get("r", [])
152-
rel_label = str(rels[0]) if isinstance(rels, list) and rels else "RELATED"
152+
if isinstance(rels, list) and rels:
153+
first_rel = rels[0]
154+
rel_label = first_rel.get("type", "RELATED") if isinstance(first_rel, dict) else str(first_rel)
155+
else:
156+
rel_label = "RELATED"
153157
src = _node_result_to_labelled(src_id, src_data)
154158
dst = _node_result_to_labelled(dst_id, dst_data)
155159
rel = Relation(label=rel_label, source_id=src_id, target_id=dst_id)

0 commit comments

Comments
 (0)