.streamlit/config.toml CHANGED
@@ -1,11 +1,3 @@
1
  [client]
2
  showSidebarNavigation = false
3
 
4
- [runner]
5
- fastReruns = true
6
-
7
- [browser]
8
- gatherUsageStats = false
9
-
10
- [global]
11
- disableWidgetStateDuplicationWarning = true
 
1
  [client]
2
  showSidebarNavigation = false
3
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -1,25 +1,92 @@
1
  import streamlit as st
2
- import os
3
- from dotenv import load_dotenv
4
 
5
- # Create an empty container
6
- placeholder = st.empty()
7
- load_dotenv()
8
 
9
- actual_email = os.getenv('email')
10
- actual_password = os.getenv('password')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- # Insert a form in the container
13
- with placeholder.form("login"):
14
- st.markdown("#### Digital Footprint AI Team")
15
- email = st.text_input("Email")
16
- password = st.text_input("Password", type="password")
17
- submit = st.form_submit_button("Login")
 
18
 
19
- if submit and email == actual_email and password == actual_password:
20
- st.switch_page("pages/home.py")
21
- st.success("Login successful")
22
- elif submit and email != actual_email and password != actual_password:
23
- st.error("Login failed")
24
- else:
25
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
 
2
 
3
+ # Create a dashboard that will display various agents on the page
4
+ st.set_page_config(layout="wide")
5
+ st.header("Digital Footprint AI Team", divider="gray")
6
 
7
+ Analysts = {
8
+ "Analyst 1": "SEO Off Page Optimization Analyst",
9
+ "Analyst 2": "SEO On Page Optimization Analyst",
10
+ "Analyst 3": "SEO Analyst",
11
+ "Analyst 4": "Social Media Analyst",
12
+ "Analyst 5": "Lead List Analyst",
13
+ "Analyst 6": "Target Market Analyst",
14
+ "Analyst 7": "SEO On Page Optimization Analyst",
15
+ "Analyst 8": "SEO On Page Optimization Analyst",
16
+ }
17
+ Data_Source = {
18
+ "Analyst_Src 1": "Data Sources - SEMRush",
19
+ "Analyst_Src 2": "Data Source - Screaming Frog",
20
+ "Analyst_Src 3": "Data Sources - SEMRush",
21
+ "Analyst_Src 4": "Data Source -",
22
+ "Analyst_Src 5": "Data Source -",
23
+ "Analyst_Src 6": "Data Source -",
24
+ "Analyst_Src 7": "SEO On Page Optimization Analyst",
25
+ "Analyst_Src 8": "SEO On Page Optimization Analyst",
26
+ }
27
+ Analysts_Description = {
28
+ "Analyst_Desc 1": "Upload Backlink List (PDF)",
29
+ "Analyst_Desc 2": "Upload Files - Crawl (CSV)",
30
+ "Analyst_Desc 3": "Upload Backlinks List (PDF)",
31
+ "Analyst_Desc 4": "Ex. SEO Keywords, Traffic Channels, Backlinks (CSV) ",
32
+ "Analyst_Desc 5": "",
33
+ "Analyst_Desc 6": "",
34
+ "Analyst_Desc 7": "Ex. SEO Keywords, Traffic Channels, Backlinks (CSV) ",
35
+ "Analyst_Desc 8": "Ex. SEO Keywords, Traffic Channels, Backlinks (CSV) ",
36
+ }
37
 
38
+ def row1():
39
+ col1, col2, col3, col4 = st.columns(4, border=True, gap="medium", vertical_alignment="top")
40
+ with col1:
41
+ st.subheader(f"{Analysts['Analyst 1']}")
42
+ st.write("PDF")
43
+ if st.button("Load Analyst", key=1):
44
+ st.switch_page("pages/agent_1.py")
45
 
46
+ with col2:
47
+ st.subheader(f"{Analysts['Analyst 2']}")
48
+ st.write("CSV")
49
+ if st.button("Load Analyst", key=2):
50
+ st.switch_page("pages/agent_2.py")
51
+
52
+ with col3:
53
+ st.subheader(f"{Analysts['Analyst 3']}")
54
+ st.write("CSV")
55
+ if st.button("Load Analyst", key=3):
56
+ st.switch_page("pages/agent_3.py")
57
+
58
+ with col4:
59
+ st.subheader(f"{Analysts['Analyst 4']}")
60
+ st.write("CSV")
61
+ if st.button("Load Analyst", key=4):
62
+ st.switch_page("pages/agent_4.py")
63
+ return col1, col2, col3, col4
64
+ row1()
65
+
66
+ def row2():
67
+ col1, col2, col3, col4 = st.columns(4, border=True, gap="medium")
68
+ with col1:
69
+ st.header("Lead List Analyst")
70
+ st.write("")
71
+ if st.button("Load Analyst", key=5, disabled=True):
72
+ st.switch_page("pages/agent_5.py")
73
+
74
+ with col2:
75
+ st.header("Target Market Analyst")
76
+ st.write("")
77
+ if st.button("Load Analyst", key=6, disabled=True):
78
+ st.switch_page("pages/agent_6.py")
79
+
80
+ with col3:
81
+ st.header("Analyst 7")
82
+ st.write("")
83
+ if st.button("Load Analyst", key=7, disabled=True):
84
+ st.switch_page("pages/image.py")
85
+
86
+ with col4:
87
+ st.header("Analyst 8")
88
+ st.write("")
89
+ if st.button("Load Analyst", key=8, disabled=True):
90
+ st.switch_page("pages/EDA.py")
91
+ return col1, col2, col3, col4
92
+ row2()
classes/Lead_List.py CHANGED
@@ -32,7 +32,7 @@ class LeadListAnalyst:
32
  # RETURN BUTTON
33
  try:
34
  if st.button("Return", type='primary'):
35
- st.switch_page("./pages/home.py")
36
  except Exception:
37
  pass
38
 
 
32
  # RETURN BUTTON
33
  try:
34
  if st.button("Return", type='primary'):
