Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -166,8 +166,14 @@ def generate_bar_chart(df, num_clusters_to_display):
|
|
| 166 |
img = Image.open(buf)
|
| 167 |
return img
|
| 168 |
|
| 169 |
-
def main(file,
|
| 170 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
df = pd.read_csv(file)
|
| 172 |
|
| 173 |
df = df[df['Answer'] == 'Fallback Message shown']
|
|
@@ -196,32 +202,13 @@ def main(file, num_clusters_to_display, categories_keywords):
|
|
| 196 |
print(f"Error: {e}")
|
| 197 |
return str(e), None, None
|
| 198 |
|
| 199 |
-
def
|
| 200 |
-
|
| 201 |
-
if bot_name == "Bot 1":
|
| 202 |
-
categories_keywords = categories_keywords_bot1
|
| 203 |
-
else:
|
| 204 |
-
categories_keywords = categories_keywords_bot2
|
| 205 |
-
return f"Selected {bot_name}"
|
| 206 |
|
| 207 |
-
|
| 208 |
-
return main(file, num_clusters_to_display, categories_keywords)
|
| 209 |
-
|
| 210 |
-
bot_selection_interface = gr.Interface(
|
| 211 |
-
fn=select_bot,
|
| 212 |
-
inputs=[
|
| 213 |
-
gr.Radio(["Bot 1", "Bot 2"], label="Select Bot")
|
| 214 |
-
],
|
| 215 |
-
outputs=[
|
| 216 |
-
gr.Textbox(label="Selected Bot")
|
| 217 |
-
],
|
| 218 |
-
title="Select Bot",
|
| 219 |
-
description="Select the bot for categorizing unanswered queries."
|
| 220 |
-
)
|
| 221 |
-
|
| 222 |
-
categorize_interface = gr.Interface(
|
| 223 |
fn=categorize_unanswered_queries,
|
| 224 |
inputs=[
|
|
|
|
| 225 |
gr.File(label="Upload CSV File (.csv)"),
|
| 226 |
gr.Slider(label="Number of Categories to Display", minimum=1, maximum=10, step=1, value=5)
|
| 227 |
],
|
|
@@ -231,9 +218,7 @@ categorize_interface = gr.Interface(
|
|
| 231 |
gr.Image(label="Bar Chart")
|
| 232 |
],
|
| 233 |
title="Unanswered User Queries Categorization",
|
| 234 |
-
description="
|
| 235 |
)
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
main_interface.launch(share=True)
|
|
|
|
| 166 |
img = Image.open(buf)
|
| 167 |
return img
|
| 168 |
|
| 169 |
+
def main(file, bot_name, num_clusters_to_display):
|
| 170 |
try:
|
| 171 |
+
global categories_keywords
|
| 172 |
+
if bot_name == "Bot 1":
|
| 173 |
+
categories_keywords = categories_keywords_bot1
|
| 174 |
+
else:
|
| 175 |
+
categories_keywords = categories_keywords_bot2
|
| 176 |
+
|
| 177 |
df = pd.read_csv(file)
|
| 178 |
|
| 179 |
df = df[df['Answer'] == 'Fallback Message shown']
|
|
|
|
| 202 |
print(f"Error: {e}")
|
| 203 |
return str(e), None, None
|
| 204 |
|
| 205 |
+
def categorize_unanswered_queries(file, bot_name, num_clusters_to_display):
|
| 206 |
+
return main(file, bot_name, num_clusters_to_display)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
|
| 208 |
+
interface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
fn=categorize_unanswered_queries,
|
| 210 |
inputs=[
|
| 211 |
+
gr.Radio(["Bot 1", "Bot 2"], label="Select Bot"),
|
| 212 |
gr.File(label="Upload CSV File (.csv)"),
|
| 213 |
gr.Slider(label="Number of Categories to Display", minimum=1, maximum=10, step=1, value=5)
|
| 214 |
],
|
|
|
|
| 218 |
gr.Image(label="Bar Chart")
|
| 219 |
],
|
| 220 |
title="Unanswered User Queries Categorization",
|
| 221 |
+
description="Select the bot, upload the CSV file, and specify the number of categories to display to categorize unanswered user queries."
|
| 222 |
)
|
| 223 |
|
| 224 |
+
interface.launch(share=True)
|
|
|
|
|
|