Find answers from the community

Home
Members
Mottzerella
M
Mottzerella
Offline, last seen 6 months ago
Joined September 25, 2024
Hi Everyone,

I'm new to Llama Parse, and trying to implement it in a small Llama 3.1 based RAG app that uses Langchain. I am trying to use Document.to_langchain_format() to make the document object usable in langchain, but I keep running into the "Attribute Error: Tuple object has no attribute 'metadata'", despite passing in a function that returns a metadata dict. The Kapa.ai hasn't been much help. Anyone able to give me some assistance here?

def get_meta(file):
filename, extension = os.path.splitext(file)
metadata_dict = {
'filepath': {"filename": extension}
}
return metadata_dict

def load_document(file):
import os
name, extension = os.path.splitext(file)
os.environ['LLAMA_CLOUD_API_KEY'] = 'llx-Ks8gd2ve9Qwwu0RrHn44RsMcrg79GtrYUFKTMJa4UwSpeFxX'

if extension == '.pdf':
from llama_parse import LlamaParse
from llama_index.core import SimpleDirectoryReader
from llama_index.core.schema import Document


parser = LlamaParse(result_type="markdown") # "markdown" and "text" are available)
file_extractor = {".pdf": parser}

llama_parse_documents = SimpleDirectoryReader(input_files=[file], file_extractor=file_extractor, file_metadata={}).load_data(),

loader = Document.to_langchain_format(llama_parse_documents)
10 comments
M
L