- Python
- TypeScript
Installation
pip install zespan llama-index
Usage
RegisterLumiqLlamaIndexCallbackHandler with LlamaIndex’s global callback manager.import zespan
from zespan import LumiqLlamaIndexCallbackHandler
from llama_index.core import Settings
from llama_index.core.callbacks import CallbackManager
zespan.init(api_key="zsp_your_api_key_here")
handler = LumiqLlamaIndexCallbackHandler()
Settings.callback_manager = CallbackManager([handler])
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What are the key points?")
print(response)
Installation
npm install @zespan/sdk llamaindex
Usage
Create aLumiqLlamaIndexHandler and attach it to your LlamaIndex callback manager.import { LumiqLlamaIndexHandler, zespan } from "@zespan/sdk";
import { Settings } from "llamaindex";
zespan.init({ apiKey: process.env.ZESPAN_API_KEY! });
const handler = new LumiqLlamaIndexHandler();
handler.attach(Settings.callbackManager);
import { VectorStoreIndex, SimpleDirectoryReader } from "llamaindex";
const documents = await new SimpleDirectoryReader().loadData({ directoryPath: "./data" });
const index = await VectorStoreIndex.fromDocuments(documents);
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({ query: "What are the key points?" });
console.log(response.toString());
handler.detach(Settings.callbackManager);

