bluenevus commited on
Commit
3a85524
·
1 Parent(s): f21f4b0

Update app.py via AI Editor

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -54,7 +54,6 @@ def get_right_col_content(selected_type):
54
  type="dot",
55
  children=[html.Div(id="loading-output")]
56
  ))
57
- # Show upload box for SHRED only
58
  if selected_type == "Shred":
59
  controls.append(
60
  html.Div([
@@ -147,9 +146,9 @@ def get_left_col_content():
147
  'overflowY': 'auto'
148
  },
149
  rows=5,
150
- autoFocus=False,
151
  wrap='soft'
152
  ),
 
153
  dbc.Row([
154
  dbc.Col(
155
  dbc.Button("Send", id="btn-send-chat", color="primary", className="mb-3 w-100"),
@@ -644,6 +643,21 @@ def download_document(n_clicks, selected_doc_type):
644
  logging.error(f"Error downloading document: {str(e)}")
645
  return dcc.send_string(f"Error downloading document: {str(e)}", f"{selected_doc_type}_error.txt")
646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
647
  if __name__ == '__main__':
648
  print("Starting the Dash application...")
649
  app.run(debug=True, host='0.0.0.0', port=7860, threaded=True)
 
54
  type="dot",
55
  children=[html.Div(id="loading-output")]
56
  ))
 
57
  if selected_type == "Shred":
58
  controls.append(
59
  html.Div([
 
146
  'overflowY': 'auto'
147
  },
148
  rows=5,
 
149
  wrap='soft'
150
  ),
151
+ dcc.Store(id="chat-input-rows", data=5),
152
  dbc.Row([
153
  dbc.Col(
154
  dbc.Button("Send", id="btn-send-chat", color="primary", className="mb-3 w-100"),
 
643
  logging.error(f"Error downloading document: {str(e)}")
644
  return dcc.send_string(f"Error downloading document: {str(e)}", f"{selected_doc_type}_error.txt")
645
 
646
+ @app.callback(
647
+ Output("chat-input", "rows"),
648
+ Input("chat-input", "value"),
649
+ State("chat-input", "rows"),
650
+ prevent_initial_call="initial_duplicate"
651
+ )
652
+ def auto_expand_textarea(value, current_rows):
653
+ if value is None or value == "":
654
+ return 5
655
+ num_lines = value.count('\n') + 1
656
+ # To avoid the box growing too huge, set a reasonable max
657
+ max_rows = 20
658
+ rows = min(max(num_lines, 5), max_rows)
659
+ return rows
660
+
661
  if __name__ == '__main__':
662
  print("Starting the Dash application...")
663
  app.run(debug=True, host='0.0.0.0', port=7860, threaded=True)