endee-llamaindex
v1.0.2
Published
LlamaIndex integration with endee vector database
Readme
endee-llamaindex
A LlamaIndex vector store integration for Endee — enabling seamless RAG (Retrieval-Augmented Generation) workflows with the Endee vector database.
Installation
npm install endee-llamaindex
# or
pnpm add endee-llamaindex
# or
yarn add endee-llamaindexPrerequisites
- An Endee account and authentication token
- An existing index created in Endee (or create one using the Endee client)
- Node.js 18+
Quick Start
import { EndeeVectorStore } from "endee-llamaindex";
import { Document, Settings, storageContextFromDefaults, VectorStoreIndex } from "llamaindex";
import { OpenAI, OpenAIEmbedding } from "@llamaindex/openai";
import { Endee } from "endee";
// Configure your embedding model
Settings.embedModel = new OpenAIEmbedding({
model: "text-embedding-3-small",
apiKey: process.env.OPENAI_API_KEY,
});
// Configure your LLM
Settings.llm = new OpenAI({
model: "gpt-4o",
apiKey: process.env.OPENAI_API_KEY,
});
// Initialize Endee client and get/create an index
const endeeClient = new Endee(process.env.ENDEE_AUTH_TOKEN ?? "");
const index = await endeeClient.getIndex("my-index");
// Or create a new index:
// const index = await endeeClient.createIndex({
// name: "my-index",
// dimension: 1536, // Match your embedding model dimension
// });
// Initialize the Endee vector store
const vectorStore = new EndeeVectorStore({
index: index,
chunkSize: 100,
});
// Create documents
const document = new Document({
text: "Your document content here...",
id_: "doc-1",
});
// Index documents with storage context
const storageContext = await storageContextFromDefaults({
vectorStore: vectorStore,
});
const vectorStoreIndex = await VectorStoreIndex.fromDocuments([document], { storageContext });
// Query the index
const queryEngine = vectorStoreIndex.asQueryEngine();
const response = await queryEngine.query({
query: "What is the main topic?",
});
console.log(response.toString());Configuration
EndeeVectorStore Parameters
| Parameter | Type | Description |
| ----------- | -------- | --------------------------------------------------- |
| index | Index | Endee index instance (from Endee.getIndex() or Endee.createIndex()) |
| chunkSize | number | Batch size for upserting vectors (default: 100) |
| textKey | string | Key used to store text in metadata (default: "text") |
Usage Examples
Indexing Documents
import fs from "node:fs/promises";
import { Endee } from "endee";
// Initialize Endee client and get/create an index
const endeeClient = new Endee(process.env.ENDEE_AUTH_TOKEN ?? "");
const index = await endeeClient.getIndex("knowledge-base");
const vectorStore = new EndeeVectorStore({
index: index,
chunkSize: 100,
});
const content = await fs.readFile("./documents/article.txt", "utf-8");
const document = new Document({ text: content, id_: "article-1" });
const storageContext = await storageContextFromDefaults({ vectorStore });
const vectorStoreIndex = await VectorStoreIndex.fromDocuments([document], { storageContext });Querying an Existing Index
import { Endee } from "endee";
// Initialize Endee client and get the index
const endeeClient = new Endee(process.env.ENDEE_AUTH_TOKEN ?? "");
const index = await endeeClient.getIndex("knowledge-base");
const vectorStore = new EndeeVectorStore({
index: index,
chunkSize: 100,
});
// Load from existing vector store
const vectorStoreIndex = await VectorStoreIndex.fromVectorStore(vectorStore);
const queryEngine = vectorStoreIndex.asQueryEngine();
const response = await queryEngine.query({
query: "Summarize the key points",
});
console.log(response.toString());Filtering in Queries
EndeeVectorStore supports metadata filtering during queries via LlamaIndex's MetadataFilters.
Currently, only the == (equals) and in operators are supported.
import { MetadataFilter } from "llamaindex";
import { Endee } from "endee";
// Initialize Endee client and get the index
const endeeClient = new Endee(process.env.ENDEE_AUTH_TOKEN ?? "");
const index = await endeeClient.getIndex("knowledge-base");
const vectorStore = new EndeeVectorStore({
index: index,
});
const vectorStoreIndex = await VectorStoreIndex.fromVectorStore(vectorStore);
const filter : MetadataFilter[] = [{key: "type", value: "sports", operator: "=="}];
const queryEngine = vectorStoreIndex.asQueryEngine({
preFilters: {filters: filter}
});
const response = await queryEngine.query({
query: "Explain the main concepts",
filters,
});
console.log(response.toString());Deleting Documents
import { Endee } from "endee";
// Initialize Endee client and get the index
const endeeClient = new Endee(process.env.ENDEE_AUTH_TOKEN ?? "");
const index = await endeeClient.getIndex("knowledge-base");
const vectorStore = new EndeeVectorStore({
index: index,
chunkSize: 100,
});
// Delete by reference document ID
await vectorStore.delete("doc-id-to-remove");API Reference
EndeeVectorStore
Methods
| Method | Description |
| --------------------- | ---------------------------------------- |
| add(nodes) | Add embedding nodes to the vector store |
| query(query) | Query the vector store for similar nodes |
| delete(refDocId) | Delete vectors by reference document ID |
| client() | Returns "Endee" string identifier |
Dependencies
- llamaindex - LlamaIndex TypeScript SDK
- endee - Endee vector database client
License
ISC
