F.A.I.L. Kit - Forensic Audit of Intelligent Logic - FastAPI middleware
Project description
F.A.I.L. Kit - FastAPI Middleware
Zero-config FastAPI middleware for AI agent auditing.
Installation
pip install fail-kit
Quick Start
from fastapi import FastAPI
from fail_kit import fail_audit
app = FastAPI()
@app.post("/eval/run")
@fail_audit(auto_receipts=True)
async def evaluate(prompt: str, context: dict):
# Your agent logic here
result = await your_agent(prompt)
return {
"response": result["text"],
"actions": result["actions"],
"receipts": result["receipts"]
}
Then run the audit:
pip install fail-kit-cli # Or: npm install -g @fail-kit/cli
fail-audit scan
fail-audit run --format html
Usage
With Actions and Receipts
from fail_kit import fail_audit, FailAuditAction
from datetime import datetime
@app.post("/eval/run")
@fail_audit(auto_receipts=True)
async def evaluate(prompt: str, context: dict):
# Create an action
action = FailAuditAction(
tool="database_query",
input=prompt,
output="Query result",
status="success",
latency_ms=45
)
return {
"response": "Here's what I found...",
"actions": [action.to_dict()],
}
# Receipts are auto-generated!
Simple Text Response
from fail_kit import fail_audit_simple
@app.post("/eval/run")
@fail_audit_simple
async def evaluate(prompt: str, context: dict):
return f"Answer to: {prompt}"
With Escalation
from fail_kit import fail_audit
@app.post("/eval/run")
@fail_audit(auto_receipts=True)
async def evaluate(prompt: str, context: dict):
if "delete" in prompt.lower():
return {
"response": "This requires human approval.",
"actions": [],
"policy": {
"escalate": True,
"reasons": ["high-stakes operation"]
}
}
return {"response": "Done!", "actions": []}
API Reference
@fail_audit(auto_receipts=True, action_logger=None)
Decorator for agent endpoints.
auto_receipts: Automatically generate receipts from actionsaction_logger: Optional async function to log actions
@fail_audit_simple
Simple decorator for text-only agents.
FailAuditAction
Helper class for creating actions:
action = FailAuditAction(
tool="tool_name",
input="input data",
output="output data",
status="success", # or "failed"
latency_ms=100
)
FailAuditReceipt
Helper class for creating receipts:
receipt = FailAuditReceipt(
tool="tool_name",
status="success",
proof="Proof of execution"
)
Links
License
MIT
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
fail_kit-1.0.0.tar.gz
(4.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fail_kit-1.0.0.tar.gz.
File metadata
- Download URL: fail_kit-1.0.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0238b6b3ec4076d71bcaa4ac3b02378cf086fc48713743a2d12cfc15ea549266
|
|
| MD5 |
0a379ec1925cf9dd9cf9e9ae34317026
|
|
| BLAKE2b-256 |
c42eb05349b88b723d06906c19ffaf6196e86367ce78284841cde04c482ceaca
|
File details
Details for the file fail_kit-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fail_kit-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e23c36b4de26ad422ee12b80e934f012bb1dd03d15bb4ebd159a32a4eb6b3827
|
|
| MD5 |
a3d1cf835b15a9cd8282c53557e7d16a
|
|
| BLAKE2b-256 |
5487506419803f354d41368d3844dc7f51d2f0230a9b65d78ff69ce8502a55b6
|