You can use this nodejs class to load a PDF, extract its text and get OpenAI Embeddings. Then, you can create a chatbot that can answer questions about the PDF.
-
nodejs / npm (like 19+)
-
OpenAI API KEY
- Install the npm modules
npm install langchain chromadb @dqbd/tiktoken pdf-parse
- Install chromadb
git clone https://github.com/chroma-core/chroma
- Go in the chroma folder
cd chroma
- Run docker build
docker-compose up -d --build
You get a class called AIQA
which loads a PDF and can be asked questions with a query
method. It can be used like this:
import AIQA from "./aiqa.js";
const KEY = "sk-...";
const CHUNK_SIZE = 800;
const DOC = "example.pdf";
(async function() {
let aiqa = await new AIQA(KEY, CHUNK_SIZE, DOC);
let history="";
let result = await aiqa.query("What do you know about this?",history);
console.dir(result.text);
})();
You can use bot.js which is a telegram bot example. You just need to put your keys and a path to a PDF file.
Also, make sure you install the npm.
npm install node-telegram-bot-api
-
Chat Bot (Telegram, Slack, IRC, Webpage, etc.)
-
?
Copyright (c) 2023 Andrew Lee. (andrew@imperialfamily.com)
All Rights Reserved.
MIT Licensed.