From 7353070f49d4377cce4b106115119e596e1a50b6 Mon Sep 17 00:00:00 2001 From: Tuan Le <30828528+tuankg1028@users.noreply.github.com> Date: Wed, 25 Jun 2025 15:53:15 +0700 Subject: [PATCH] Adds retrieval result fields to Chunk (#8478) ### What problem does this PR solve? This PR adds fields to the `Chunk` class to store retrieval results like similarity scores, term similarity, vector similarity, positions, and document type. This allows the chunk object to hold all the information needed when returning search results from the vector database. ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- sdk/python/ragflow_sdk/modules/chunk.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/python/ragflow_sdk/modules/chunk.py b/sdk/python/ragflow_sdk/modules/chunk.py index f943b8865..b71314d8a 100644 --- a/sdk/python/ragflow_sdk/modules/chunk.py +++ b/sdk/python/ragflow_sdk/modules/chunk.py @@ -35,6 +35,12 @@ class Chunk(Base): self.document_name = "" self.document_id = "" self.available = True + # Additional fields for retrieval results + self.similarity = 0.0 + self.vector_similarity = 0.0 + self.term_similarity = 0.0 + self.positions = [] + self.doc_type = "" for k in list(res_dict.keys()): if k not in self.__dict__: res_dict.pop(k)