Find answers from the community

Updated 2 years ago

Is there a way to modify `response get

At a glance

The community member who posted the original question is asking if there is a way to modify the response.get_formatted_sources() function to display the name of the source file instead of a meaningless document ID. In the comments, another community member suggests parsing the source_nodes to obtain the document ID, which can then be used to look up the file name. Another community member mentions that the document ID can be set directly before feeding it into an index. The final comment expresses curiosity about why the SimpleDirectoryReader does not save the file names. There is no explicitly marked answer in the post and comments.

Is there a way to modify response.get_formatted_sources() to produce the name of the source file rather than a meaningless doc id like Doc id: 3e176859?
j
m
M
4 comments
you can directly parse the source_nodes which contain the objects (containing the text chunk, the doc id which you can then use to look up the file name)
btw you can set the doc_id directly before you feed into an index document.doc_id = "foo" - otherwise we just generate a random number
I'm curious why the SimpleDirectoryReader does not save the filenames?
Add a reply
Sign up and join the conversation on Discord