Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ 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
|
53 |
custom_css = """
|
54 |
/* General container styling */
|
55 |
.gradio-container {
|
@@ -58,12 +58,13 @@ custom_css = """
|
|
58 |
min-height: 100vh;
|
59 |
padding: 0;
|
60 |
margin: 0;
|
|
|
61 |
}
|
62 |
|
63 |
/* Header styling */
|
64 |
h1 {
|
65 |
color: #075e54 !important; /* WhatsApp green */
|
66 |
-
font-size: 1.5em !important;
|
67 |
text-align: center;
|
68 |
margin: 10px 0;
|
69 |
text-shadow: none;
|
@@ -71,7 +72,7 @@ h1 {
|
|
71 |
|
72 |
p {
|
73 |
color: #075e54 !important;
|
74 |
-
font-size: 0.9em !important;
|
75 |
text-align: center;
|
76 |
margin-bottom: 10px;
|
77 |
}
|
@@ -84,34 +85,36 @@ p {
|
|
84 |
padding: 0 !important;
|
85 |
max-width: 100% !important;
|
86 |
margin: 0 !important;
|
87 |
-
height: 80vh !important;
|
88 |
overflow-y: auto !important;
|
89 |
display: flex;
|
90 |
flex-direction: column-reverse; /* Bottom-up chat like WhatsApp */
|
91 |
}
|
92 |
|
93 |
-
/* Chat bubbles: WhatsApp-style design with reduced
|
94 |
.chatbot .bubble {
|
95 |
border-radius: 10px !important;
|
96 |
-
padding:
|
97 |
-
margin:
|
98 |
max-width: 65% !important;
|
99 |
-
font-size:
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
103 |
}
|
104 |
|
105 |
/* User bubble: Right-aligned, green like WhatsApp sender */
|
106 |
.chatbot .bubble:nth-child(odd) {
|
107 |
-
background: #dcf8c6 !important;
|
108 |
margin-left: auto !important;
|
109 |
align-self: flex-end !important;
|
110 |
}
|
111 |
|
112 |
/* Bot bubble: Left-aligned, light gray like WhatsApp receiver */
|
113 |
.chatbot .bubble:nth-child(even) {
|
114 |
-
background: #fff !important;
|
115 |
margin-right: auto !important;
|
116 |
align-self: flex-start !important;
|
117 |
}
|
@@ -122,29 +125,29 @@ p {
|
|
122 |
bottom: 0 !important;
|
123 |
width: 100% !important;
|
124 |
max-width: 100% !important;
|
125 |
-
background: #f0f0f0 !important;
|
126 |
-
padding: 8px !important;
|
127 |
box-shadow: 0 -2px 5px rgba(0,0,0,0.1) !important;
|
128 |
z-index: 1000 !important;
|
129 |
display: flex !important;
|
130 |
align-items: center !important;
|
131 |
}
|
132 |
|
133 |
-
/* Textbox styling: Compact and WhatsApp-like
|
134 |
input[type="text"] {
|
135 |
border: 1px solid #ccc !important;
|
136 |
border-radius: 20px !important;
|
137 |
-
padding: 8px 12px !important;
|
138 |
-
font-size:
|
139 |
box-shadow: none !important;
|
140 |
flex-grow: 1 !important;
|
141 |
-
margin-right: 8px !important;
|
142 |
-
color: #000 !important;
|
143 |
}
|
144 |
|
145 |
input[type="text"]::placeholder {
|
146 |
-
color: #757575 !important;
|
147 |
-
font-size:
|
148 |
}
|
149 |
|
150 |
input[type="text"]:focus {
|
@@ -155,29 +158,29 @@ input[type="text"]:focus {
|
|
155 |
/* Send button: Large and prominent */
|
156 |
button {
|
157 |
border-radius: 20px !important;
|
158 |
-
background: #075e54 !important;
|
159 |
-
color: white !important;
|
160 |
-
padding: 10px 20px !important;
|
161 |
-
font-size:
|
162 |
border: none !important;
|
163 |
-
min-width: 90px !important;
|
164 |
transition: background 0.3s ease !important;
|
165 |
-
text-align: center !important;
|
166 |
}
|
167 |
|
168 |
button:hover {
|
169 |
background: #054d44 !important;
|
170 |
}
|
171 |
|
172 |
-
/* Clear button: Reduced size
|
173 |
button[aria-label="Clear Chat"] {
|
174 |
background: #e0e0e0 !important;
|
175 |
-
padding: 6px 12px !important;
|
176 |
font-size: 0.8em !important;
|
177 |
-
min-width: 70px !important;
|
178 |
margin-top: 8px !important;
|
179 |
align-self: center !important;
|
180 |
-
color: #000 !important;
|
181 |
}
|
182 |
|
183 |
button[aria-label="Clear Chat"]:hover {
|
@@ -239,7 +242,7 @@ with gr.Blocks(title="LIC Agent Chatbot", css=custom_css) as demo:
|
|
239 |
|
240 |
chatbot_ui = gr.Chatbot(
|
241 |
label="LIC Assistant",
|
242 |
-
height=600,
|
243 |
bubble_full_width=False,
|
244 |
avatar_images=("🧑", "🤖"),
|
245 |
show_copy_button=True
|
@@ -266,7 +269,7 @@ with gr.Blocks(title="LIC Agent Chatbot", css=custom_css) as demo:
|
|
266 |
return history, query
|
267 |
|
268 |
send.click(fn=send_message, inputs=[state, msg], outputs=[chatbot_ui, msg])
|
269 |
-
msg.submit(fn=send_message, inputs=[state, msg], outputs=[chatbot_ui, msg])
|
270 |
clear.click(lambda: ([], []), None, [chatbot_ui, state], queue=False)
|
271 |
|
272 |
demo.launch()
|
|
|
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 {
|
|
|
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;
|
|
|
72 |
|
73 |
p {
|
74 |
color: #075e54 !important;
|
75 |
+
font-size: 0.9em !important;
|
76 |
text-align: center;
|
77 |
margin-bottom: 10px;
|
78 |
}
|
|
|
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 |
}
|
|
|
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 {
|
|
|
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 {
|
|
|
242 |
|
243 |
chatbot_ui = gr.Chatbot(
|
244 |
label="LIC Assistant",
|
245 |
+
height=600,
|
246 |
bubble_full_width=False,
|
247 |
avatar_images=("🧑", "🤖"),
|
248 |
show_copy_button=True
|
|
|
269 |
return history, query
|
270 |
|
271 |
send.click(fn=send_message, inputs=[state, msg], outputs=[chatbot_ui, msg])
|
272 |
+
msg.submit(fn=send_message, inputs=[state, msg], outputs=[chatbot_ui, msg])
|
273 |
clear.click(lambda: ([], []), None, [chatbot_ui, state], queue=False)
|
274 |
|
275 |
demo.launch()
|