Hi Team ,
I am getting this error when loading pdf or txt through HNSWLib.
Below is code snippet :
Attempt to load Text File
/ Initialize the LLM to use to answer the question /
const model = new OpenAI({openAIApiKey:OPENAI_API_KEY});
/ Load in the file we want to do question answering over /
const loader = new PDFLoader(__dirname + "/naval.txt");
const docs = await loader.load();
/ Create the vectorstore /
const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings({openAIApiKey:OPENAI_API_KEY}));
/ Create the chain /
const chain = VectorDBQAChain.fromLLM(model, vectorStore);
/ Ask it a question /
const result = await chain.call({
query: "What did the president say about Justice Breyer?",
});
Attempt to load PDF File
/ Initialize the LLM to use to answer the question /
const model = new OpenAI({openAIApiKey:OPENAI_API_KEY});
/ Load in the file we want to do question answering over /
const loader = new TextLoader(__dirname + "/naval.pdf");
const docs = await loader.load();
/ Create the vectorstore /
const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings({openAIApiKey:OPENAI_API_KEY}));
/ Create the chain /
const chain = VectorDBQAChain.fromLLM(model, vectorStore);
/ Ask it a question /
const result = await chain.call({
query: "What did the president say about Justice Breyer?",
});
Hi Team , I am getting this error when loading pdf or txt through HNSWLib.
Below is code snippet :
Attempt to load Text File
/ Initialize the LLM to use to answer the question / const model = new OpenAI({openAIApiKey:OPENAI_API_KEY}); / Load in the file we want to do question answering over /
const loader = new PDFLoader(__dirname + "/naval.txt"); const docs = await loader.load(); / Create the vectorstore / const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings({openAIApiKey:OPENAI_API_KEY})); / Create the chain / const chain = VectorDBQAChain.fromLLM(model, vectorStore); / Ask it a question / const result = await chain.call({ query: "What did the president say about Justice Breyer?", });
Attempt to load PDF File
/ Initialize the LLM to use to answer the question / const model = new OpenAI({openAIApiKey:OPENAI_API_KEY}); / Load in the file we want to do question answering over /
const loader = new TextLoader(__dirname + "/naval.pdf"); const docs = await loader.load(); / Create the vectorstore / const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings({openAIApiKey:OPENAI_API_KEY})); / Create the chain / const chain = VectorDBQAChain.fromLLM(model, vectorStore); / Ask it a question / const result = await chain.call({ query: "What did the president say about Justice Breyer?", });
Both the time it throws same error :
Please let me know if i am missing something.