from llama_index.core 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, recursive=True ).load_data()
# once you have the docs, you can iterate like this to remove the metadata keys for doc in documents: doc.excluded_embed_metadata_keys = [] doc.excluded_llm_metadata_keys = []