35
+ st.switch_page("./app.py")
36
  except Exception:
37
  pass
38
 
classes/Seo.py CHANGED
@@ -3,7 +3,6 @@ import requests
3
  from dotenv import load_dotenv
4
  import os
5
  import pandas as pd
6
- import pandas._libs.tslibs.parsing
7
  import time
8
  import chardet
9
  from helper.telemetry import collect_telemetry
@@ -37,7 +36,7 @@ class SeoAnalyst:
37
  # RETURN BUTTON
38
  try:
39
  if st.button("Return", type='primary'):
40
- st.switch_page("./pages/home.py")
41
  except Exception:
42
  pass
43
 
@@ -100,11 +99,9 @@ class SeoAnalyst:
100
 
101
  def traffic_files(self, df_traffic):
102
  traffic_channels = df_traffic
103
- try:
104
- traffic_channels.rename(columns={traffic_channels.columns[0]: 'date'}, inplace=True)
105
- traffic_channels['date'] = pd.to_datetime(traffic_channels['date'], format='mixed')
106
- except pandas._libs.tslibs.parsing.DateParseError:
107
- pass
108
  traffic_channels_sort = traffic_channels.sort_values("date", ascending=False)
109
 
110
  organic_traffic = traffic_channels_sort['Organic Search'].values[0]
@@ -174,7 +171,7 @@ class SeoAnalyst:
174
  self.file_dict = upload.file_dict
175
 
176
  st.write("") # FOR THE HIDE BUTTON
177
- self.uploaded_file_seo = st.file_uploader("Upload SEO Keywords CSV (SEMRush)", type='csv')
178
  if self.uploaded_file_seo:
179
  self.delete_sessions()
180
  try:
@@ -213,7 +210,7 @@ class SeoAnalyst:
213
  start_time = time.time()
214
  if analyze_button:
215
  hide_button()
216
- if self.uploaded_files or self.uploaded_file_seo:
217
  combined_text = ""
218
  with st.spinner('Analyzing...', show_time=True):
219
  st.write('')
 
3
  from dotenv import load_dotenv
4
  import os
5
  import pandas as pd
 
6
  import time
7
  import chardet
8
  from helper.telemetry import collect_telemetry
 
36
  # RETURN BUTTON
37
  try:
38
  if st.button("Return", type='primary'):
39
+ st.switch_page("./app.py")
40
  except Exception:
41
  pass
42
 
 
99
 
100
  def traffic_files(self, df_traffic):
101
  traffic_channels = df_traffic
102
+ traffic_channels.rename(columns={traffic_channels.columns[0]: 'date'}, inplace=True)
103
+ traffic_channels['date'] = pd.to_datetime(traffic_channels['date'], format='mixed')
104
+
 
 
105
  traffic_channels_sort = traffic_channels.sort_values("date", ascending=False)
106
 
107
  organic_traffic = traffic_channels_sort['Organic Search'].values[0]
 
171
  self.file_dict = upload.file_dict
172
 
173
  st.write("") # FOR THE HIDE BUTTON
174
+ self.uploaded_file_seo = st.file_uploader("Upload SEO Keywords CSV (SEMRush)", type='csv', key=3)
175
  if self.uploaded_file_seo:
176
  self.delete_sessions()
177
  try:
 
210
  start_time = time.time()
211
  if analyze_button:
212
  hide_button()
213
+ if self.uploaded_files or self.uploaded_file or self.uploaded_file_seo:
214
  combined_text = ""
215
  with st.spinner('Analyzing...', show_time=True):
216
  st.write('')
classes/Seo_Off_Page.py CHANGED
@@ -1,5 +1,3 @@
1
- from io import StringIO
2
- from urllib.parse import urlparse
3
  import streamlit as st
4
  import requests
5
  from dotenv import load_dotenv
@@ -36,7 +34,7 @@ class SeoOffPageAnalyst:
36
  # RETURN BUTTON
37
  try:
38
  if st.button("Return", type='primary'):
39
- st.switch_page("./pages/home.py")
40
  except Exception:
41
  pass
42
 
@@ -104,19 +102,8 @@ class SeoOffPageAnalyst:
104
  for file_info in st.session_state['uploaded_files'].values():
105
  if file_info['type'] == 'pdf':
106
  combined_text += file_info['content'] + "\n"
107
- elif file_info['type'] == 'csv':
108
- # Load CSV
109
- df = pd.read_csv(StringIO(file_info['content'].to_csv(index=True)))
110
-
111
- # Count total rows
112
- num_rows = len(df)
113
-
114
- # Extract unique domains from 'Source url'
115
- df['Source Domain'] = df['Source url'].apply(lambda x: urlparse(x).netloc)
116
- unique_domains = df['Source Domain'].nunique()
117
-
118
- combined_text += f"Total Backlinks Count: {num_rows}\n"
119
- combined_text += f"Referring Domain: {unique_domains}"
120
 
121
  # OUTPUT FOR SEO ANALYST
122
  payload_txt = {"question": combined_text}
 
 
 
1
  import streamlit as st
2
  import requests
3
  from dotenv import load_dotenv
 
34
  # RETURN BUTTON
35
  try:
36
  if st.button("Return", type='primary'):
37
+ st.switch_page("./app.py")
38
  except Exception:
39
  pass
40
 
 
102
  for file_info in st.session_state['uploaded_files'].values():
103
  if file_info['type'] == 'pdf':
104
  combined_text += file_info['content'] + "\n"
105
+ elif file_info['type'] == 'csv':
106
+ combined_text += file_info['content'].to_csv(index=True) + "\n"
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  # OUTPUT FOR SEO ANALYST
109
  payload_txt = {"question": combined_text}
classes/Seo_On_Page.py CHANGED
@@ -36,7 +36,7 @@ class SeoOnPageAnalyst:
36
  # RETURN BUTTON
37
  try:
38
  if st.button("Return", type='primary'):
39
- st.switch_page("./pages/home.py")
40
  except Exception:
41
  pass
