tdeshane commited on
Commit
38614a2
1 Parent(s): 87c4f81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -14,6 +14,9 @@ from collections import defaultdict
14
  import os
15
 
16
 
 
 
 
17
  def find_most_valuable_feature(csv_file):
18
  print("find_most_valuable_feature")
19
  print(csv_file)
@@ -106,6 +109,7 @@ def process_and_analyze_data(csv_file):
106
 
107
  @cl.on_message
108
  async def handle_message(message: cl.Message):
 
109
  # Retrieve the CSV file from the message
110
  csv_file = next(
111
  (
@@ -120,6 +124,7 @@ async def handle_message(message: cl.Message):
120
  print(f"CSV File: {csv_file}")
121
 
122
  if csv_file:
 
123
  try:
124
 
125
  image_buffer = find_most_valuable_feature(csv_file)
@@ -152,7 +157,8 @@ async def handle_message(message: cl.Message):
152
  except Exception as e:
153
  await cl.Message(content=f"An error occurred: {str(e)}").send()
154
  else:
155
- await cl.Message(content="Please upload a CSV file.").send()
 
156
 
157
 
158
  # Run the ChainLit app
 
14
  import os
15
 
16
 
17
+ got_csv = False
18
+
19
+
20
  def find_most_valuable_feature(csv_file):
21
  print("find_most_valuable_feature")
22
  print(csv_file)
 
109
 
110
  @cl.on_message
111
  async def handle_message(message: cl.Message):
112
+ global got_csv
113
  # Retrieve the CSV file from the message
114
  csv_file = next(
115
  (
 
124
  print(f"CSV File: {csv_file}")
125
 
126
  if csv_file:
127
+ got_csv = True
128
  try:
129
 
130
  image_buffer = find_most_valuable_feature(csv_file)
 
157
  except Exception as e:
158
  await cl.Message(content=f"An error occurred: {str(e)}").send()
159
  else:
160
+ if not got_csv:
161
+ await cl.Message(content="Please upload a CSV file.").send()
162
 
163
 
164
  # Run the ChainLit app