A compliance-ready Streamlit app that creates auditable JSON records for every AI interaction.
- Every interaction logged with full model metadata
- Grounded explanations based solely on observable inputs/outputs
- Governance flags for risk domains (financial, medical, HR, legal) and PII
- Append-only JSONL audit log for compliance review
- Download logs as CSV directly from the sidebar
- Runs entirely with free, local, open-source tools (Ollama)
1. Install dependencies
pip install -r requirements.txt2. Pull the model via Ollama
ollama pull llama3.1:8b3. Run the app
streamlit run app.py4. Run tests
pytest tests/ -vai-audit-trail/
├── app.py # Streamlit UI
├── src/
│ ├── schemas.py # Pydantic data models
│ ├── llm_client.py # Ollama wrapper
│ ├── explanation.py # Observable-evidence rationale engine
│ ├── governance.py # Rule-based PII & risk detection
│ └── audit_logger.py # Append-only JSONL logger
├── tests/
│ └── test_audit_system.py # Unit tests
├── logs/ # Created automatically at runtime
│ └── audit_log.jsonl
└── artifacts/explanations/ # AIX360-style JSON artifacts
Each line in logs/audit_log.jsonl is a JSON object with these top-level keys:
| Field | Description |
|---|---|
audit_id |
UUID4, unique per interaction |
timestamp_utc |
ISO 8601 naive UTC |
session_id |
8-char hex, resets on "New Session" |
model |
Provider, model name, temperature, max_tokens |
request |
System prompt, user prompt, context documents |
response |
Response text, latency in ms |
explanation |
Rationale summary, evidence used, artifact path |
governance |
Risk flags, PII detected, policy status |