This Streamlit app is designed to perform Q&A on the content of a PDF document using IBM WatsonX's LLM and LangChain. By uploading a PDF file, users can ask questions about the content, and the app will respond with relevant answers from the document.
- PDF Document Loading: Load and index PDF files for question-answering.
- Embeddings & Text Splitting: Use Hugging Face embeddings for semantic search and split text using LangChain's
RecursiveCharacterTextSplitter. - Q&A with IBM WatsonX: Integrate with IBM WatsonX's LLM to answer questions based on the PDF content.
- Interactive Chat Interface: Uses Streamlit's chat interface to display responses and retain chat history.
- Conda (recommended) or Python >= 3.10
- IBM WatsonX API access credentials
git clone https://github.com/WalkingDevFlag/PDF-QA-Chatbot
cd <repository-directory>conda create --name watsonx python=3.10
conda activate watsonxUse the requirements.txt file to install necessary packages:
pip install -r requirements.txtCreate a .env file in the root directory with the following variables:
WATSONX_APIKEY=your_watsonx_apikey
WATSONX_URL=your_watsonx_url
WATSONX_MODEL_ID=your_model_id
WATSONX_PROJECT_ID=your_project_id
Replace each placeholder with your actual IBM WatsonX API key, URL, Model ID, Project ID, and the path to your PDF file.
Make sure the pdfs you want to run on are present in the "resources" directory
-
Start the App:
streamlit run app.py
-
Interact with the Q&A System:
- The app provides a chat interface. Enter your questions related to the PDF content, and WatsonX will generate responses based on the indexed document.
-
Historical Messages:
- All past questions and answers are displayed in the chat interface, allowing for a seamless Q&A session.
To create a Conda environment with the necessary packages, follow these commands:
conda create --name watsonx python=3.10
conda activate watsonx
pip install -r requirements.txt- app.py: Main script to run the Streamlit app.
- .env: Environment file containing IBM WatsonX credentials.
- requirements.txt: List of Python packages required for the project.
- IBM WatsonX for API and LLM capabilities.
- LangChain for document loading, embeddings, and retrieval chains.
- Streamlit for the user interface and chat capabilities.
- Generate you WatsonX API-KEYS here
- Get you Project_id here
- Langchain IBM watsonx.ai documentation