dify
dify copied to clipboard
Include Original Document Page Numbers in Retrieval Results
Self Checks
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
1. Is this request related to a challenge you're experiencing? Tell me about your story.
When adding a pdf document into kwnowledge, it saved the page_number with metadata
# api/core/rag/extrator/pdf_extractor.py
...
for page_number, page in enumerate(pdf_reader):
text_page = page.get_textpage()
content = text_page.get_text_range()
text_page.close()
page.close()
metadata = {"source": blob.source, "page": page_number}
yield Document(page_content=content, metadata=metadata)
...
and this page_number is saved into a vector store. however, this value is not returned with knowledge retrieval. I believe a simple change in knowledge_retrieval_node.py and/or llm_node.py would add page_number to the retrieval results. If you guys are willing to accept a PR, I will make one
2. Additional context or comments
I would appreciate it if you could provide access to the original documents or sources that the LLM referenced when generating its response. Including the specific page numbers would greatly enhance the credibility of the information.
3. Can you help us with this feature?
- [X] I am interested in contributing to this feature.