Skip to content

amarishsajwan/pdf-reader-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


PDF-based QA Bot with Langchain and OpenAI

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.

Table of Contents

Prerequisites

Ensure you have the following installed:

  • Node.js v14.x or higher
  • npm v6.x or higher

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/your-repo-name.git
    cd your-repo-name
  2. Install the dependencies:

    npm install
  3. Create a .env file in the root of the project and add your OpenAI API key:

    OPENAI_API_KEY=your_openai_api_key_here
    

Usage

  1. Start the server:

    npm start
  2. The server will run on port 3000 by default. You can test the bot by sending a POST request to http://localhost:3000/bot with a JSON payload containing your question.

API Endpoints

POST /bot

Endpoint to ask a question based on the content of the PDF document.

Request Body

{
  "question": "Your question here"
}

Response

{
  "answer": "The answer to your question"
}

Environment Variables

The project requires the following environment variables:

  • OPENAI_API_KEY: Your OpenAI API key.

Project Structure

.
├── 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.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes and commit them (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

License

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published