Spaces:
Build error
Build error
desired outcome output (#11)
Browse files- Add write_snapshot function to display channel analysis and enhance output formatting (86523549187f342d0bdd4c554c410a38299ea8e2)
38 unmodified lines3940414243444516 unmodified lines62636465666781 unmodified lines14915015115215315415515615715815918 unmodified lines17817918018118218318491 unmodified lines27627727827928028128238 unmodified linesreturn markdown_tabledef write_table(website_and_tools_data):if website_and_tools_data:16 unmodified lines# Add a row to the Markdown table string# Replace underscores with spaces and apply title case to categorycategory_formatted = category.replace('_', ' ').title()current_footprint_formatted = current_footprint.replace('_', ' ')best_of_breed_formatted = best_of_breed.replace('_', ' ')81 unmodified linesdef display_outputs():client_name = data_field("Client Name")client_website = data_field("Client Website")overview = get_analyst_response("DF Overview Analyst")st.markdown("# Digital Marketing Audit")st.markdown(f"for: **{client_name} ({client_website})**")st.write("")st.write("")st.write("")st.markdown("### DIGITAL FOOTPRINT OVERVIEW")18 unmodified linesst.markdown("---")st.markdown("### SNAPSHOT BY CHANNEL")st.table(get_analyst_response("Snapshot Analyst"))st.markdown("---")st.markdown("## AUDITS PER CHANNEL")91 unmodified linesst.write(target_market_data['summary'])st.markdown("##### WHAT IS THE DESIRED OUTCOMES OF DIGITAL MARKETING?")st.write("TBD")st.markdown("##### WHAT IS THE PULL-THROUGH OFFER?")pull_through_data = get_analyst_response("Pull through offers Analyst")38 unmodified lines3940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310416 unmodified lines12112212312412512612781 unmodified lines20921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024118 unmodified lines26026126226326426526691 unmodified lines35835936036136236336438 unmodified linesreturn markdown_tabledef write_snapshot(data):if data:try:parsed_data = dataif isinstance(parsed_data, list):# Create Markdown table headermarkdown_table = "| Channel | Status | Requirements | What's Needed to Deliver |\n"markdown_table += "|---|---|---|---|\n"# Loop through the list of dictionariesfor item in parsed_data:# Use .get() for safety in case keys are missingchannel = item.get('channel', 'N/A')status = item.get('status', 'N/A')requirements = item.get('requirements', 'N/A')deliver = item.get('deliver', 'N/A')# Add a row to the Markdown table string# Replace underscores with spaces and apply title case to category# Replace underscores with spaces firstchannel_temp = channel.replace('_', ' ')# Apply title case if there are multiple words, otherwise uppercaseif ' ' in channel_temp: # Check for spaces directlychannel_formatted = channel_temp.title()else:channel_formatted = channel_temp.upper() # Use upper() instead of upper_case()markdown_table += f"| {channel_formatted} | {status} | {requirements} | {deliver} |\n"# Display the complete Markdown tablest.markdown(markdown_table)# Handle case if data is not a list (e.g., a single dictionary)elif isinstance(parsed_data, dict):st.write("Analysis Result (Summary):")# You might want to display dictionary data differentlyst.json(parsed_data) # Example: Display as JSONelse:st.warning("data is not in the expected list format.")st.write(parsed_data) # Show the raw dataexcept json.JSONDecodeError:st.error("Error: Could not parse the data as JSON.")st.text(data) # Show the raw string dataexcept AttributeError:st.error("Error: Could not find expected keys ('channel', 'status', 'requirements', 'deliver') in the data.")st.write(parsed_data) # Show the data that caused the errorexcept Exception as e:st.error(f"An unexpected error occurred while processing data: {e}")st.write(data) # Show the raw dataelse:st.warning("No data retrieved for analysis.")# --- End: Loop and display data ---def write_table(website_and_tools_data):if website_and_tools_data:16 unmodified lines# Add a row to the Markdown table string# Replace underscores with spaces and apply title case to categorycategory_formatted = category.replace('_', ' ').title()current_footprint_formatted = current_footprint.replace('_', ' ')best_of_breed_formatted = best_of_breed.replace('_', ' ')81 unmodified linesdef display_outputs():client_name = data_field("Client Name")client_website = data_field("Client Website")overview = get_analyst_response("DF Overview Analyst")st.markdown("# Digital Marketing Audit")st.markdown(f"for: **{client_name} ({client_website})**")st.write("")st.write("")st.markdown("#### Table of Contents")st.markdown("""<ul><li><a href='#digital-footprint-overview'>Digital Footprint Overview</a></li><li><a href='#executive-summary'>Executive Summary</a></li><li><a href='#client-footprint'>Client Footprint</a></li><li><a href='#snapshot-by-channel'>Snapshot by Channel</a></li><li><a href='#website-and-tools'>Website and Tools</a></li><li><a href='#search-engine-marketing'>Search Engine Marketing</a></li><li><a href='#search-engine-optimization'>Search Engine Optimization</a></li><li><a href='#social-media'>Social Media</a></li><li><a href='#content'>Content</a></li><li><a href='#market-place'>Market Place</a></li><li><a href='#target-market'>Target Market</a></li><li><a href='#desired-outcomes'>Desired Outcomes</a></li></ul>""", unsafe_allow_html=True)st.markdown("---")st.write("")st.write("")st.markdown("### DIGITAL FOOTPRINT OVERVIEW")18 unmodified linesst.markdown("---")st.markdown("### SNAPSHOT BY CHANNEL")st.write(write_snapshot(get_analyst_response("Snapshot Analyst"))) #write_snapshotst.markdown("---")st.markdown("## AUDITS PER CHANNEL")91 unmodified linesst.write(target_market_data['summary'])st.markdown("##### WHAT IS THE DESIRED OUTCOMES OF DIGITAL MARKETING?")st.markdown(get_analyst_response("Desired Outcomes Analyst"))st.markdown("##### WHAT IS THE PULL-THROUGH OFFER?")pull_through_data = get_analyst_response("Pull through offers Analyst")
pages/output.py+85-3