Update app.py
Browse files
app.py
CHANGED
|
@@ -159,81 +159,58 @@ def init():
|
|
| 159 |
return [{"role": "assistant", "content": WELCOME_MESSAGE_EN}], 0, "", [], False
|
| 160 |
|
| 161 |
with gr.Blocks(css="""
|
| 162 |
-
html, body {
|
| 163 |
-
margin: 0 !important;
|
| 164 |
-
padding: 0 !important;
|
| 165 |
-
height: 100vh !important;
|
| 166 |
-
overflow: hidden !important;
|
| 167 |
-
}
|
| 168 |
-
#chatbox {
|
| 169 |
-
height: 100% !important;
|
| 170 |
-
overflow-y: auto !important;
|
| 171 |
-
padding-bottom: 160px !important;
|
| 172 |
-
}
|
| 173 |
-
.input-row {
|
| 174 |
-
position: fixed !important;
|
| 175 |
-
bottom: 0;
|
| 176 |
-
left: 0;
|
| 177 |
-
width: 100%;
|
| 178 |
-
background: white;
|
| 179 |
-
padding: 10px 20px;
|
| 180 |
-
box-sizing: border-box;
|
| 181 |
-
display: flex;
|
| 182 |
-
align-items: center;
|
| 183 |
-
gap: 12px;
|
| 184 |
-
z-index: 10;
|
| 185 |
-
}
|
| 186 |
.send-btn {
|
| 187 |
background-color: #25D366 !important;
|
| 188 |
color: white !important;
|
| 189 |
-
border: none
|
| 190 |
-
border-radius: 24px
|
| 191 |
-
font-size: 20px
|
| 192 |
-
padding: 8px 20px
|
| 193 |
-
height: 48px
|
| 194 |
-
width: 60px
|
| 195 |
-
margin-left: 8px
|
| 196 |
-
cursor: pointer
|
| 197 |
}
|
| 198 |
#chatbox .avatar-container {
|
| 199 |
width: 64px !important;
|
| 200 |
height: 64px !important;
|
|
|
|
|
|
|
| 201 |
background-size: 100% 100% !important;
|
|
|
|
| 202 |
border-radius: 50% !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
background-color: transparent !important;
|
| 204 |
}
|
| 205 |
#chatbox .message.user { background-color: #DCF8C6 !important; }
|
| 206 |
#chatbox .message.assistant { background-color: #ffffff !important; }
|
| 207 |
-
footer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
display: none !important;
|
| 209 |
}
|
|
|
|
|
|
|
| 210 |
""") as demo:
|
| 211 |
gr.HTML("""
|
| 212 |
<script>
|
| 213 |
-
const scrollToBottom = () => {
|
| 214 |
-
const chatbox = document.getElementById("chatbox");
|
| 215 |
-
if (!chatbox) return;
|
| 216 |
-
let attempts = 0;
|
| 217 |
-
const maxAttempts = 10;
|
| 218 |
-
const scroll = () => {
|
| 219 |
-
chatbox.scrollTop = chatbox.scrollHeight + 200;
|
| 220 |
-
attempts += 1;
|
| 221 |
-
if (attempts < maxAttempts) {
|
| 222 |
-
setTimeout(scroll, 100);
|
| 223 |
-
}
|
| 224 |
-
};
|
| 225 |
-
scroll();
|
| 226 |
-
};
|
| 227 |
-
|
| 228 |
const waitForChatbox = () => {
|
| 229 |
const chatbox = document.getElementById("chatbox");
|
| 230 |
if (chatbox) {
|
| 231 |
const observer = new MutationObserver(() => {
|
| 232 |
-
|
| 233 |
});
|
| 234 |
observer.observe(chatbox, { childList: true, subtree: true });
|
| 235 |
} else {
|
| 236 |
-
setTimeout(waitForChatbox,
|
| 237 |
}
|
| 238 |
};
|
| 239 |
waitForChatbox();
|
|
@@ -245,11 +222,12 @@ footer, .icon-button-wrapper, label.svelte-1to105q {
|
|
| 245 |
label="",
|
| 246 |
avatar_images=["user_avatar.jpg", "humanlike_avatar.png"],
|
| 247 |
bubble_full_width=False,
|
|
|
|
| 248 |
show_copy_button=False,
|
| 249 |
type="messages"
|
| 250 |
)
|
| 251 |
|
| 252 |
-
with gr.Row(
|
| 253 |
user_input = gr.Textbox(
|
| 254 |
show_label=False,
|
| 255 |
placeholder="Type your message here and press send...",
|
|
|
|
| 159 |
return [{"role": "assistant", "content": WELCOME_MESSAGE_EN}], 0, "", [], False
|
| 160 |
|
| 161 |
with gr.Blocks(css="""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
.send-btn {
|
| 163 |
background-color: #25D366 !important;
|
| 164 |
color: white !important;
|
| 165 |
+
border: none;
|
| 166 |
+
border-radius: 24px;
|
| 167 |
+
font-size: 20px;
|
| 168 |
+
padding: 8px 20px;
|
| 169 |
+
height: 48px;
|
| 170 |
+
width: 60px;
|
| 171 |
+
margin-left: 8px;
|
| 172 |
+
cursor: pointer;
|
| 173 |
}
|
| 174 |
#chatbox .avatar-container {
|
| 175 |
width: 64px !important;
|
| 176 |
height: 64px !important;
|
| 177 |
+
min-width: 64px !important;
|
| 178 |
+
min-height: 64px !important;
|
| 179 |
background-size: 100% 100% !important;
|
| 180 |
+
background-position: center center !important;
|
| 181 |
border-radius: 50% !important;
|
| 182 |
+
padding: 0 !important;
|
| 183 |
+
margin: 0 !important;
|
| 184 |
+
border: none !important;
|
| 185 |
+
box-shadow: none !important;
|
| 186 |
background-color: transparent !important;
|
| 187 |
}
|
| 188 |
#chatbox .message.user { background-color: #DCF8C6 !important; }
|
| 189 |
#chatbox .message.assistant { background-color: #ffffff !important; }
|
| 190 |
+
footer { display: none !important; }
|
| 191 |
+
.svelte-1ipelgc { display: none !important; }
|
| 192 |
+
|
| 193 |
+
.icon-button-wrapper {
|
| 194 |
+
display: none !important;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
label.svelte-1to105q {
|
| 198 |
display: none !important;
|
| 199 |
}
|
| 200 |
+
|
| 201 |
+
|
| 202 |
""") as demo:
|
| 203 |
gr.HTML("""
|
| 204 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
const waitForChatbox = () => {
|
| 206 |
const chatbox = document.getElementById("chatbox");
|
| 207 |
if (chatbox) {
|
| 208 |
const observer = new MutationObserver(() => {
|
| 209 |
+
chatbox.scrollTop = chatbox.scrollHeight;
|
| 210 |
});
|
| 211 |
observer.observe(chatbox, { childList: true, subtree: true });
|
| 212 |
} else {
|
| 213 |
+
setTimeout(waitForChatbox, 500);
|
| 214 |
}
|
| 215 |
};
|
| 216 |
waitForChatbox();
|
|
|
|
| 222 |
label="",
|
| 223 |
avatar_images=["user_avatar.jpg", "humanlike_avatar.png"],
|
| 224 |
bubble_full_width=False,
|
| 225 |
+
height=500,
|
| 226 |
show_copy_button=False,
|
| 227 |
type="messages"
|
| 228 |
)
|
| 229 |
|
| 230 |
+
with gr.Row():
|
| 231 |
user_input = gr.Textbox(
|
| 232 |
show_label=False,
|
| 233 |
placeholder="Type your message here and press send...",
|