bluenevus commited on
Commit
f53a13f
Β·
1 Parent(s): a6102b0

Update app.py via AI Editor

Browse files
Files changed (1) hide show
  1. app.py +30 -24
app.py CHANGED
@@ -181,20 +181,23 @@ app = dash.Dash(
181
  )
182
 
183
  def chat_message_card(msg, is_user):
184
- align = "end" if is_user else "start"
185
  color = "primary" if is_user else "secondary"
186
  avatar = "πŸ§‘" if is_user else "πŸ€–"
187
- return dbc.Card(
188
- dbc.CardBody([
189
- html.Div([
190
- html.Span(avatar, style={"fontSize": "2rem"}),
191
- html.Span(msg, style={"whiteSpace": "pre-wrap", "marginLeft": "0.75rem", "overflowWrap": "break-word", "wordBreak": "break-word"})
192
- ], style={"display": "flex", "alignItems": "center", "justifyContent": align})
193
- ]),
194
- className=f"mb-2 ms-3 me-3",
195
- color=color,
196
- inverse=is_user,
197
- style={"maxWidth": "80%", "alignSelf": f"flex-{align}"}
 
 
 
198
  )
199
 
200
  def uploaded_file_card(filename, is_img):
@@ -233,20 +236,23 @@ def left_navbar_static():
233
  ], style={"padding": "1rem", "backgroundColor": "#f8f9fa", "height": "100vh", "overflowY": "auto"})
234
 
235
  def chat_box_card():
236
- # Fix the chat window height and allow vertical scroll
237
  return dbc.Card(
238
  dbc.CardBody([
239
- html.Div(id="chat-window", style={
240
- "height": "70vh",
241
- "overflowY": "auto",
242
- "overflowX": "auto",
243
- "display": "flex",
244
- "flexDirection": "column",
245
- "justifyContent": "flex-end",
246
- "backgroundColor": "#fff",
247
- "padding": "0.5rem",
248
- "borderRadius": "0.5rem"
249
- })
 
 
 
250
  ]),
251
  className="mt-3",
252
  style={
 
181
  )
182
 
183
  def chat_message_card(msg, is_user):
184
+ align = "flex-end" if is_user else "flex-start"
185
  color = "primary" if is_user else "secondary"
186
  avatar = "πŸ§‘" if is_user else "πŸ€–"
187
+ return html.Div(
188
+ dbc.Card(
189
+ dbc.CardBody([
190
+ html.Div([
191
+ html.Span(avatar, style={"fontSize": "2rem"}),
192
+ html.Span(msg, style={"whiteSpace": "pre-wrap", "marginLeft": "0.75rem", "overflowWrap": "break-word", "wordBreak": "break-word"})
193
+ ], style={"display": "flex", "alignItems": "center"})
194
+ ]),
195
+ className=f"mb-2 ms-3 me-3",
196
+ color=color,
197
+ inverse=is_user,
198
+ style={"maxWidth": "80%"}
199
+ ),
200
+ style={"display": "flex", "justifyContent": align, "width": "100%"}
201
  )
202
 
203
  def uploaded_file_card(filename, is_img):
 
236
  ], style={"padding": "1rem", "backgroundColor": "#f8f9fa", "height": "100vh", "overflowY": "auto"})
237
 
238
  def chat_box_card():
239
+ # Use a scrollable vertical container for chat history
240
  return dbc.Card(
241
  dbc.CardBody([
242
+ html.Div(
243
+ id="chat-window-container",
244
+ children=[
245
+ html.Div(id="chat-window", style={"width": "100%"})
246
+ ],
247
+ style={
248
+ "height": "70vh",
249
+ "overflowY": "auto",
250
+ "overflowX": "hidden",
251
+ "backgroundColor": "#fff",
252
+ "padding": "0.5rem",
253
+ "borderRadius": "0.5rem"
254
+ }
255
+ )
256
  ]),
257
  className="mt-3",
258
  style={