Skip to content

Copy Paste Examples

Krishna Kishor Tirupati edited this page May 23, 2026 · 1 revision

Copy-Paste Examples

These examples are small runnable folders designed for developers searching for practical PolicyAware integration patterns. Each example includes a README.md, runnable Python, YAML policy, and captured terminal output.

Core Examples

Example What It Shows Link
FastAPI LLM Policy Middleware Protect a FastAPI /chat endpoint with policy checks before model execution. https://github.com/ktirupati/policyaware/tree/main/examples/fastapi-llm-policy-middleware
LangChain Policy Guardrails Wrap a chain-style LLM call with deny-by-default policy, PII redaction, and secret blocking. https://github.com/ktirupati/policyaware/tree/main/examples/langchain-policy-guardrails
MCP Tool Permission Gateway Govern connector-level and action-level tool permissions for agent workflows. https://github.com/ktirupati/policyaware/tree/main/examples/mcp-tool-permission-gateway

Governance Examples

Example What It Shows Link
PII Redaction Policy Inspect and redact sensitive text before model execution. https://github.com/ktirupati/policyaware/tree/main/examples/pii-redaction-policy
Regulated RAG Assistant Require citations and stricter controls for healthcare-style RAG. https://github.com/ktirupati/policyaware/tree/main/examples/regulated-rag-assistant
Provider Routing By Risk Route public-safe requests to low-cost models and high-risk requests to approved models. https://github.com/ktirupati/policyaware/tree/main/examples/provider-routing-by-risk
Audit Trace Viewer Write audit traces and generate a local HTML trace viewer. https://github.com/ktirupati/policyaware/tree/main/examples/audit-trace-viewer
Approval Workflow Hooks Send high-risk requests to approval instead of calling a model. https://github.com/ktirupati/policyaware/tree/main/examples/approval-workflow-hooks

Recommended First Run

pip install policyaware
cd examples/pii-redaction-policy
python demo.py

Expected output:

contains_pii=True
categories=email, phone
redacted=Contact [REDACTED_EMAIL] or [REDACTED_PHONE] about claim ACME-42.
gateway_decision=conditional_allow
gateway_actions=redact

Why These Examples Matter

They show how PolicyAware fits into common developer searches:

  • FastAPI LLM policy middleware
  • LangChain policy guardrails
  • MCP tool permission gateway
  • PII redaction before LLM calls
  • regulated RAG governance
  • risk-based model routing
  • audit trace viewer
  • approval workflow hooks

Clone this wiki locally