Spaces:
Sleeping
Sleeping
Update ui.py
Browse files
ui.py
CHANGED
|
@@ -1,25 +1,98 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def build_ui(login_fn, send_fn):
|
| 4 |
-
with gr.Blocks() as app:
|
| 5 |
|
| 6 |
email = gr.State("")
|
| 7 |
name = gr.State("")
|
| 8 |
plan = gr.State("")
|
| 9 |
relation = gr.State("")
|
| 10 |
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
# ===== LOGIN =====
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# ===== CHAT =====
|
| 19 |
-
chatbot = gr.Chatbot()
|
| 20 |
-
msg = gr.Textbox(label="Message")
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# ===== LOGIN ACTION =====
|
| 25 |
login_btn.click(
|
|
@@ -28,7 +101,7 @@ def build_ui(login_fn, send_fn):
|
|
| 28 |
outputs=[email, name, plan, relation, status]
|
| 29 |
)
|
| 30 |
|
| 31 |
-
# ===== SEND
|
| 32 |
send.click(
|
| 33 |
send_fn,
|
| 34 |
inputs=[email, name, plan, relation, msg, chatbot],
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
CSS = """
|
| 4 |
+
body {
|
| 5 |
+
background: #f7f7f8;
|
| 6 |
+
margin: 0;
|
| 7 |
+
font-family: Arial;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
.gradio-container {
|
| 11 |
+
max-width: 820px;
|
| 12 |
+
margin: auto;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.header {
|
| 16 |
+
position: sticky;
|
| 17 |
+
top: 0;
|
| 18 |
+
background: white;
|
| 19 |
+
padding: 12px;
|
| 20 |
+
border-bottom: 1px solid #ddd;
|
| 21 |
+
font-size: 20px;
|
| 22 |
+
font-weight: bold;
|
| 23 |
+
text-align: center;
|
| 24 |
+
z-index: 10;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
.chatbot {
|
| 28 |
+
height: 520px;
|
| 29 |
+
overflow-y: auto;
|
| 30 |
+
padding: 10px;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
textarea {
|
| 34 |
+
border-radius: 20px !important;
|
| 35 |
+
padding: 10px !important;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
button {
|
| 39 |
+
border-radius: 12px !important;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.input-area {
|
| 43 |
+
position: sticky;
|
| 44 |
+
bottom: 0;
|
| 45 |
+
background: white;
|
| 46 |
+
padding: 10px;
|
| 47 |
+
border-top: 1px solid #ddd;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.plus-btn {
|
| 51 |
+
background: #eee !important;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.send-btn {
|
| 55 |
+
background: #10a37f !important;
|
| 56 |
+
color: white !important;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
footer {display:none;}
|
| 60 |
+
"""
|
| 61 |
+
|
| 62 |
def build_ui(login_fn, send_fn):
|
| 63 |
+
with gr.Blocks(css=CSS) as app:
|
| 64 |
|
| 65 |
email = gr.State("")
|
| 66 |
name = gr.State("")
|
| 67 |
plan = gr.State("")
|
| 68 |
relation = gr.State("")
|
| 69 |
|
| 70 |
+
# ===== HEADER =====
|
| 71 |
+
gr.HTML("<div class='header'>🤖 BDAi By Azad</div>")
|
| 72 |
|
| 73 |
# ===== LOGIN =====
|
| 74 |
+
with gr.Row():
|
| 75 |
+
email_input = gr.Textbox(
|
| 76 |
+
placeholder="Gmail দিয়ে লগইন করুন...",
|
| 77 |
+
show_label=False,
|
| 78 |
+
scale=4
|
| 79 |
+
)
|
| 80 |
+
login_btn = gr.Button("Login", scale=1)
|
| 81 |
+
|
| 82 |
+
status = gr.Textbox(label="Status", interactive=False)
|
| 83 |
|
| 84 |
# ===== CHAT =====
|
| 85 |
+
chatbot = gr.Chatbot(elem_classes="chatbot")
|
|
|
|
| 86 |
|
| 87 |
+
# ===== INPUT =====
|
| 88 |
+
with gr.Row(elem_classes="input-area"):
|
| 89 |
+
plus = gr.Button("+", elem_classes="plus-btn", scale=1)
|
| 90 |
+
msg = gr.Textbox(
|
| 91 |
+
placeholder="মেসেজ লিখুন...",
|
| 92 |
+
show_label=False,
|
| 93 |
+
scale=8
|
| 94 |
+
)
|
| 95 |
+
send = gr.Button("➤", elem_classes="send-btn", scale=1)
|
| 96 |
|
| 97 |
# ===== LOGIN ACTION =====
|
| 98 |
login_btn.click(
|
|
|
|
| 101 |
outputs=[email, name, plan, relation, status]
|
| 102 |
)
|
| 103 |
|
| 104 |
+
# ===== SEND =====
|
| 105 |
send.click(
|
| 106 |
send_fn,
|
| 107 |
inputs=[email, name, plan, relation, msg, chatbot],
|