lplalbert commented on code in PR #412:
URL: https://github.com/apache/hugegraph-ai/pull/412#discussion_r4581370898
##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/milvus_vector_store.py:
##########
@@ -166,14 +158,15 @@ def search(self, query_vector: List[float], top_k: int,
dis_threshold: float = 0
ret = []
for hits in results:
for hit in hits:
- if hit.distance < dis_threshold:
- prop_str = hit.entity.get("property")
- prop = self._serialize_property(prop_str)
- ret.append(prop)
+ if hit.distance <= dis_threshold:
+ # Property strings round-trip verbatim: decoding
JSON-shaped
+ # chunk text ("123", '{"a": 1}') would change its type
and
+ # make downstream consumers drop it as malformed.
+ ret.append(hit.entity.get("property"))
Review Comment:
Fixed in `aeed04e` — good catch, this was a regression from `129cc48`.
Root cause: the `gremlin_examples` index stores its `{"query", "gremlin"}`
dicts as JSON text (text-column backend), and
`GremlinExampleIndexQuery._get_match_result` returned whatever the store handed
it. The removed store-side decode had been serving this index, so with verbatim
stored text the consumer received strings and `_format_examples` raised
`TypeError` on `example['query']`.
Structural fix: decode at the boundary that owns the example shape —
`_get_match_result` parses string hits with `json.loads`, restoring the dict
format for Text2Gremlin and the GraphRAG gremlin path while chunk text keeps
its verbatim round trip (that half of `129cc48` stays correct for the chunks
index).
Validation: red-green — `test_get_match_result_decodes_stored_json_text`
(mock store returns JSON text and an already-decoded dict) and the demanded
`test_milvus_dict_properties_round_trip_into_gremlin_example_results` (dict ->
Milvus stored text -> `_get_match_result` -> the same dict; red before the fix
returns the JSON string). Full suite 1312 passed, 12 skipped, 2 known
pre-existing failures; ruff clean; ty 0 new. The string round-trip guarantee
from your #414 note is now documented beside this implementation in `83ba325`.
##########
hugegraph-llm/src/hugegraph_llm/api/models/rag_requests.py:
##########
@@ -48,10 +48,11 @@ class RAGRequest(BaseModel):
# Graph Configs
max_graph_items: int = Query(30, description="Maximum number of items for
GQL queries in graph.")
topk_return_results: int = Query(20, description="Number of sorted results
to return finally.")
- vector_dis_threshold: float = Query(
- 0.9,
- description="Threshold for vector similarity\
- (results greater than this will be
ignored).",
+ vector_dis_threshold: Optional[float] = Query(
+ None,
+ description="Distance threshold override for this request, applied to
chunk retrieval and \
Review Comment:
Fixed in `2e68185`. Both `RAGRequest` and `GraphRAGRequest` now describe
`vector_dis_threshold` as the keyword-to-vertex override falling back to
`VECTOR_DIS_THRESHOLD`, and state explicitly that chunk retrieval always prunes
at `CHUNK_DIS_THRESHOLD` and ignores the field.
--
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]