import streamlit as st from PyPDF2 import PdfReader from langchain_text_splitters import RecursiveCharacterTextSplitter from langchain_community.embeddings import HuggingFaceEmbeddings from langchain_community.vectorstores import FAISS import os from langchain_groq import ChatGroq from langchain.chains.question_answering import load_qa_chain os.environ["GROQ_API_KEY"] = "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" # Page config st.set_page_config(page_title="📄 Chat with PDF", layout="wide") # Theme switcher radio theme = st.radio("🌓 Select Theme", ["Dark", "Light"], horizontal=True) # Define colors based on theme if theme == "Dark": bg_color = "rgba(0, 0, 0, 0.85)" app_bg = "rgba(20, 20, 20, 0.6)" sidebar_bg = "rgba(10, 10, 10, 0.9)" text_color = "#FFFFFF" input_bg = "rgba(50, 50, 50, 0.5)" accent_color = "#2AA198" else: bg_color = "#f0f2f6" app_bg = "rgba(255, 255, 255, 0.6)" sidebar_bg = "rgba(255, 255, 255, 0.9)" text_color = "#000000" input_bg = "rgba(240, 240, 240, 0.9)" accent_color = "#2AA198" # Inject CSS styles st.markdown(f""" """, unsafe_allow_html=True) # Sidebar UI with st.sidebar: st.markdown("### 📁 Upload PDF") file = st.file_uploader("Upload your PDF", type="pdf") st.write("Then ask your question below!") # Main UI st.markdown(f"