mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-21 14:55:36 -04:00
21 lines
500 B
TypeScript
21 lines
500 B
TypeScript
import {
|
|
Document,
|
|
SentenceSplitter,
|
|
Settings,
|
|
VectorStoreIndex,
|
|
} from "llamaindex";
|
|
|
|
export const STORAGE_DIR = "./data";
|
|
|
|
// Update node parser
|
|
Settings.nodeParser = new SentenceSplitter({
|
|
chunkSize: 512,
|
|
chunkOverlap: 20,
|
|
});
|
|
(async () => {
|
|
// generate a document with a very long sentence (9000 words long)
|
|
const longSentence = "is ".repeat(9000) + ".";
|
|
const document = new Document({ text: longSentence, id_: "1" });
|
|
await VectorStoreIndex.fromDocuments([document]);
|
|
})();
|