AskMyDoc is an AI-powered application that allows users to upload PDF documents and ask questions based on the content of those documents. It uses a combination of frontend technologies (React, Axios and TailwindCSS) and backend technologies (Node.js, Express.js, Langchain, Google Vertex AI, pdfreader, and multer) to provide this functionality.
Visit Live App or (https://ask-my-doc.vercel.app/)
Note: Sending frequent questions might exceed requests quota please take care of that.
- Frontend: React, TailwindCSS, Axios
- Backend: node.js, express.js, @langchain, @langchain/google-vertexai, pdfreader, multer
Follow the steps below to set up the project on your local machine.
First, clone the repository to your local machine:
git clone <repo-url>
Navigate to the client/ui
directory from root and install the frontend dependencies:
cd client/ui
npm install
Move to the server
directory from and install the backend dependencies:
If you are in ui
directory right now:
cd ../../server
npm install
If you are at root:
cd server
npm install
In the client/ui
directory, create a .env
file and add the following environment variable:
VITE_BACKEND_API = "your-backend-api-link"
In the server directory, create a JSON file containing your Google project credentials. Name it credentials.json
or any name of your choice.
Create a .env
file in the server directory and add the following environment variable, specifying the path to your Google project credentials:
GOOGLE_APPLICATION_CREDENTIALS = "path-to-your-google-project-credentials.json-file"
In my example:
GOOGLE_APPLICATION_CREDENTIALS= "./credentials.json"
To run the frontend application, navigate to the client/ui
directory and execute:
npm run dev
This will start the frontend application at http://localhost:5173/.
To run the backend server, navigate to the server
directory and execute:
npm run dev
The server will run by default at http://localhost:4000/. If you want to use a different port, set the PORT
environment variable in your .env
file or change the hardcoded port value in the index.js
file.
You might need to create an uploads
directory in the server
directory to store uploaded files. Create it manually if it's not created automatically on starting server, you can also run the following command in server
directory:
mkdir uploads
This should allow you to run your application locally.
There are only two end-points in our application for now:
POST
: /upload
Description: Uploads a PDF file to the server.
- Form Data is to be sent with a key
pdf
with pdf file as its value - Headers to send form data
headers: {
'Content-Type': 'multipart/form-data',
},
- JSON
- filename (string): The name with which the file is stored on the server. This is the same value that has to be sent in
/ask
request.
{
filename: "Name of the file stored at server."
}
POST
: /ask
Description: Asks a question based on the content of an uploaded PDF.
- JSON
- question (string): The question to ask.
- filename (string): The name of the file on the server to take context from. Will be received in response from
/upload
request.
{
question: "User's question.",
filename: "Name of the file to pick context from."
}
- JSON
- answer (string): The AI-generated answer.
{"answer": "Your AI generated answer"}
That's all for setting up and running AskMyDoc! Check out the application and enjoy asking questions from your PDF documents. If you encounter any issues, feel free to open an issue on the repository.