Skip to main content

TealTiger governance callback handler for LlamaIndex — deterministic policy enforcement, cost tracking, and audit for RAG pipelines

Project description

llamaindex-tealtiger

Deterministic governance callback handler for LlamaIndex — policy enforcement, cost tracking, PII detection, and structured audit for RAG pipelines. No LLM in the governance path.

PyPI License Python

Install

pip install llamaindex-tealtiger

Zero-Config Quickstart (3 lines)

from llama_index.core import Settings
from llamaindex_tealtiger import TealTigerCallback

Settings.callback_manager.add_handler(TealTigerCallback())

That's it. Every LLM call, retriever fetch, and tool invocation is now logged with cost tracking and PII detection — nothing is blocked.

Enforce Mode — Block Policy Violations

from llama_index.core import Settings
from llamaindex_tealtiger import TealTigerCallback, GovernanceDenyError

handler = TealTigerCallback(
    mode="ENFORCE",
    policies=[
        {"type": "tool_allowlist", "tools": ["search", "calculator"]},
    ],
    budget=5.00,  # USD session limit
    agent_id="rag-pipeline-prod",
)
Settings.callback_manager.add_handler(handler)

# Any tool not in the allowlist raises GovernanceDenyError
# before the tool executes — no wasted compute.
try:
    index.as_query_engine().query("Run dangerous_tool now")
except GovernanceDenyError as e:
    print(f"Blocked: {e.decision['reason']}")
    print(f"Codes:   {e.decision['reason_codes']}")

Use with TealEngine (Advanced Policies)

from tealtiger.core.engine import TealEngine
from llamaindex_tealtiger import TealTigerCallback

engine = TealEngine(policies=[...])

handler = TealTigerCallback(
    mode="ENFORCE",
    engine=engine,
    budget=10.00,
)

Features

Feature Description
Three Modes OBSERVE (log only), MONITOR (log + warn), ENFORCE (log + block)
Cost Tracking Per-request and session-level cost accumulation using TealTiger pricing
Budget Limits Session-level USD budget with automatic DENY on breach
PII Detection Email, phone, SSN, credit card, IP address patterns
Secret Detection API keys, tokens, Bearer headers, AWS keys, GitHub PATs
Params Hashing SHA-256 digest of JCS-canonicalized args for reproducibility
Policy Engine Built-in allowlist/blocklist or plug in TealEngine for advanced rules
Fail Closed Policy timeouts and errors always result in DENY
Audit Trail Full decision history with correlation IDs and proposed_call_id
OpenTelemetry Automatic trace_id capture when OTel is available
Adapter Source Every event tagged with adapter_source: llamaindex-tealtiger

Governance Modes

Mode Behavior
OBSERVE Allow all, log decisions, track cost (default)
MONITOR Allow all, log denials as warnings
ENFORCE Block denied actions, raise GovernanceDenyError

Session Report

report = handler.report()
# {
#   "session_id": "...",
#   "mode": "ENFORCE",
#   "total_evaluations": 42,
#   "allowed": 40,
#   "denied": 2,
#   "total_cost_usd": 0.0847,
#   "budget_usd": 5.00,
#   "pii_findings_total": 3,
#   "secrets_detected_total": 1,
# }

Requirements

  • Python ≥ 3.9
  • llama-index-core >= 0.11.0
  • tealtiger >= 1.3.0

Links

License

Apache-2.0

Project details


Download files

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

Source Distribution

llamaindex_tealtiger-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

llamaindex_tealtiger-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file llamaindex_tealtiger-0.1.0.tar.gz.

File metadata

  • Download URL: llamaindex_tealtiger-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for llamaindex_tealtiger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d3de16881085e65499899aaa0c9efde699ba838f21a7d183a6c8c487eb849f6b
MD5 b6177a2c79c6ad1a1a6c1462cbe40b3f
BLAKE2b-256 ffaa1e23a05bc20bac60cd859889810d6b4ffffc3457f6e1991bd69721a43eba

See more details on using hashes here.

File details

Details for the file llamaindex_tealtiger-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llamaindex_tealtiger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69aabf8ebefef877b42a8392e8790f8c5b3e09019039671b61b2d9ea3b2e67f9
MD5 049ff8070f5d2f0461b52ad85cc69f07
BLAKE2b-256 7267c90ce57676fe1895f0304f2a0e55e655b0b5e51c7bb82f6f18664940557d

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 Pingdom Monitoring Sentry Error logging StatusPage Status page