mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-21 14:55:36 -04:00
6d4d96f8fe
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
24 lines
670 B
TypeScript
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);
|