Spaces:
Sleeping
Sleeping
Update app.py
Browse files1316 unmodified lines1317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671316 unmodified linespassreturn [''] * len(row)def variable_outputs(file_inputs):file_inputs_single = file_inputs# Call batch file processing and get analysis results(img_bucketfull_list,img_trust_list,img_nps_list,img_loyalty_list,img_consideration_list,img_satisfaction_list,df_builder_pivot_list,output_text_list,) = batch_file_processing(file_inputs_single)# Get the first file resultsimg_trust = img_trust_list[0] if img_trust_list else Noneimg_nps = img_nps_list[0] if img_nps_list else Noneimg_loyalty = img_loyalty_list[0] if img_loyalty_list else Noneimg_consideration = img_consideration_list[0] if img_consideration_list else Noneimg_satisfaction = img_satisfaction_list[0] if img_satisfaction_list else Noneoutput_text = output_text_list[0] if output_text_list else ""df_builder_pivot = df_builder_pivot_list[0] if df_builder_pivot_list else None# Return exactly what your components need - including markdown textreturn ("<span style='font-size:20px; font-weight:bold;'>Trust and NPS Drivers</span>", # markdown_3"""This analysis shows which Trust Buckets® are most effective in building trust and improving your key performance indicators (KPIs).<br><br>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.""", # markdown_4img_trust, # trust_plotimg_nps, # nps_plotimg_loyalty, # loyalty_plotimg_consideration, # consideration_plotimg_satisfaction, # satisfaction_plotoutput_text, # summary_text"<span style='font-size:20px; font-weight:bold;'>TrustBuilders®</span>", # markdown_5"""These are the specific reasons to trust and recommend. They can be your brand values, features, attributes, programs, and messages.<br>For practical purposes, they tell you exactly what to do and say to build more trust and improve your KPIs.<br>In the table, use the little arrows to toggle by Trust Bucket® or Trust Builder® importance.<br>Tip: Compare Owners and Prospects. Even though some of the Trust Buckets® are the same, the Trust Builders® are very different.""", # markdown_6df_builder_pivot, # df_builder_pivot)def reset_outputs():# Reset outputs1316 unmodified lines13171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821316 unmodified linespassreturn [''] * len(row)def variable_outputs(file_inputs):file_inputs_single = file_inputs# Call batch file processing and get analysis results(img_bucketfull_list,img_trust_list,img_nps_list,img_loyalty_list,img_consideration_list,img_satisfaction_list,df_builder_pivot_list,output_text_list,) = batch_file_processing(file_inputs_single)# Get number of datasets uploadedk = len(file_inputs_single)# Container for visible plotsglobal plots_visibleplots_visible = []# Use zip_longest to iterate over the lists, padding with Nonefor row, (img_bucketfull,img_trust,img_nps,img_loyalty,img_consideration,img_satisfaction,df_builder_pivot,output_text,) in enumerate(zip_longest(img_bucketfull_list,img_trust_list,img_nps_list,img_loyalty_list,img_consideration_list,img_satisfaction_list,df_builder_pivot_list,output_text_list,)):# Get dataset namedataset_name = file_inputs_single[row].split("/")[-1]global plots# Based on the number of files uploaded, determine the content of each textboxplots = [gr.Markdown("<span style='font-size:20px; font-weight:bold;'>Trust and NPS Drivers</span>",visible=True,),gr.Markdown("""The analysis identifies the TrustLogic® dimensions that are most effective in driving your audience's likelihood to recommend and trust you""",visible=True,),# ✅ Side-by-side Trust & NPS driversgr.Image(value=combine_two_images_horizontally(img_trust, "Trust Drivers", img_nps, "NPS Drivers"),type="pil",label="Trust + NPS Drivers",visible=True,),gr.Image(value=None,type="pil",visible=False,),gr.Image(value=None,type="pil",visible=False,),gr.Image(value=None,type="pil",visible=False,),gr.Image(value=None,type="pil",visible=False,),gr.Textbox(value=output_text,visible=False,),]# add current plots to containerplots_visible += plotsif isinstance(df_builder_pivot, pd.DataFrame):logger.debug(f"df_builder_pivot: {df_builder_pivot}")markdown_5 = gr.Markdown("<span style='font-size:20px; font-weight:bold;'> What to say and do to build your trust and Net Promoter Score </span>",visible=True,)markdown_6 = gr.Markdown("<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>",#+ "<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. "# + "<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.",visible=True,)styled_df = df_builder_pivot.style.apply(bold_high_impact_row, axis=1)table_builder_2 = gr.Dataframe(value=styled_df,headers=list(df_builder_pivot.columns),interactive=False,label=f"{dataset_name}",visible=True,height=800,wrap=True,)plots_visible.append(markdown_5)plots_visible.append(markdown_6)plots_visible.append(table_builder_2)else:plots_visible.append(gr.Markdown("", visible=False))plots_visible.append(gr.Markdown("", visible=False))plots_visible.append(gr.Dataframe(value=None, label="", visible=False))plots_invisible = [gr.Markdown("", visible=False),gr.Markdown("", visible=False),gr.Image(label="Trust Buckets", visible=False),gr.Markdown("", visible=False),gr.Markdown("", visible=False),gr.Image(label="Trust Drivers", visible=False),gr.Image(label="NPS Drivers", visible=False),gr.Image(label="Loyalty Drivers", visible=False),gr.Image(label="Consideration Drivers", visible=False),gr.Image(label="Satisfaction Drivers", visible=False),gr.Textbox(label="Analysis Summary", visible=False),gr.Markdown("", visible=False),gr.Markdown("", visible=False),gr.Dataframe(value=None, label=" ", visible=False),]return plots_visible + plots_invisible * (max_outputs - k)def reset_outputs():# Reset outputs
app.py+158-43