Wajahat698 commited on
Commit
e42d8f1
·
verified ·
1 Parent(s): f177fd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -12
app.py CHANGED
@@ -2553,7 +2553,6 @@ def load_nps_and_r2(file_path):
2553
 
2554
 
2555
 
2556
-
2557
  with gr.Blocks(css=css, js=js_func) as demo:
2558
  gr.HTML("""
2559
  <style>
@@ -2612,15 +2611,58 @@ with gr.Blocks(css=css, js=js_func) as demo:
2612
  gr.Markdown("""<div style='text-align: center;'><h3>How much of your NPS is determined by TrustLogic®</h3></div>""")
2613
  trust_r2_img = gr.HTML()
2614
 
 
2615
  with gr.Column():
2616
- outputs = reset_outputs()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2617
 
2618
- # 🔁 States - MOVED OUTSIDE OF DATA SECTION
2619
  vw_customers_state11 = gr.State(value=["example_files/VW Owners.xlsx"])
2620
  vw_prospects_state12 = gr.State(value=["example_files/Volkswagen Non Customers.xlsx"])
2621
  vw_customers_state = gr.State(value=["VW Owners.xlsx"])
2622
  vw_prospects_state = gr.State(value=["Volkswagen Non Customers.xlsx"])
2623
- selected_dataset_ai = gr.State(value="VW Owners.xlsx") # ✅ Matches dictionary key
2624
  chat_history = gr.State(value=[])
2625
 
2626
  # Show/hide data section functionality
@@ -2637,7 +2679,14 @@ with gr.Blocks(css=css, js=js_func) as demo:
2637
  def set_vw_prospects():
2638
  return "Volkswagen Non Customers.xlsx"
2639
 
2640
- # Event handlers - MOVED OUTSIDE OF DATA SECTION
 
 
 
 
 
 
 
2641
  show_data_btn.click(
2642
  fn=toggle_data_section,
2643
  inputs=data_visible_state,
@@ -2650,8 +2699,6 @@ with gr.Blocks(css=css, js=js_func) as demo:
2650
  outputs=[bot, chat_history]
2651
  )
2652
 
2653
- ## All widget functions here ##
2654
-
2655
  vw_customers_btn.click(
2656
  fn=display_trust_score_1,
2657
  inputs=[],
@@ -2665,15 +2712,15 @@ with gr.Blocks(css=css, js=js_func) as demo:
2665
  )
2666
 
2667
  vw_customers_btn.click(
2668
- fn=process_examples,
2669
  inputs=[vw_customers_state],
2670
- outputs=outputs,
2671
  )
2672
 
2673
  vw_prospects_btn.click(
2674
- fn=process_examples,
2675
  inputs=[vw_prospects_state],
2676
- outputs=outputs,
2677
  )
2678
 
2679
  vw_customers_btn.click(
@@ -2714,7 +2761,7 @@ with gr.Blocks(css=css, js=js_func) as demo:
2714
  )
2715
 
2716
  demo.load(
2717
- fn=process_examples,
2718
  inputs=[vw_customers_state],
2719
  outputs=outputs
2720
  )
 
2553
 
2554
 
2555
 
 
2556
  with gr.Blocks(css=css, js=js_func) as demo:
2557
  gr.HTML("""
2558
  <style>
 
2611
  gr.Markdown("""<div style='text-align: center;'><h3>How much of your NPS is determined by TrustLogic®</h3></div>""")
2612
  trust_r2_img = gr.HTML()
2613
 
2614
+ # ADD THE MISSING OUTPUTS SECTION HERE
2615
  with gr.Column():
2616
+ # Create all the output components that reset_outputs() expects
2617
+ outputs = []
2618
+
2619
+ # Trust and NPS Drivers section
2620
+ markdown_3 = gr.Markdown(
2621
+ "<span style='font-size:20px; font-weight:bold;'>Trust and NPS Drivers</span>",
2622
+ visible=True,
2623
+ )
2624
+ markdown_4 = gr.Markdown(
2625
+ """
2626
+ This analysis shows which Trust Buckets® are most effective in building trust and improving your key performance indicators (KPIs).
2627
+ <br><br>
2628
+ 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.
2629
+ """,
2630
+ visible=True,
2631
+ )
2632
+ trust_plot = gr.Image(value=None, label="Trust Drivers", visible=False)
2633
+ nps_plot = gr.Image(value=None, label="NPS Drivers", visible=False)
2634
+ loyalty_plot = gr.Image(value=None, label="Loyalty Drivers", visible=False)
2635
+ consideration_plot = gr.Image(value=None, label="Consideration Drivers", visible=False)
2636
+ satisfaction_plot = gr.Image(value=None, label="Satisfaction Drivers", visible=False)
2637
+ summary_text = gr.Textbox(value=None, label="Analysis Summary", visible=False)
2638
+
2639
+ # TrustBuilders section
2640
+ markdown_5 = gr.Markdown(
2641
+ "<span style='font-size:20px; font-weight:bold;'>TrustBuilders®",
2642
+ visible=True,
2643
+ )
2644
+ markdown_6 = gr.Markdown(
2645
+ "These are the specific reasons to trust and recommend. They can be your brand values, features, attributes, programs, and messages. "
2646
+ + "<br>For practical purposes, they tell you exactly what to do and say to build more trust and improve your KPIs. "
2647
+ + "<br>In the table, use the little arrows to toggle by Trust Bucket® or Trust Builder® importance. "
2648
+ + "<br>Tip: Compare Owners and Prospects. Even though some of the Trust Buckets® are the same, the Trust Builders® are very different.",
2649
+ visible=True,
2650
+ )
2651
+ df_builder_pivot = gr.Dataframe(value=None, label="", visible=True)
2652
+
2653
+ # Collect outputs in the correct order
2654
+ outputs = [
2655
+ markdown_3, markdown_4, trust_plot, nps_plot, loyalty_plot,
2656
+ consideration_plot, satisfaction_plot, summary_text,
2657
+ markdown_5, markdown_6, df_builder_pivot
2658
+ ]
2659
 
2660
+ # 🔁 States
2661
  vw_customers_state11 = gr.State(value=["example_files/VW Owners.xlsx"])
2662
  vw_prospects_state12 = gr.State(value=["example_files/Volkswagen Non Customers.xlsx"])
2663
  vw_customers_state = gr.State(value=["VW Owners.xlsx"])
2664
  vw_prospects_state = gr.State(value=["Volkswagen Non Customers.xlsx"])
2665
+ selected_dataset_ai = gr.State(value="VW Owners.xlsx")
2666
  chat_history = gr.State(value=[])
2667
 
2668
  # Show/hide data section functionality
 
2679
  def set_vw_prospects():
2680
  return "Volkswagen Non Customers.xlsx"
2681
 
2682
+ # MODIFIED process_examples function to work with your outputs
2683
+ def process_examples_wrapper(file_inputs):
2684
+ # Call your existing variable_outputs function
2685
+ result = variable_outputs(file_inputs)
2686
+ # Return only the first 11 items to match your outputs list
2687
+ return result[:11]
2688
+
2689
+ # Event handlers
2690
  show_data_btn.click(
2691
  fn=toggle_data_section,
2692
  inputs=data_visible_state,
 
2699
  outputs=[bot, chat_history]
2700
  )
2701
 
 
 
2702
  vw_customers_btn.click(
2703
  fn=display_trust_score_1,
2704
  inputs=[],
 
2712
  )
2713
 
2714
  vw_customers_btn.click(
2715
+ fn=process_examples_wrapper, # Use the wrapper function
2716
  inputs=[vw_customers_state],
2717
+ outputs=outputs, # Use the outputs list we created
2718
  )
2719
 
2720
  vw_prospects_btn.click(
2721
+ fn=process_examples_wrapper, # Use the wrapper function
2722
  inputs=[vw_prospects_state],
2723
+ outputs=outputs, # Use the outputs list we created
2724
  )
2725
 
2726
  vw_customers_btn.click(
 
2761
  )
2762
 
2763
  demo.load(
2764
+ fn=process_examples_wrapper, # Use the wrapper function
2765
  inputs=[vw_customers_state],
2766
  outputs=outputs
2767
  )