Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,11 +46,28 @@ with gr.Blocks() as nps:
|
|
| 46 |
def add_category(categories, new_category):
|
| 47 |
if new_category.strip() != "" and len(categories) < 5: # Limit to 5 categories
|
| 48 |
categories.append(new_category.strip())
|
| 49 |
-
return categories, "", f"**Categories:**\n" + "\n".join([f"- {cat}" for cat in categories])
|
| 50 |
|
| 51 |
-
# Function to
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
def display_categories(categories):
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# UI for adding categories
|
| 56 |
with gr.Row():
|
|
@@ -89,7 +106,7 @@ with gr.Blocks() as nps:
|
|
| 89 |
# Function to use template categories
|
| 90 |
def use_template():
|
| 91 |
template_categories = ["Product Experience", "Customer Support", "Price of Service", "Other"]
|
| 92 |
-
return template_categories, f"**Categories:**\n" + "\n".join([f"- {cat}" for cat in template_categories])
|
| 93 |
|
| 94 |
# Event handlers
|
| 95 |
add_category_btn.click(
|
|
|
|
| 46 |
def add_category(categories, new_category):
|
| 47 |
if new_category.strip() != "" and len(categories) < 5: # Limit to 5 categories
|
| 48 |
categories.append(new_category.strip())
|
| 49 |
+
return categories, "", f"**Categories:**\n" + "\n".join([f"- {cat} ποΈ" for cat in categories])
|
| 50 |
|
| 51 |
+
# Function to remove a category
|
| 52 |
+
def remove_category(categories, category_to_remove):
|
| 53 |
+
if category_to_remove in categories:
|
| 54 |
+
categories.remove(category_to_remove)
|
| 55 |
+
return categories, f"**Categories:**\n" + "\n".join([f"- {cat} ποΈ" for cat in categories])
|
| 56 |
+
|
| 57 |
+
# Function to display categories with remove buttons
|
| 58 |
def display_categories(categories):
|
| 59 |
+
category_rows = []
|
| 60 |
+
for cat in categories:
|
| 61 |
+
with gr.Row():
|
| 62 |
+
gr.Markdown(f"- {cat}")
|
| 63 |
+
remove_btn = gr.Button("ποΈ", elem_id=f"remove_{cat}")
|
| 64 |
+
remove_btn.click(
|
| 65 |
+
fn=remove_category,
|
| 66 |
+
inputs=[categories, gr.State(cat)],
|
| 67 |
+
outputs=[categories, category_status]
|
| 68 |
+
)
|
| 69 |
+
category_rows.append(gr.Row())
|
| 70 |
+
return category_rows
|
| 71 |
|
| 72 |
# UI for adding categories
|
| 73 |
with gr.Row():
|
|
|
|
| 106 |
# Function to use template categories
|
| 107 |
def use_template():
|
| 108 |
template_categories = ["Product Experience", "Customer Support", "Price of Service", "Other"]
|
| 109 |
+
return template_categories, f"**Categories:**\n" + "\n".join([f"- {cat} ποΈ" for cat in template_categories])
|
| 110 |
|
| 111 |
# Event handlers
|
| 112 |
add_category_btn.click(
|