Skip to content

Install the integration:

bash
pip install 'poma[langchain]'

The LangChain integration gives you three helpers:

  • PomaFileLoader to load files from a path
  • PomaChunksetSplitter to turn documents into POMA chunkset documents
  • PomaCheatsheetRetrieverLC to wrap a LangChain vector store and return cheatsheet documents

Chunk documents with PrimeCut

python
from poma import PrimeCut
from poma.integrations.langchain import PomaFileLoader, PomaChunksetSplitter

client = PrimeCut()
documents = PomaFileLoader("./docs").load()

splitter = PomaChunksetSplitter(client, verbose=True)
chunkset_docs = splitter.split_documents(documents)

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

Each output Document stores the chunkset text in page_content and includes the source chunks in metadata. The splitter expects each input document to carry a valid metadata["source_path"].

Add the chunksets to your vector store

python
# Replace this with your preferred LangChain vector store.
vector_store = ...
vector_store.add_documents(chunkset_docs)

Retrieve cheatsheets instead of raw chunksets

python
from poma.integrations.langchain import PomaCheatsheetRetrieverLC

retriever = PomaCheatsheetRetrieverLC(vector_store, top_k=4)
cheatsheet_docs = retriever.invoke("How do I authenticate?")

print(cheatsheet_docs[0].page_content)

PomaCheatsheetRetrieverLC groups hits by document and returns one cheatsheet Document per document.