diff --git a/apps/simple/markdown.ts b/apps/simple/markdown.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc71c69541b2b2b19e3c47c3f9487af0eb278137 --- /dev/null +++ b/apps/simple/markdown.ts @@ -0,0 +1,20 @@ +import { MarkdownReader, VectorStoreIndex } from "llamaindex"; + +async function main() { + // Load PDF + const reader = new MarkdownReader(); + const documents = await reader.loadData("node_modules/llamaindex/README.md"); + + // Split text and create embeddings. Store them in a VectorStoreIndex + const index = await VectorStoreIndex.fromDocuments(documents); + + // Query the index + const queryEngine = index.asQueryEngine(); + + const response = await queryEngine.query("What does the example code do?"); + + // Output response + console.log(response.toString()); +} + +main().catch(console.error);