Framework: LlamaIndex · pip install llama-index
SDK: pip install klickd==4.0.0
LlamaIndex offers two natural integration points for .klickd:
- System-prompt injection — same pattern as LangChain / OpenAI; the payload becomes the system message of a chat engine or agent.
- Document ingestion — the structured fields of a
.klickdpayload are turned intoDocumentobjects and embedded into a vector index alongside the rest of the user's corpus.
The reusable helpers live at
examples/v4/integrations/llamaindex/klickd_llamaindex.py.
from klickd import load_klickd
from llama_index.llms.openai import OpenAI
from llama_index.core.llms import ChatMessage
from examples.v4.integrations.llamaindex.klickd_llamaindex import klickd_to_system_prompt
with open("examples/v4/personas/01-eleve-terminale-fr.klickd", "rb") as f:
payload = load_klickd(f.read())
system_prompt = klickd_to_system_prompt(payload)
llm = OpenAI(model="gpt-4o")
response = llm.chat([
ChatMessage(role="system", content=system_prompt),
ChatMessage(role="user", content="Let's continue."),
])
print(response.message.content)from klickd import load_klickd
from llama_index.core import VectorStoreIndex
from examples.v4.integrations.llamaindex.klickd_llamaindex import klickd_to_documents
with open("examples/v4/personas/03-fullstack-developer-en.klickd", "rb") as f:
payload = load_klickd(f.read())
docs = klickd_to_documents(payload)
index = VectorStoreIndex.from_documents(docs)
query_engine = index.as_query_engine()
print(query_engine.query("What is the user currently blocked on?"))klickd_to_documents() emits one Document per structurally distinct
section (user_preferences, context, knowledge, plus one per
memory[] entry), with metadata carrying the section name, version, and
the original domain / profile_kind so you can filter on retrieval.
- Strip
_-prefixed debug / benchmark fields before ingest — the helper does this for you. - Encrypted envelopes: pass
passphrase=...toload_klickd_path(). - Treat the index as user-scoped: never co-mingle multiple users'
.klickdpayloads in the same vector store without a tenant filter.