Now you can qna with your pdf files.
Sample code is as follows.
const { QNAWithPDF } = require('./')
// or ES6 remove the comment
// import { QNAWithPDF } from './index.js'
const qnaWithPDF = new QNAWithPDF('./config.json');
qnaWithPDF.init('./invoice.pdf').then(qna => {
qna.answer("How much is the total cost of the invoice ?")
.then(result => {
return result; // You will see the result here.
})
.catch(e => {
throw new Error(e);
})
})if you want run with javascript run this folowing command in your command line;
npm run buildAnd you will see in your directory a dist folder. Now you will run this project with javascript.
Note: Don't forget the import changes. You should import from
distfolder.
The sample configuration file is included in the library. You can see the default content of the config file below.
{
"chroma": {
"collectionName": "collection_name", // change your chroma collection name
"url": "http://localhost:8000" // change your chroma server url
},
"textSplitter": { // text splitter initial values
"chunkSize": 100,
"chunkOverlap": 50
},
"inference": { // HuggingFaceInference Class initial values
"apiKey": "-", // hugging face api key
"temperature": 1.0,
"maxTokens": 50,
"model": "-" // provide a model in hugging face
},
"inferenceEmbeddings": { // HuggingFaceInferenceEmbeddings initial values
"apiKey": "-" // provide a hugging face api key
}
}You can find the model that suits you on Hugging Face.
You should have python version >= 3.11.6
You must have a chroma db on your project.
npm install --save chromadb
# or
yarn add chromadband follow this command
pip install chromadblast step
#if your location equals to db path you can write and run only chroma run
chroma run --path /db_pathFor more informations click here.
You must have a hugging face access token. And you must add to access token for config.json file.
Please make sure you provide the fields in the config file content.
- Multiple PDF support
- Memory support
- Less dependency and modularity