from PyPDF2 import PdfReader import streamlit as st from langchain_text_splitters import RecursiveCharacterTextSplitter def get_pdf_text(pdf_docs): try: text = "" for pdf in pdf_docs: pdf_reader = PdfReader(pdf) for page in pdf_reader.pages: text += page.extract_text() return text except Exception as e: st.error(f"Error extracting text from PDF: {e}") return None def get_text_chunks(text): try: text_splitter = RecursiveCharacterTextSplitter(chunk_size=10000, chunk_overlap=1000) chunks = text_splitter.split_text(text) return chunks except Exception as e: st.error(f"Error splitting text into chunks: {e}") return None