Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -48,36 +48,17 @@ with gr.Blocks() as nps:
|
|
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
|
53 |
-
|
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
|
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():
|
74 |
category_input = gr.Textbox(label="New Category", placeholder="Enter category name")
|
75 |
add_category_btn = gr.Button("Add Category")
|
|
|
76 |
category_status = gr.Markdown("**Categories:**\n- None")
|
77 |
|
78 |
-
# Display added categories
|
79 |
-
category_display = gr.Column(visible=False)
|
80 |
-
|
81 |
# File upload and template buttons
|
82 |
uploaded_file = gr.File(label="Upload CSV", type="filepath")
|
83 |
template_btn = gr.Button("Use Template")
|
@@ -114,10 +95,9 @@ with gr.Blocks() as nps:
|
|
114 |
inputs=[categories, category_input],
|
115 |
outputs=[categories, category_input, category_status]
|
116 |
)
|
117 |
-
|
118 |
-
fn=
|
119 |
-
|
120 |
-
outputs=category_display
|
121 |
)
|
122 |
uploaded_file.change(
|
123 |
fn=load_data,
|
|
|
48 |
categories.append(new_category.strip())
|
49 |
return categories, "", f"**Categories:**\n" + "\n".join([f"- {cat}" for cat in categories])
|
50 |
|
51 |
+
# Function to reset categories
|
52 |
+
def reset_categories():
|
53 |
+
return [], "**Categories:**\n- None"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
# UI for adding categories
|
56 |
with gr.Row():
|
57 |
category_input = gr.Textbox(label="New Category", placeholder="Enter category name")
|
58 |
add_category_btn = gr.Button("Add Category")
|
59 |
+
reset_btn = gr.Button("Reset Categories")
|
60 |
category_status = gr.Markdown("**Categories:**\n- None")
|
61 |
|
|
|
|
|
|
|
62 |
# File upload and template buttons
|
63 |
uploaded_file = gr.File(label="Upload CSV", type="filepath")
|
64 |
template_btn = gr.Button("Use Template")
|
|
|
95 |
inputs=[categories, category_input],
|
96 |
outputs=[categories, category_input, category_status]
|
97 |
)
|
98 |
+
reset_btn.click(
|
99 |
+
fn=reset_categories,
|
100 |
+
outputs=[categories, category_status]
|
|
|
101 |
)
|
102 |
uploaded_file.change(
|
103 |
fn=load_data,
|