42
 
@@ -105,10 +105,7 @@ class SeoOnPageAnalyst:
105
  if file_info['type'] == 'pdf':
106
  combined_text += file_info['content'] + "\n"
107
  elif file_info['type'] == 'csv':
108
- try:
109
- combined_text += "CrawlFile CSV: {"+ file_info['content'].to_csv(index=True) + "\n"
110
- except AttributeError:
111
- pass
112
  except KeyError:
113
  pass
114
  try:
@@ -124,11 +121,11 @@ class SeoOnPageAnalyst:
124
  result = self.request_model(payload_txt)
125
  end_time = time.time()
126
  time_lapsed = end_time - start_time
 
127
  debug_info = {'analyst': self.analyst_name,
128
  'url_uuid': self.model_url.split("-")[-1],
129
  'time_lapsed' : time_lapsed,
130
- 'crawl_file': [file.name for file in self.uploaded_files] if self.uploaded_files else ['Not available'],
131
- 'gt_metrix': [file.name for file in self.gtmetrix] if self.gtmetrix else ['Not available'],
132
  'payload': payload_txt,
133
  'result': result}
134
 
 
36
  # RETURN BUTTON
37
  try:
38
  if st.button("Return", type='primary'):
39
+ st.switch_page("./app.py")
40
  except Exception:
41
  pass
42
 
 
105
  if file_info['type'] == 'pdf':
106
  combined_text += file_info['content'] + "\n"
107
  elif file_info['type'] == 'csv':
108
+ combined_text += "CrawlFile CSV: {"+ file_info['content'].to_csv(index=True) + "\n"
 
 
 
109
  except KeyError:
110
  pass
111
  try:
 
121
  result = self.request_model(payload_txt)
122
  end_time = time.time()
123
  time_lapsed = end_time - start_time
124
+
125
  debug_info = {'analyst': self.analyst_name,
126
  'url_uuid': self.model_url.split("-")[-1],
127
  'time_lapsed' : time_lapsed,
128
+
 
129
  'payload': payload_txt,
130
  'result': result}
131
 
classes/Social_Media.py CHANGED
@@ -12,6 +12,7 @@ from helper.initialize_analyze_session import initialize_analyze_session
12
 
13
  class SocialMediaAnalyst:
14
  def __init__(self, model_url, analyst_name, data_src, analyst_description):
 
15
  self.file_dict = {}
16
  self.model_url = model_url
17
  self.analyst_name = analyst_name
@@ -34,7 +35,7 @@ class SocialMediaAnalyst:
34
  # RETURN BUTTON
35
  try:
36
  if st.button("Return", type='primary'):
37
- st.switch_page("./pages/home.py")
38
  except Exception:
39
  pass
40
 
@@ -79,12 +80,7 @@ class SocialMediaAnalyst:
79
  uploaded_file.seek(0) # Reset file pointer to the beginning
80
  return result['encoding']
81
 
82
- def facebook_ad_campaign(self, facebook_ad_campaign):
83
- facebook_ads = facebook_ad_campaign[~facebook_ad_campaign['Ad name'].isna()].shape[0]
84
- st.session_state['facebook_ads'] = facebook_ads
85
- return facebook_ads
86
-
87
- def facebook_organic(self, facebook_organic_post):
88
  try:
89
  facebook_engagement_rate = (facebook_organic_post['Reactions, Comments and Shares'].mean() / self.facebooks).round(2)
90
  st.session_state['facebook_engagement_rate'] = facebook_engagement_rate
@@ -92,16 +88,21 @@ class SocialMediaAnalyst:
92
  pass
93
  # Post Frequency
94
  facebook_post_frequency = facebook_organic_post[~facebook_organic_post['Post ID'].isna()].shape[0]
95
- st.session_state['facebook_post_frequency'] = facebook_post_frequency
 
 
 
96
  st.session_state['facebook_review_rate'] = self.facebook_rr
 
 
97
  st.session_state['facebook_followers'] = self.facebooks
98
-
99
  try:
100
- return facebook_post_frequency, facebook_engagement_rate
101
  except UnboundLocalError:
102
- return facebook_post_frequency
103
-
104
- def linkedin_content_metrics(self, linkedin_content_metrics):
105
  # Avg. engagement rate
106
  try:
107
  linkedin_engagement_rate = linkedin_content_metrics['Engagement rate (organic)'].mean().round(2)
@@ -112,12 +113,6 @@ class SocialMediaAnalyst:
112
  linkedin_content_metrics['Engagement rate (organic)'] = pd.to_numeric(linkedin_content_metrics['Engagement rate (organic)'], errors='coerce')
113
  linkedin_engagement_rate = linkedin_content_metrics['Engagement rate (organic)'].mean().round(2)
114
  # Post Frequency
115
-
116
- st.session_state['linkedin_engagement_rate'] = linkedin_engagement_rate
117
-
118
- return linkedin_engagement_rate
119
-
120
- def linkedin_content_post(self, linkedin_content_post):
121
  try:
122
  linkedin_post_frequency = linkedin_content_post[~linkedin_content_post['Post title'].isna()].shape[0]
123
  except Exception:
@@ -128,8 +123,10 @@ class SocialMediaAnalyst:
128
  st.write(linkedin_content_post)
129
 
130
  st.session_state['linkedin_post_frequency'] = linkedin_post_frequency
131
- return linkedin_post_frequency
132
-
 
 
133
  def terminate_session(self, session):
134
  try:
135
  del st.session_state[session]
@@ -196,7 +193,8 @@ class SocialMediaAnalyst:
196
  linkedin_metrics
197
  linkedin_post
198
  tiktok_post
199
-
 
200
  with col2:
201
  st.write("") # FOR THE HIDE BUTTON
202
  st.write("") # FOR THE HIDE BUTTON
@@ -212,79 +210,66 @@ class SocialMediaAnalyst:
212
  combined_text = ""
213
  with st.spinner('Analyzing...', show_time=True):
214
  st.write('')
 
 
 
 
 
 
 
 
