-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
99 lines (91 loc) · 2.92 KB
/
Copy pathmain.py
File metadata and controls
99 lines (91 loc) · 2.92 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
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
import streamlit as st
from components.sidebar import sidebar_ui
from components.chat_ui import chat_ui
from components.pdf_handler import handle_pdf_upload
from PIL import Image
img = Image.open("assets/note2knowledge_logo.png")
st.set_page_config(
page_title="Note2Knowledge – Study Guide & Personal Assistant",
page_icon=img,
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS for UI improvements
st.markdown("""
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
.app-header {
background: linear-gradient(135deg, #1a1d2e 0%, #16213e 50%, #0f3460 100%);
border-radius: 16px;
padding: 24px 32px;
margin-bottom: 24px;
border: 1px solid rgba(79, 140, 255, 0.2);
}
.app-title {
font-size: 2.8rem;
font-weight: 700;
background: linear-gradient(90deg, #4F8CFF, #a78bfa);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin: 0;
line-height: 1.2;
}
.app-tagline {
font-size: 0.9rem;
color: #8892a4;
margin: 4px 0 0 0;
}
.mode-badge {
display: inline-block;
background: rgba(79, 140, 255, 0.12);
border: 1px solid rgba(79, 140, 255, 0.3);
color: #4F8CFF;
border-radius: 20px;
padding: 4px 14px;
font-size: 0.8rem;
font-weight: 600;
}
hr { border-color: rgba(79, 140, 255, 0.12) !important; margin: 16px 0 !important; }
[data-testid="stSidebar"] { background: #12151f !important; }
.stButton > button { border-radius: 8px !important; font-weight: 600 !important; }
.stTextInput > div > div > input,
.stTextArea > div > div > textarea {
border-radius: 10px !important;
border: 1px solid rgba(79, 140, 255, 0.25) !important;
}
[data-testid="stChatInput"] > div {
border-radius: 12px !important;
border: 1px solid rgba(79, 140, 255, 0.3) !important;
}
</style>
""", unsafe_allow_html=True)
# Initialize session state
if "pdf_content" not in st.session_state:
st.session_state.pdf_content = None
if "user_focus" not in st.session_state:
st.session_state.user_focus = ""
# Sidebar
selected_mode, selected_sub_mode = sidebar_ui()
# Header
mode_label = f"{selected_mode}" + (f" › {selected_sub_mode}" if selected_sub_mode else "")
st.markdown(f"""
<div class="app-header">
<div>
<p class="app-title">📘 Note2Knowledge</p>
<p class="app-tagline">Study Guide & Personal Assistant · <span class="mode-badge">{mode_label}</span></p>
</div>
</div>
""", unsafe_allow_html=True)
# PDF Handler (only show in Summarizer mode)
if selected_mode == "📰 Summarizer":
pdf_text, user_focus, summarize_clicked = handle_pdf_upload()
if summarize_clicked and pdf_text:
st.session_state.pdf_content = pdf_text
st.session_state.user_focus = user_focus
st.divider()
st.success("✅ PDF loaded! You can now ask questions about it in the chat below.")
st.divider()
# Chat UI
chat_ui(selected_mode, selected_sub_mode)