Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -23,6 +23,7 @@ generator = pipeline("text2text-generation", model="google/flan-t5-base")
|
|
23 |
# Function to classify customer comments
|
24 |
@spaces.GPU
|
25 |
def classify_comments(categories):
|
|
|
26 |
sentiments = []
|
27 |
assigned_categories = []
|
28 |
for comment in df['customer_comment']:
|
@@ -132,6 +133,7 @@ with gr.Blocks() as nps:
|
|
132 |
|
133 |
# Function to load data from uploaded CSV
|
134 |
def load_data(file):
|
|
|
135 |
if file is not None:
|
136 |
file.seek(0) # Reset file pointer
|
137 |
if file.name.endswith('.csv'):
|
@@ -142,7 +144,6 @@ with gr.Blocks() as nps:
|
|
142 |
required_columns = ['customer_comment', 'customer_nps']
|
143 |
if not all(col in custom_df.columns for col in required_columns):
|
144 |
return f"Error: Uploaded CSV must contain the following columns: {', '.join(required_columns)}"
|
145 |
-
global df
|
146 |
df = custom_df
|
147 |
return "Custom CSV loaded successfully!"
|
148 |
else:
|
|
|
23 |
# Function to classify customer comments
|
24 |
@spaces.GPU
|
25 |
def classify_comments(categories):
|
26 |
+
global df # Ensure we're modifying the global DataFrame
|
27 |
sentiments = []
|
28 |
assigned_categories = []
|
29 |
for comment in df['customer_comment']:
|
|
|
133 |
|
134 |
# Function to load data from uploaded CSV
|
135 |
def load_data(file):
|
136 |
+
global df # Ensure we're modifying the global DataFrame
|
137 |
if file is not None:
|
138 |
file.seek(0) # Reset file pointer
|
139 |
if file.name.endswith('.csv'):
|
|
|
144 |
required_columns = ['customer_comment', 'customer_nps']
|
145 |
if not all(col in custom_df.columns for col in required_columns):
|
146 |
return f"Error: Uploaded CSV must contain the following columns: {', '.join(required_columns)}"
|
|
|
147 |
df = custom_df
|
148 |
return "Custom CSV loaded successfully!"
|
149 |
else:
|