Spaces:
Sleeping
Sleeping
Commit
·
c169c98
1
Parent(s):
216da8f
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,7 +53,27 @@ body {
|
|
| 53 |
background-color: #f0f5fb; /* Light pastel blue background */
|
| 54 |
}
|
| 55 |
.gradio-container {
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
/* Simple styling for buttons */
|
| 59 |
#send-btn {
|
|
@@ -72,6 +92,14 @@ body {
|
|
| 72 |
#clear-btn:hover {
|
| 73 |
background-color: #fff9e6 !important;
|
| 74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
footer {
|
| 76 |
display: none !important;
|
| 77 |
}
|
|
@@ -83,7 +111,7 @@ footer {
|
|
| 83 |
with gr.Blocks(css=css) as demo:
|
| 84 |
# Custom header with branding
|
| 85 |
gr.HTML("""
|
| 86 |
-
<div style="background: linear-gradient(135deg, #4a90e2, #75c6ef); padding: 15px; border-radius: 16px 16px 0 0; color: white; border-bottom: 3px solid #e6c200;">
|
| 87 |
<h1 style="font-size: 24px; font-weight: 600; margin: 0; display: flex; align-items: center; font-family: 'Palatino', serif;">
|
| 88 |
<span style="margin-right: 10px; font-size: 22px;">🛡️</span>
|
| 89 |
<span style="font-weight: 700; margin-right: 5px;">Safe</span>
|
|
@@ -129,8 +157,53 @@ with gr.Blocks(css=css) as demo:
|
|
| 129 |
chatbot = gr.Chatbot(
|
| 130 |
label="Conversation",
|
| 131 |
show_label=True,
|
| 132 |
-
height=400
|
|
|
|
| 133 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
with gr.Row():
|
| 135 |
user_input = gr.Textbox(
|
| 136 |
placeholder="Type your message here...",
|
|
|
|
| 53 |
background-color: #f0f5fb; /* Light pastel blue background */
|
| 54 |
}
|
| 55 |
.gradio-container {
|
| 56 |
+
background-color: white;
|
| 57 |
+
border-radius: 16px;
|
| 58 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.05);
|
| 59 |
+
max-width: 90%;
|
| 60 |
+
margin: 15px auto;
|
| 61 |
+
padding-bottom: 20px;
|
| 62 |
+
}
|
| 63 |
+
/* Header styling with diagonal shield */
|
| 64 |
+
.app-header {
|
| 65 |
+
position: relative;
|
| 66 |
+
overflow: hidden;
|
| 67 |
+
}
|
| 68 |
+
.app-header::before {
|
| 69 |
+
content: "🛡️";
|
| 70 |
+
position: absolute;
|
| 71 |
+
font-size: 100px;
|
| 72 |
+
opacity: 0.1;
|
| 73 |
+
right: -20px;
|
| 74 |
+
top: -30px;
|
| 75 |
+
transform: rotate(15deg);
|
| 76 |
+
pointer-events: none;
|
| 77 |
}
|
| 78 |
/* Simple styling for buttons */
|
| 79 |
#send-btn {
|
|
|
|
| 92 |
#clear-btn:hover {
|
| 93 |
background-color: #fff9e6 !important;
|
| 94 |
}
|
| 95 |
+
/* User/assistant emoji in chat */
|
| 96 |
+
.user-msg::before {
|
| 97 |
+
content: "👤 ";
|
| 98 |
+
}
|
| 99 |
+
.bot-msg::before {
|
| 100 |
+
content: "🛡️ ";
|
| 101 |
+
}
|
| 102 |
+
/* Hide elements */
|
| 103 |
footer {
|
| 104 |
display: none !important;
|
| 105 |
}
|
|
|
|
| 111 |
with gr.Blocks(css=css) as demo:
|
| 112 |
# Custom header with branding
|
| 113 |
gr.HTML("""
|
| 114 |
+
<div class="app-header" style="background: linear-gradient(135deg, #4a90e2, #75c6ef); padding: 15px; border-radius: 16px 16px 0 0; color: white; border-bottom: 3px solid #e6c200;">
|
| 115 |
<h1 style="font-size: 24px; font-weight: 600; margin: 0; display: flex; align-items: center; font-family: 'Palatino', serif;">
|
| 116 |
<span style="margin-right: 10px; font-size: 22px;">🛡️</span>
|
| 117 |
<span style="font-weight: 700; margin-right: 5px;">Safe</span>
|
|
|
|
| 157 |
chatbot = gr.Chatbot(
|
| 158 |
label="Conversation",
|
| 159 |
show_label=True,
|
| 160 |
+
height=400,
|
| 161 |
+
elem_classes=["chat-box"]
|
| 162 |
)
|
| 163 |
+
|
| 164 |
+
# Add JavaScript to inject user/assistant emojis
|
| 165 |
+
gr.HTML("""
|
| 166 |
+
<script>
|
| 167 |
+
// Function to add emojis to chat messages
|
| 168 |
+
function addEmojisToChat() {
|
| 169 |
+
setTimeout(function() {
|
| 170 |
+
// Find all user messages and add emoji
|
| 171 |
+
document.querySelectorAll('.user').forEach(function(el) {
|
| 172 |
+
if (!el.querySelector('.emoji-added')) {
|
| 173 |
+
let textEl = el.querySelector('p');
|
| 174 |
+
if (textEl) {
|
| 175 |
+
textEl.innerHTML = '👤 ' + textEl.innerHTML;
|
| 176 |
+
let span = document.createElement('span');
|
| 177 |
+
span.className = 'emoji-added';
|
| 178 |
+
span.style.display = 'none';
|
| 179 |
+
el.appendChild(span);
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
});
|
| 183 |
+
|
| 184 |
+
// Find all bot messages and add emoji
|
| 185 |
+
document.querySelectorAll('.bot').forEach(function(el) {
|
| 186 |
+
if (!el.querySelector('.emoji-added')) {
|
| 187 |
+
let textEl = el.querySelector('p');
|
| 188 |
+
if (textEl) {
|
| 189 |
+
textEl.innerHTML = '🛡️ ' + textEl.innerHTML;
|
| 190 |
+
let span = document.createElement('span');
|
| 191 |
+
span.className = 'emoji-added';
|
| 192 |
+
span.style.display = 'none';
|
| 193 |
+
el.appendChild(span);
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
});
|
| 197 |
+
|
| 198 |
+
// Call this function again to catch new messages
|
| 199 |
+
addEmojisToChat();
|
| 200 |
+
}, 1000);
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
// Start the process
|
| 204 |
+
window.addEventListener('load', addEmojisToChat);
|
| 205 |
+
</script>
|
| 206 |
+
""")
|
| 207 |
with gr.Row():
|
| 208 |
user_input = gr.Textbox(
|
| 209 |
placeholder="Type your message here...",
|