Wajahat698 commited on
Commit
8a2842a
·
verified ·
1 Parent(s): 8bfe968

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -156
app.py CHANGED
@@ -1317,164 +1317,51 @@ def bold_high_impact_row(row):
1317
  pass
1318
  return [''] * len(row)
1319
 
1320
-
1321
  def variable_outputs(file_inputs):
1322
-
1323
- file_inputs_single = file_inputs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1324
 
1325
- # Call batch file processing and get analysis results
1326
- (
1327
- img_bucketfull_list,
1328
- img_trust_list,
1329
- img_nps_list,
1330
- img_loyalty_list,
1331
- img_consideration_list,
1332
- img_satisfaction_list,
1333
- df_builder_pivot_list,
1334
- output_text_list,
1335
- ) = batch_file_processing(file_inputs_single)
1336
-
1337
- # Get number of datasets uploaded
1338
- k = len(file_inputs_single)
1339
-
1340
- # Container for visible plots
1341
- global plots_visible
1342
- plots_visible = []
1343
-
1344
- # Use zip_longest to iterate over the lists, padding with None
1345
- for row, (
1346
- img_bucketfull,
1347
- img_trust,
1348
- img_nps,
1349
- img_loyalty,
1350
- img_consideration,
1351
- img_satisfaction,
1352
- df_builder_pivot,
1353
- output_text,
1354
- ) in enumerate(
1355
- zip_longest(
1356
- img_bucketfull_list,
1357
- img_trust_list,
1358
- img_nps_list,
1359
- img_loyalty_list,
1360
- img_consideration_list,
1361
- img_satisfaction_list,
1362
- df_builder_pivot_list,
1363
- output_text_list,
1364
- )
1365
- ):
1366
- # Get dataset name
1367
- dataset_name = file_inputs_single[row].split("/")[-1]
1368
- global plots
1369
- # Based on the number of files uploaded, determine the content of each textbox
1370
- plots = [
1371
-
1372
- gr.Markdown(
1373
- "<span style='font-size:20px; font-weight:bold;'>Trust and NPS Drivers</span>",
1374
- visible=True,
1375
- ),
1376
- gr.Markdown(
1377
- """
1378
- The analysis identifies the TrustLogic® dimensions that are most effective in driving your audience's likelihood to recommend and trust you
1379
- """,
1380
- visible=True,
1381
- ),
1382
-
1383
- # ✅ Side-by-side Trust & NPS drivers
1384
- gr.Image(
1385
- value=combine_two_images_horizontally(img_trust, "Trust Drivers", img_nps, "NPS Drivers"),
1386
- type="pil",
1387
- label="Trust + NPS Drivers",
1388
- visible=True,
1389
- ),
1390
- gr.Image(
1391
- value=None,
1392
- type="pil",
1393
- visible=False,
1394
- ),
1395
-
1396
-
1397
- gr.Image(
1398
- value=None,
1399
- type="pil",
1400
- visible=False,
1401
- ),
1402
- gr.Image(
1403
- value=None,
1404
- type="pil",
1405
- visible=False,
1406
- ),
1407
- gr.Image(
1408
- value=None,
1409
- type="pil",
1410
- visible=False,
1411
- ),
1412
- gr.Textbox(
1413
- value=output_text,
1414
- visible=False,
1415
- ),
1416
- ]
1417
-
1418
- # add current plots to container
1419
- plots_visible += plots
1420
-
1421
- if isinstance(df_builder_pivot, pd.DataFrame):
1422
- logger.debug(f"df_builder_pivot: {df_builder_pivot}")
1423
-
1424
- markdown_5 = gr.Markdown(
1425
- "<span style='font-size:20px; font-weight:bold;'> What to say and do to build your trust and Net Promoter Score </span>",
1426
- visible=True,
1427
- )
1428
-
1429
- markdown_6 = gr.Markdown(
1430
- "<span style='font-size:17px; font-weight:bold;'>The features and messages that improve your NPS and trust most effectively. They key ones are marked in bold.</span>",
1431
- #+ "<br>In the table, use the little arrow in each column to toggle the most to least effective TrustBuilders® to fill each Trust Bucket®. Your focus is only on the Trust Bucket® with the highest driver impact. "
1432
- # + "<br> Note: Even if Trust Buckets® for Customers and Prospects overlap, the most effective statements are very different. This provides clear guidance for acquisition versus loyalty activities.",
1433
- visible=True,
1434
- )
1435
-
1436
- styled_df = df_builder_pivot.style.apply(bold_high_impact_row, axis=1)
1437
-
1438
-
1439
- table_builder_2 = gr.Dataframe(
1440
- value=styled_df,
1441
- headers=list(df_builder_pivot.columns),
1442
- interactive=False,
1443
- label=f"{dataset_name}",
1444
- visible=True,
1445
- height=800,
1446
- wrap=True,
1447
- )
1448
-
1449
-
1450
-
1451
- plots_visible.append(markdown_5)
1452
- plots_visible.append(markdown_6)
1453
- plots_visible.append(table_builder_2)
1454
- else:
1455
- plots_visible.append(gr.Markdown("", visible=False))
1456
- plots_visible.append(gr.Markdown("", visible=False))
1457
- plots_visible.append(gr.Dataframe(value=None, label="", visible=False))
1458
-
1459
- plots_invisible = [
1460
- gr.Markdown("", visible=False),
1461
- gr.Markdown("", visible=False),
1462
- gr.Image(label="Trust Buckets", visible=False),
1463
- gr.Markdown("", visible=False),
1464
- gr.Markdown("", visible=False),
1465
- gr.Image(label="Trust Drivers", visible=False),
1466
- gr.Image(label="NPS Drivers", visible=False),
1467
- gr.Image(label="Loyalty Drivers", visible=False),
1468
- gr.Image(label="Consideration Drivers", visible=False),
1469
- gr.Image(label="Satisfaction Drivers", visible=False),
1470
- gr.Textbox(label="Analysis Summary", visible=False),
1471
- gr.Markdown("", visible=False),
1472
- gr.Markdown("", visible=False),
1473
- gr.Dataframe(value=None, label=" ", visible=False),
1474
- ]
1475
-
1476
- return plots_visible + plots_invisible * (max_outputs - k)
1477
-
1478
 
