i am trying to retrive the metadata from the retrived answer but it’s returning empty
and also i have to Implement a mechanism to upload multiple documents (PDF, DOCX, or TXT format)
all_text = " "
# Process each uploaded file
for file_name, file_content in uploaded_files.items():
if file_name.endswith('.pdf'):
# Process PDF file
pdf_reader = PdfReader(io.BytesIO(file_content))
text = ""
for page in pdf_reader.pages:
text += page.extract_text()
elif file_name.endswith('.txt'):
# Process TXT file
text = file_content.decode("utf-8")
elif file_name.endswith('.docx'):
# Process DOCX file
text = docx2txt.process(io.BytesIO(file_content))
else:
# Unsupported file type
print(f"Unsupported file type: {file_name}")
continue
# Append text to all_text
all_text += text
text_splitter = RecursiveCharacterTextSplitter(
# Set a really small chunk size, just to show.
chunk_size=500,
chunk_overlap=50,
length_function=len,
is_separator_regex=False,
)
chunks = text_splitter.split_text(all_text)
embeddings = GoogleGenerativeAIEmbeddings(model = "models/embedding-001", google_api_key=apikey)
vector_store = FAISS.from_texts(chunks, embedding=embeddings)
query = "what are Types of Reflection"
docs = vector_store.similarity_search(query,k=2)
docs
query = "what are Types of Reflection"
docs = vector_store.similarity_search(query,k=2)
docs
New contributor
Harsh yadav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.