Skip to content

Install the integration:

bash
pip install 'poma[llamaindex]'

The LlamaIndex integration gives you three helpers:

  • PomaFileReader to load supported files into Document objects
  • PomaChunksetNodeParser to turn documents into structure-aware nodes
  • PomaCheatsheetRetrieverLI to wrap an existing retriever and return cheatsheet nodes

Parse documents into chunkset nodes

python
from poma import PrimeCut
from poma.integrations.llamaindex import PomaFileReader, PomaChunksetNodeParser

client = PrimeCut()
documents = PomaFileReader().load_data("./docs")
parser = PomaChunksetNodeParser(client=client)
nodes = parser.get_nodes_from_documents(documents, show_progress=True)

print(len(nodes))
print(nodes[0].metadata.keys())

Each node keeps the original chunkset data and the matching chunks in metadata. The parser expects each input document to carry a valid metadata["source_path"].

Wrap an existing retriever

python
from llama_index.core import VectorStoreIndex
from poma.integrations.llamaindex import PomaCheatsheetRetrieverLI

index = VectorStoreIndex(nodes)
base_retriever = index.as_retriever(similarity_top_k=4)
retriever = PomaCheatsheetRetrieverLI(base_retriever)

response = retriever.as_query_engine().query("How do I authenticate?")
print(str(response))

PomaCheatsheetRetrieverLI groups hits by document and returns a structure-preserving cheatsheet per document.