-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnavegation.py
142 lines (124 loc) · 4.61 KB
/
navegation.py
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import warnings
warnings.filterwarnings("ignore", category=Warning)
import streamlit as st
import st_pages # required modules
# Set page config
st.set_page_config(page_title="TalkNexus - Ollama Chatbot Multi-Model Interface", layout="wide", page_icon="🤖")
# Load custom CSS from file
def load_css(file_name):
with open(file_name) as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
load_css('styles.css')
# Initialize session state
if 'current_page' not in st.session_state:
st.session_state.current_page = "Home"
# Header
st.markdown(f"""
<div class="header">
<div class="animated-bg"></div>
<div class="header-content">
<h1 class="header-title">Ollama Chatbot Multi-Model Interface</h1>
<p class="header-subtitle">Advanced Language Models & Intelligent Conversations</p>
</div>
</div>
""", unsafe_allow_html=True)
# Enhanced pages definition
PAGES = {
"Home": {
"icon": "house-door",
"func": st_pages.home,
"description": "Guidelines & Overview",
"badge": "Informative",
"color": "var(--primary-color)"
},
"Language Models Management": {
"icon": "gear",
"func": st_pages.model_management,
"description": "Download Models",
"badge": "Configurations",
"color": "var(--secondary-color)"
},
"AI Conversation": {
"icon": "chat-dots",
"func": st_pages.ai_chatbot,
"description": "Interactive AI Chat",
"badge": "Application",
"color": "var(--highlight-color)"
},
"RAG Conversation": {
"icon": "chat-dots",
"func": st_pages.rag_chat,
"description": "PDF AI Chat Assistant",
"badge": "Application",
"color": "var(--highlight-color)"
}
}
st.markdown("""
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css">
""", unsafe_allow_html=True)
def navigate():
with st.sidebar:
st.markdown('''
<a href="https://github.com/TsLu1s/talknexus" target="_blank" style="text-decoration: none; color: inherit; display: block;">
<div class="header-container" style="cursor: pointer;">
<div class="profile-section">
<div class="profile-info">
<h1 style="font-size: 38px;">TalkNexus</h1>
<span class="active-badge" style="font-size: 20px;">AI Chatbot Multi-Model Application</span>
</div>
</div>
</div>
</a>
''', unsafe_allow_html=True)
st.markdown('---')
# Create menu items
for page, info in PAGES.items():
selected = st.session_state.current_page == page
# Create the button (invisible but clickable)
if st.button(
f"{page}",
key=f"nav_{page}",
use_container_width=True,
type="secondary" if selected else "primary"
):
st.session_state.current_page = page
st.rerun()
# Visual menu item
st.markdown(f"""
<div class="menu-item {'selected' if selected else ''}">
<div class="menu-icon">
<i class="bi bi-{info['icon']}"></i>
</div>
<div class="menu-content">
<div class="menu-title">{page}</div>
<div class="menu-description">{info['description']}</div>
</div>
<div class="menu-badge">{info['badge']}</div>
</div>
""", unsafe_allow_html=True)
# Close navigation container
st.markdown('</div>', unsafe_allow_html=True)
return st.session_state.current_page
# Get selected page and run its function
try:
selected_page = navigate()
# Update session state
if selected_page != st.session_state.current_page:
st.session_state.current_page = selected_page
st.rerun()
# Run the selected function
page_function = PAGES[selected_page]["func"]
page_function()
except Exception as e:
st.error(f"Error loading page: {str(e)}")
st_pages.home.run()
# Display the footer
st.markdown("""
<div class="footer">
<div class="footer-content">
<p>© 2024 Powered by <a href="https://github.com/TsLu1s" target="_blank">TsLu1s </a>.
Advanced Language Models & Intelligent Conversations
| Project Source: <a href="https://github.com/TsLu1s/talknexus" target="_blank"> TalkNexus</p>
</div>
</div>
""", unsafe_allow_html=True)