Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2426,7 +2426,6 @@ def load_nps_and_r2(file_path):
|
|
| 2426 |
|
| 2427 |
return nps_img, r2_img
|
| 2428 |
|
| 2429 |
-
|
| 2430 |
with gr.Blocks(css=css, js=js_func) as demo:
|
| 2431 |
gr.HTML("""
|
| 2432 |
<style>
|
|
@@ -2494,45 +2493,9 @@ with gr.Blocks(css=css, js=js_func) as demo:
|
|
| 2494 |
gr.Markdown("""<div style='text-align: center;'><h3>How much of your NPS is determined by TrustLogic®</h3></div>""")
|
| 2495 |
trust_r2_img = gr.HTML()
|
| 2496 |
|
| 2497 |
-
#
|
| 2498 |
-
|
| 2499 |
-
|
| 2500 |
-
visible=True,
|
| 2501 |
-
)
|
| 2502 |
-
markdown_4 = gr.Markdown(
|
| 2503 |
-
"""
|
| 2504 |
-
This analysis shows which Trust Buckets® are most effective in building trust and improving your key performance indicators (KPIs).
|
| 2505 |
-
<br><br>
|
| 2506 |
-
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.
|
| 2507 |
-
""",
|
| 2508 |
-
visible=True,
|
| 2509 |
-
)
|
| 2510 |
-
trust_plot = gr.Image(value=None, label="Trust Drivers", visible=True)
|
| 2511 |
-
nps_plot = gr.Image(value=None, label="NPS Drivers", visible=True)
|
| 2512 |
-
loyalty_plot = gr.Image(value=None, label="Loyalty Drivers", visible=True)
|
| 2513 |
-
consideration_plot = gr.Image(value=None, label="Consideration Drivers", visible=True)
|
| 2514 |
-
satisfaction_plot = gr.Image(value=None, label="Satisfaction Drivers", visible=True)
|
| 2515 |
-
summary_text = gr.Textbox(value=None, label="Analysis Summary", visible=True)
|
| 2516 |
-
|
| 2517 |
-
markdown_5 = gr.Markdown(
|
| 2518 |
-
"<span style='font-size:20px; font-weight:bold;'>TrustBuilders®",
|
| 2519 |
-
visible=True,
|
| 2520 |
-
)
|
| 2521 |
-
markdown_6 = gr.Markdown(
|
| 2522 |
-
"These are the specific reasons to trust and recommend. They can be your brand values, features, attributes, programs, and messages. "
|
| 2523 |
-
+ "<br>For practical purposes, they tell you exactly what to do and say to build more trust and improve your KPIs. "
|
| 2524 |
-
+ "<br>In the table, use the little arrows to toggle by Trust Bucket® or Trust Builder® importance. "
|
| 2525 |
-
+ "<br>Tip: Compare Owners and Prospects. Even though some of the Trust Buckets® are the same, the Trust Builders® are very different.",
|
| 2526 |
-
visible=True,
|
| 2527 |
-
)
|
| 2528 |
-
df_builder_pivot = gr.Dataframe(value=None, label="", visible=True)
|
| 2529 |
-
|
| 2530 |
-
# Create outputs list for functions
|
| 2531 |
-
outputs = [
|
| 2532 |
-
markdown_3, markdown_4, trust_plot, nps_plot, loyalty_plot,
|
| 2533 |
-
consideration_plot, satisfaction_plot, summary_text,
|
| 2534 |
-
markdown_5, markdown_6, df_builder_pivot
|
| 2535 |
-
]
|
| 2536 |
|
| 2537 |
# Show/hide data section functionality
|
| 2538 |
def toggle_data_section(visible):
|
|
@@ -2566,32 +2529,32 @@ with gr.Blocks(css=css, js=js_func) as demo:
|
|
| 2566 |
outputs=trust_score_output,
|
| 2567 |
)
|
| 2568 |
|
| 2569 |
-
|
| 2570 |
-
|
| 2571 |
-
|
| 2572 |
-
|
| 2573 |
-
|
| 2574 |
-
|
| 2575 |
-
|
| 2576 |
-
|
| 2577 |
-
|
| 2578 |
-
|
| 2579 |
-
|
| 2580 |
-
|
| 2581 |
-
|
| 2582 |
-
|
|
|
|
|
|
|
|
|
|
| 2583 |
|
| 2584 |
-
def set_vw_prospects():
|
| 2585 |
-
return "Volkswagen Non Customers.xlsx"
|
| 2586 |
-
|
| 2587 |
vw_customers_btn.click(
|
| 2588 |
-
fn=
|
| 2589 |
inputs=[],
|
| 2590 |
outputs=selected_dataset_ai
|
| 2591 |
)
|
| 2592 |
|
| 2593 |
vw_prospects_btn.click(
|
| 2594 |
-
fn=
|
| 2595 |
inputs=[],
|
| 2596 |
outputs=selected_dataset_ai
|
| 2597 |
)
|
|
@@ -2619,15 +2582,9 @@ with gr.Blocks(css=css, js=js_func) as demo:
|
|
| 2619 |
inputs=[],
|
| 2620 |
outputs=trust_score_output
|
| 2621 |
)
|
| 2622 |
-
|
| 2623 |
-
demo.load(
|
| 2624 |
-
fn=process_examples,
|
| 2625 |
-
inputs=[vw_customers_state],
|
| 2626 |
-
outputs=outputs
|
| 2627 |
-
)
|
| 2628 |
|
| 2629 |
try:
|
| 2630 |
demo.launch(server_name="0.0.0.0")
|
| 2631 |
except Exception as e:
|
| 2632 |
logger.error(f"Error launching Gradio app: {e}")
|
| 2633 |
-
raise e
|
|
|
|
| 2426 |
|
| 2427 |
return nps_img, r2_img
|
| 2428 |
|
|
|
|
| 2429 |
with gr.Blocks(css=css, js=js_func) as demo:
|
| 2430 |
gr.HTML("""
|
| 2431 |
<style>
|
|
|
|
| 2493 |
gr.Markdown("""<div style='text-align: center;'><h3>How much of your NPS is determined by TrustLogic®</h3></div>""")
|
| 2494 |
trust_r2_img = gr.HTML()
|
| 2495 |
|
| 2496 |
+
# Create placeholder components for dynamic outputs
|
| 2497 |
+
with gr.Column() as dynamic_outputs_container:
|
| 2498 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2499 |
|
| 2500 |
# Show/hide data section functionality
|
| 2501 |
def toggle_data_section(visible):
|
|
|
|
| 2529 |
outputs=trust_score_output,
|
| 2530 |
)
|
| 2531 |
|
| 2532 |
+
# Modified to handle component rendering
|
| 2533 |
+
@gr.render(inputs=[vw_customers_state, vw_prospects_state, selected_dataset_ai], triggers=[vw_customers_btn.click, vw_prospects_btn.click, demo.load])
|
| 2534 |
+
def render_dynamic_outputs(vw_cust_state, vw_pros_state, selected_dataset):
|
| 2535 |
+
# Determine which dataset to use
|
| 2536 |
+
if selected_dataset == "VW Owners.xlsx":
|
| 2537 |
+
file_inputs = vw_cust_state
|
| 2538 |
+
else:
|
| 2539 |
+
file_inputs = vw_pros_state
|
| 2540 |
+
|
| 2541 |
+
# Get the components from variable_outputs
|
| 2542 |
+
output_components = variable_outputs(file_inputs)
|
| 2543 |
+
|
| 2544 |
+
# Render the components
|
| 2545 |
+
with gr.Column():
|
| 2546 |
+
for component in output_components:
|
| 2547 |
+
if component is not None and hasattr(component, 'render'):
|
| 2548 |
+
component.render()
|
| 2549 |
|
|
|
|
|
|
|
|
|
|
| 2550 |
vw_customers_btn.click(
|
| 2551 |
+
fn=lambda: "VW Owners.xlsx",
|
| 2552 |
inputs=[],
|
| 2553 |
outputs=selected_dataset_ai
|
| 2554 |
)
|
| 2555 |
|
| 2556 |
vw_prospects_btn.click(
|
| 2557 |
+
fn=lambda: "Volkswagen Non Customers.xlsx",
|
| 2558 |
inputs=[],
|
| 2559 |
outputs=selected_dataset_ai
|
| 2560 |
)
|
|
|
|
| 2582 |
inputs=[],
|
| 2583 |
outputs=trust_score_output
|
| 2584 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2585 |
|
| 2586 |
try:
|
| 2587 |
demo.launch(server_name="0.0.0.0")
|
| 2588 |
except Exception as e:
|
| 2589 |
logger.error(f"Error launching Gradio app: {e}")
|
| 2590 |
+
raise e
|