source_nodes
attribute. And each source node has metadata response.source_nodes[0].node.metadata
AttributeError: 'Document' object has no attribute 'file_metadata'
from llama_index import SimpleDirectoryReader filename_fn = lambda filename: {'file_name': filename} # automatically sets the metadata of each document according to filename_fn documents = SimpleDirectoryReader('./data', file_metadata=filename_fn).load_data() print(documents[0].metadata['file_name'])
>>> from llama_index import SimpleDirectoryReader >>> name_fn = lambda filename: {'file_name': filename} >>> filename_fn = lambda filename: {'file_name': filename} >>> documents = SimpleDirectoryReader('./docs/examples/data/paul_graham', file_metadata=filename_fn).load_data() >>> print(documents[0].metadata['file_name']) docs/examples/data/paul_graham/paul_graham_essay.txt >>>
response = chat_engine.chat(prompt)
response.source_nodes[0].node.metadata