Files
LlamaIndexTS/examples/markdown.ts
T
2025-02-10 15:43:29 +07:00

24 lines
670 B
TypeScript

import { MarkdownReader } from "@llamaindex/readers/markdown";
import { VectorStoreIndex } from "llamaindex";
async function main() {
// Load Markdown file
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({
query: "What does the example code do?",
});
// Output response
console.log(response.toString());
}
main().catch(console.error);