This Streamlit application allows you to upload PDF files, process their text, and interact with the content using natural language queries powered by Google Gemini AI.
- Upload PDF Files: Upload multiple PDF files and process them to extract text.
- Text Chunking: Automatically splits the extracted text into manageable chunks for better processing.
- Vector Store Creation: Uses Google Generative AI embeddings to create a vector store for efficient similarity searches.
- Conversational Chain: Utilizes Google Gemini AI to answer questions based on the content of the uploaded PDFs.
- Interactive UI: Simple and user-friendly interface to interact with your PDFs.
- Python 3.7+
-
Clone the repository:
git clone https://github.com/thevishvammoliya/Learn-Smart cd Learn-Smart
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Set up environment variables:
Create a
.env
file in the root of your project and add your Google API key:GOOGLE_API_KEY=your-google-api-key
-
Run the Streamlit app:
streamlit run app.py
-
Upload PDFs:
- Use the sidebar to upload multiple PDF files.
- Click on the "Submit & Process" button to extract and process the text from the PDFs.
-
Ask Questions:
- Enter your question in the text input field and press Enter.
- The application will use the content of the uploaded PDFs to answer your question.
-
PDF Text Extraction:
The
get_pdf_text
function extracts text from the uploaded PDF files. -
Text Chunking:
The
get_text_chunks
function splits the extracted text into smaller chunks usingRecursiveCharacterTextSplitter
. -
Vector Store Creation:
The
get_vector_store
function creates a vector store from the text chunks using Google Generative AI embeddings and FAISS. -
Conversational Chain:
The
get_conversational_chain
function sets up a QA chain using Google Gemini AI to answer questions based on the processed PDF content. -
User Input Handling:
The
user_input
function processes the user's question, performs a similarity search on the vector store, and retrieves the most relevant chunks to generate an answer.
- Upload PDFs: Use the sidebar to upload your PDF files.
- Ask a Question: Enter a question like "What is the main topic of the document?" in the input field.
- Get an Answer: The app will display a detailed answer based on the content of the uploaded PDFs.
Enjoy chatting with your PDFs using LearnSmart! 🚀
Here is the content for your requirements.txt
file:
streamlit
google-generativeai
python-dotenv
langchain
PyPDF2
chromadb
faiss-cpu
langchain_google_genai
langchain_community
Replace the API key in env.example
file and rename it to .env
:
GOOGLE_API_KEY="YOUR_API_KEY_HERE"