omnismart-personas
Role-based, data-scoped LLM persona templates + router for production analytics copilots. The pattern behind IntelAI's 9-persona RAG copilot, extracted as a tiny, zero-dependency, pure-Python library.
A persona pairs a system prompt with a data-access scope (which business domains it may see) and a sampling temperature — so the same retrieval system can answer through different role-conditioned prompts and data filters ("persona-routed RAG").
Install
pip install omnismart-personas
Use
from omnismart_personas import persona_for_role, scope_records, build_rag_prompt
persona = persona_for_role("cfo") # → CFO persona (scope: Finance, Growth)
persona.can_access("People") # False — out of scope
rows = [
{"category": "Finance", "metric": "gross_margin", "value": 0.42},
{"category": "People", "metric": "headcount", "value": 220},
]
visible = scope_records(persona, rows) # drops the People row
prompt = build_rag_prompt(
persona,
"What drove the Q1 gross-margin change?",
[f"{r['metric']}={r['value']}" for r in visible],
language="en",
)
# → send `prompt` to any LLM
API
list_personas()→ the 9 persona keysget_persona(name)/persona_for_role(role)→ aPersonaPersona(name, display_name, system_prompt, allowed_tools, data_access, temperature)— immutable;.can_access(domain)scope_records(persona, records, domain_key="category")→ records in scopebuild_system_prompt(persona, *, language="en", extra=None)build_rag_prompt(persona, query, snippets, *, language="en")
Personas: ceo, cfo, cto, coo, chro, esg, risk, analyst, general.
LangChain
Use the personas in any LangChain RAG chain — pip install "omnismart-personas[langchain]":
from omnismart_personas import persona_for_role
from omnismart_personas.langchain import persona_chat_prompt, persona_retriever_filter
from langchain_openai import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser
persona = persona_for_role("cfo")
prompt = persona_chat_prompt(persona) # system = scope; {context} + {question}
chain = prompt | ChatOpenAI(model="gpt-4o-mini") | StrOutputParser()
docs = persona_retriever_filter(persona, retriever.invoke(q)) # RBAC on retrieved docs
answer = chain.invoke({"context": "\n".join(d.page_content for d in docs), "question": q})
persona_retriever_filter drops Documents whose metadata["category"] is outside the
persona's data_access scope — the same role boundaries, enforced in your LangChain pipeline.
Test
pip install -e ".[test]" && pytest
License
Licensed under the AGPL-3.0 and part of the IntelAI project. The AGPL requires that a network service built on this code, or on a modified copy of it, publish its own source. For closed-source use, a commercial license is available; see the IntelAI repository's COMMERCIAL.md.
The library makes no network calls and collects no telemetry.
Metadata
Release files for omnismart-personas 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| omnismart_personas-0.1.7.tar.gz | 20.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| omnismart_personas-0.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.4 kB
Release files / omnismart_personas-0.1.7.tar.gz
| Download URL | omnismart_personas-0.1.7.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db84e040f2bc8c2735c32d4778ef30bb3ce9bc6491f3f0f43acb3a3aab7dbb81
|
|
BLAKE2b-256 checksum How to use checksums |
c3680ae2d036c4d63070443ebd6eb9d431f10ab081becb86d2d56869d1b1cba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / omnismart_personas-0.1.7-py3-none-any.whl
| Download URL | omnismart_personas-0.1.7-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e9a45b442fa46a764506802195270e27ef2b736db42b40872f020de452360db4
|
|
BLAKE2b-256 checksum How to use checksums |
32e78e0b407ef83000287d2beb39b2b7900fc78401da68e8daa6e24cd6759889
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|