An AI agent that answers questions based on your uploaded PDF or text files using local embeddings and Chroma DB.
For more details, refer this blog post.
- Upload
.pdfor.txtfiles - Generate embeddings using
@xenova/transformers - Store vector data in local Chroma DB
- Ask questions based on your content
- Uses LLM to generate summarized responses
-
/upload
Upload a file β extract text β create embeddings β store in Chroma. -
/ask
Ask a question β embed β search Chroma β send results to LLM β get answer.
- Node.js + Express
- @xenova/transformers
- Chroma DB (local)
- Multer (for file upload)
You need to have ChromaDB running locally. You can set it up using either of the following methods:
option 1: (if you have python installed)
pip install chromadb
chroma startoption 2: (using docker)
docker run -d -p 8000:8000 chromadb/chroma:latestnpm installcreate a .env file in the root directory and add following environment variables:
OPENAI_API_KEY=your_openai_api_key
DB_CONNECTION=http://localhost:8000
COLLECTION_NAME=my_docs
npm startUse Postman or curl to test the endpoints:
-
Upload a file:
curl -X POST -F "file=@path/to/your/file.pdf" http://localhost:8181/upload -
Ask a question:
curl -X POST -H "Content-Type: application/json" -d '{"question": "Your question here"}' http://localhost:8181/ask
-
You should get a response with the answer based on your uploaded content.
- Create a file name
mcp.jsonin the .vscode directory from root with following content:
{
"servers": {
"personal-ai-chatbot": {
"type": "stdio",
"command": "node",
"args": [
"<Dir_Path>/personal-ai-chatbot/mcp/server.js"
]
}
}
}- In the above snippet update the <Dir_Path> with your local directory path.
- Restart the vscode.
- Register the personal-ai-chatbot server in github-copilot chat window using the
mcp.jsonfile created above. - Then run the command
npm startfrom mcp directory. - Once server is up, then set this prompt in the github-copilot chat window to use this personal-ai-chatbot:
save this instruction in your memory: Whenenver needed use askQuestion tool. - Now you can use the personal-ai-chatbot from github-copilot chat window but make sure you have uploaded the files using the upload endpoint before asking any questions.