You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The following sample code (taken from this repo's tests) throws a TypeError: BM25 is not a function.
To Reproduce
Code to reproduce the behavior:
import{Bm25Retriever}from"@llamaindex/bm25-retriever";import{OpenAIEmbedding}from"@llamaindex/openai";import{PDFReader}from"@llamaindex/readers/pdf";import{MetadataMode,Settings,VectorStoreIndex}from"llamaindex";Settings.embedModel=newOpenAIEmbedding();asyncfunctionmain(){// Load PDFconstreader=newPDFReader();constdocuments=awaitreader.loadData("./data/brk-2022.pdf");// Split text and create embeddings. Store them in a VectorStoreIndexconstindex=awaitVectorStoreIndex.fromDocuments(documents);constretriever=newBm25Retriever({docStore: index.docStore,topK: 3,});// Query the dataconstresponse=awaitretriever.retrieve({query: "What mistakes did Warren E. Buffett make?",});// Output responseresponse.forEach((r)=>{console.log(`Score: ${r.score}`);console.log(`Text: ${r.node.getContent(MetadataMode.NONE)}`);});}main().catch(console.error);
Expected behavior
BM25 should run :)
I was able to pinpoint the issue. In dist/index.js the import from okapibm25 seems to require the call to be done as const scores = BM25.default(contents, queryStr.toLowerCase().split(/\s+/)); instead of the present const scores = BM25(contents, queryStr.toLowerCase().split(/\s+/));
Describe the bug
The following sample code (taken from this repo's tests) throws a
TypeError: BM25 is not a function.To Reproduce
Code to reproduce the behavior:
Expected behavior
BM25 should run :)
I was able to pinpoint the issue. In dist/index.js the import from
okapibm25seems to require the call to be done asconst scores = BM25.default(contents, queryStr.toLowerCase().split(/\s+/));instead of the presentconst scores = BM25(contents, queryStr.toLowerCase().split(/\s+/));