Skip to content

subhashydv/personal-ai-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors