desired outcome output

#11
by notjulietxd - opened
Files changed (1) hide show
  1. pages/output.py +85 -3
pages/output.py CHANGED
@@ -39,7 +39,66 @@ def write_client_footprint():
39
 
40
  return markdown_table
41
 
42
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  def write_table(website_and_tools_data):
44
 
45
  if website_and_tools_data:
@@ -62,6 +121,7 @@ def write_table(website_and_tools_data):
62
  # Add a row to the Markdown table string
63
  # Replace underscores with spaces and apply title case to category
64
  category_formatted = category.replace('_', ' ').title()
 
65
  current_footprint_formatted = current_footprint.replace('_', ' ')
66
  best_of_breed_formatted = best_of_breed.replace('_', ' ')
67
 
@@ -149,11 +209,33 @@ def seo_on_page_table(df_data):
149
  def display_outputs():
150
  client_name = data_field("Client Name")
151
  client_website = data_field("Client Website")
 
 
 
152
  overview = get_analyst_response("DF Overview Analyst")
153
 
154
  st.markdown("# Digital Marketing Audit")
155
  st.markdown(f"for: **{client_name} ({client_website})**")
156
  st.write("")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  st.write("")
158
  st.write("")
159
  st.markdown("### DIGITAL FOOTPRINT OVERVIEW")
@@ -178,7 +260,7 @@ def display_outputs():
178
  st.markdown("---")
179
 
180
  st.markdown("### SNAPSHOT BY CHANNEL")
181
- st.table(get_analyst_response("Snapshot Analyst"))
182
  st.markdown("---")
183
 
184
  st.markdown("## AUDITS PER CHANNEL")
@@ -276,7 +358,7 @@ Regardless, it is still a great channel worth investing to improve a business’
276
  st.write(target_market_data['summary'])
277
 
278
  st.markdown("##### WHAT IS THE DESIRED OUTCOMES OF DIGITAL MARKETING?")
279
- st.write("TBD")
280
 
281
  st.markdown("##### WHAT IS THE PULL-THROUGH OFFER?")
282
  pull_through_data = get_analyst_response("Pull through offers Analyst")
 
39
 
40
  return markdown_table
41
 
42
+ def write_snapshot(data):
43
+
44
+ if data:
45
+ try:
46
+
47
+ parsed_data = data
48
+
49
+ if isinstance(parsed_data, list):
50
+ # Create Markdown table header
51
+ markdown_table = "| Channel | Status | Requirements | What's Needed to Deliver |\n"
52
+ markdown_table += "|---|---|---|---|\n"
53
+
54
+ # Loop through the list of dictionaries
55
+ for item in parsed_data:
56
+ # Use .get() for safety in case keys are missing
57
+ channel = item.get('channel', 'N/A')
58
+ status = item.get('status', 'N/A')
59
+ requirements = item.get('requirements', 'N/A')
60
+ deliver = item.get('deliver', 'N/A')
61
+
62
+ # Add a row to the Markdown table string
63
+ # Replace underscores with spaces and apply title case to category
64
+ # Replace underscores with spaces first
65
+ channel_temp = channel.replace('_', ' ')
66
+
67
+ # Apply title case if there are multiple words, otherwise uppercase
68
+ if ' ' in channel_temp: # Check for spaces directly
69
+ channel_formatted = channel_temp.title()
70
+ else:
71
+ channel_formatted = channel_temp.upper() # Use upper() instead of upper_case()
72
+
73
+
74
+ markdown_table += f"| {channel_formatted} | {status} | {requirements} | {deliver} |\n"
75
+
76
+
77
+ # Display the complete Markdown table
78
+ st.markdown(markdown_table)
79
+
80
+ # Handle case if data is not a list (e.g., a single dictionary)
81
+ elif isinstance(parsed_data, dict):
82
+ st.write("Analysis Result (Summary):")
83
+ # You might want to display dictionary data differently
84
+ st.json(parsed_data) # Example: Display as JSON
85
+ else:
86
+ st.warning("data is not in the expected list format.")
87
+ st.write(parsed_data) # Show the raw data
88
+
89
+ except json.JSONDecodeError:
90
+ st.error("Error: Could not parse the data as JSON.")
91
+ st.text(data) # Show the raw string data
92
+ except AttributeError:
93
+ st.error("Error: Could not find expected keys ('channel', 'status', 'requirements', 'deliver') in the data.")
94
+ st.write(parsed_data) # Show the data that caused the error
95
+ except Exception as e:
96
+ st.error(f"An unexpected error occurred while processing data: {e}")
97
+ st.write(data) # Show the raw data
98
+ else:
99
+ st.warning("No data retrieved for analysis.")
100
+ # --- End: Loop and display data ---
101
+
102
  def write_table(website_and_tools_data):
103
 
104
  if website_and_tools_data:
 
121
  # Add a row to the Markdown table string
122
  # Replace underscores with spaces and apply title case to category
123
  category_formatted = category.replace('_', ' ').title()
124
+
125
  current_footprint_formatted = current_footprint.replace('_', ' ')
126
  best_of_breed_formatted = best_of_breed.replace('_', ' ')
127
 
 
209
  def display_outputs():
210
  client_name = data_field("Client Name")
211
  client_website = data_field("Client Website")
212
+
213
+
214
+
215
  overview = get_analyst_response("DF Overview Analyst")
216
 
217
  st.markdown("# Digital Marketing Audit")
218
  st.markdown(f"for: **{client_name} ({client_website})**")
219
  st.write("")
220
+ st.write("")
221
+
222
+ st.markdown("#### Table of Contents")
223
+ st.markdown("""<ul><li><a href='#digital-footprint-overview'>Digital Footprint Overview</a></li>
224
+ <li><a href='#executive-summary'>Executive Summary</a></li>
225
+ <li><a href='#client-footprint'>Client Footprint</a></li>
226
+ <li><a href='#snapshot-by-channel'>Snapshot by Channel</a></li>
227
+ <li><a href='#website-and-tools'>Website and Tools</a></li>
228
+ <li><a href='#search-engine-marketing'>Search Engine Marketing</a></li>
229
+ <li><a href='#search-engine-optimization'>Search Engine Optimization</a></li>
230
+ <li><a href='#social-media'>Social Media</a></li>
231
+ <li><a href='#content'>Content</a></li>
232
+ <li><a href='#market-place'>Market Place</a></li>
233
+ <li><a href='#target-market'>Target Market</a></li>
234
+ <li><a href='#desired-outcomes'>Desired Outcomes</a></li>
235
+ </ul>""", unsafe_allow_html=True)
236
+
237
+ st.markdown("---")
238
+
239
  st.write("")
240
  st.write("")
241
  st.markdown("### DIGITAL FOOTPRINT OVERVIEW")
 
260
  st.markdown("---")
261
 
262
  st.markdown("### SNAPSHOT BY CHANNEL")
263
+ st.write(write_snapshot(get_analyst_response("Snapshot Analyst"))) #write_snapshot
264
  st.markdown("---")
265
 
266
  st.markdown("## AUDITS PER CHANNEL")
 
358
  st.write(target_market_data['summary'])
359
 
360
  st.markdown("##### WHAT IS THE DESIRED OUTCOMES OF DIGITAL MARKETING?")
361
+ st.markdown(get_analyst_response("Desired Outcomes Analyst"))
362
 
363
  st.markdown("##### WHAT IS THE PULL-THROUGH OFFER?")
364
  pull_through_data = get_analyst_response("Pull through offers Analyst")