Skip to main content

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

License

Apache-2.0

Release files for llamaindex-tealtiger 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llamaindex-tealtiger 0.1.0
File Size Uploaded
llamaindex_tealtiger-0.1.0.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llamaindex-tealtiger 0.1.0
File Interpreter ABI Platform
llamaindex_tealtiger-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.2 kB

Release files / llamaindex_tealtiger-0.1.0.tar.gz

Download URL llamaindex_tealtiger-0.1.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d3de16881085e65499899aaa0c9efde699ba838f21a7d183a6c8c487eb849f6b
BLAKE2b-256 checksum
How to use checksums
ffaa1e23a05bc20bac60cd859889810d6b4ffffc3457f6e1991bd69721a43eba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / llamaindex_tealtiger-0.1.0-py3-none-any.whl

Download URL llamaindex_tealtiger-0.1.0-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69aabf8ebefef877b42a8392e8790f8c5b3e09019039671b61b2d9ea3b2e67f9
BLAKE2b-256 checksum
How to use checksums
7267c90ce57676fe1895f0304f2a0e55e655b0b5e51c7bb82f6f18664940557d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page