dschandra commited on
Commit
5d0c81e
·
verified ·
1 Parent(s): 4c0679a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -83
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 WhatsApp-like mobile view with adjusted bubble size
53
  custom_css = """
54
  /* General container styling */
55
  .gradio-container {
56
- font-family: 'Segoe UI', Arial, sans-serif;
57
- background: #e5ddd5; /* WhatsApp-inspired light background */
58
  min-height: 100vh;
59
  padding: 0;
60
  margin: 0;
61
- font-size: 14px; /* Base font size for consistency */
62
  }
63
 
64
  /* Header styling */
65
  h1 {
66
- color: #075e54 !important; /* WhatsApp green */
67
- font-size: 1.5em !important;
68
  text-align: center;
69
- margin: 10px 0;
70
  text-shadow: none;
71
  }
72
 
73
  p {
74
- color: #075e54 !important;
75
- font-size: 0.9em !important;
76
  text-align: center;
77
- margin-bottom: 10px;
78
  }
79
 
80
- /* Chatbot container: Mimics WhatsApp chat window */
81
  .chatbot {
82
- border-radius: 0 !important;
83
- box-shadow: none !important;
84
- background: #e5ddd5 !important;
85
- padding: 0 !important;
86
- max-width: 100% !important;
87
- margin: 0 !important;
88
- height: 80vh !important;
89
  overflow-y: auto !important;
90
- display: flex;
91
- flex-direction: column-reverse; /* Bottom-up chat like WhatsApp */
92
  }
93
 
94
- /* Chat bubbles: WhatsApp-style design with reduced size */
95
  .chatbot .bubble {
96
- border-radius: 10px !important;
97
- padding: 6px 10px !important; /* Reduced padding */
98
- margin: 3px 6px !important; /* Reduced margin */
99
- max-width: 65% !important;
100
- font-size: 14px !important; /* Absolute size for consistency */
101
- min-height: 20px !important; /* Minimum height to control size */
102
- min-width: 50px !important; /* Minimum width to control size */
103
  word-wrap: break-word !important;
104
- line-height: 1.2 !important; /* Tighter line spacing */
105
- color: #000 !important;
106
  }
107
 
108
- /* User bubble: Right-aligned, green like WhatsApp sender */
109
  .chatbot .bubble:nth-child(odd) {
110
- background: #dcf8c6 !important;
 
111
  margin-left: auto !important;
112
  align-self: flex-end !important;
113
  }
114
 
115
- /* Bot bubble: Left-aligned, light gray like WhatsApp receiver */
116
  .chatbot .bubble:nth-child(even) {
117
- background: #fff !important;
118
  margin-right: auto !important;
119
  align-self: flex-start !important;
120
  }
121
 
122
- /* Input area: Bottom navigation bar style */
123
  .gradio-row:last-child {
124
- position: fixed !important;
125
- bottom: 0 !important;
126
  width: 100% !important;
127
- max-width: 100% !important;
128
- background: #f0f0f0 !important;
129
- padding: 8px !important;
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: Compact and WhatsApp-like */
137
  input[type="text"] {
138
- border: 1px solid #ccc !important;
139
- border-radius: 20px !important;
140
  padding: 8px 12px !important;
141
  font-size: 14px !important;
142
- box-shadow: none !important;
143
  flex-grow: 1 !important;
144
- margin-right: 8px !important;
145
- color: #000 !important;
146
  }
147
 
148
  input[type="text"]::placeholder {
149
- color: #757575 !important;
150
  font-size: 14px !important;
151
  }
152
 
153
  input[type="text"]:focus {
154
- border-color: #075e54 !important;
155
  outline: none !important;
156
  }
157
 
158
- /* Send button: Large and prominent */
159
  button {
160
- border-radius: 20px !important;
161
- background: #075e54 !important;
162
  color: white !important;
163
- padding: 10px 20px !important;
164
  font-size: 14px !important;
165
  border: none !important;
166
- min-width: 90px !important;
167
  transition: background 0.3s ease !important;
168
  text-align: center !important;
169
  }
170
 
171
  button:hover {
172
- background: #054d44 !important;
173
  }
174
 
175
- /* Clear button: Reduced size */
176
  button[aria-label="Clear Chat"] {
177
- background: #e0e0e0 !important;
178
- padding: 6px 12px !important;
179
- font-size: 0.8em !important;
180
- min-width: 70px !important;
181
- margin-top: 8px !important;
182
  align-self: center !important;
183
- color: #000 !important;
184
  }
185
 
186
  button[aria-label="Clear Chat"]:hover {
187
- background: #d0d0d0 !important;
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: 5px;
205
  }
206
 
207
  .chatbot::-webkit-scrollbar-track {
208
- background: #e5ddd5;
209
  }
210
 
211
  .chatbot::-webkit-scrollbar-thumb {
212
- background: #075e54;
213
- border-radius: 5px;
214
  }
215
 
216
  .chatbot::-webkit-scrollbar-thumb:hover {
217
- background: #054d44;
218
  }
219
 
220
  /* Mobile-specific adjustments */
221
  @media (max-width: 768px) {
222
  .chatbot {
223
- height: 80vh !important;
 
 
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: 8px 18px !important;
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
  """