File size: 4,359 Bytes
e8ae44a
 
 
 
f22fae1
e8ae44a
 
a960c9f
 
 
e8ae44a
f22fae1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e8ae44a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db9053b
e8ae44a
 
 
 
 
f22fae1
 
e8ae44a
 
 
 
 
f22fae1
 
e8ae44a
f22fae1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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…")