dcata004 commited on
Commit
b1144a3
·
verified ·
1 Parent(s): b237fea

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+
5
+ def scan_terms(url):
6
+ if not url:
7
+ return "Please enter a URL.", "GRAY"
8
+
9
+ try:
10
+ headers = {'User-Agent': 'Mozilla/5.0'}
11
+ response = requests.get(url, headers=headers, timeout=10)
12
+ soup = BeautifulSoup(response.text, 'html.parser')
13
+ text = soup.get_text().lower()
14
+
15
+ # Risk Keywords
16
+ red_flags = [
17
+ "perpetual license",
18
+ "irrevocable license",
19
+ "right to use",
20
+ "train our models",
21
+ "improve our services",
22
+ "royalty-free",
23
+ "worldwide license"
24
+ ]
25
+
26
+ found_flags = [phrase for phrase in red_flags if phrase in text]
27
+
28
+ if len(found_flags) > 0:
29
+ return f"🚨 HIGH RISK DETECTED\n\nWe found clauses that may grant the vendor rights to your data:\n" + "\n".join([f"- '{f}'" for f in found_flags]), "RED"
30
+ else:
31
+ return "✅ NO OBVIOUS RED FLAGS FOUND\n\n(Note: This is an automated scan, not legal advice. Always review the full contract.)", "GREEN"
32
+
33
+ except Exception as e:
34
+ return f"Error scanning URL: {str(e)}", "GRAY"
35
+
36
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
37
+ gr.Markdown("# 📜 AI Liability Scanner")
38
+ gr.Markdown("Paste a Vendor's 'Terms of Service' URL to scan for clauses that grant them the right to train on your data.")
39
+
40
+ url_input = gr.Textbox(label="Terms of Service URL", placeholder="https://openai.com/policies/terms")
41
+ scan_btn = gr.Button("Scan Contract", variant="primary")
42
+ output_box = gr.Textbox(label="Risk Assessment")
43
+
44
+ scan_btn.click(scan_terms, inputs=url_input, outputs=output_box)
45
+
46
+ demo.launch()