Update app.py
Browse files
app.py
CHANGED
@@ -115,12 +115,11 @@ isp_theme = gr.themes.Default().set(
|
|
115 |
# Custom CSS for logo positioning and disclaimer footer
|
116 |
custom_css = """
|
117 |
#logo-img {
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
width: 200px;
|
122 |
height: auto;
|
123 |
-
|
124 |
}
|
125 |
#disclaimer-footer {
|
126 |
width: 100%;
|
@@ -136,25 +135,24 @@ custom_css = """
|
|
136 |
max-width: 800px;
|
137 |
margin: 0 auto;
|
138 |
padding: 20px;
|
139 |
-
position: relative;
|
140 |
-
padding-top: 60px;
|
141 |
}
|
142 |
.title {
|
143 |
color: #003366;
|
144 |
margin-bottom: 10px;
|
|
|
145 |
}
|
146 |
.chatbot {
|
147 |
-
border: none;
|
148 |
border-radius: 5px;
|
149 |
-
padding:
|
150 |
margin-bottom: 15px;
|
151 |
}
|
152 |
.button-row {
|
153 |
display: flex;
|
154 |
gap: 10px;
|
|
|
155 |
margin-bottom: 15px;
|
156 |
}
|
157 |
-
/* Remove borders and shadows from chat bubbles */
|
158 |
.chatbot .message,
|
159 |
.chatbot .message::before,
|
160 |
.chatbot .message::after {
|
@@ -165,18 +163,17 @@ custom_css = """
|
|
165 |
border: none !important;
|
166 |
box-shadow: none !important;
|
167 |
}
|
168 |
-
/* Adjust padding, margin, and width for chat bubbles */
|
169 |
.chatbot .message-content {
|
170 |
-
padding: 5px 10px;
|
171 |
-
margin-bottom: 8px;
|
172 |
-
max-width: 70%;
|
173 |
-
word-wrap: break-word;
|
174 |
}
|
175 |
.chatbot .message-bubble {
|
176 |
-
background-color: #FFFFFF;
|
177 |
-
border-radius: 8px;
|
178 |
-
box-sizing: border-box;
|
179 |
-
display: inline-block;
|
180 |
}
|
181 |
"""
|
182 |
|
@@ -188,33 +185,32 @@ assistant_logo = os.getenv('LOGO')
|
|
188 |
# Gradio interface using Blocks
|
189 |
with gr.Blocks(theme=isp_theme, css=custom_css) as iface:
|
190 |
with gr.Column(elem_classes="container"):
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
gr.Markdown(f"# {assistant_title}", elem_classes="title")
|
201 |
|
202 |
gr.Markdown("Chat with a Historical Figure")
|
203 |
|
204 |
# Chatbot and message input
|
205 |
with gr.Row():
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
with gr.Row(elem_classes="button-row"):
|
219 |
submit = gr.Button("Submit", variant="primary")
|
220 |
clear = gr.ClearButton([msg, chatbot], value="Clear", variant="secondary")
|
|
|
115 |
# Custom CSS for logo positioning and disclaimer footer
|
116 |
custom_css = """
|
117 |
#logo-img {
|
118 |
+
display: block;
|
119 |
+
margin: 0 auto;
|
120 |
+
width: 150px;
|
|
|
121 |
height: auto;
|
122 |
+
padding-bottom: 20px; /* Space below logo */
|
123 |
}
|
124 |
#disclaimer-footer {
|
125 |
width: 100%;
|
|
|
135 |
max-width: 800px;
|
136 |
margin: 0 auto;
|
137 |
padding: 20px;
|
|
|
|
|
138 |
}
|
139 |
.title {
|
140 |
color: #003366;
|
141 |
margin-bottom: 10px;
|
142 |
+
text-align: center; /* Center the title */
|
143 |
}
|
144 |
.chatbot {
|
145 |
+
border: none;
|
146 |
border-radius: 5px;
|
147 |
+
padding: 10px;
|
148 |
margin-bottom: 15px;
|
149 |
}
|
150 |
.button-row {
|
151 |
display: flex;
|
152 |
gap: 10px;
|
153 |
+
justify-content: center; /* Center the buttons */
|
154 |
margin-bottom: 15px;
|
155 |
}
|
|
|
156 |
.chatbot .message,
|
157 |
.chatbot .message::before,
|
158 |
.chatbot .message::after {
|
|
|
163 |
border: none !important;
|
164 |
box-shadow: none !important;
|
165 |
}
|
|
|
166 |
.chatbot .message-content {
|
167 |
+
padding: 5px 10px;
|
168 |
+
margin-bottom: 8px;
|
169 |
+
max-width: 70%;
|
170 |
+
word-wrap: break-word;
|
171 |
}
|
172 |
.chatbot .message-bubble {
|
173 |
+
background-color: #FFFFFF;
|
174 |
+
border-radius: 8px;
|
175 |
+
box-sizing: border-box;
|
176 |
+
display: inline-block;
|
177 |
}
|
178 |
"""
|
179 |
|
|
|
185 |
# Gradio interface using Blocks
|
186 |
with gr.Blocks(theme=isp_theme, css=custom_css) as iface:
|
187 |
with gr.Column(elem_classes="container"):
|
188 |
+
# Logo and Title
|
189 |
+
gr.HTML(
|
190 |
+
f"""
|
191 |
+
<img id='logo-img' src='{assistant_logo}' alt='Assistant Logo' onerror="this.style.display='none';document.getElementById('logo-error').style.display='block';">
|
192 |
+
<div id='logo-error' style='display:none;'>Logo not found</div>
|
193 |
+
""",
|
194 |
+
elem_id='logo-container'
|
195 |
+
)
|
196 |
+
gr.Markdown(f"# {assistant_title}", elem_classes="title")
|
|
|
197 |
|
198 |
gr.Markdown("Chat with a Historical Figure")
|
199 |
|
200 |
# Chatbot and message input
|
201 |
with gr.Row():
|
202 |
+
chatbot = gr.Chatbot(
|
203 |
+
height=500,
|
204 |
+
avatar_images=(None, assistant_avatar),
|
205 |
+
elem_classes="chatbot"
|
206 |
+
)
|
207 |
+
|
208 |
+
msg = gr.Textbox(
|
209 |
+
placeholder="Type your message here...",
|
210 |
+
container=False,
|
211 |
+
scale=7
|
212 |
+
)
|
213 |
+
|
214 |
with gr.Row(elem_classes="button-row"):
|
215 |
submit = gr.Button("Submit", variant="primary")
|
216 |
clear = gr.ClearButton([msg, chatbot], value="Clear", variant="secondary")
|