Update app.py
Browse files
app.py
CHANGED
|
@@ -49,187 +49,175 @@ def chatbot(history, query):
|
|
| 49 |
history.append((query, response))
|
| 50 |
return history, history
|
| 51 |
|
| 52 |
-
# Custom CSS for a
|
| 53 |
custom_css = """
|
| 54 |
/* General container styling */
|
| 55 |
.gradio-container {
|
| 56 |
-
font-family: '
|
| 57 |
-
background: #
|
| 58 |
min-height: 100vh;
|
| 59 |
padding: 0;
|
| 60 |
margin: 0;
|
| 61 |
-
font-size: 14px; /* Base font size
|
| 62 |
}
|
| 63 |
|
| 64 |
/* Header styling */
|
| 65 |
h1 {
|
| 66 |
-
color: #
|
| 67 |
-
font-size:
|
| 68 |
text-align: center;
|
| 69 |
-
margin:
|
| 70 |
text-shadow: none;
|
| 71 |
}
|
| 72 |
|
| 73 |
p {
|
| 74 |
-
color: #
|
| 75 |
-
font-size:
|
| 76 |
text-align: center;
|
| 77 |
-
margin-bottom:
|
| 78 |
}
|
| 79 |
|
| 80 |
-
/* Chatbot container
|
| 81 |
.chatbot {
|
| 82 |
-
border-radius:
|
| 83 |
-
box-shadow:
|
| 84 |
-
background: #
|
| 85 |
-
padding:
|
| 86 |
-
max-width:
|
| 87 |
-
margin: 0 !important;
|
| 88 |
-
height:
|
| 89 |
overflow-y: auto !important;
|
| 90 |
-
display:
|
| 91 |
-
flex-direction: column-reverse; /* Bottom-up chat like WhatsApp */
|
| 92 |
}
|
| 93 |
|
| 94 |
-
/* Chat bubbles:
|
| 95 |
.chatbot .bubble {
|
| 96 |
-
border-radius:
|
| 97 |
-
padding:
|
| 98 |
-
margin:
|
| 99 |
-
max-width:
|
| 100 |
-
font-size: 14px !important; /*
|
| 101 |
-
min-height:
|
| 102 |
-
min-width:
|
| 103 |
word-wrap: break-word !important;
|
| 104 |
-
line-height: 1.
|
| 105 |
-
color: #
|
| 106 |
}
|
| 107 |
|
| 108 |
-
/* User bubble: Right-aligned,
|
| 109 |
.chatbot .bubble:nth-child(odd) {
|
| 110 |
-
background: #
|
|
|
|
| 111 |
margin-left: auto !important;
|
| 112 |
align-self: flex-end !important;
|
| 113 |
}
|
| 114 |
|
| 115 |
-
/* Bot bubble: Left-aligned, light gray
|
| 116 |
.chatbot .bubble:nth-child(even) {
|
| 117 |
-
background: #
|
| 118 |
margin-right: auto !important;
|
| 119 |
align-self: flex-start !important;
|
| 120 |
}
|
| 121 |
|
| 122 |
-
/* Input area
|
| 123 |
.gradio-row:last-child {
|
| 124 |
-
position: fixed !important;
|
| 125 |
-
bottom: 0 !important;
|
| 126 |
width: 100% !important;
|
| 127 |
-
max-width:
|
| 128 |
-
|
| 129 |
-
padding:
|
| 130 |
-
box-shadow: 0 -2px 5px rgba(0,0,0,0.1) !important;
|
| 131 |
-
z-index: 1000 !important;
|
| 132 |
display: flex !important;
|
| 133 |
align-items: center !important;
|
|
|
|
| 134 |
}
|
| 135 |
|
| 136 |
-
/* Textbox styling
|
| 137 |
input[type="text"] {
|
| 138 |
-
border: 1px solid #
|
| 139 |
-
border-radius:
|
| 140 |
padding: 8px 12px !important;
|
| 141 |
font-size: 14px !important;
|
| 142 |
-
box-shadow:
|
| 143 |
flex-grow: 1 !important;
|
| 144 |
-
margin-right:
|
| 145 |
-
color: #
|
| 146 |
}
|
| 147 |
|
| 148 |
input[type="text"]::placeholder {
|
| 149 |
-
color: #
|
| 150 |
font-size: 14px !important;
|
| 151 |
}
|
| 152 |
|
| 153 |
input[type="text"]:focus {
|
| 154 |
-
border-color: #
|
| 155 |
outline: none !important;
|
| 156 |
}
|
| 157 |
|
| 158 |
-
/* Send button
|
| 159 |
button {
|
| 160 |
-
border-radius:
|
| 161 |
-
background: #
|
| 162 |
color: white !important;
|
| 163 |
-
padding:
|
| 164 |
font-size: 14px !important;
|
| 165 |
border: none !important;
|
| 166 |
-
min-width:
|
| 167 |
transition: background 0.3s ease !important;
|
| 168 |
text-align: center !important;
|
| 169 |
}
|
| 170 |
|
| 171 |
button:hover {
|
| 172 |
-
background: #
|
| 173 |
}
|
| 174 |
|
| 175 |
-
/* Clear button
|
| 176 |
button[aria-label="Clear Chat"] {
|
| 177 |
-
background: #
|
| 178 |
-
padding: 6px
|
| 179 |
-
font-size:
|
| 180 |
-
min-width:
|
| 181 |
-
margin-top:
|
| 182 |
align-self: center !important;
|
| 183 |
-
color: #
|
| 184 |
}
|
| 185 |
|
| 186 |
button[aria-label="Clear Chat"]:hover {
|
| 187 |
-
background: #
|
| 188 |
-
}
|
| 189 |
-
|
| 190 |
-
/* Animations */
|
| 191 |
-
@keyframes slideIn {
|
| 192 |
-
from {
|
| 193 |
-
opacity: 0;
|
| 194 |
-
transform: translateY(10px);
|
| 195 |
-
}
|
| 196 |
-
to {
|
| 197 |
-
opacity: 1;
|
| 198 |
-
transform: translateY(0);
|
| 199 |
-
}
|
| 200 |
}
|
| 201 |
|
| 202 |
/* Scrollbar styling */
|
| 203 |
.chatbot::-webkit-scrollbar {
|
| 204 |
-
width:
|
| 205 |
}
|
| 206 |
|
| 207 |
.chatbot::-webkit-scrollbar-track {
|
| 208 |
-
background: #
|
| 209 |
}
|
| 210 |
|
| 211 |
.chatbot::-webkit-scrollbar-thumb {
|
| 212 |
-
background: #
|
| 213 |
-
border-radius:
|
| 214 |
}
|
| 215 |
|
| 216 |
.chatbot::-webkit-scrollbar-thumb:hover {
|
| 217 |
-
background: #
|
| 218 |
}
|
| 219 |
|
| 220 |
/* Mobile-specific adjustments */
|
| 221 |
@media (max-width: 768px) {
|
| 222 |
.chatbot {
|
| 223 |
-
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
.gradio-row:last-child {
|
|
|
|
| 226 |
padding: 5px !important;
|
| 227 |
}
|
| 228 |
input[type="text"] {
|
| 229 |
padding: 6px 10px !important;
|
| 230 |
}
|
| 231 |
button {
|
| 232 |
-
padding:
|
| 233 |
}
|
| 234 |
}
|
| 235 |
"""
|
|
|
|
| 49 |
history.append((query, response))
|
| 50 |
return history, history
|
| 51 |
|
| 52 |
+
# Custom CSS for a normal chatbot visual design
|
| 53 |
custom_css = """
|
| 54 |
/* General container styling */
|
| 55 |
.gradio-container {
|
| 56 |
+
font-family: 'Arial', sans-serif;
|
| 57 |
+
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%); /* Neutral gradient */
|
| 58 |
min-height: 100vh;
|
| 59 |
padding: 0;
|
| 60 |
margin: 0;
|
| 61 |
+
font-size: 14px; /* Base font size */
|
| 62 |
}
|
| 63 |
|
| 64 |
/* Header styling */
|
| 65 |
h1 {
|
| 66 |
+
color: #2c3e50 !important; /* Dark blue for professionalism */
|
| 67 |
+
font-size: 24px !important;
|
| 68 |
text-align: center;
|
| 69 |
+
margin: 15px 0;
|
| 70 |
text-shadow: none;
|
| 71 |
}
|
| 72 |
|
| 73 |
p {
|
| 74 |
+
color: #34495e !important; /* Slightly lighter blue */
|
| 75 |
+
font-size: 14px !important;
|
| 76 |
text-align: center;
|
| 77 |
+
margin-bottom: 15px;
|
| 78 |
}
|
| 79 |
|
| 80 |
+
/* Chatbot container */
|
| 81 |
.chatbot {
|
| 82 |
+
border-radius: 8px !important;
|
| 83 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
|
| 84 |
+
background: #ffffff !important;
|
| 85 |
+
padding: 10px !important;
|
| 86 |
+
max-width: 800px !important;
|
| 87 |
+
margin: 0 auto !important;
|
| 88 |
+
height: 70vh !important; /* Adjusted for normal view */
|
| 89 |
overflow-y: auto !important;
|
| 90 |
+
display: block; /* Reset to default flow */
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
+
/* Chat bubbles: Normal design */
|
| 94 |
.chatbot .bubble {
|
| 95 |
+
border-radius: 8px !important;
|
| 96 |
+
padding: 8px 12px !important;
|
| 97 |
+
margin: 5px 0 !important;
|
| 98 |
+
max-width: 70% !important;
|
| 99 |
+
font-size: 14px !important; /* Normal text size */
|
| 100 |
+
min-height: 30px !important; /* Controlled minimum height */
|
| 101 |
+
min-width: 60px !important; /* Controlled minimum width */
|
| 102 |
word-wrap: break-word !important;
|
| 103 |
+
line-height: 1.4 !important; /* Readable line spacing */
|
| 104 |
+
color: #2c3e50 !important; /* Consistent text color */
|
| 105 |
}
|
| 106 |
|
| 107 |
+
/* User bubble: Right-aligned, light blue */
|
| 108 |
.chatbot .bubble:nth-child(odd) {
|
| 109 |
+
background: #3498db !important; /* Light blue for user */
|
| 110 |
+
color: #ffffff !important; /* White text for contrast */
|
| 111 |
margin-left: auto !important;
|
| 112 |
align-self: flex-end !important;
|
| 113 |
}
|
| 114 |
|
| 115 |
+
/* Bot bubble: Left-aligned, light gray */
|
| 116 |
.chatbot .bubble:nth-child(even) {
|
| 117 |
+
background: #ecf0f1 !important; /* Light gray for bot */
|
| 118 |
margin-right: auto !important;
|
| 119 |
align-self: flex-start !important;
|
| 120 |
}
|
| 121 |
|
| 122 |
+
/* Input area */
|
| 123 |
.gradio-row:last-child {
|
|
|
|
|
|
|
| 124 |
width: 100% !important;
|
| 125 |
+
max-width: 800px !important;
|
| 126 |
+
margin: 10px auto !important;
|
| 127 |
+
padding: 10px !important;
|
|
|
|
|
|
|
| 128 |
display: flex !important;
|
| 129 |
align-items: center !important;
|
| 130 |
+
background: transparent !important;
|
| 131 |
}
|
| 132 |
|
| 133 |
+
/* Textbox styling */
|
| 134 |
input[type="text"] {
|
| 135 |
+
border: 1px solid #bdc3c7 !important;
|
| 136 |
+
border-radius: 4px !important;
|
| 137 |
padding: 8px 12px !important;
|
| 138 |
font-size: 14px !important;
|
| 139 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
|
| 140 |
flex-grow: 1 !important;
|
| 141 |
+
margin-right: 10px !important;
|
| 142 |
+
color: #2c3e50 !important;
|
| 143 |
}
|
| 144 |
|
| 145 |
input[type="text"]::placeholder {
|
| 146 |
+
color: #7f8c8d !important; /* Gray placeholder */
|
| 147 |
font-size: 14px !important;
|
| 148 |
}
|
| 149 |
|
| 150 |
input[type="text"]:focus {
|
| 151 |
+
border-color: #3498db !important;
|
| 152 |
outline: none !important;
|
| 153 |
}
|
| 154 |
|
| 155 |
+
/* Send button */
|
| 156 |
button {
|
| 157 |
+
border-radius: 4px !important;
|
| 158 |
+
background: #3498db !important; /* Matching user bubble */
|
| 159 |
color: white !important;
|
| 160 |
+
padding: 8px 20px !important;
|
| 161 |
font-size: 14px !important;
|
| 162 |
border: none !important;
|
| 163 |
+
min-width: 80px !important;
|
| 164 |
transition: background 0.3s ease !important;
|
| 165 |
text-align: center !important;
|
| 166 |
}
|
| 167 |
|
| 168 |
button:hover {
|
| 169 |
+
background: #2980b9 !important;
|
| 170 |
}
|
| 171 |
|
| 172 |
+
/* Clear button */
|
| 173 |
button[aria-label="Clear Chat"] {
|
| 174 |
+
background: #bdc3c7 !important; /* Silver gray */
|
| 175 |
+
padding: 6px 15px !important;
|
| 176 |
+
font-size: 14px !important;
|
| 177 |
+
min-width: 90px !important;
|
| 178 |
+
margin-top: 10px !important;
|
| 179 |
align-self: center !important;
|
| 180 |
+
color: #ffffff !important;
|
| 181 |
}
|
| 182 |
|
| 183 |
button[aria-label="Clear Chat"]:hover {
|
| 184 |
+
background: #95a5a6 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
}
|
| 186 |
|
| 187 |
/* Scrollbar styling */
|
| 188 |
.chatbot::-webkit-scrollbar {
|
| 189 |
+
width: 6px;
|
| 190 |
}
|
| 191 |
|
| 192 |
.chatbot::-webkit-scrollbar-track {
|
| 193 |
+
background: #f5f7fa;
|
| 194 |
}
|
| 195 |
|
| 196 |
.chatbot::-webkit-scrollbar-thumb {
|
| 197 |
+
background: #3498db;
|
| 198 |
+
border-radius: 3px;
|
| 199 |
}
|
| 200 |
|
| 201 |
.chatbot::-webkit-scrollbar-thumb:hover {
|
| 202 |
+
background: #2980b9;
|
| 203 |
}
|
| 204 |
|
| 205 |
/* Mobile-specific adjustments */
|
| 206 |
@media (max-width: 768px) {
|
| 207 |
.chatbot {
|
| 208 |
+
max-width: 100% !important;
|
| 209 |
+
height: 65vh !important; /* Adjusted for mobile */
|
| 210 |
+
margin: 0 !important;
|
| 211 |
}
|
| 212 |
.gradio-row:last-child {
|
| 213 |
+
max-width: 100% !important;
|
| 214 |
padding: 5px !important;
|
| 215 |
}
|
| 216 |
input[type="text"] {
|
| 217 |
padding: 6px 10px !important;
|
| 218 |
}
|
| 219 |
button {
|
| 220 |
+
padding: 6px 15px !important;
|
| 221 |
}
|
| 222 |
}
|
| 223 |
"""
|