This is how im creating documents, can you help me add sentence splitter in it
try {
const dataPath = path.resolve('../documents');
const reader = new SimpleDirectoryReader();
const documents = await reader.loadData({ directoryPath: dataPath });
const documentsWithMetadata = [];
//uploading files to firebase storage and collection
const uploadedFiles = await uploadFiles();
const filesInfo = uploadedFiles.uploadedFilesInfo;
documents.forEach((doc) => {
const fileName = path.basename(doc.id_);
const fileObj = filesInfo.find((info) => info.hasOwnProperty(fileName));
const fileId = fileObj ? fileObj[fileName].id : null;
// Create a Document instance with metadata
const documentWithMetadata = new Document({
// embedding:5,
text: doc.text,
metadata: {
filename: fileName,
fileId: fileId
}
});
documentsWithMetadata.push(documentWithMetadata);
});
//connection with AstraDB
const astraVS = new AstraDBVectorStore();
await astraVS.create(collectionName, {
vector: { dimension: 1536, metric: "cosine" },
});
await astraVS.connect(collectionName);
const ctx = await storageContextFromDefaults({ vectorStore: astraVS });
await VectorStoreIndex.fromDocuments(documentsWithMetadata, {
storageContext: ctx,
});