This chatbot application is designed to provide interactive and intelligent responses to user queries. It leverages NLP models for generating embeddings, retrieving relevant information, and facilitating seamless conversations. The application is built using Python and integrates several services and utilities for efficiency.
- Interactive Chat: Responds to user queries with contextual and relevant answers.
- PDF Upload and Processing: Users can upload PDF documents which are processed further.
- Embedding Service: Converts text into embeddings for similarity calculations and retrieval tasks.
- API Integration: Exposes endpoints for chat and PDF-related operations.
- Customizable Configurations: Includes a configuration file for easy customization of settings.
- Python: Ensure Python 3.8 or higher is installed.
- Virtual Environment: It is recommended to use a virtual environment for dependency management.
- Dependencies: Install the required libraries listed in
requirements.txt.
-
Clone the repository:
git clone <repository_url>
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure the application:
- Update
utils/config.pyfor application-specific configurations.
- Update
-
Run the application:
streamlit run app.py
-
Access the application: Open your browser and navigate to
http://localhost:8501.
To run the application using Docker, make sure Docker is installed on your system. Follow the steps below:
- Build the Docker image:
docker build -t streamlit-app . - Create and run the Docker container:
docker run -itd --name pdf-chatbot -p 8051:801 streamlit-app
- View the Running Container:
docker ps
- View logs for troubleshooting:
docker logs <container-id-of-pdf-chatbot>
- Access the application: Paste the network URL provided in the logs into your browser, and the application will be running!
http://localhost:8501
- URL:
/chat - Method: POST
- Description: Handles user queries and returns chatbot responses.
- Request Body:
{ "query": "<user_query>" } - Response:
{ "response": "<chatbot_response>" }
- URL:
/upload-pdf - Method: POST
- Description: Allows users to upload PDF files for information retrieval.
- Request Body:
- Form-data with key
filecontaining the PDF.
- Form-data with key
- Response:
{ "status": "success", "message": "PDF uploaded successfully." }
- URL:
/pdf-metadata - Method: GET
- Description: Fetches metadata of uploaded PDFs.
- Response:
{ "pdf_id": [ { "name": "pdf_name", "path": "pdf_path", "embeddings_path": "embeddings_path", "text": "extracted_text", "file_path": "file_path" } ] }
- Contextual Responses: Uses embeddings and similarity calculations to provide meaningful answers.
- Customizable Models: Allows integration with different NLP models.
- Upload PDFs: Users can upload documents for analysis.
- Metadata Extraction: Retrieves title, author, and page count.
- Content Retrieval: Finds relevant sections based on user queries.
- Text to Embedding: Converts user queries and document chunks into embeddings for similarity comparison.
- Device Management: Automatically moves tensors to CPU for compatibility.
- Ensure that the
uploadsdirectory is writable for storing uploaded files.