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)
This commit is contained in:
Tuan Le 2025-06-25 15:53:15 +07:00 committed by GitHub
parent dac5bcdf17
commit 7353070f49
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)