bitflicker64 commented on code in PR #383:
URL: https://github.com/apache/hugegraph-ai/pull/383#discussion_r4286733809
##########
hugegraph-llm/src/hugegraph_llm/nodes/hugegraph_node/graph_query_node.py:
##########
@@ -364,7 +365,7 @@ def _subgraph_query(self, context: Dict[str, Any]) ->
Dict[str, Any]:
# TODO: use generator or asyncio to speed up the query logic
for matched_vid in matched_vids:
gremlin_query = VID_QUERY_NEIGHBOR_TPL.format(
- keywords=f"'{matched_vid}'",
+ keywords=gremlin_literal(matched_vid),
Review Comment:
Important: with numeric ids kept numeric, this neighbor query finds
numeric-id vertices for the first time, and the path formatter cannot handle
them. On a numeric-id graph, graph RAG now loses all graph context instead of
returning the vertex that `main` returns. In `_process_vertex`, `matched_str`
is `item["id"]`, an `int` here. When that id is already in `v_cache`, line 197
sets `node_str = matched_str`, and `flat_rel += node_str` raises `TypeError:
can only concatenate str (not "int") to str`. Any start vertex with two or more
paths hits this: every path begins with the start vertex, so the second path
finds it in `v_cache`. `operator_schedule` catches the error and returns
without `graph_result`. Evidence: against HugeGraph 1.7.0 (RocksDB), I added a
`customize_number` vertex `123` linked to two person vertices. At this head,
`GraphQueryNode.operator_schedule({"query": "who is n123", "match_vids":
[123]})` returns `graph_result_flag=-1` and no `graph_result`. The same call wi
th `graph_query_node.py` from 84ee9c4 returns `['123{name: n123}']`, because
`g.V('123')` found no paths there.
`test_subgraph_query_keeps_numeric_vertex_ids_numeric` misses this because
`FakeGremlinEndpoint` returns no paths for `.repeat(` queries. Please make
`_process_vertex` build a string, for example `node_str = str(matched_str)`.
Please also extend the numeric test so that the fake returns at least two paths
starting at `123`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]