This is a Flask web application that provides AI-powered document search and retrieval functionality. It leverages the LangChain framework to process natural language queries and search through PDF documents for relevant information.
- Process natural language queries with a pre-trained language model.
- Upload and index PDF documents for efficient search and retrieval.
- Retrieve relevant document sections based on query similarity.
- Python 3.7 or higher
-
Clone the repository:
git clone https://github.com/pharth/ChatWithPDF cd ChatWithPDF
2.Create a virtual environment:
python -m venv venv
3.Activate the virtual environment: On Windows:
venv\Scripts\activate
On macOS and Linux:
source venv/bin/activate
4.Install the required packages from requirements.txt:
pip install -r requirements.txt
1.Run the Flask application:
python app.py
2.Endpoints:
Processes a natural language query using the language model.
Request:
{
"query": "Your question here"
}
Response:
{
"answer": "Response from the language model"
}
Queries the indexed PDF documents.
Request:
{
"query": "Your question related to the documents"
}
Response:
{
"answer": "Relevant answer from the documents",
"sources": [
{
"source": "source file name",
"page_content": "relevant page content"
}
]
}
Uploads and indexes a PDF document.
Request:
Form-data with the key "file" and the PDF file as value.
Response:
{
"status": "Successfully Uploaded",
"filename": "uploaded_file_name.pdf",
"doc_len": 10,
"chunks": 20
}