This project demonstrates a PDF-based Question Answering (QA) bot built using Node.js, Express, Langchain, and OpenAI's GPT-3.5-turbo-instruct model. The bot reads a PDF document, processes its content, and answers questions based on the document's content.
- Prerequisites
- Installation
- Usage
- API Endpoints
- Environment Variables
- Project Structure
- Contributing
- License
Ensure you have the following installed:
- Node.js v14.x or higher
- npm v6.x or higher
-
Clone the repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name -
Install the dependencies:
npm install
-
Create a
.envfile in the root of the project and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key_here
-
Start the server:
npm start
-
The server will run on port
3000by default. You can test the bot by sending a POST request tohttp://localhost:3000/botwith a JSON payload containing your question.
Endpoint to ask a question based on the content of the PDF document.
{
"question": "Your question here"
}{
"answer": "The answer to your question"
}The project requires the following environment variables:
OPENAI_API_KEY: Your OpenAI API key.
.
├── src
│ └── documents
│ └── budget_speech.pdf
├── .env
├── .gitignore
├── package.json
├── README.md
└── server.js
src/documents/budget_speech.pdf: The PDF document used for the QA bot..env: File to store environment variables.server.js: The main server file containing the bot logic.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes and commit them (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to modify this README as per your project's requirements.