From 8c1b76f3c316fc83c40eb965a6c565b2ca758b84 Mon Sep 17 00:00:00 2001 From: swk777 <swk777@gmail.com> Date: Tue, 22 Aug 2023 11:05:24 +0800 Subject: [PATCH] add example to simple --- apps/simple/markdown.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 apps/simple/markdown.ts diff --git a/apps/simple/markdown.ts b/apps/simple/markdown.ts new file mode 100644 index 000000000..cc71c6954 --- /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); -- GitLab