215
  # INITIALIZING SESSIONS
216
- try: # FACEBOOK
217
- try: # ORGANIC POST
218
- combined_text += f"\nFacebook Followers: {self.facebooks}"
219
- facebook_organic_post = st.session_state['facebook_organic_post']
220
- self.facebook_organic(facebook_organic_post)
221
- facebook_post_frequency = st.session_state['facebook_post_frequency']
222
- combined_text += f"\nFacebook Post Frequency: {facebook_post_frequency}"
223
- try: # ENGAGEMENT RATE TRY CATCH
224
- facebook_engagement_rate = st.session_state['facebook_engagement_rate']
225
- combined_text += f"\nFacebook Audience Engagement Rate: {facebook_engagement_rate}%"
226
- except KeyError:
227
- pass
228
-
229
- except KeyError:
230
- pass
231
- try: # AD CAMPAIGN
232
- combined_text += f"\nFacebook Review Rate: {self.facebook_rr}"
233
- facebook_ad_campaign = st.session_state['facebook_ad_campaign']
234
- self.facebook_ad_campaign(facebook_ad_campaign)
235
- facebook_ads = st.session_state['facebook_ads']
236
- combined_text += f"\nFacebook Ads: {facebook_ads}"
237
  except KeyError:
238
  pass
239
- try: # FACEBOOK ORGANIC POST CSV
240
- combined_text += f"\nFacebook Organic Post CSV: {facebook_organic_post.to_csv(index=True)}"
241
- except UnboundLocalError:
242
- pass
243
- try: # FACEBOOK ADS CAMPAIGN CSV
244
- combined_text += f"\nFacebook Ads Campaign CSV: {facebook_ad_campaign.to_csv(index=True)}"
245
- except UnboundLocalError:
246
- pass
 
247
  except KeyError:
248
  pass
 
 
 
 
 
 
249
 
250
- try: # LINKEDIN
251
- try: # LINKEDIN CONTENT POST
252
- combined_text += f"\nLinkedin Followers: {self.linkedin_f}"
253
- linkedin_content_post = st.session_state['linkedin_content_post']
254
- self.linkedin_content_post(linkedin_content_post)
255
- linkedin_post_frequency = st.session_state['linkedin_post_frequency']
256
- combined_text += f"\nLinkedin Post Frequency: {linkedin_post_frequency}"
257
- except KeyError:
258
- pass
259
- try: # LINKEDIN CONTENT METRICS
260
- linkedin_content_metrics = st.session_state['linkedin_content_metrics']
261
- self.linkedin_content_metrics(linkedin_content_metrics)
262
- linkedin_engagement_rate = st.session_state['linkedin_engagement_rate']
263
- combined_text += f"\nLinkedin Engagement Rate: {linkedin_engagement_rate}%"
264
- except KeyError:
265
- pass
266
- try: # LINKEDIN CONTENT METRICS CSV
267
- combined_text += f"\nLinkedin Content Metrics: {linkedin_content_metrics.to_csv(index=True)}"
268
- except UnboundLocalError:
269
- pass
270
- try: # LINKEDIN CONTENT POST CSV
271
- combined_text += f"\nLinkedin Content Post: {linkedin_content_post.to_csv(index=True)}"
272
- except UnboundLocalError:
273
- pass
274
  except KeyError:
275
  pass
276
-
277
  try:
278
- combined_text += f"\nInstagram Followers: {self.instagram}"
279
- combined_text += f"\nInstagram Audience Engagement Rate: {self.instagram_er}%"
280
- combined_text += f"\nInstagram Post Frequency: {self.instagram_pf}"
281
  except KeyError:
282
  pass
283
 
284
  try:
285
- combined_text += f"\nTwitter Followers: {self.twitter}"
286
- combined_text += f"\nTwitter Audience Engagement Rate: {self.twitter_er}%"
287
- combined_text += f"\nTwitter Post Frequency: {self.twitter_pf}"
288
  except KeyError:
289
  pass
290
 
@@ -315,6 +300,7 @@ class SocialMediaAnalyst:
315
  'analyst': self.analyst_name,
316
  'url_uuid': self.model_url.split("-")[-1],
317
  'time_lapsed': time_lapsed,
 
318
  'facebook_organic_post': [fb_organic_post.name] if fb_organic_post else ['Not available'],
319
  'fb_ads_campaign': [fb_ads_campaign.name] if fb_ads_campaign else ['Not available'],
320
  'linkedin_content_metrics': [linkedin_metrics.name] if linkedin_metrics else ['Not available'],
 
12
 
13
  class SocialMediaAnalyst:
14
  def __init__(self, model_url, analyst_name, data_src, analyst_description):
15
+ self.uploaded_files = []
16
  self.file_dict = {}
17
  self.model_url = model_url
18
  self.analyst_name = analyst_name
 
35
  # RETURN BUTTON
36
  try:
37
  if st.button("Return", type='primary'):
38
+ st.switch_page("./app.py")
39
  except Exception:
40
  pass
41
 
 
80
  uploaded_file.seek(0) # Reset file pointer to the beginning
81
  return result['encoding']
82
 
83
+ def facebook(self, facebook_organic_post, facebook_ad_campaign):
 
 
 
 
 
84
  try:
85
  facebook_engagement_rate = (facebook_organic_post['Reactions, Comments and Shares'].mean() / self.facebooks).round(2)
86
  st.session_state['facebook_engagement_rate'] = facebook_engagement_rate
 
88
  pass
89
  # Post Frequency
90
  facebook_post_frequency = facebook_organic_post[~facebook_organic_post['Post ID'].isna()].shape[0]
91
+
92
+ # Ads
93
+ facebook_ads = facebook_ad_campaign[~facebook_ad_campaign['Ad name'].isna()].shape[0]
94
+
95
  st.session_state['facebook_review_rate'] = self.facebook_rr
96
+ st.session_state['facebook_ads'] = facebook_ads
97
+ st.session_state['facebook_post_frequency'] = facebook_post_frequency
98
  st.session_state['facebook_followers'] = self.facebooks
99
+
100
  try:
101
+ return facebook_engagement_rate, facebook_ads, facebook_post_frequency
102
  except UnboundLocalError:
103
+ return facebook_ads, facebook_post_frequency
104
+
105
+ def linkedin(self, linkedin_content_metrics, linkedin_content_post):
106
  # Avg. engagement rate
107
  try:
108
  linkedin_engagement_rate = linkedin_content_metrics['Engagement rate (organic)'].mean().round(2)
 
113
  linkedin_content_metrics['Engagement rate (organic)'] = pd.to_numeric(linkedin_content_metrics['Engagement rate (organic)'], errors='coerce')
114
  linkedin_engagement_rate = linkedin_content_metrics['Engagement rate (organic)'].mean().round(2)
115
  # Post Frequency
 
 
 
 
 
 
116
  try:
117
  linkedin_post_frequency = linkedin_content_post[~linkedin_content_post['Post title'].isna()].shape[0]
118
  except Exception:
 
123
  st.write(linkedin_content_post)
124
 
125
  st.session_state['linkedin_post_frequency'] = linkedin_post_frequency
126
+ st.session_state['linkedin_engagement_rate'] = linkedin_engagement_rate
127
+
128
+ return linkedin_post_frequency, linkedin_engagement_rate
129
+
130
  def terminate_session(self, session):
131
  try:
132
  del st.session_state[session]
 
193
  linkedin_metrics
194
  linkedin_post
195
  tiktok_post
196
+
197
+
198
  with col2:
199
  st.write("") # FOR THE HIDE BUTTON
200
  st.write("") # FOR THE HIDE BUTTON
 
210
  combined_text = ""
211
  with st.spinner('Analyzing...', show_time=True):
212
  st.write('')
213
+ try:
214
+ for file_info in st.session_state['uploaded_files'].values():
215
+ if file_info['type'] == 'pdf':
216
+ combined_text += file_info['content'] + "\n"
217
+ elif file_info['type'] == 'csv':
218
+ combined_text += file_info['content'].to_csv(index=True) + "\n"
219
+ except KeyError:
220
+ pass
221
  # INITIALIZING SESSIONS
222
+ try:
223
+ facebook_organic_post = st.session_state['facebook_organic_post']
224
+ facebook_ad_campaign = st.session_state['facebook_ad_campaign']
225
+
226
+ self.facebook(facebook_organic_post, facebook_ad_campaign)
227
+ try:
228
+ facebook_engagement_rate = st.session_state['facebook_engagement_rate']
229
+ combined_text += f"\nFacebook Audience Engagement Rate: {facebook_engagement_rate}%"
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  except KeyError:
231
  pass
232
+ facebook_ads = st.session_state['facebook_ads']
233
+ facebook_post_frequency = st.session_state['facebook_post_frequency']
234
+ combined_text += f"\nFacebook Followers: {self.facebooks}"
235
+ combined_text += f"\nFacebook Review Rate: {self.facebook_rr}"
236
+ combined_text += f"\nFacebook Ads: {facebook_ads}"
237
+ combined_text += f"\nFacebook Post Frequency: {facebook_post_frequency}"
238
+
239
+ combined_text += facebook_organic_post.to_csv(index=True)
240
+ combined_text += facebook_ad_campaign.to_csv(index=True)
241
  except KeyError:
242
  pass
243
+
244
+ try:
245
+ linkedin_content_metrics = st.session_state['linkedin_content_metrics']
246
+ linkedin_content_post = st.session_state['linkedin_content_post']
247
+
248
+ self.linkedin(linkedin_content_metrics, linkedin_content_post)
249
 
