Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: order chunks from docx by positions. (#7979)

Kevin Hu93f5df716f5a
diff --git a/rag/nlp/__init__.py b/rag/nlp/__init__.py
index 06f49623ed..f88c059a5f 100644
--- a/rag/nlp/__init__.py
+++ b/rag/nlp/__init__.py
@@ -279,12 +279,13 @@ def tokenize_chunks(chunks, doc, eng, pdf_parser=None):
def tokenize_chunks_with_images(chunks, doc, eng, images):
res = []
# wrap up as es documents
- for ck, image in zip(chunks, images):
+ for ii, (ck, image) in enumerate(zip(chunks, images)):
if len(ck.strip()) == 0:
continue
logging.debug("-- {}".format(ck))
d = copy.deepcopy(doc)
d["image"] = image
+ add_positions(d, [[ii]*5])
tokenize(d, ck, eng)
res.append(d)
return res