Spaces:
Sleeping
Sleeping
Solarum Asteridion
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,7 +107,11 @@ def chatbot_interface(user_message, history):
|
|
| 107 |
|
| 108 |
# Define Gradio Interface
|
| 109 |
with gr.Blocks(css="""
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
background-color: #ece5dd;
|
| 112 |
padding: 20px;
|
| 113 |
}
|
|
@@ -117,24 +121,27 @@ with gr.Blocks(css="""
|
|
| 117 |
background-color: #ffffff;
|
| 118 |
border-radius: 10px;
|
| 119 |
padding: 10px;
|
|
|
|
| 120 |
}
|
| 121 |
#textbox {
|
| 122 |
-
width:
|
| 123 |
padding: 10px;
|
| 124 |
border-radius: 20px;
|
| 125 |
border: 1px solid #ccc;
|
| 126 |
outline: none;
|
|
|
|
| 127 |
}
|
| 128 |
#send-button {
|
| 129 |
background-color: #128c7e;
|
| 130 |
color: white;
|
| 131 |
-
padding: 10px
|
| 132 |
border: none;
|
| 133 |
border-radius: 50%;
|
| 134 |
cursor: pointer;
|
| 135 |
margin-left: 10px;
|
| 136 |
width: 50px;
|
| 137 |
height: 50px;
|
|
|
|
| 138 |
}
|
| 139 |
#send-button:hover {
|
| 140 |
background-color: #075e54;
|
|
@@ -147,24 +154,14 @@ with gr.Blocks(css="""
|
|
| 147 |
border-radius: 5px;
|
| 148 |
cursor: pointer;
|
| 149 |
margin-top: 10px;
|
|
|
|
| 150 |
}
|
| 151 |
#clear-button:hover {
|
| 152 |
background-color: #128c7e;
|
| 153 |
}
|
| 154 |
-
#timezone-dropdown {
|
| 155 |
-
margin-top: 10px;
|
| 156 |
-
}
|
| 157 |
.message {
|
| 158 |
margin-bottom: 10px;
|
| 159 |
}
|
| 160 |
-
.user-message {
|
| 161 |
-
text-align: right;
|
| 162 |
-
color: #333;
|
| 163 |
-
}
|
| 164 |
-
.ai-message {
|
| 165 |
-
text-align: left;
|
| 166 |
-
color: #555;
|
| 167 |
-
}
|
| 168 |
/* Scrollbar Styling */
|
| 169 |
#chatbot::-webkit-scrollbar {
|
| 170 |
width: 8px;
|
|
@@ -185,16 +182,20 @@ with gr.Blocks(css="""
|
|
| 185 |
with gr.Column(scale=1):
|
| 186 |
chatbot = gr.Chatbot(label="Chatbot", elem_id="chatbot", type="messages")
|
| 187 |
with gr.Column(scale=1):
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
|
| 197 |
def update_chat(user_message, history):
|
|
|
|
|
|
|
| 198 |
history, updated_history = chatbot_interface(user_message, history)
|
| 199 |
formatted_history = [
|
| 200 |
format_message(msg['content'], is_user=(msg['role'] == 'user'))
|
|
|
|
| 107 |
|
| 108 |
# Define Gradio Interface
|
| 109 |
with gr.Blocks(css="""
|
| 110 |
+
/* Import Raleway font from Google Fonts */
|
| 111 |
+
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@400;600&display=swap');
|
| 112 |
+
|
| 113 |
+
body, .gradio-container {
|
| 114 |
+
font-family: 'Raleway', sans-serif;
|
| 115 |
background-color: #ece5dd;
|
| 116 |
padding: 20px;
|
| 117 |
}
|
|
|
|
| 121 |
background-color: #ffffff;
|
| 122 |
border-radius: 10px;
|
| 123 |
padding: 10px;
|
| 124 |
+
font-size: 16px;
|
| 125 |
}
|
| 126 |
#textbox {
|
| 127 |
+
width: 80%;
|
| 128 |
padding: 10px;
|
| 129 |
border-radius: 20px;
|
| 130 |
border: 1px solid #ccc;
|
| 131 |
outline: none;
|
| 132 |
+
font-size: 16px;
|
| 133 |
}
|
| 134 |
#send-button {
|
| 135 |
background-color: #128c7e;
|
| 136 |
color: white;
|
| 137 |
+
padding: 10px;
|
| 138 |
border: none;
|
| 139 |
border-radius: 50%;
|
| 140 |
cursor: pointer;
|
| 141 |
margin-left: 10px;
|
| 142 |
width: 50px;
|
| 143 |
height: 50px;
|
| 144 |
+
font-size: 20px;
|
| 145 |
}
|
| 146 |
#send-button:hover {
|
| 147 |
background-color: #075e54;
|
|
|
|
| 154 |
border-radius: 5px;
|
| 155 |
cursor: pointer;
|
| 156 |
margin-top: 10px;
|
| 157 |
+
font-size: 14px;
|
| 158 |
}
|
| 159 |
#clear-button:hover {
|
| 160 |
background-color: #128c7e;
|
| 161 |
}
|
|
|
|
|
|
|
|
|
|
| 162 |
.message {
|
| 163 |
margin-bottom: 10px;
|
| 164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
/* Scrollbar Styling */
|
| 166 |
#chatbot::-webkit-scrollbar {
|
| 167 |
width: 8px;
|
|
|
|
| 182 |
with gr.Column(scale=1):
|
| 183 |
chatbot = gr.Chatbot(label="Chatbot", elem_id="chatbot", type="messages")
|
| 184 |
with gr.Column(scale=1):
|
| 185 |
+
with gr.Row():
|
| 186 |
+
msg = gr.Textbox(
|
| 187 |
+
placeholder="Type your message here...",
|
| 188 |
+
show_label=False,
|
| 189 |
+
container=False,
|
| 190 |
+
elem_id="textbox"
|
| 191 |
+
)
|
| 192 |
+
send = gr.Button("➤", elem_id="send-button")
|
| 193 |
+
with gr.Row():
|
| 194 |
+
clear = gr.Button("Clear Chat", elem_id="clear-button")
|
| 195 |
|
| 196 |
def update_chat(user_message, history):
|
| 197 |
+
if user_message.strip() == "":
|
| 198 |
+
return history, history # Do not process empty messages
|
| 199 |
history, updated_history = chatbot_interface(user_message, history)
|
| 200 |
formatted_history = [
|
| 201 |
format_message(msg['content'], is_user=(msg['role'] == 'user'))
|