250
+ linkedin_post_frequency = st.session_state['linkedin_post_frequency']
251
+ linkedin_engagement_rate = st.session_state['linkedin_engagement_rate']
252
+
253
+ combined_text += f"\nLinkedin Followers: {self.linkedin_f}"
254
+ combined_text += f"\nLinkedin Post Frequency: {linkedin_post_frequency}"
255
+ combined_text += f"\nLinkedin Engagement Rate: {linkedin_engagement_rate}%"
256
+
257
+ combined_text += linkedin_content_metrics.to_csv(index=True)
258
+ combined_text += linkedin_content_post.to_csv(index=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  except KeyError:
260
  pass
261
+
262
  try:
263
+ combined_text += f"\Instagram Followers: {self.instagram}"
264
+ combined_text += f"\Instagram Audience Engagement Rate: {self.instagram_er}%"
265
+ combined_text += f"\Instagram Post Frequency: {self.instagram_pf}"
266
  except KeyError:
267
  pass
268
 
269
  try:
270
+ combined_text += f"\Twitter Followers: {self.twitter}"
271
+ combined_text += f"\Twitter Audience Engagement Rate: {self.twitter_er}%"
272
+ combined_text += f"\Twitter Post Frequency: {self.twitter_pf}"
273
  except KeyError:
274
  pass
275
 
 
300
  'analyst': self.analyst_name,
301
  'url_uuid': self.model_url.split("-")[-1],
302
  'time_lapsed': time_lapsed,
303
+ #'backlink_files': [*st.session_state['uploaded_files']],
304
  'facebook_organic_post': [fb_organic_post.name] if fb_organic_post else ['Not available'],
305
  'fb_ads_campaign': [fb_ads_campaign.name] if fb_ads_campaign else ['Not available'],
306
  'linkedin_content_metrics': [linkedin_metrics.name] if linkedin_metrics else ['Not available'],
classes/Target_Market.py CHANGED
@@ -32,7 +32,7 @@ class TargetMarketAnalyst:
32
  # RETURN BUTTON
33
  try:
34
  if st.button("Return", type='primary'):
35
- st.switch_page("./pages/home.py")
36
  except Exception:
37
  pass
38
 
 
32
  # RETURN BUTTON
33
  try:
34
  if st.button("Return", type='primary'):
35
+ st.switch_page("./app.py")
36
  except Exception:
37
  pass
38
 
classes/test.py DELETED
@@ -1,219 +0,0 @@
1
- import streamlit as st
2
- import requests
3
- from dotenv import load_dotenv
4
- import os
5
- import pandas as pd
6
- import time
7
- import chardet
8
- from helper.telemetry import collect_telemetry
9
- from helper.upload_File import uploadFile
10
- from helper.button_behaviour import hide_button
11
- from helper.initialize_analyze_session import initialize_analyze_session
12
-
13
- class test:
14
- def __init__(self, model_url, analyst_name, data_src, analyst_description):
15
- self.uploaded_files = []
16
- self.file_dict = {}
17
- self.model_url = model_url
18
- self.analyst_name = analyst_name
19
- self.data_src = data_src
20
- self.analyst_description = analyst_description
21
- self.initialize()
22
- self.row1()
23
-
24
- def initialize(self):
25
- # FOR ENV
26
- load_dotenv()
27
-
28
- # AGENT NAME
29
- st.header(self.analyst_name)
30
-
31
- # EVALUATION FORM LINK
32
- url = os.getenv('Link')
33
- st.write('Evaluation Form: [Link](%s)' % url)
34
-
35
- # RETURN BUTTON
36
- try:
37
- if st.button("Return", type='primary'):
38
- st.switch_page("./pages/home.py")
39
- except Exception:
40
- pass
41
-
42
- def request_model(self, payload_txt):
43
- response = requests.post(self.model_url, json=payload_txt)
44
- response.raise_for_status()
45
- output = response.json()
46
-
47
- categories = []
48
- current_footprint = []
49
- number_of_backlinks = []
50
-
51
- for key, value in output.items():
52
- if key == 'json':
53
- for item in value:
54
- categories.append(item.get('category', 'N/A').replace('_', ' ').title())
55
- current_footprint.append(item.get('current_footprint', 'N/A'))
56
- number_of_backlinks.append(item.get('best_of_breed_solution', 'N/A'))
57
-
58
- output = ""
59
- for i in range(len(categories)):
60
- output += f"\n\n---\n **Category:** {categories[i]}"
61
- output += f"\n\n **Count:** {current_footprint[i]}\n\n"
62
- output += f"**Best of Breed Solution:** {number_of_backlinks[i]}"
63
-
64
- data = {
65
- "": [str(category) for category in categories],
66
- "Current Footprint": [str(footprint) for footprint in current_footprint],
67
- "Best of Breed Solution": [str(backlink) for backlink in number_of_backlinks]
68
- }
69
- df_output = pd.DataFrame(data)
70
- with st.expander("AI Analysis", expanded=True, icon="🤖"):
71
- st.table(df_output.style.set_table_styles(
72
- [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
73
- {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
74
- ).set_properties(**{'text-align': 'center'}))
75
-
76
- return output
77
-
78
- def detect_encoding(self, uploaded_file):
79
- result = chardet.detect(uploaded_file.read(100000))
80
- uploaded_file.seek(0) # Reset file pointer to the beginning
81
- return result['encoding']
82
-
83
- def facebook(self, facebook_organic_post, facebook_ad_campaign):
84
- try:
85
- facebook_engagement_rate = (facebook_organic_post['Reactions, Comments and Shares'].mean() / self.facebooks).round(2)
86
- st.session_state['facebook_engagement_rate'] = facebook_engagement_rate
87
- except TypeError:
88
- pass
89
- # Post Frequency
90
- facebook_post_frequency = facebook_organic_post[~facebook_organic_post['Post ID'].isna()].shape[0]
91
-
92
- # Ads
93
- facebook_ads = facebook_ad_campaign[~facebook_ad_campaign['Ad name'].isna()].shape[0]
94
-
95
- st.session_state['facebook_review_rate'] = self.facebook_rr
96
- st.session_state['facebook_ads'] = facebook_ads
97
- st.session_state['facebook_post_frequency'] = facebook_post_frequency
98
- st.session_state['facebook_followers'] = self.facebooks
99
-
100
- try:
101
- return facebook_engagement_rate, facebook_ads, facebook_post_frequency
102
- except UnboundLocalError:
103
- return facebook_ads, facebook_post_frequency
104
-
105
- def terminate_session(self, session):
106
- try:
107
- del st.session_state[session]
108
- except KeyError:
109
- pass
110
-
111
- def row1(self):
112
- col1, col2 = st.columns(gap="medium", spec=[0.33, 0.66])
113
- with col1:
114
- intensity = st.select_slider(
115
- "Vague - Precise",
116
- options=[0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
117
-
118
- )
119
-
120
-
121
- self.facebooks = st.number_input('Facebook Followers:', min_value=1, max_value=99999999, value=None, step=1, placeholder='Enter Facebook Followers')
122
- self.facebook_rr = st.text_input("Facebook Review Rate:", placeholder='Enter Facebook Review Rate')
123
-
124
- self.instagram = st.text_input("Instagram Followers:", placeholder='Enter Instagram Followers')
125
- self.instagram_er = st.text_input("Instagram Audience Engagement Rate:", placeholder='Enter Instagram Audience Engagement Rate')
126
- self.instagram_pf = st.text_input("Instagram Post Frequency:", placeholder='Enter Instagram Post Frequency')
127
-
128
- followers = {
129
- 'Facebook Followers': self.facebooks if self.facebooks else 'N/A',
130
- 'Facebook Review Rate': self.facebook_rr if self.facebook_rr else 'N/A',
131
- }
132
-
133
- with col2:
134
- st.write("") # FOR THE HIDE BUTTON
135
- st.write("") # FOR THE HIDE BUTTON
136
- st.write("AI Analyst Output: ")
137
- st.session_state['analyzing'] = False
138
- st.write("") # FOR THE HIDE BUTTON
139
- analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
140
- start_time = time.time()
141
- if analyze_button:
142
- hide_button()
143
- try:
144
- if self.facebooks:
145
- combined_text = ""
146
- with st.spinner('Analyzing...', show_time=True):
147
- st.write('')
148
-
149
- intensity = str(intensity)
150
- combined_text += f"Intensity: {intensity}\n"
151
- # INITIALIZING SESSIONS
152
- try:
153
- facebook_organic_post = st.session_state['facebook_organic_post']
154
- facebook_ad_campaign = st.session_state['facebook_ad_campaign']
155
-
156
- self.facebook(facebook_organic_post, facebook_ad_campaign)
157
- try:
158
- facebook_engagement_rate = st.session_state['facebook_engagement_rate']
159
- combined_text += f"\nFacebook Audience Engagement Rate: {facebook_engagement_rate}%"
160
- except KeyError:
161
- pass
162
- facebook_ads = st.session_state['facebook_ads']
163
- facebook_post_frequency = st.session_state['facebook_post_frequency']
164
- combined_text += f"\nFacebook Followers: {self.facebooks}"
165
- combined_text += f"\nFacebook Review Rate: {self.facebook_rr}"
166
- combined_text += f"\nFacebook Ads: {facebook_ads}"
167
- combined_text += f"\nFacebook Post Frequency: {facebook_post_frequency}"
168
-
169
- combined_text += facebook_organic_post.to_csv(index=True)
170
- combined_text += facebook_ad_campaign.to_csv(index=True)
171
- except KeyError:
172
- pass
173
-
174
- try:
175
- combined_text += f"Instagram Followers: {self.instagram}\n"
176
- combined_text += f"Instagram Audience Engagement Rate: {self.instagram_er}%\n"
177
- combined_text += f"Instagram Post Frequency: {self.instagram_pf}\n"
178
- except KeyError:
179
- pass
180
-
181
-
182
-
183
- # OUTPUT FOR SEO ANALYST
184
- payload_txt = {"question": combined_text}
185
- result = self.request_model(payload_txt)
186
-
187
- end_time = time.time()
188
- time_lapsed = end_time - start_time
189
- debug_info = {
190
- 'analyst': self.analyst_name,
191
- 'url_uuid': self.model_url.split("-")[-1],
192
- 'time_lapsed': time_lapsed,
193
- #'backlink_files': [*st.session_state['uploaded_files']],
194
- 'payload': payload_txt,
195
- 'result': result,
196
- }
197
-
198
- collect_telemetry(debug_info)
199
-
200
- with st.expander("Debug information", icon="⚙"):
201
- st.write(debug_info)
202
-
203
- for df in st.session_state.keys():
204
- del st.session_state[df]
205
- for facebook_ad_campaign in st.session_state.keys():
206
- del st.session_state[facebook_ad_campaign]
207
-
208
- st.session_state['analyzing'] = False
209
- else:
210
- st.info("Please upload CSV or PDF files first.")
211
- hide_button()
212
- except AttributeError:
213
- st.info("Please upload CSV or PDF files first.")
214
- hide_button()
215
-
216
- if __name__ == "__main__":
217
- st.set_page_config(layout="wide")
218
-
219
- upload = uploadFile()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
helper/desc.py DELETED
@@ -1,30 +0,0 @@
1
- Analysts = {
2
- "Analyst 1": "SEO Off Page Optimization Analyst",
3
- "Analyst 2": "SEO On Page Optimization Analyst",
4
- "Analyst 3": "SEO Analyst",
5
- "Analyst 4": "Social Media Analyst",
6
- "Analyst 5": "Lead List Analyst",
7
- "Analyst 6": "Target Market Analyst",
8
- "Analyst 7": "SEO On Page Optimization Analyst",
9
- "Analyst 8": "SEO On Page Optimization Analyst",
10
- }
11
- Data_Source = {
12
- "Analyst_Src 1": "Data Sources - SEMRush",
13
- "Analyst_Src 2": "Data Source - Screaming Frog",
14
- "Analyst_Src 3": "Data Sources - SEMRush",
15
- "Analyst_Src 4": "Data Source -",
16
- "Analyst_Src 5": "Data Source -",
17
- "Analyst_Src 6": "Data Source -",
18
- "Analyst_Src 7": "SEO On Page Optimization Analyst",
19
- "Analyst_Src 8": "SEO On Page Optimization Analyst",
20
- }
21
- Analysts_Description = {
22
- "Analyst_Desc 1": "Upload Backlink List (PDF)",
23
- "Analyst_Desc 2": "Upload Files - Crawl (CSV)",
24
- "Analyst_Desc 3": "Upload Backlinks List (PDF)",
25
- "Analyst_Desc 4": "Ex. SEO Keywords, Traffic Channels, Backlinks (CSV) ",
26
- "Analyst_Desc 5": "",
27
- "Analyst_Desc 6": "",
28
- "Analyst_Desc 7": "Ex. SEO Keywords, Traffic Channels, Backlinks (CSV) ",
29
- "Analyst_Desc 8": "Ex. SEO Keywords, Traffic Channels, Backlinks (CSV) ",
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/agent_1.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- from helper.desc import Analysts, Analysts_Description, Data_Source
3
  from classes.Seo_Off_Page import SeoOffPageAnalyst
4
 
5
  # SPECIFY API URL & ANALYST NAME
 
1
  import os
2
+ from app import Analysts, Analysts_Description, Data_Source
3
  from classes.Seo_Off_Page import SeoOffPageAnalyst
4
 
5
  # SPECIFY API URL & ANALYST NAME
pages/agent_2.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- from helper.desc import Analysts, Analysts_Description, Data_Source
3
  from classes.Seo_On_Page import SeoOnPageAnalyst
4
 
5
  # SPECIFY API URL ANALYST NAME, DATA SOURCE & DESCRIPTION
 
1
  import os
2
+ from app import Analysts, Analysts_Description, Data_Source
3
  from classes.Seo_On_Page import SeoOnPageAnalyst
4
 
5
  # SPECIFY API URL ANALYST NAME, DATA SOURCE & DESCRIPTION
pages/agent_3.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
- from helper.desc import Analysts, Analysts_Description, Data_Source
 
3
  from classes.Seo import SeoAnalyst
4
 
5
  # SPECIFY API URL & ANALYST NAME
 
1
  import os
2
+ from app import Analysts, Analysts_Description, Data_Source
3
+ import streamlit as st
4
  from classes.Seo import SeoAnalyst
5
 
6
  # SPECIFY API URL & ANALYST NAME
pages/agent_4.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  from classes.Social_Media import SocialMediaAnalyst
3
- from helper.desc import Analysts, Analysts_Description, Data_Source
4
 
5
  # SPECIFY API URL & ANALYST NAME
6
  start = SocialMediaAnalyst(os.getenv('MODEL_Social_Media_Analyst'), Analysts['Analyst 4'], Data_Source['Analyst_Src 4'],Analysts_Description['Analyst_Desc 4'])
 
1
  import os
2
  from classes.Social_Media import SocialMediaAnalyst
3
+ from app import Analysts, Analysts_Description, Data_Source
4
 
5
  # SPECIFY API URL & ANALYST NAME
6
  start = SocialMediaAnalyst(os.getenv('MODEL_Social_Media_Analyst'), Analysts['Analyst 4'], Data_Source['Analyst_Src 4'],Analysts_Description['Analyst_Desc 4'])
pages/agent_5.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  from classes.Lead_List import LeadListAnalyst
3
- from helper.desc import Analysts, Analysts_Description, Data_Source
4
 
5
  # SPECIFY API URL & ANALYST NAME
6
  start = LeadListAnalyst(os.getenv('Model_Lead_list_Analyst'), Analysts['Analyst 5'], Data_Source['Analyst_Src 5'],Analysts_Description['Analyst_Desc 5'])
 
1
  import os
2
  from classes.Lead_List import LeadListAnalyst
3
+ from app import Analysts, Analysts_Description, Data_Source
4
 
5
  # SPECIFY API URL & ANALYST NAME
6
  start = LeadListAnalyst(os.getenv('Model_Lead_list_Analyst'), Analysts['Analyst 5'], Data_Source['Analyst_Src 5'],Analysts_Description['Analyst_Desc 5'])
pages/agent_6.py CHANGED
@@ -1,6 +1,6 @@
1
  import os
2
  from classes.Target_Market import TargetMarketAnalyst
3
- from helper.desc import Analysts, Analysts_Description, Data_Source
4
 
5
  # SPECIFY API URL & ANALYST NAME
6
  start = TargetMarketAnalyst(os.getenv('Model_Target_Market_Analyst'), Analysts['Analyst 6'], Data_Source['Analyst_Src 6'],Analysts_Description['Analyst_Desc 6'])
 
1
  import os
2
  from classes.Target_Market import TargetMarketAnalyst
3
+ from app import Analysts, Analysts_Description, Data_Source
4
 
5
  # SPECIFY API URL & ANALYST NAME
6
  start = TargetMarketAnalyst(os.getenv('Model_Target_Market_Analyst'), Analysts['Analyst 6'], Data_Source['Analyst_Src 6'],Analysts_Description['Analyst_Desc 6'])
pages/home.py DELETED
@@ -1,63 +0,0 @@
1
- import streamlit as st
2
- from helper.desc import Analysts
3
-
4
- st.set_page_config(layout="wide")
5
- # Create a dashboard that will display various agents on the page
6
- st.header("Digital Footprint AI Team", divider="gray")
7
-
8
- def row1():
9
- col1, col2, col3, col4 = st.columns(4, border=True, gap="medium", vertical_alignment="top")
10
- with col1:
11
- st.subheader(f"{Analysts['Analyst 1']}")
12
- st.write("PDF")
13
- if st.button("Load Analyst", key=1):
14
- st.switch_page("pages/agent_1.py")
15
-
16
- with col2:
17
- st.subheader(f"{Analysts['Analyst 2']}")
18
- st.write("CSV")
19
- if st.button("Load Analyst", key=2):
20
- st.switch_page("pages/agent_2.py")
21
-
22
- with col3:
23
- st.subheader(f"{Analysts['Analyst 3']}")
24
- st.write("CSV")
25
- if st.button("Load Analyst", key=3):
26
- st.switch_page("pages/agent_3.py")
27
-
28
- with col4:
29
- st.subheader(f"{Analysts['Analyst 4']}")
30
- st.write("CSV")
31
- if st.button("Load Analyst", key=4):
32
- st.switch_page("pages/agent_4.py")
33
- return col1, col2, col3, col4
34
-
35
- def row2():
36
- col1, col2, col3, col4 = st.columns(4, border=True, gap="medium")
37
- with col1:
38
- st.header("Lead List Analyst")
39
- st.write("")
40
- if st.button("Load Analyst", key=5, disabled=True):
41
- st.switch_page("pages/agent_5.py")
42
-
43
- with col2:
44
- st.header("Target Market Analyst")
45
- st.write("")
46
- if st.button("Load Analyst", key=6, disabled=True):
47
- st.switch_page("pages/agent_6.py")
48
-
49
- with col3:
50
- st.header("Analyst 7")
51
- st.write("")
52
- if st.button("Load Analyst", key=7, disabled=True):
53
- st.switch_page("pages/image.py")
54
-
55
- with col4:
56
- st.header("Finetuning Test")
57
- st.write("")
58
- if st.button("Load Test", key=8, disabled=True):
59
- st.switch_page("pages/test.py")
60
- return col1, col2, col3, col4
61
-
62
- row1()
63
- row2()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/test.py DELETED
@@ -1,7 +0,0 @@
1
- import os
2
- from helper.desc import Analysts, Analysts_Description, Data_Source
3
- from classes.test import test
4
-
5
- # SPECIFY API URL & ANALYST NAME
6
- start = test(os.getenv('MODEL_SEO_Analyst'), Analysts['Analyst 3'], Data_Source['Analyst_Src 3'],Analysts_Description['Analyst_Desc 3'])
7
-