Find answers from the community

Updated 2 months ago

I am building a retriever using

I am building a retriever using llamaindex's display_source_node function :

Plain Text
for node in nodes:
    display_source_node(node, source_length=10000)

and it returns a structure like so:

Plain Text
Node ID: d4d67180-71c8-4328-b3f1-1e98fa42ab69
Similarity: 0.8694979150607424
Text: We also list two qualitative examples where safety [...]


This is great, but can I somehow return the Source Document (name of the file + extension) to which the text belongs?

Plain Text
Node ID:
Source Document: example5.pdf
Similarity:
Text: 

Something like this ?
R
b
2 comments
You can set show_source_metadata to True, it'll show your the metadata for each node, which includes the file information
Plain Text
display_source_node(node, show_source_metadata=True)
Attachment
image.png
Works, thanks πŸ™‚
Add a reply
Sign up and join the conversation on Discord