Update app.py
Browse files
app.py
CHANGED
|
@@ -22,20 +22,43 @@ Keep a simple, approachable, and friendly tone."""
|
|
| 22 |
|
| 23 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
with gr.Blocks(css="""
|
| 26 |
-
body
|
| 27 |
-
.gradio-container
|
| 28 |
-
.chat-message
|
| 29 |
-
.chat-message.user
|
| 30 |
-
.chat-message.bot
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
to {opacity:1;}
|
| 34 |
-
}
|
| 35 |
""") as demo:
|
| 36 |
with gr.Sidebar():
|
| 37 |
gr.LoginButton()
|
|
|
|
| 38 |
chatbot.render()
|
|
|
|
| 39 |
|
| 40 |
if __name__=="__main__":
|
| 41 |
demo.launch()
|
|
|
|
| 22 |
|
| 23 |
chatbot = gr.ChatInterface(respond, type="messages")
|
| 24 |
|
| 25 |
+
fade_js = """
|
| 26 |
+
<script>
|
| 27 |
+
const observer = new MutationObserver(mutations=>{
|
| 28 |
+
mutations.forEach(m=>{
|
| 29 |
+
m.addedNodes.forEach(node=>{
|
| 30 |
+
if(node.classList && node.classList.contains('chat-message')){
|
| 31 |
+
node.style.opacity = 0;
|
| 32 |
+
node.style.transition = "opacity 0.5s ease";
|
| 33 |
+
requestAnimationFrame(()=>{
|
| 34 |
+
node.style.opacity = 1;
|
| 35 |
+
});
|
| 36 |
+
}
|
| 37 |
+
});
|
| 38 |
+
});
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
document.addEventListener("DOMContentLoaded", ()=>{
|
| 42 |
+
const chatContainer = document.querySelector(".chat-interface");
|
| 43 |
+
if(chatContainer) observer.observe(chatContainer, {childList:true, subtree:true});
|
| 44 |
+
});
|
| 45 |
+
</script>
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
with gr.Blocks(css="""
|
| 49 |
+
body{background-color:#000; font-family:'Arial',sans-serif;}
|
| 50 |
+
.gradio-container{border-radius:25px; padding:20px; max-width:700px; margin:20px auto; background-color:#fff; outline:none;}
|
| 51 |
+
.chat-message{border-radius:25px; padding:12px 18px; margin:8px 0; display:flex; flex-direction:column; outline:none;}
|
| 52 |
+
.chat-message.user{background-color:#dceefc; align-items:flex-end; outline:none;}
|
| 53 |
+
.chat-message.bot{background-color:#f0f0f0; align-items:flex-start; outline:none;}
|
| 54 |
+
textarea{border:none; outline:none; border-radius:15px; padding:8px; background-color:#f9f9f9;}
|
| 55 |
+
button{border:none; border-radius:15px;}
|
|
|
|
|
|
|
| 56 |
""") as demo:
|
| 57 |
with gr.Sidebar():
|
| 58 |
gr.LoginButton()
|
| 59 |
+
|
| 60 |
chatbot.render()
|
| 61 |
+
gr.HTML(fade_js)
|
| 62 |
|
| 63 |
if __name__=="__main__":
|
| 64 |
demo.launch()
|