jeremierostan commited on
Commit
2c07b09
1 Parent(s): ed6f8c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -41
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
- position: absolute;
119
- top: 20px;
120
- right: 20px;
121
- width: 200px;
122
  height: auto;
123
- z-index: 1000;
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; /* Remove the blue border */
148
  border-radius: 5px;
149
- padding: 5px; /* Reduce padding around the chat area */
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; /* Smaller padding for better sizing */
171
- margin-bottom: 8px; /* Space between messages */
172
- max-width: 70%; /* Restrict maximum width for better appearance */
173
- word-wrap: break-word; /* Ensure text wraps properly */
174
  }
175
  .chatbot .message-bubble {
176
- background-color: #FFFFFF; /* Ensure background is white */
177
- border-radius: 8px; /* Rounded corners for messages */
178
- box-sizing: border-box; /* Ensure padding is included in width */
179
- display: inline-block; /* Align the bubble content properly */
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
- with gr.Row():
192
- # Logo and Title
193
- gr.HTML(
194
- f"""
195
- <img id='logo-img' src='{assistant_logo}' alt='Assistant Logo' onerror="this.style.display='none';document.getElementById('logo-error').style.display='block';">
196
- <div id='logo-error' style='display:none;'>Logo not found</div>
197
- """,
198
- elem_id='logo-container'
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
- with gr.Column(scale=6):
207
- chatbot = gr.Chatbot(
208
- height=500,
209
- avatar_images=(None, assistant_avatar),
210
- elem_classes="chatbot"
211
- )
212
- with gr.Column(scale=1):
213
- msg = gr.Textbox(
214
- placeholder="Type your message here...",
215
- container=False
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")