-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.py
More file actions
65 lines (58 loc) · 2.19 KB
/
ui.py
File metadata and controls
65 lines (58 loc) · 2.19 KB
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
import streamlit as st
def load_css():
with open("style.css") as f:
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
# ---------- Header ----------
def header():
st.markdown("""
<div style="
text-align:center;
padding:14px;
background-color:#f5f9ff;
border-radius:10px;
margin-bottom:20px;
">
<h2 style="color:#4f8ef7;margin:0;">ConsentClear</h2>
<p style="color:#555;margin-top:4px;">AI-Powered Document Analysis</p>
</div>
""", unsafe_allow_html=True)
# ---------- Left Panel ----------
def left_panel_upload():
st.markdown("<div class='upload-card'>", unsafe_allow_html=True)
files = st.file_uploader(
"Upload PDFs, Images, or Audio files",
type=["pdf", "png", "jpg", "jpeg", "wav", "mp3"],
accept_multiple_files=True
)
st.markdown("</div>", unsafe_allow_html=True)
return files
def left_panel_actions():
analyze_btn = st.button("AI Analysis", use_container_width=True)
threat_btn = st.button("Threats & Warnings", use_container_width=True)
return analyze_btn, threat_btn
# ---------- Right Panel ----------
def right_panel_extracted(text: str):
st.markdown("### Extracted Text")
if text:
st.markdown(
f"""
<div class="results-card" style="max-height: 350px; overflow-y:auto;">
<pre style="white-space: pre-wrap;">{text}</pre>
</div>
""", unsafe_allow_html=True
)
else:
st.info("No text extracted yet. Upload a file to extract text.")
# ---------- Results Display ----------
def show_results(results: list, title: str, color="#4f8ef7"):
st.markdown(f"### {title}")
if results:
items_html = "<ul style='padding-left:20px;'>"
for r in results:
safe_r = r.replace("<", "<").replace(">", ">")
safe_r = safe_r.replace("\n", "<br>")
items_html += f"<li style='margin-bottom:6px;'>{safe_r}</li>"
items_html += "</ul>"
st.markdown(f"<div class='results-card'>{items_html}</div>", unsafe_allow_html=True)
else:
st.info(f"No {title.lower()} found.")