mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-23 07:45:27 -04:00
23 lines
623 B
TypeScript
23 lines
623 B
TypeScript
import { MarkdownReader, 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);
|