1479
  def reset_outputs():
1480
  # Reset outputs
 
1317
  pass
1318
  return [''] * len(row)
1319
 
 
1320
  def variable_outputs(file_inputs):
1321
+ file_inputs_single = file_inputs
1322
+
1323
+ # Call batch file processing and get analysis results
1324
+ (
1325
+ img_bucketfull_list,
1326
+ img_trust_list,
1327
+ img_nps_list,
1328
+ img_loyalty_list,
1329
+ img_consideration_list,
1330
+ img_satisfaction_list,
1331
+ df_builder_pivot_list,
1332
+ output_text_list,
1333
+ ) = batch_file_processing(file_inputs_single)
1334
+
1335
+ # Get the first file results
1336
+ img_trust = img_trust_list[0] if img_trust_list else None
1337
+ img_nps = img_nps_list[0] if img_nps_list else None
1338
+ img_loyalty = img_loyalty_list[0] if img_loyalty_list else None
1339
+ img_consideration = img_consideration_list[0] if img_consideration_list else None
1340
+ img_satisfaction = img_satisfaction_list[0] if img_satisfaction_list else None
1341
+ output_text = output_text_list[0] if output_text_list else ""
1342
+ df_builder_pivot = df_builder_pivot_list[0] if df_builder_pivot_list else None
1343
 
1344
+ # Return exactly what your components need - including markdown text
1345
+ return (
1346
+ "<span style='font-size:20px; font-weight:bold;'>Trust and NPS Drivers</span>", # markdown_3
1347
+ """
1348
+ This analysis shows which Trust Buckets® are most effective in building trust and improving your key performance indicators (KPIs).
1349
+ <br><br>
1350
+ The middle line is the average importance. The bars extending to the right show which Trust Buckets® are most important. The higher the percentage, the more important the Trust Bucket® is to your audience.
1351
+ """, # markdown_4
1352
+ img_trust, # trust_plot
1353
+ img_nps, # nps_plot
1354
+ img_loyalty, # loyalty_plot
1355
+ img_consideration, # consideration_plot
1356
+ img_satisfaction, # satisfaction_plot
1357
+ output_text, # summary_text
1358
+ "<span style='font-size:20px; font-weight:bold;'>TrustBuilders®</span>", # markdown_5
1359
+ """These are the specific reasons to trust and recommend. They can be your brand values, features, attributes, programs, and messages.
1360
+ <br>For practical purposes, they tell you exactly what to do and say to build more trust and improve your KPIs.
1361
+ <br>In the table, use the little arrows to toggle by Trust Bucket® or Trust Builder® importance.
1362
+ <br>Tip: Compare Owners and Prospects. Even though some of the Trust Buckets® are the same, the Trust Builders® are very different.""", # markdown_6
1363
+ df_builder_pivot, # df_builder_pivot
1364
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1365
 
1366
  def reset_outputs():
1367
  # Reset outputs