anktechsol's picture
Update src/app.py
788163d verified
raw
history blame
4.36 kB
import streamlit as st
from compliance_lib import fetch_text, run_check, generate_report, RULES
import textwrap, json, datetime, os
st.set_page_config(page_title="Anupalan Karta – Compliance Checker",
layout="wide")
st.title("🛡️ Anupalan Karta (अनुपालंकर्ता)")
st.subheader("Unified compliance self-check Tool")
# --- introduction and how-to guide ------------------------------------------
st.markdown("""
## Introduction
**Anupalan Karta** (अनुपालंकर्ता) is a simple tool to help business owners, data architects, and data owners quickly check if their policies and procedures meet important regulations like GDPR, EU AI Act, and ISO 27001.
### Why is this important?
- Regulations protect your business from legal risks, fines, and reputational harm.
- Checking compliance early helps you fix gaps before audits or problems arise.
- Anupalan Karta gives you a fast, automated review and clear feedback, so you know where you stand.
## How to use
1. **Choose your input:**
On the left, either paste your policy text, enter a public website link, or upload a file (.txt, .md, .pdf).
2. **Select frameworks:**
Pick which compliance standards you want to check (you can select more than one).
3. **Run the check:**
Click "Run compliance check" to see which requirements you meet and which need attention.
4. **Get your report:**
Optionally, generate a summary report with next steps, and download it as a Markdown file.
**Who is this for?**
This tool is designed for business owners, data architects, and anyone responsible for data and compliance in their organization. No technical expertise is needed—just your policy documents.
---
**Need a deeper compliance review or expert guidance?**
Visit [anktechsol.com](https://anktechsol.com) for professional compliance consulting, detailed policy analysis, and tailored solutions for your business.
---
""")
# --- sidebar ---------------------------------------------------------------
with st.sidebar:
st.header("📑 Input options")
mode = st.radio("Choose data source:",
("Paste text", "URL of public policy", "Upload file"))
if mode == "Paste text":
raw_text = st.text_area("Paste your policy / procedures here")
elif mode == "URL of public policy":
url = st.text_input("Public URL (HTTPS)")
raw_text = fetch_text(url) if url else ""
else:
up = st.file_uploader("Upload .txt, .md or .pdf", type=["txt", "md", "pdf"])
raw_text = up.read().decode("utf-8", errors="ignore") if up else ""
st.markdown("---")
selected_fw = st.multiselect(
"Frameworks to check",
list(RULES.keys()),
default=list(RULES.keys())
)
run_btn = st.button("Run compliance check")
# --- main body --------------------------------------------------------------
if run_btn and raw_text.strip():
with st.spinner("Running rule-based checks…"):
results = run_check(raw_text)
st.subheader("📊 Checklist results")
for fw in selected_fw:
passed = sum(1 for _, ok in results[fw] if ok)
total = len(results[fw])
st.write(f"**{fw}: {passed}/{total} items passed**")
st.progress(passed / total)
for label, ok in results[fw]:
st.write(("✅" if ok else "❌") + " " + label)
st.markdown("---")
# --- AI report section --------------------------------------------------
st.subheader("📝 Generate narrative report")
if st.button("Generate AI report"):
with st.spinner("Calling model… this may take ~30 s"):
bullet = "\n".join(
f"- {fw}: {sum(ok for _, ok in results[fw])}/{len(results[fw])} passed"
for fw in selected_fw
)
from config import AI_REPORT_PROMPT # <-- import the prompt template
prompt = AI_REPORT_PROMPT.format(bullet=bullet)
report = generate_report(prompt)
st.markdown("#### Draft report")
st.code(report, language="markdown")
st.download_button("⬇️ Download .md",
report.encode("utf-8"),
file_name="anupalan_karta_report.md",
mime="text/markdown")
else:
st.info("Awaiting input…")