Skip to content

Latest commit

Β 

History

History
102 lines (78 loc) Β· 2.79 KB

File metadata and controls

102 lines (78 loc) Β· 2.79 KB

🧠 Personal AI Chatbot

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.

πŸš€ Features

  • Upload .pdf or .txt files
  • Generate embeddings using @xenova/transformers
  • Store vector data in local Chroma DB
  • Ask questions based on your content
  • Uses LLM to generate summarized responses

βš™οΈ How It Works

  1. /upload
    Upload a file β†’ extract text β†’ create embeddings β†’ store in Chroma.

  2. /ask
    Ask a question β†’ embed β†’ search Chroma β†’ send results to LLM β†’ get answer.

πŸ“¦ Stack

  • Node.js + Express
  • @xenova/transformers
  • Chroma DB (local)
  • Multer (for file upload)

πŸ§ͺ Run Locally

Install chromadb

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 start

option 2: (using docker)

docker run -d -p 8000:8000 chromadb/chroma:latest

Install dependencies

npm install

create 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

Start the server

npm start

Test the endpoints

Use 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.

Running it with MCP Server (optional) : setup with vscode & github-copilot

  1. Create a file name mcp.json in 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"
         ]
      }
   }
}
  1. In the above snippet update the <Dir_Path> with your local directory path.
  2. Restart the vscode.
  3. Register the personal-ai-chatbot server in github-copilot chat window using the mcp.json file created above.
  4. Then run the command npm start from mcp directory.
  5. 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.
  6. 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.