Skip to main content

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 keys
  • get_persona(name) / persona_for_role(role) → a Persona
  • Persona(name, display_name, system_prompt, allowed_tools, data_access, temperature) — immutable; .can_access(domain)
  • scope_records(persona, records, domain_key="category") → records in scope
  • build_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

MIT licensed. Part of the IntelAI project.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omnismart_personas-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

omnismart_personas-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file omnismart_personas-0.1.1.tar.gz.

File metadata

  • Download URL: omnismart_personas-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for omnismart_personas-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9d083d1480abf4684cf2443ba3449c76864ec14cfafe2a65609242a0df639c5d
MD5 710d103681f2338e4f1ac69409e3ba55
BLAKE2b-256 c57afa2e1a2ae6c1326763ac2ffe237fe1a51f1321f949c167e4c5882e0ce3e1

See more details on using hashes here.

File details

Details for the file omnismart_personas-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for omnismart_personas-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9df963dc6252f5bd2d7f66eb537d3c8d7b6067f1b0dceed3e07a0752d279c51
MD5 551ddb56b4a4fef399466b128c2a1e45
BLAKE2b-256 bb20d4c1ca30cf4c72252555d2cffe7b37b59225103c5074f47100cb580d8c1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page