Ronio Jerico Roque commited on
Commit
986cd95
·
1 Parent(s): 2f70cff

Refactor: Clean up code structure and improve file upload handling

Browse files
classes/Linkedin.py CHANGED
@@ -67,12 +67,13 @@ class Linkedin:
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):
@@ -130,36 +131,15 @@ class Linkedin:
130
  pass
131
  return file_name
132
 
133
- def row1(self):
134
- self.linkedin_f = st.text_input("Followers:", placeholder='Enter Linkedin Followers')
135
-
136
- followers = {
137
- 'Linkedin Followers': self.linkedin_f if self.linkedin_f else 'N/A'
138
- }
139
-
140
- linkedin_metrics = self.file_upload("linkedin_content_metrics", "Content Metrics CSV", "linkedin_content_metrics")
141
- linkedin_post = self.file_upload("linkedin_content_post", "Content Post CSV", "linkedin_content_post")
142
-
143
- linkedin_metrics
144
- linkedin_post
145
- '''
146
- st.write("") # FOR THE HIDE BUTTON
147
- st.write("") # FOR THE HIDE BUTTON
148
- st.write("AI Analyst Output: ")
149
- st.session_state['analyzing'] = False
150
- st.write("") # FOR THE HIDE BUTTON'
151
- '''
152
- #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
153
- start_time = time.time()
154
- if st.session_state['analyze'] == 'clicked':
155
- hide_button()
156
  try:
157
- if (linkedin_metrics and linkedin_metrics.name) or (linkedin_post and linkedin_post.name):
158
  combined_text = ""
159
  with st.spinner('Linkedin...', show_time=True):
160
  st.write('')
161
  # INITIALIZING SESSIONS
162
- combined_text += f"Client Summary: {st.session_state.nature}\n"
163
 
164
  try: # LINKEDIN
165
  try: # LINKEDIN CONTENT POST
@@ -190,10 +170,12 @@ class Linkedin:
190
 
191
  # OUTPUT FOR SEO ANALYST
192
  payload_txt = {"question": combined_text}
193
- result = self.request_model(payload_txt)
194
 
195
- end_time = time.time()
196
- time_lapsed = end_time - start_time
 
 
197
  debug_info = {
198
  #'analyst': self.analyst_name,
199
  'url_uuid': self.model_url.split("-")[-1],
@@ -203,22 +185,41 @@ class Linkedin:
203
  'payload': payload_txt,
204
  'result': result,
205
  }
206
-
207
  collect_telemetry(debug_info)
208
 
209
- with st.expander("Debug information", icon="⚙"):
210
- st.write(debug_info)
211
-
212
- for df in st.session_state.keys():
213
- del st.session_state[df]
214
- for facebook_ad_campaign in st.session_state.keys():
215
- del st.session_state[facebook_ad_campaign]
216
 
217
- st.session_state['analyzing'] = False
 
 
218
  except AttributeError:
219
  st.info("Please upload CSV or PDF files first.")
220
  hide_button()
 
 
 
 
 
 
 
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  if __name__ == "__main__":
223
  st.set_page_config(layout="wide")
224
 
 
67
  "Best of Breed Solution": [str(backlink) for backlink in number_of_backlinks]
68
  }
69
  df_output = pd.DataFrame(data)
70
+ '''
71
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
72
  st.table(df_output.style.set_table_styles(
73
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
74
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
75
  ).set_properties(**{'text-align': 'center'}))
76
+ '''
77
  return output
78
 
79
  def detect_encoding(self, uploaded_file):
 
131
  pass
132
  return file_name
133
 
134
+ def process(self):
135
+ session = st.session_state.analyze
136
+ if (self.linkedin_f or (self.linkedin_metrics and self.linkedin_metrics.name) or (self.linkedin_post and self.linkedin_post.name)) and session == "clicked":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  try:
 
138
  combined_text = ""
139
  with st.spinner('Linkedin...', show_time=True):
140
  st.write('')
141
  # INITIALIZING SESSIONS
142
+ #combined_text += f"Client Summary: {st.session_state.nature}\n"
143
 
144
  try: # LINKEDIN
145
  try: # LINKEDIN CONTENT POST
 
170
 
171
  # OUTPUT FOR SEO ANALYST
172
  payload_txt = {"question": combined_text}
173
+ #result = self.request_model(payload_txt)
174
 
175
+ #end_time = time.time()
176
+ #time_lapsed = end_time - start_time
177
+ debug_info = {'data_field' : 'Linkedin', 'result': combined_text}
178
+ '''
179
  debug_info = {
180
  #'analyst': self.analyst_name,
181
  'url_uuid': self.model_url.split("-")[-1],
 
185
  'payload': payload_txt,
186
  'result': result,
187
  }
188
+ '''
189
  collect_telemetry(debug_info)
190
 
191
+ #with st.expander("Debug information", icon="⚙"):
192
+ # st.write(debug_info)
 
 
 
 
 
193
 
194
+ st.session_state['analyzing'] = False
195
+ #for key in st.session_state.keys():
196
+ # del st.session_state[session]
197
  except AttributeError:
198
  st.info("Please upload CSV or PDF files first.")
199
  hide_button()
200
+
201
+ def row1(self):
202
+ self.linkedin_f = st.text_input("Followers:", placeholder='Enter Linkedin Followers')
203
+
204
+ followers = {
205
+ 'Linkedin Followers': self.linkedin_f if self.linkedin_f else 'N/A'
206
+ }
207
 
208
+ self.linkedin_metrics = self.file_upload("linkedin_content_metrics", "Content Metrics CSV", "linkedin_content_metrics")
209
+ self.linkedin_post = self.file_upload("linkedin_content_post", "Content Post CSV", "linkedin_content_post")
210
+
211
+ self.linkedin_metrics
212
+ self.linkedin_post
213
+ '''
214
+ st.write("") # FOR THE HIDE BUTTON
215
+ st.write("") # FOR THE HIDE BUTTON
216
+ st.write("AI Analyst Output: ")
217
+ st.session_state['analyzing'] = False
218
+ st.write("") # FOR THE HIDE BUTTON'
219
+ '''
220
+ #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
221
+ self.process()
222
+
223
  if __name__ == "__main__":
224
  st.set_page_config(layout="wide")
225
 
classes/Off_Page.py CHANGED
@@ -10,6 +10,7 @@ from helper.upload_File import uploadFile
10
  from helper.button_behaviour import hide_button, unhide_button
11
  from helper.initialize_analyze_session import initialize_analyze_session
12
  import pandas as pd
 
13
 
14
  class SeoOffPageAnalyst:
15
  def __init__(self, model_url):
@@ -28,7 +29,6 @@ class SeoOffPageAnalyst:
28
 
29
  # AGENT NAME
30
  #st.header(self.analyst_name)
31
-
32
 
33
  def request_model(self, payload_txt):
34
  response = requests.post(self.model_url, json=payload_txt)
@@ -68,26 +68,21 @@ class SeoOffPageAnalyst:
68
  ).set_properties(**{'text-align': 'center'}))
69
  '''
70
  return output
71
-
72
- def row1(self):
73
- #st.write(self.data_src)
74
- self.uploaded_files = st.file_uploader('Backlinks - SEMRush', type='csv', accept_multiple_files=True, key="seo_off")
75
- if self.uploaded_files:
76
- upload.multiple_upload_file(self.uploaded_files)
77
-
78
- #st.write("") # FOR THE HIDE BUTTON
79
- #st.write("") # FOR THE HIDE BUTTON
80
-
81
- st.session_state['analyzing'] = False
82
- start_time = time.time()
83
- if self.uploaded_files and st.session_state['analyze'] == 'clicked':
84
  combined_text = ""
85
  with st.spinner('SEO Off Page Analyst...', show_time=True):
86
  st.write('')
87
  for file_info in st.session_state['uploaded_files'].values():
 
88
  if file_info['type'] == 'pdf':
89
  combined_text += file_info['content'] + "\n"
90
- elif file_info['type'] == 'csv':
 
91
  # Load CSV
92
  df = pd.read_csv(StringIO(file_info['content'].to_csv(index=True)))
93
 
@@ -98,24 +93,37 @@ class SeoOffPageAnalyst:
98
  df['Source Domain'] = df['Source url'].apply(lambda x: urlparse(x).netloc)
99
  unique_domains = df['Source Domain'].nunique()
100
 
101
- combined_text += f"Total rows: {num_rows}\n"
102
  combined_text += f"Referring Domain: {unique_domains}"
103
 
104
  # OUTPUT FOR SEO ANALYST
105
  payload_txt = {"question": combined_text}
106
- result = self.request_model(payload_txt)
107
 
108
- end_time = time.time()
109
- time_lapsed = end_time - start_time
110
-
111
- debug_info = {'url_uuid': self.model_url.split("-")[-1],'time_lapsed' : time_lapsed, 'files': [*st.session_state['uploaded_files']],'payload': payload_txt, 'result': result}
112
 
 
 
113
  collect_telemetry(debug_info)
114
 
115
  #with st.expander("Debug information", icon="⚙"):
116
  # st.write(debug_info)
117
  print("done2")
118
  st.session_state['analyzing'] = False
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
 
121
  if __name__ == "__main__":
 
10
  from helper.button_behaviour import hide_button, unhide_button
11
  from helper.initialize_analyze_session import initialize_analyze_session
12
  import pandas as pd
13
+ import asyncio
14
 
15
  class SeoOffPageAnalyst:
16
  def __init__(self, model_url):
 
29
 
30
  # AGENT NAME
31
  #st.header(self.analyst_name)
 
32
 
33
  def request_model(self, payload_txt):
34
  response = requests.post(self.model_url, json=payload_txt)
 
68
  ).set_properties(**{'text-align': 'center'}))
69
  '''
70
  return output
71
+
72
+ def process(self):
73
+ print("init off page")
74
+ start_time = time.time()
75
+ session = st.session_state['analyze']
76
+ if self.uploaded_files and session == 'clicked':
 
 
 
 
 
 
 
77
  combined_text = ""
78
  with st.spinner('SEO Off Page Analyst...', show_time=True):
79
  st.write('')
80
  for file_info in st.session_state['uploaded_files'].values():
81
+ '''
82
  if file_info['type'] == 'pdf':
83
  combined_text += file_info['content'] + "\n"
84
+ '''
85
+ if file_info['type'] == 'csv':
86
  # Load CSV
87
  df = pd.read_csv(StringIO(file_info['content'].to_csv(index=True)))
88
 
 
93
  df['Source Domain'] = df['Source url'].apply(lambda x: urlparse(x).netloc)
94
  unique_domains = df['Source Domain'].nunique()
95
 
96
+ combined_text += f"Total Backlinks Count: {num_rows}\n"
97
  combined_text += f"Referring Domain: {unique_domains}"
98
 
99
  # OUTPUT FOR SEO ANALYST
100
  payload_txt = {"question": combined_text}
101
+ #result = self.request_model(payload_txt)
102
 
103
+ #end_time = time.time()
104
+ #time_lapsed = end_time - start_time
 
 
105
 
106
+ debug_info = {'data_field' : 'Backlinks', 'result': combined_text}
107
+ #debug_info = {'url_uuid': self.model_url.split("-")[-1],'time_lapsed' : time_lapsed, 'files': [*st.session_state['uploaded_files']],'payload': payload_txt, 'result': result}
108
  collect_telemetry(debug_info)
109
 
110
  #with st.expander("Debug information", icon="⚙"):
111
  # st.write(debug_info)
112
  print("done2")
113
  st.session_state['analyzing'] = False
114
+
115
+ def row1(self):
116
+ #st.write(self.data_src)
117
+ self.uploaded_files = st.file_uploader('Backlinks - SEMRush', type='csv', accept_multiple_files=True, key="seo_off")
118
+ if self.uploaded_files:
119
+ upload.multiple_upload_file(self.uploaded_files)
120
+
121
+ #st.write("") # FOR THE HIDE BUTTON
122
+ #st.write("") # FOR THE HIDE BUTTON
123
+
124
+ st.session_state['analyzing'] = False
125
+
126
+ self.process()
127
 
128
 
129
  if __name__ == "__main__":
classes/On_Page_Crawl.py CHANGED
@@ -64,32 +64,19 @@ class SeoOnCrawl:
64
  "Remarks": [str(footprint) for footprint in remarks],
65
  }
66
  df_output = pd.DataFrame(data)
 
67
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
68
  st.table(df_output.style.set_table_styles(
69
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
70
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
71
  ).set_properties(**{'text-align': 'center'}))
72
-
73
 
74
  return output
75
 
76
- def row1(self):
77
- #st.write(self.data_src)
78
- self.uploaded_files = st.file_uploader("Crawl File - ScreamingFrog:", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on_backlink")
79
- #self.gtmetrix = st.file_uploader("GTmetrix", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on_gt")
80
- if self.uploaded_files:
81
- upload.multiple_upload_file(self.uploaded_files)
82
- self.file_dict = upload.file_dict
83
- #if self.gtmetrix:
84
- # upload.upload_gt(self.gtmetrix)
85
-
86
- #st.write("") # FOR THE HIDE BUTTON
87
- #st.write("") # FOR THE HIDE BUTTON
88
- #st.write("AI Analyst Output: ")
89
- st.session_state['analyzing'] = False
90
- #st.write("") # FOR THE HIDE BUTTON
91
-
92
- if st.session_state['analyze'] == 'clicked':
93
  start_time = time.time()
94
  if self.uploaded_files:
95
  combined_text = ""
@@ -118,35 +105,51 @@ class SeoOnCrawl:
118
  '''
119
  # OUTPUT FOR SEO ANALYST
120
  payload_txt = {"question": combined_text}
121
- result = self.request_model(payload_txt)
122
- end_time = time.time()
123
- time_lapsed = end_time - start_time
 
 
124
  debug_info = {#'analyst': self.analyst_name,
125
  'url_uuid': self.model_url.split("-")[-1],
126
  'time_lapsed' : time_lapsed,
127
  'crawl_file': [file.name for file in self.uploaded_files] if self.uploaded_files else ['Not available'],
128
  #'gt_metrix': [file.name for file in self.gtmetrix] if self.gtmetrix else ['Not available'],
129
  'payload': payload_txt,
130
- 'result': result}
 
131
 
132
  collect_telemetry(debug_info)
133
 
134
 
135
- with st.expander("Debug information", icon="⚙"):
136
- st.write(debug_info)
137
 
138
 
139
  st.session_state['analyzing'] = False
140
 
141
- for df_seo in st.session_state.keys():
142
- del st.session_state[df_seo]
143
  try:
144
  self.file_dict.popitem()
145
  except KeyError:
146
  pass
147
- if 'analyze' not in st.session_state:
148
- st.session_state['analyze'] = ''
149
- st.session_state['analyze'] == ''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
 
151
 
152
  if __name__ == "__main__":
 
64
  "Remarks": [str(footprint) for footprint in remarks],
65
  }
66
  df_output = pd.DataFrame(data)
67
+ '''
68
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
69
  st.table(df_output.style.set_table_styles(
70
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
71
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
72
  ).set_properties(**{'text-align': 'center'}))
73
+ '''
74
 
75
  return output
76
 
77
+ def process(self):
78
+ session = st.session_state.analyze
79
+ if session == 'clicked':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  start_time = time.time()
81
  if self.uploaded_files:
82
  combined_text = ""
 
105
  '''
106
  # OUTPUT FOR SEO ANALYST
107
  payload_txt = {"question": combined_text}
108
+ #result = self.request_model(payload_txt)
109
+ #end_time = time.time()
110
+ #time_lapsed = end_time - start_time
111
+ debug_info = {'data_field' : 'Crawl', 'result': combined_text}
112
+ '''
113
  debug_info = {#'analyst': self.analyst_name,
114
  'url_uuid': self.model_url.split("-")[-1],
115
  'time_lapsed' : time_lapsed,
116
  'crawl_file': [file.name for file in self.uploaded_files] if self.uploaded_files else ['Not available'],
117
  #'gt_metrix': [file.name for file in self.gtmetrix] if self.gtmetrix else ['Not available'],
118
  'payload': payload_txt,
119
+ 'result': result}'
120
+ '''
121
 
122
  collect_telemetry(debug_info)
123
 
124
 
125
+ #with st.expander("Debug information", icon="⚙"):
126
+ # st.write(debug_info)
127
 
128
 
129
  st.session_state['analyzing'] = False
130
 
 
 
131
  try:
132
  self.file_dict.popitem()
133
  except KeyError:
134
  pass
135
+
136
+ def row1(self):
137
+ #st.write(self.data_src)
138
+ self.uploaded_files = st.file_uploader("Crawl File - ScreamingFrog:", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on_backlink")
139
+ #self.gtmetrix = st.file_uploader("GTmetrix", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on_gt")
140
+ if self.uploaded_files:
141
+ upload.multiple_upload_file(self.uploaded_files)
142
+ self.file_dict = upload.file_dict
143
+ #if self.gtmetrix:
144
+ # upload.upload_gt(self.gtmetrix)
145
+
146
+ #st.write("") # FOR THE HIDE BUTTON
147
+ #st.write("") # FOR THE HIDE BUTTON
148
+ #st.write("AI Analyst Output: ")
149
+ st.session_state['analyzing'] = False
150
+ #st.write("") # FOR THE HIDE BUTTON
151
+
152
+ self.process()
153
 
154
 
155
  if __name__ == "__main__":
classes/On_Page_GT.py CHANGED
@@ -64,44 +64,32 @@ class SeoOnGT:
64
  "Remarks": [str(footprint) for footprint in remarks],
65
  }
66
  df_output = pd.DataFrame(data)
 
67
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
68
  st.table(df_output.style.set_table_styles(
69
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
70
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
71
  ).set_properties(**{'text-align': 'center'}))
72
-
73
 
74
  return output
75
 
76
- def row1(self):
77
- #st.write(self.data_src)
78
- #self.uploaded_files = st.file_uploader("Upload Backlink List (PDF)", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on")
79
- self.gtmetrix = st.file_uploader("GTmetrix:", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on_gt")
80
- '''
81
- if self.uploaded_files:
82
- upload.multiple_upload_file(self.uploaded_files)
83
- self.file_dict = upload.file_dict
84
- '''
85
- if self.gtmetrix:
86
- upload.upload_gt(self.gtmetrix)
87
-
88
- self.website_responsiveness = st.text_input("Website Responsiveness - Google PageSpeed Insight:", placeholder='Enter Website Responsiveness')
89
- self.content_management_system = st.text_input("Content Management System - BuiltWith:", placeholder='Enter Content Management System')
90
- self.SSL_certificate = st.text_input("SSL Certificate - BuiltWith:", placeholder='Enter SSL Certificate')
91
- self.web_analytics = st.text_input("Web Analytics - BuiltWith:", placeholder='Enter Web Analytics')
92
- self.client_relations_management_system = st.text_input("Client Relations Management System - BuiltWith:", placeholder='Enter Client Relations Management System')
93
- self.lead_generation_mechanism = st.text_input("Lead Generation Mechanism - Business Context (Lead Generation & Lead Nurturing):", placeholder='Enter Lead Generation Mechanism')
94
-
95
- #st.write("") # FOR THE HIDE BUTTON
96
- #st.write("") # FOR THE HIDE BUTTON
97
- #st.write("AI Analyst Output: ")
98
- st.session_state['analyzing'] = False
99
- #st.write("") # FOR THE HIDE BUTTON
100
-
101
- if st.session_state['analyze'] == 'clicked':
102
  start_time = time.time()
103
- if self.gtmetrix:
104
  combined_text = ""
 
 
 
 
 
 
 
 
 
 
 
105
  with st.spinner('SEO On Page Analyst...', show_time=True):
106
  st.write('')
107
  '''
@@ -126,19 +114,60 @@ class SeoOnGT:
126
  except KeyError:
127
  pass
128
  try:
129
- combined_text += f"\nWebsite Responsiveness: {self.website_responsiveness}"
130
- combined_text += f"\nContent Management System: {self.content_management_system}%"
131
- combined_text += f"\nSSL Certificate: {self.SSL_certificate}"
132
- combined_text += f"\nWeb Analytics: {self.web_analytics}"
133
- combined_text += f"\nClient Relations Management System: {self.client_relations_management_system}"
134
- combined_text += f"\nLead Generation Mechanism: {self.lead_generation_mechanism}"
 
 
 
 
135
  except KeyError:
136
  pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  # OUTPUT FOR SEO ANALYST
138
  payload_txt = {"question": combined_text}
139
- result = self.request_model(payload_txt)
140
- end_time = time.time()
141
- time_lapsed = end_time - start_time
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  debug_info = {#'analyst': self.analyst_name,
143
  'url_uuid': self.model_url.split("-")[-1],
144
  'time_lapsed' : time_lapsed,
@@ -147,11 +176,32 @@ class SeoOnGT:
147
  'payload': payload_txt,
148
  'result': result}
149
 
150
- collect_telemetry(debug_info)
151
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
- with st.expander("Debug information", icon="⚙"):
154
- st.write(debug_info)
155
 
156
 
157
  st.session_state['analyzing'] = False
@@ -162,9 +212,38 @@ class SeoOnGT:
162
  self.file_dict.popitem()
163
  except KeyError:
164
  pass
165
- if 'analyze' not in st.session_state:
166
- st.session_state['analyze'] = ''
167
- st.session_state['analyze'] == ''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
 
170
  if __name__ == "__main__":
 
64
  "Remarks": [str(footprint) for footprint in remarks],
65
  }
66
  df_output = pd.DataFrame(data)
67
+ '''
68
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
69
  st.table(df_output.style.set_table_styles(
70
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
71
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
72
  ).set_properties(**{'text-align': 'center'}))
73
+ '''
74
 
75
  return output
76
 
77
+ def process(self):
78
+ session = st.session_state.analyze
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  start_time = time.time()
80
+ if (self.website_responsiveness or self.content_management_system or self.SSL_certificate or self.web_analytics or self.client_relations_management_system or self.lead_generation_mechanism or self.first_meaningful_paint or self.mobile_responsiveness or self.mobile_loading_speed or self.desktop_loading_speed) and session == 'clicked':
81
  combined_text = ""
82
+ website_responsiveness = ""
83
+ content_management_system = ""
84
+ SSL_certificate = ""
85
+ mobile_responsiveness = ""
86
+ desktop_loading_speed = ""
87
+ mobile_loading_speed = ""
88
+ web_analytics = ""
89
+ client_relations_management_system = ""
90
+ mobile_loading_speed = ""
91
+ first_meaningful_paint = ""
92
+ lead_generation_mechanism = ""
93
  with st.spinner('SEO On Page Analyst...', show_time=True):
94
  st.write('')
95
  '''
 
114
  except KeyError:
115
  pass
116
  try:
117
+ website_responsiveness += f"\nWebsite Responsiveness: {self.website_responsiveness}"
118
+ content_management_system += f"\nContent Management System: {self.content_management_system}%"
119
+ SSL_certificate += f"\nSSL Certificate: {self.SSL_certificate}"
120
+ mobile_responsiveness += f"\nMobile Responsiveness: {self.mobile_responsiveness}"
121
+ desktop_loading_speed += f"\nDesktop Loading Speed: {self.desktop_loading_speed}"
122
+ mobile_loading_speed += f"\nMobile Loading Speed: {self.mobile_loading_speed}"
123
+ first_meaningful_paint += f"\nFirst Meaningful Paint: {self.first_meaningful_paint}"
124
+ web_analytics += f"\nWeb Analytics: {self.web_analytics}"
125
+ client_relations_management_system += f"\nClient Relations Management System: {self.client_relations_management_system}"
126
+ lead_generation_mechanism += f"\nLead Generation Mechanism: {self.lead_generation_mechanism}"
127
  except KeyError:
128
  pass
129
+ # OUTPUT FOR WEBSITE RESPONSIVENESS
130
+ payload_txt_website_responsiveness = {"question": website_responsiveness}
131
+ #result_website_responsiveness = self.request_model(website_responsiveness)
132
+
133
+ # OUTPUT FOR CONTENT MANAGEMENT SYSTEM
134
+ payload_txt_content_management_system = {"question": content_management_system}
135
+ #result_content_management_system = self.request_model(content_management_system)
136
+
137
+ # OUTPUT FOR SSL CERTIFICATE
138
+ payload_txt_SSL_certificate = {"question": SSL_certificate}
139
+ #result_SSL_certificate = self.request_model(SSL_certificate)
140
+
141
+ # OUTPUT FOR WEB ANALYTICS
142
+ payload_txt_web_analytics = {"question": web_analytics}
143
+ #result_web_analytics = self.request_model(web_analytics)
144
+
145
+ # OUTPUT FOR CLIENT RELATIONS MANAGEMENT SYSTEM
146
+ payload_txt_client_relations_management_system = {"question": client_relations_management_system}
147
+ #result_client_relations_management_system = self.request_model(client_relations_management_system)
148
+
149
+ # OUTPUT FOR LEAD GENERATION MECHANISM
150
+ payload_txt_lead_generation_mechanism = {"question": lead_generation_mechanism}
151
+ #result_lead_generation_mechanism = self.request_model(lead_generation_mechanism)
152
+
153
  # OUTPUT FOR SEO ANALYST
154
  payload_txt = {"question": combined_text}
155
+ #result = self.request_model(payload_txt)
156
+ #end_time = time.time()
157
+ #time_lapsed = end_time - start_time
158
+
159
+ debug_info = {'data_field' : 'GT Metrix', 'result': combined_text}
160
+ debug_info_website_responsiveness = {'data_field' : 'Website Responsiveness', 'result': website_responsiveness}
161
+ debug_info_content_management_system = {'data_field' : 'Content Management System', 'result': content_management_system}
162
+ debug_info_SSL_certificate = {'data_field' : 'SSL Certificate', 'result': SSL_certificate}
163
+ debug_info_mobile_responsiveness = {'data_field' : 'Mobile Responsiveness', 'result': mobile_responsiveness}
164
+ debug_info_desktop_loading_speed = {'data_field' : 'Desktop Loading Speed', 'result': desktop_loading_speed}
165
+ debug_info_mobile_loading_speed = {'data_field' : 'Mobile Loading Speed', 'result': mobile_loading_speed}
166
+ debug_info_first_meaningful_paint = {'data_field' : 'First Meaningful Paint', 'result': first_meaningful_paint}
167
+ debug_info_web_analytics = {'data_field' : 'Web Analytics', 'result': web_analytics}
168
+ debug_info_client_relations_management_system = {'data_field' : 'Client Relations Management System', 'result': client_relations_management_system}
169
+ debug_info_lead_generation_mechanism = {'data_field' : 'Lead Generation Mechanism', 'result': lead_generation_mechanism}
170
+ '''
171
  debug_info = {#'analyst': self.analyst_name,
172
  'url_uuid': self.model_url.split("-")[-1],
173
  'time_lapsed' : time_lapsed,
 
176
  'payload': payload_txt,
177
  'result': result}
178
 
179
+ if self.gtmetrix:
180
+ collect_telemetry(debug_info)
181
+ '''
182
+ if self.website_responsiveness:
183
+ collect_telemetry(debug_info_website_responsiveness)
184
+ if self.content_management_system:
185
+ collect_telemetry(debug_info_content_management_system)
186
+ if self.SSL_certificate:
187
+ collect_telemetry(debug_info_SSL_certificate)
188
+ if self.mobile_responsiveness:
189
+ collect_telemetry(debug_info_mobile_responsiveness)
190
+ if self.desktop_loading_speed:
191
+ collect_telemetry(debug_info_desktop_loading_speed)
192
+ if self.mobile_loading_speed:
193
+ collect_telemetry(debug_info_mobile_loading_speed)
194
+ if self.first_meaningful_paint:
195
+ collect_telemetry(debug_info_first_meaningful_paint)
196
+ if self.web_analytics:
197
+ collect_telemetry(debug_info_web_analytics)
198
+ if self.client_relations_management_system:
199
+ collect_telemetry(debug_info_client_relations_management_system)
200
+ if self.lead_generation_mechanism:
201
+ collect_telemetry(debug_info_lead_generation_mechanism)
202
 
203
+ #with st.expander("Debug information", icon="⚙"):
204
+ # st.write(debug_info)
205
 
206
 
207
  st.session_state['analyzing'] = False
 
212
  self.file_dict.popitem()
213
  except KeyError:
214
  pass
215
+
216
+ def row1(self):
217
+ #st.write(self.data_src)
218
+ #self.uploaded_files = st.file_uploader("Upload Backlink List (PDF)", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on")
219
+ #self.gtmetrix = st.file_uploader("GTmetrix:", type=['pdf', 'csv'], accept_multiple_files=True, key="seo_on_gt")
220
+ '''
221
+ if self.uploaded_files:
222
+ upload.multiple_upload_file(self.uploaded_files)
223
+ self.file_dict = upload.file_dict
224
+
225
+ if self.gtmetrix:
226
+ upload.upload_gt(self.gtmetrix)
227
+ '''
228
+ self.website_responsiveness = st.text_input("Website Overall Health Scores - GTMetrix:", placeholder='Enter Website Overall Health Scores')
229
+ self.content_management_system = st.text_input("Content Management System - BuiltWith:", placeholder='Enter Content Management System')
230
+ self.SSL_certificate = st.text_input("SSL Certificate - BuiltWith:", placeholder='Enter SSL Certificate')
231
+ self.mobile_responsiveness = st.text_input("Mobile Responsiveness - GTMetrix:", placeholder='Enter Mobile Responsiveness')
232
+ self.desktop_loading_speed = st.text_input("Desktop Loading Speed - GTMetrix:", placeholder='Enter Desktop Loading Speed')
233
+ self.mobile_loading_speed = st.text_input("Mobile Loading Speed - GTMetrix:", placeholder='Enter Mobile Loading Speed')
234
+ self.web_analytics = st.text_input("Web Analytics - BuiltWith:", placeholder='Enter Web Analytics')
235
+ self.client_relations_management_system = st.text_input("Client Relations Management System - BuiltWith:", placeholder='Enter Client Relations Management System')
236
+ self.first_meaningful_paint = st.text_input("First Meaningful Paint - GTMetrix:", placeholder='Enter First Meaningful Paint')
237
+ self.lead_generation_mechanism = st.text_input("Lead Generation Mechanism - Business Context (Lead Generation & Lead Nurturing):", placeholder='Enter Lead Generation Mechanism')
238
+
239
+ #st.write("") # FOR THE HIDE BUTTON
240
+ #st.write("") # FOR THE HIDE BUTTON
241
+ #st.write("AI Analyst Output: ")
242
+ st.session_state['analyzing'] = False
243
+ #st.write("") # FOR THE HIDE BUTTON
244
+ self.process()
245
+
246
+
247
 
248
 
249
  if __name__ == "__main__":
classes/Seo.py CHANGED
@@ -146,72 +146,25 @@ class Seo:
146
  del st.session_state['referral_traffic']
147
  except KeyError:
148
  pass
149
-
150
- def row1(self):
151
- #st.write("") # FOR SPACINGs
152
-
153
- #st.write("") # FOR SPACINGs
154
- '''
155
- self.uploaded_files = st.file_uploader("Backlinks (SEO)", type=['pdf', 'csv'], accept_multiple_files=True, key="seo1")
156
- if self.uploaded_files:
157
- self.delete_sessions()
158
- upload.upload_file_seo(self.uploaded_files)
159
- self.file_dict = upload.file_dict
160
- '''
161
- #st.write("") # FOR THE HIDE BUTTON
162
- self.uploaded_file_seo = st.file_uploader("SEO Keywords - SEMRush", type='csv', key="seo2")
163
- if self.uploaded_file_seo:
164
- self.delete_sessions()
165
- try:
166
- encoding_seo = self.detect_encoding(self.uploaded_file_seo)
167
- st.session_state['df_seo'] = pd.read_csv(self.uploaded_file_seo, encoding=encoding_seo, low_memory=False, key="seo3")
168
- except Exception:
169
- pass
170
-
171
-
172
- self.uploaded_file = st.file_uploader("Traffic Channels - SEMRush", type='csv')
173
- if self.uploaded_file:
174
- self.delete_sessions()
175
- try:
176
- encoding = self.detect_encoding(self.uploaded_file)
177
- st.session_state['df_traffic'] = pd.read_csv(self.uploaded_file, encoding=encoding, low_memory=False, key="seo4")
178
- except Exception:
179
- pass
180
-
181
- st.write("") # FOR THE HIDE BUTTON
182
- self.others = st.file_uploader("Traffic Acquisition - GA4", type='csv', key="seo5")
183
- if self.others:
184
- self.delete_sessions()
185
- try:
186
- st.session_state['others'] = pd.read_csv(self.others, skiprows=9)
187
- except Exception:
188
- pass
189
-
190
- self.page_index = st.text_input("Pages Indexed - Google Search Console:", placeholder='Enter Pages Indexed')
191
- self.bounce_rate = st.text_input("Bounce Rate - GA4:", placeholder='Enter Bounce Rate')
192
-
193
- followers = {
194
- 'Pages Indexed': self.page_index if self.page_index else 'N/A',
195
- 'Bounce Rate': self.bounce_rate if self.bounce_rate else 'N/A'
196
- }
197
-
198
- #st.write("") # FOR THE HIDE BUTTON
199
- #st.write("") # FOR THE HIDE BUTTON
200
- #st.write("AI Analyst Output: ")
201
- st.session_state['analyzing'] = False
202
- #st.write("") # FOR THE HIDE BUTTON
203
- #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
204
- start_time = time.time()
205
- if st.session_state['analyze'] == 'clicked':
206
- hide_button()
207
- if self.uploaded_file or self.others or self.uploaded_file_seo:
208
  combined_text = ""
 
 
 
 
 
209
  with st.spinner('Seo Analyst...', show_time=True):
210
  st.write('')
211
 
212
  # INITIALIZING SESSIONS
213
- combined_text += f"Pages Indexed: {self.page_index}\n"
214
- combined_text += f"Bounce Rate: {self.bounce_rate}\n"
215
  '''
216
  try:
217
  backlink_files = self.file_dict
@@ -228,12 +181,13 @@ class Seo:
228
  direct_traffic = st.session_state['direct_traffic']
229
  referral_traffic = st.session_state['referral_traffic']
230
 
231
- combined_text += df_traffic.to_csv(index=True)
232
 
233
- combined_text += f"\nOrganic Traffic: {organic_traffic}"
234
- combined_text += f"\nPaid Traffic: {paid_traffic}"
235
- combined_text += f"\nDirect Traffic: {direct_traffic}"
236
- combined_text += f"\nReferral Traffic: {referral_traffic}"
 
 
237
 
238
  except KeyError:
239
  pass
@@ -242,10 +196,10 @@ class Seo:
242
  df_seo = st.session_state['df_seo']
243
  self.keyword_ranking(df_seo)
244
  keyword_ranking = st.session_state['keyword_ranking']
245
- combined_text += f"\nKeyword Ranking Top 10: {keyword_ranking['Keyword_top_10']}"
246
- combined_text += f"\nKeyword Ranking Top 100: {keyword_ranking['Keyword_top_100']}\n\n"
247
 
248
- combined_text += df_seo.to_csv(index=True)
249
  except KeyError:
250
  pass
251
 
@@ -259,17 +213,29 @@ class Seo:
259
 
260
  traffics = ga4_direct_traffic + ga4_organic_traffic + ga4_paid_social + ga4_referral_traffic
261
 
262
- combined_text += f"Traffics: {traffics}"
263
- combined_text += f"Paid Traffic: {ga4_paid_social}\nOrganic Traffic: {ga4_organic_traffic}\nDirect Traffic: {ga4_direct_traffic}\nReferral Traffic: {ga4_referral_traffic}"
264
  except KeyError:
265
  pass
266
-
267
 
268
  # OUTPUT FOR SEO ANALYST
269
- payload_txt = {"question": combined_text}
270
- result = self.request_model(payload_txt)
271
- end_time = time.time()
272
- time_lapsed = end_time - start_time
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  debug_info = {
274
  #'analyst': self.analyst_name,
275
  'url_uuid': self.model_url.split("-")[-1],
@@ -279,21 +245,86 @@ class Seo:
279
  'payload': payload_txt,
280
  'result': result,
281
  }
 
 
 
 
 
 
 
 
 
 
 
282
 
283
- collect_telemetry(debug_info)
284
-
285
- with st.expander("Debug information", icon="⚙"):
286
- st.write(debug_info)
287
-
288
- for df_traffic in st.session_state.keys():
289
- del st.session_state[df_traffic]
290
- for df_seo in st.session_state.keys():
291
- del st.session_state[df_seo]
292
- for others in st.session_state.keys():
293
- del st.session_state[others]
294
- print("done1")
295
  st.session_state['analyzing'] = False
296
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
  if __name__ == "__main__":
299
  st.set_page_config(layout="wide")
 
146
  del st.session_state['referral_traffic']
147
  except KeyError:
148
  pass
149
+
150
+ def process (self):
151
+ start_time = time.time()
152
+
153
+ session = st.session_state.analyze
154
+ print(session)
155
+ if (self.uploaded_file or self.others or self.uploaded_file_seo) and session == 'clicked':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  combined_text = ""
157
+ seo_keywords = ""
158
+ traffic_channels = ""
159
+ traffic_aqcuisition = ""
160
+ pages_index = ""
161
+ bounce_rate = ""
162
  with st.spinner('Seo Analyst...', show_time=True):
163
  st.write('')
164
 
165
  # INITIALIZING SESSIONS
166
+ pages_index += f"Pages Indexed: {self.page_index}\n"
167
+ bounce_rate += f"Bounce Rate: {self.bounce_rate}\n"
168
  '''
169
  try:
170
  backlink_files = self.file_dict
 
181
  direct_traffic = st.session_state['direct_traffic']
182
  referral_traffic = st.session_state['referral_traffic']
183
 
 
184
 
185
+
186
+ traffic_channels += f"\nOrganic Traffic: {organic_traffic}"
187
+ traffic_channels += f"\nPaid Traffic: {paid_traffic}"
188
+ traffic_channels += f"\nDirect Traffic: {direct_traffic}"
189
+ traffic_channels += f"\nReferral Traffic: {referral_traffic}"
190
+ traffic_channels += df_traffic.to_csv(index=True)
191
 
192
  except KeyError:
193
  pass
 
196
  df_seo = st.session_state['df_seo']
197
  self.keyword_ranking(df_seo)
198
  keyword_ranking = st.session_state['keyword_ranking']
199
+ seo_keywords += f"\nKeyword Ranking Top 10: {keyword_ranking['Keyword_top_10']}"
200
+ seo_keywords += f"\nKeyword Ranking Top 100: {keyword_ranking['Keyword_top_100']}\n\n"
201
 
202
+ seo_keywords += df_seo.to_csv(index=True)
203
  except KeyError:
204
  pass
205
 
 
213
 
214
  traffics = ga4_direct_traffic + ga4_organic_traffic + ga4_paid_social + ga4_referral_traffic
215
 
216
+ traffic_aqcuisition += f"Traffics: {traffics}"
217
+ traffic_aqcuisition += f"\nPaid Traffic: {ga4_paid_social}\nOrganic Traffic: {ga4_organic_traffic}\nDirect Traffic: {ga4_direct_traffic}\nReferral Traffic: {ga4_referral_traffic}"
218
  except KeyError:
219
  pass
 
220
 
221
  # OUTPUT FOR SEO ANALYST
222
+ payload_txt_seo_keywords = {"question": seo_keywords}
223
+ payload_txt_traffic_channels = {"question": traffic_channels}
224
+ payload_txt_traffic_aqcuisition = {"question": traffic_aqcuisition}
225
+ payload_txt_pages_index = {"question": pages_index}
226
+ payload_txt_bounce_rate = {"question": bounce_rate}
227
+
228
+
229
+ #result = self.request_model(payload_txt)
230
+ #end_time = time.time()
231
+ #time_lapsed = end_time - start_time
232
+ debug_info_seo_keywords = {'data_field' : 'SEO Keywords', 'result': seo_keywords}
233
+ debug_info_traffic_channels = {'data_field' : 'Traffic Channels', 'result': traffic_channels}
234
+ debug_info_traffic_aqcuisition = {'data_field' : 'Traffic Acquisition', 'result': traffic_aqcuisition}
235
+ debug_info_pages_index = {'data_field' : 'Pages Indexed', 'result': pages_index}
236
+ debug_info_bounce_rate = {'data_field' : 'Bounce Rate', 'result': bounce_rate}
237
+
238
+ '''
239
  debug_info = {
240
  #'analyst': self.analyst_name,
241
  'url_uuid': self.model_url.split("-")[-1],
 
245
  'payload': payload_txt,
246
  'result': result,
247
  }
248
+ '''
249
+ if self.bounce_rate:
250
+ collect_telemetry(debug_info_bounce_rate)
251
+ if self.page_index:
252
+ collect_telemetry(debug_info_pages_index)
253
+ if self.others:
254
+ collect_telemetry(debug_info_traffic_aqcuisition)
255
+ if self.uploaded_file:
256
+ collect_telemetry(debug_info_traffic_channels)
257
+ if self.uploaded_file_seo:
258
+ collect_telemetry(debug_info_seo_keywords)
259
 
260
+ #with st.expander("Debug information", icon="⚙"):
261
+ # st.write(debug_info)
262
+
263
+
264
+ #del st.session_state[df_traffic]
265
+
266
+ #del st.session_state[df_seo]
267
+
268
+ #del st.session_state[others]
269
+
 
 
270
  st.session_state['analyzing'] = False
271
+
272
+ def row1(self):
273
+ #st.write("") # FOR SPACINGs
274
+
275
+ #st.write("") # FOR SPACINGs
276
+ '''
277
+ self.uploaded_files = st.file_uploader("Backlinks (SEO)", type=['pdf', 'csv'], accept_multiple_files=True, key="seo1")
278
+ if self.uploaded_files:
279
+ self.delete_sessions()
280
+ upload.upload_file_seo(self.uploaded_files)
281
+ self.file_dict = upload.file_dict
282
+ '''
283
+ #st.write("") # FOR THE HIDE BUTTON
284
+ self.uploaded_file_seo = st.file_uploader("SEO Keywords - SEMRush", type='csv', key="seo2")
285
+ if self.uploaded_file_seo:
286
+ self.delete_sessions()
287
+ try:
288
+ encoding_seo = self.detect_encoding(self.uploaded_file_seo)
289
+ st.session_state['df_seo'] = pd.read_csv(self.uploaded_file_seo, encoding=encoding_seo, low_memory=False)
290
+ except Exception:
291
+ pass
292
+
293
+
294
+ self.uploaded_file = st.file_uploader("Traffic Channels - SEMRush", type='csv')
295
+ if self.uploaded_file:
296
+ self.delete_sessions()
297
+ try:
298
+ encoding = self.detect_encoding(self.uploaded_file)
299
+ st.session_state['df_traffic'] = pd.read_csv(self.uploaded_file, encoding=encoding, low_memory=False)
300
+ except Exception:
301
+ pass
302
+
303
+ st.write("") # FOR THE HIDE BUTTON
304
+ self.others = st.file_uploader("Traffic Acquisition - GA4", type='csv', key="seo5")
305
+ if self.others:
306
+
307
+ try:
308
+ st.session_state['others'] = pd.read_csv(self.others, skiprows=9)
309
+ except Exception:
310
+ pass
311
+
312
+ self.page_index = st.text_input("Pages Indexed - Google Search Console:", placeholder='Enter Pages Indexed')
313
+ self.bounce_rate = st.text_input("Bounce Rate - GA4:", placeholder='Enter Bounce Rate')
314
+
315
+ followers = {
316
+ 'Pages Indexed': self.page_index if self.page_index else 'N/A',
317
+ 'Bounce Rate': self.bounce_rate if self.bounce_rate else 'N/A'
318
+ }
319
+
320
+ #st.write("") # FOR THE HIDE BUTTON
321
+ #st.write("") # FOR THE HIDE BUTTON
322
+ #st.write("AI Analyst Output: ")
323
+ st.session_state['analyzing'] = False
324
+ #st.write("") # FOR THE HIDE BUTTON
325
+ #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
326
+
327
+ self.process()
328
 
329
  if __name__ == "__main__":
330
  st.set_page_config(layout="wide")
classes/Social_Media_FB.py CHANGED
@@ -105,23 +105,7 @@ class Facebook:
105
  except UnboundLocalError:
106
  return facebook_post_frequency
107
 
108
- def linkedin_content_metrics(self, linkedin_content_metrics):
109
- # Avg. engagement rate
110
- try:
111
- linkedin_engagement_rate = linkedin_content_metrics['Engagement rate (organic)'].mean().round(2)
112
- except Exception:
113
- new_header = linkedin_content_metrics.iloc[0] #grab the first row for the header
114
- linkedin_content_metrics = linkedin_content_metrics[1:] #take the data less the header row
115
- linkedin_content_metrics.columns = new_header #set the header row as the df header
116
- linkedin_content_metrics['Engagement rate (organic)'] = pd.to_numeric(linkedin_content_metrics['Engagement rate (organic)'], errors='coerce')
117
- linkedin_engagement_rate = linkedin_content_metrics['Engagement rate (organic)'].mean().round(2)
118
- # Post Frequency
119
-
120
- st.session_state['linkedin_engagement_rate'] = linkedin_engagement_rate
121
-
122
- return linkedin_engagement_rate
123
 
124
- def linkedin_content_post(self, linkedin_content_post):
125
  try:
126
  linkedin_post_frequency = linkedin_content_post[~linkedin_content_post['Post title'].isna()].shape[0]
127
  except Exception:
@@ -154,39 +138,19 @@ class Facebook:
154
  except Exception:
155
  pass
156
  return file_name
157
-
158
- def row1(self):
159
- self.facebooks = st.number_input('Followers:', min_value=1, max_value=99999999, value=None, step=1, placeholder='Enter Followers')
160
- self.facebook_rr = st.text_input("Review Rate:", placeholder='Enter Review Rate')
161
-
162
- followers = {
163
- 'Facebook Followers': self.facebooks if self.facebooks else 'N/A',
164
- 'Facebook Review Rate': self.facebook_rr if self.facebook_rr else 'N/A',
165
- }
166
 
167
- fb_organic_post = self.file_upload("fb_post", "Organic Post CSV", "facebook_organic_post")
168
- fb_ads_campaign = self.file_upload("fb_campaign", "Ads Campaign CSV", "facebook_ad_campaign")
169
-
170
- fb_organic_post
171
- fb_ads_campaign
172
-
173
- '''
174
- st.write("") # FOR THE HIDE BUTTON
175
- st.write("") # FOR THE HIDE BUTTON
176
- st.write("AI Analyst Output: ")
177
- st.session_state['analyzing'] = False
178
- st.write("") # FOR THE HIDE BUTTON
179
- '''
180
- start_time = time.time()
181
- if st.session_state['analyze'] == 'clicked':
182
  hide_button()
183
  try:
184
- if (fb_organic_post and fb_organic_post.name) or (fb_ads_campaign and fb_ads_campaign.name):
185
  combined_text = ""
186
  with st.spinner('Social Media Analyst...', show_time=True):
187
  st.write('')
188
  # INITIALIZING SESSIONS
189
- combined_text += f"Client Summary: {st.session_state.nature}\n"
190
  try: # FACEBOOK
191
  try: # ORGANIC POST
192
  combined_text += f"\nFacebook Followers: {self.facebooks}"
@@ -223,10 +187,12 @@ class Facebook:
223
 
224
  # OUTPUT FOR SEO ANALYST
225
  payload_txt = {"question": combined_text}
226
- result = self.request_model(payload_txt)
227
 
228
  end_time = time.time()
229
  time_lapsed = end_time - start_time
 
 
230
  debug_info = {
231
  'analyst': self.analyst_name,
232
  'url_uuid': self.model_url.split("-")[-1],
@@ -236,16 +202,15 @@ class Facebook:
236
  'payload': payload_txt,
237
  'result': result,
238
  }
239
-
240
  collect_telemetry(debug_info)
241
 
242
  #with st.expander("Debug information", icon="⚙"):
243
  # st.write(debug_info)
244
 
245
- for df in st.session_state.keys():
246
- del st.session_state[df]
247
- for facebook_ad_campaign in st.session_state.keys():
248
- del st.session_state[facebook_ad_campaign]
249
 
250
  st.session_state['analyzing'] = False
251
 
@@ -253,6 +218,31 @@ class Facebook:
253
 
254
  hide_button()
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  if __name__ == "__main__":
257
  st.set_page_config(layout="wide")
258
 
 
105
  except UnboundLocalError:
106
  return facebook_post_frequency
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
 
109
  try:
110
  linkedin_post_frequency = linkedin_content_post[~linkedin_content_post['Post title'].isna()].shape[0]
111
  except Exception:
 
138
  except Exception:
139
  pass
140
  return file_name
 
 
 
 
 
 
 
 
 
141
 
142
+ def process(self):
143
+ start_time = time.time()
144
+ session = st.session_state.analyze
145
+ if session == 'clicked':
 
 
 
 
 
 
 
 
 
 
 
146
  hide_button()
147
  try:
148
+ if (self.fb_organic_post and self.fb_organic_post.name) or (self.fb_ads_campaign and self.fb_ads_campaign.name):
149
  combined_text = ""
150
  with st.spinner('Social Media Analyst...', show_time=True):
151
  st.write('')
152
  # INITIALIZING SESSIONS
153
+ #combined_text += f"Client Summary: {st.session_state.nature}\n"
154
  try: # FACEBOOK
155
  try: # ORGANIC POST
156
  combined_text += f"\nFacebook Followers: {self.facebooks}"
 
187
 
188
  # OUTPUT FOR SEO ANALYST
189
  payload_txt = {"question": combined_text}
190
+ #result = self.request_model(payload_txt)
191
 
192
  end_time = time.time()
193
  time_lapsed = end_time - start_time
194
+ debug_info = {'data_field' : 'Facebook', 'result': combined_text}
195
+ '''
196
  debug_info = {
197
  'analyst': self.analyst_name,
198
  'url_uuid': self.model_url.split("-")[-1],
 
202
  'payload': payload_txt,
203
  'result': result,
204
  }
205
+ '''
206
  collect_telemetry(debug_info)
207
 
208
  #with st.expander("Debug information", icon="⚙"):
209
  # st.write(debug_info)
210
 
211
+
212
+ #del st.session_state[df]
213
+ #del st.session_state[facebook_ad_campaign]
 
214
 
215
  st.session_state['analyzing'] = False
216
 
 
218
 
219
  hide_button()
220
 
221
+ def row1(self):
222
+ self.facebooks = st.number_input('Followers:', min_value=1, max_value=99999999, value=None, step=1, placeholder='Enter Followers')
223
+ self.facebook_rr = st.text_input("Review Rate:", placeholder='Enter Review Rate')
224
+
225
+ followers = {
226
+ 'Facebook Followers': self.facebooks if self.facebooks else 'N/A',
227
+ 'Facebook Review Rate': self.facebook_rr if self.facebook_rr else 'N/A',
228
+ }
229
+
230
+ self.fb_organic_post = self.file_upload("fb_post", "Organic Post CSV", "facebook_organic_post")
231
+ self.fb_ads_campaign = self.file_upload("fb_campaign", "Ads Campaign CSV", "facebook_ad_campaign")
232
+
233
+ self.fb_organic_post
234
+ self.fb_ads_campaign
235
+
236
+ '''
237
+ st.write("") # FOR THE HIDE BUTTON
238
+ st.write("") # FOR THE HIDE BUTTON
239
+ st.write("AI Analyst Output: ")
240
+ st.session_state['analyzing'] = False
241
+ st.write("") # FOR THE HIDE BUTTON
242
+ '''
243
+ self.process()
244
+
245
+
246
  if __name__ == "__main__":
247
  st.set_page_config(layout="wide")
248
 
classes/Social_Media_IG.py CHANGED
@@ -103,6 +103,44 @@ class Instagram:
103
  pass
104
  return file_name
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  def row1(self):
107
  self.instagram = st.text_input("Followers:", placeholder='Enter Instagram Followers')
108
  self.instagram_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Instagram Audience Engagement Rate')
@@ -119,48 +157,7 @@ class Instagram:
119
  st.write("") # FOR THE HIDE BUTTON'
120
  '''
121
  #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
122
- start_time = time.time()
123
- if st.session_state['analyze'] == 'clicked':
124
- hide_button()
125
- if self.instagram or self.instagram_er or self.instagram_pf:
126
- try:
127
- combined_text = ""
128
- with st.spinner('Instagram...', show_time=True):
129
- st.write('')
130
- try:
131
- combined_text += f"\nInstagram Followers: {self.instagram}"
132
- combined_text += f"\nInstagram Audience Engagement Rate: {self.instagram_er}%"
133
- combined_text += f"\nInstagram Post Frequency: {self.instagram_pf}"
134
- except KeyError:
135
- pass
136
-
137
-
138
- # OUTPUT FOR SEO ANALYST
139
- payload_txt = {"question": combined_text}
140
- result = self.request_model(payload_txt)
141
-
142
- end_time = time.time()
143
- time_lapsed = end_time - start_time
144
- debug_info = {
145
- #'analyst': self.analyst_name,
146
- 'url_uuid': self.model_url.split("-")[-1],
147
- 'time_lapsed': time_lapsed,
148
- 'payload': payload_txt,
149
- 'result': result,
150
- }
151
-
152
- collect_telemetry(debug_info)
153
-
154
- for df in st.session_state.keys():
155
- del st.session_state[df]
156
- for facebook_ad_campaign in st.session_state.keys():
157
- del st.session_state[facebook_ad_campaign]
158
-
159
-
160
- except AttributeError:
161
- st.info("Please upload CSV or PDF files first.")
162
- hide_button()
163
-
164
  if __name__ == "__main__":
165
  st.set_page_config(layout="wide")
166
 
 
103
  pass
104
  return file_name
105
 
106
+ def process(self):
107
+ session = st.session_state.analyze
108
+ if (self.instagram or self.instagram_er or self.instagram_pf) and session == 'clicked':
109
+ try:
110
+ combined_text = ""
111
+ with st.spinner('Instagram...', show_time=True):
112
+ st.write('')
113
+ try:
114
+ combined_text += f"\nInstagram Followers: {self.instagram}"
115
+ combined_text += f"\nInstagram Audience Engagement Rate: {self.instagram_er}%"
116
+ combined_text += f"\nInstagram Post Frequency: {self.instagram_pf}"
117
+ except KeyError:
118
+ pass
119
+
120
+
121
+ # OUTPUT FOR SEO ANALYST
122
+ payload_txt = {"question": combined_text}
123
+ #result = self.request_model(payload_txt)
124
+
125
+ #end_time = time.time()
126
+ #time_lapsed = end_time - start_time
127
+ debug_info = {'data_field' : 'Instagram', 'result': combined_text}
128
+ '''
129
+ debug_info = {
130
+ #'analyst': self.analyst_name,
131
+ 'url_uuid': self.model_url.split("-")[-1],
132
+ 'time_lapsed': time_lapsed,
133
+ 'payload': payload_txt,
134
+ 'result': result,
135
+ }
136
+ '''
137
+ collect_telemetry(debug_info)
138
+
139
+
140
+ except AttributeError:
141
+ st.info("Please upload CSV or PDF files first.")
142
+ hide_button()
143
+
144
  def row1(self):
145
  self.instagram = st.text_input("Followers:", placeholder='Enter Instagram Followers')
146
  self.instagram_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Instagram Audience Engagement Rate')
 
157
  st.write("") # FOR THE HIDE BUTTON'
158
  '''
159
  #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
160
+ self.process()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  if __name__ == "__main__":
162
  st.set_page_config(layout="wide")
163
 
classes/Tiktok.py CHANGED
@@ -67,12 +67,13 @@ class Tiktok:
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):
@@ -100,39 +101,15 @@ class Tiktok:
100
  except Exception:
101
  pass
102
  return file_name
103
-
104
- def row1(self):
105
- self.tiktok_f = st.text_input("Followers:", placeholder='Enter Tiktok Followers')
106
- self.tiktok_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Tiktok Audience Engagement Rate')
107
- self.tiktok_pf = st.text_input("Post Frequency:", placeholder='Enter Tiktok Post Frequency')
108
-
109
- followers = {
110
- 'Tiktok Followers': self.tiktok_f if self.tiktok_f else 'N/A'
111
- }
112
- tiktok_post = self.file_upload("Tiktok", "Tiktok Content post", "Tiktok")
113
-
114
- tiktok_post
115
-
116
- '''
117
- st.write("") # FOR THE HIDE BUTTON
118
- st.write("") # FOR THE HIDE BUTTON
119
- st.write("AI Analyst Output: ")
120
- st.session_state['analyzing'] = False
121
- st.write("") # FOR THE HIDE BUTTON'
122
- '''
123
- #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
124
- start_time = time.time()
125
- if 'analyze' not in st.session_state:
126
- st.session_state['analyze'] = ''
127
- if st.session_state['analyze'] == 'clicked':
128
- hide_button()
129
- if self.tiktok_f or self.tiktok_er or self.tiktok_pf:
130
  try:
131
  combined_text = ""
132
  with st.spinner('Tiktok...', show_time=True):
133
  st.write('')
134
  # INITIALIZING SESSIONS
135
- combined_text += f"Client Summary: {st.session_state.nature}\n"
136
  try:
137
  combined_text += f"\nTiktok Followers: {self.tiktok_f}"
138
  combined_text += f"\nTiktok Audience Engagement Rate: {self.tiktok_er}%"
@@ -142,10 +119,12 @@ class Tiktok:
142
 
143
  # OUTPUT FOR SEO ANALYST
144
  payload_txt = {"question": combined_text}
145
- result = self.request_model(payload_txt)
146
 
147
- end_time = time.time()
148
- time_lapsed = end_time - start_time
 
 
149
  debug_info = {
150
  #'analyst': self.analyst_name,
151
  'url_uuid': self.model_url.split("-")[-1],
@@ -153,22 +132,39 @@ class Tiktok:
153
  'payload': payload_txt,
154
  'result': result,
155
  }
156
-
157
  collect_telemetry(debug_info)
158
 
159
  #with st.expander("Debug information", icon="⚙"):
160
  # st.write(debug_info)
161
 
162
- for df in st.session_state.keys():
163
- del st.session_state[df]
164
- for facebook_ad_campaign in st.session_state.keys():
165
- del st.session_state[facebook_ad_campaign]
166
-
167
  st.session_state['analyzing'] = False
168
  except AttributeError:
169
  st.info("Please upload CSV or PDF files first.")
170
  hide_button()
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  if __name__ == "__main__":
173
  st.set_page_config(layout="wide")
174
 
 
67
  "Best of Breed Solution": [str(backlink) for backlink in number_of_backlinks]
68
  }
69
  df_output = pd.DataFrame(data)
70
+ '''
71
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
72
  st.table(df_output.style.set_table_styles(
73
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
74
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
75
  ).set_properties(**{'text-align': 'center'}))
76
+ '''
77
  return output
78
 
79
  def detect_encoding(self, uploaded_file):
 
101
  except Exception:
102
  pass
103
  return file_name
104
+ def process(self):
105
+ session = st.session_state.analyze
106
+ if (self.tiktok_f or self.tiktok_er or self.tiktok_pf) and session == 'clicked':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  try:
108
  combined_text = ""
109
  with st.spinner('Tiktok...', show_time=True):
110
  st.write('')
111
  # INITIALIZING SESSIONS
112
+ #combined_text += f"Client Summary: {st.session_state.nature}\n"
113
  try:
114
  combined_text += f"\nTiktok Followers: {self.tiktok_f}"
115
  combined_text += f"\nTiktok Audience Engagement Rate: {self.tiktok_er}%"
 
119
 
120
  # OUTPUT FOR SEO ANALYST
121
  payload_txt = {"question": combined_text}
122
+ #result = self.request_model(payload_txt)
123
 
124
+ #end_time = time.time()
125
+ #time_lapsed = end_time - start_time
126
+ debug_info = {'data_field' : 'Tiktok', 'result': combined_text}
127
+ '''
128
  debug_info = {
129
  #'analyst': self.analyst_name,
130
  'url_uuid': self.model_url.split("-")[-1],
 
132
  'payload': payload_txt,
133
  'result': result,
134
  }
135
+ '''
136
  collect_telemetry(debug_info)
137
 
138
  #with st.expander("Debug information", icon="⚙"):
139
  # st.write(debug_info)
140
 
 
 
 
 
 
141
  st.session_state['analyzing'] = False
142
  except AttributeError:
143
  st.info("Please upload CSV or PDF files first.")
144
  hide_button()
145
 
146
+ def row1(self):
147
+ self.tiktok_f = st.text_input("Followers:", placeholder='Enter Tiktok Followers')
148
+ self.tiktok_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Tiktok Audience Engagement Rate')
149
+ self.tiktok_pf = st.text_input("Post Frequency:", placeholder='Enter Tiktok Post Frequency')
150
+
151
+ followers = {
152
+ 'Tiktok Followers': self.tiktok_f if self.tiktok_f else 'N/A'
153
+ }
154
+ tiktok_post = self.file_upload("Tiktok", "Tiktok Content post", "Tiktok")
155
+
156
+ tiktok_post
157
+
158
+ '''
159
+ st.write("") # FOR THE HIDE BUTTON
160
+ st.write("") # FOR THE HIDE BUTTON
161
+ st.write("AI Analyst Output: ")
162
+ st.session_state['analyzing'] = False
163
+ st.write("") # FOR THE HIDE BUTTON'
164
+ '''
165
+ #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
166
+ self.process()
167
+
168
  if __name__ == "__main__":
169
  st.set_page_config(layout="wide")
170
 
classes/Twitter.py CHANGED
@@ -66,13 +66,14 @@ class Twitter:
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):
@@ -113,29 +114,9 @@ class Twitter:
113
  pass
114
  return file_name
115
 
116
- def row1(self):
117
- self.twitter = st.text_input("Followers:", placeholder='Enter Twitter Followers')
118
- self.twitter_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Twitter Audience Engagement Rate')
119
- self.twitter_pf = st.text_input("Post Frequency:", placeholder='Enter Post Frequency')
120
-
121
- followers = {
122
- 'Twitter Followers': self.twitter if self.twitter else 'N/A',
123
- }
124
-
125
- '''
126
- st.write("") # FOR THE HIDE BUTTON
127
- st.write("") # FOR THE HIDE BUTTON
128
- st.write("AI Analyst Output: ")
129
- st.session_state['analyzing'] = False
130
- st.write("") # FOR THE HIDE BUTTON'
131
- '''
132
- #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
133
- start_time = time.time()
134
- if 'analyze' not in st.session_state:
135
- st.session_state['analyze'] = ''
136
- if st.session_state['analyze'] == 'clicked':
137
- hide_button()
138
- if self.twitter or self.twitter_er or self.twitter_pf:
139
  try:
140
  combined_text = ""
141
  with st.spinner('Twitter...', show_time=True):
@@ -153,10 +134,12 @@ class Twitter:
153
 
154
  # OUTPUT FOR SEO ANALYST
155
  payload_txt = {"question": combined_text}
156
- result = self.request_model(payload_txt)
157
 
158
- end_time = time.time()
159
- time_lapsed = end_time - start_time
 
 
160
  debug_info = {
161
  #'analyst': self.analyst_name,
162
  'url_uuid': self.model_url.split("-")[-1],
@@ -164,19 +147,32 @@ class Twitter:
164
  'payload': payload_txt,
165
  'result': result,
166
  }
167
-
168
  collect_telemetry(debug_info)
169
-
170
-
171
- for df in st.session_state.keys():
172
- del st.session_state[df]
173
- for facebook_ad_campaign in st.session_state.keys():
174
- del st.session_state[facebook_ad_campaign]
175
 
176
  st.session_state['analyzing'] = False
177
  except AttributeError:
178
  st.info("Please upload CSV or PDF files first.")
179
  hide_button()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
  if __name__ == "__main__":
182
  st.set_page_config(layout="wide")
 
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
+ '''
70
  df_output = pd.DataFrame(data)
71
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
72
  st.table(df_output.style.set_table_styles(
73
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
74
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
75
  ).set_properties(**{'text-align': 'center'}))
76
+ '''
77
  return output
78
 
79
  def detect_encoding(self, uploaded_file):
 
114
  pass
115
  return file_name
116
 
117
+ def process(self):
118
+ session = st.session_state.analyze
119
+ if (self.twitter or self.twitter_er or self.twitter_pf) and session == 'clicked':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  try:
121
  combined_text = ""
122
  with st.spinner('Twitter...', show_time=True):
 
134
 
135
  # OUTPUT FOR SEO ANALYST
136
  payload_txt = {"question": combined_text}
137
+ #result = self.request_model(payload_txt)
138
 
139
+ #end_time = time.time()
140
+ #time_lapsed = end_time - start_time
141
+ debug_info = {'data_field' : 'Twitter', 'result': combined_text}
142
+ '''
143
  debug_info = {
144
  #'analyst': self.analyst_name,
145
  'url_uuid': self.model_url.split("-")[-1],
 
147
  'payload': payload_txt,
148
  'result': result,
149
  }
150
+ '''
151
  collect_telemetry(debug_info)
 
 
 
 
 
 
152
 
153
  st.session_state['analyzing'] = False
154
  except AttributeError:
155
  st.info("Please upload CSV or PDF files first.")
156
  hide_button()
157
+
158
+ def row1(self):
159
+ self.twitter = st.text_input("Followers:", placeholder='Enter Twitter Followers')
160
+ self.twitter_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Twitter Audience Engagement Rate')
161
+ self.twitter_pf = st.text_input("Post Frequency:", placeholder='Enter Post Frequency')
162
+
163
+ followers = {
164
+ 'Twitter Followers': self.twitter if self.twitter else 'N/A',
165
+ }
166
+
167
+ '''
168
+ st.write("") # FOR THE HIDE BUTTON
169
+ st.write("") # FOR THE HIDE BUTTON
170
+ st.write("AI Analyst Output: ")
171
+ st.session_state['analyzing'] = False
172
+ st.write("") # FOR THE HIDE BUTTON'
173
+ '''
174
+ #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
175
+ self.process()
176
 
177
  if __name__ == "__main__":
178
  st.set_page_config(layout="wide")
classes/Youtube.py CHANGED
@@ -67,12 +67,13 @@ class YouTube:
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):
@@ -80,23 +81,6 @@ class YouTube:
80
  uploaded_file.seek(0) # Reset file pointer to the beginning
81
  return result['encoding']
82
 
83
-
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
- st.session_state['facebook_post_frequency'] = facebook_post_frequency
92
- st.session_state['facebook_review_rate'] = self.facebook_rr
93
- st.session_state['facebook_followers'] = self.facebooks
94
-
95
- try:
96
- return facebook_post_frequency, facebook_engagement_rate
97
- except UnboundLocalError:
98
- return facebook_post_frequency
99
-
100
  def terminate_session(self, session):
101
  try:
102
  del st.session_state[session]
@@ -118,34 +102,15 @@ class YouTube:
118
  pass
119
  return file_name
120
 
121
- def row1(self):
122
- self.youtube = st.text_input("Followers:", placeholder='Enter Youtube Followers')
123
- self.youtube_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Youtube Audience Engagement Rate')
124
- self.youtube_pf = st.text_input("Post Frequency:", placeholder='Enter Youtube Post Frequency')
125
-
126
- followers = {
127
- 'Youtube Followers': self.youtube if self.youtube else 'N/A',
128
- }
129
- '''
130
- st.write("") # FOR THE HIDE BUTTON
131
- st.write("") # FOR THE HIDE BUTTON
132
- st.write("AI Analyst Output: ")
133
- st.session_state['analyzing'] = False
134
- st.write("") # FOR THE HIDE BUTTON
135
- '''
136
- #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
137
- start_time = time.time()
138
- if 'analyze' not in st.session_state:
139
- st.session_state['analyze'] = ''
140
- if st.session_state['analyze'] == 'clicked':
141
- hide_button()
142
- if self.youtube or self.youtube_er or self.youtube_pf:
143
  try:
144
  combined_text = ""
145
  with st.spinner('Youtube...', show_time=True):
146
  st.write('')
147
  # INITIALIZING SESSIONS
148
- combined_text += f"Client Summary: {st.session_state.nature}\n"
149
 
150
  try:
151
  combined_text += f"\nYoutube Followers: {self.youtube}"
@@ -158,10 +123,12 @@ class YouTube:
158
 
159
  # OUTPUT FOR SEO ANALYST
160
  payload_txt = {"question": combined_text}
161
- result = self.request_model(payload_txt)
162
 
163
- end_time = time.time()
164
- time_lapsed = end_time - start_time
 
 
165
  debug_info = {
166
  #'analyst': self.analyst_name,
167
  'url_uuid': self.model_url.split("-")[-1],
@@ -169,21 +136,34 @@ class YouTube:
169
  'payload': payload_txt,
170
  'result': result,
171
  }
172
-
173
  collect_telemetry(debug_info)
174
 
175
  #with st.expander("Debug information", icon="⚙"):
176
  # st.write(debug_info)
177
 
178
- for df in st.session_state.keys():
179
- del st.session_state[df]
180
- for facebook_ad_campaign in st.session_state.keys():
181
- del st.session_state[facebook_ad_campaign]
182
-
183
  st.session_state['analyzing'] = False
184
  except AttributeError:
185
  st.info("Please upload CSV or PDF files first.")
186
  hide_button()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
  if __name__ == "__main__":
189
  st.set_page_config(layout="wide")
 
67
  "Best of Breed Solution": [str(backlink) for backlink in number_of_backlinks]
68
  }
69
  df_output = pd.DataFrame(data)
70
+ '''
71
  with st.expander("AI Analysis", expanded=True, icon="🤖"):
72
  st.table(df_output.style.set_table_styles(
73
  [{'selector': 'th:first-child, td:first-child', 'props': [('width', '20px')]},
74
  {'selector': 'th, td', 'props': [('width', '150px'), ('text-align', 'center')]}]
75
  ).set_properties(**{'text-align': 'center'}))
76
+ '''
77
  return output
78
 
79
  def detect_encoding(self, uploaded_file):
 
81
  uploaded_file.seek(0) # Reset file pointer to the beginning
82
  return result['encoding']
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  def terminate_session(self, session):
85
  try:
86
  del st.session_state[session]
 
102
  pass
103
  return file_name
104
 
105
+ def process(self):
106
+ session = st.session_state.analyze
107
+ if (self.youtube or self.youtube_er or self.youtube_pf) and session == 'clicked':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  try:
109
  combined_text = ""
110
  with st.spinner('Youtube...', show_time=True):
111
  st.write('')
112
  # INITIALIZING SESSIONS
113
+ #combined_text += f"Client Summary: {st.session_state.nature}\n"
114
 
115
  try:
116
  combined_text += f"\nYoutube Followers: {self.youtube}"
 
123
 
124
  # OUTPUT FOR SEO ANALYST
125
  payload_txt = {"question": combined_text}
126
+ #result = self.request_model(payload_txt)
127
 
128
+ #end_time = time.time()
129
+ #time_lapsed = end_time - start_time
130
+ debug_info = {'data_field' : 'YouTube', 'result': combined_text}
131
+ '''
132
  debug_info = {
133
  #'analyst': self.analyst_name,
134
  'url_uuid': self.model_url.split("-")[-1],
 
136
  'payload': payload_txt,
137
  'result': result,
138
  }
139
+ '''
140
  collect_telemetry(debug_info)
141
 
142
  #with st.expander("Debug information", icon="⚙"):
143
  # st.write(debug_info)
144
 
 
 
 
 
 
145
  st.session_state['analyzing'] = False
146
  except AttributeError:
147
  st.info("Please upload CSV or PDF files first.")
148
  hide_button()
149
+
150
+ def row1(self):
151
+ self.youtube = st.text_input("Followers:", placeholder='Enter Youtube Followers')
152
+ self.youtube_er = st.text_input("Audience Engagement Rate:", placeholder='Enter Youtube Audience Engagement Rate')
153
+ self.youtube_pf = st.text_input("Post Frequency:", placeholder='Enter Youtube Post Frequency')
154
+
155
+ followers = {
156
+ 'Youtube Followers': self.youtube if self.youtube else 'N/A',
157
+ }
158
+ '''
159
+ st.write("") # FOR THE HIDE BUTTON
160
+ st.write("") # FOR THE HIDE BUTTON
161
+ st.write("AI Analyst Output: ")
162
+ st.session_state['analyzing'] = False
163
+ st.write("") # FOR THE HIDE BUTTON
164
+ '''
165
+ #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
166
+ self.process()
167
 
168
  if __name__ == "__main__":
169
  st.set_page_config(layout="wide")
helper/telemetry.py CHANGED
@@ -19,6 +19,7 @@ def collect_telemetry(data):
19
  return
20
 
21
  try:
 
22
  # Get the current UTC time
23
  utc_now = datetime.now(timezone.utc)
24
 
@@ -28,6 +29,7 @@ def collect_telemetry(data):
28
  # Convert the UTC time to GMT+8
29
  timestamp = utc_now.astimezone(gmt_plus_8).isoformat()
30
  data['timestamp'] = timestamp
 
31
  client = MongoClient(mongodb_uri)
32
  db = client.get_database() # Use the default database specified in the URI
33
  collection = db["df_data"] # Replace "telemetry" with your desired collection name
 
19
  return
20
 
21
  try:
22
+ '''
23
  # Get the current UTC time
24
  utc_now = datetime.now(timezone.utc)
25
 
 
29
  # Convert the UTC time to GMT+8
30
  timestamp = utc_now.astimezone(gmt_plus_8).isoformat()
31
  data['timestamp'] = timestamp
32
+ '''
33
  client = MongoClient(mongodb_uri)
34
  db = client.get_database() # Use the default database specified in the URI
35
  collection = db["df_data"] # Replace "telemetry" with your desired collection name
helper/upload_File.py CHANGED
@@ -7,7 +7,7 @@ class uploadFile:
7
  def __init__(self):
8
  self.file_dict = {}
9
  self.file_gt = {}
10
-
11
  def multiple_upload_file(self, uploaded_files):
12
  for _ in range(len(self.file_dict)):
13
  self.file_dict.popitem()
 
7
  def __init__(self):
8
  self.file_dict = {}
9
  self.file_gt = {}
10
+
11
  def multiple_upload_file(self, uploaded_files):
12
  for _ in range(len(self.file_dict)):
13
  self.file_dict.popitem()
pages/home.py CHANGED
@@ -1,6 +1,5 @@
1
  import os
2
  import streamlit as st
3
- st.set_page_config(layout="wide")
4
  from classes.Off_Page import SeoOffPageAnalyst
5
  from classes.On_Page_GT import SeoOnGT
6
  from classes.On_Page_Crawl import SeoOnCrawl
@@ -12,63 +11,106 @@ from classes.Twitter import Twitter
12
  from classes.Youtube import YouTube
13
  from classes.Linkedin import Linkedin
14
  from classes.Tiktok import Tiktok
 
 
15
 
16
-
17
- # Create a dashboard that will display various agents on the page
18
- st.write("# Digital Footprint AI Team")
19
- if 'nature' not in st.session_state:
20
- st.session_state['nature'] = ''
21
- if 'analyze' not in st.session_state:
22
- st.session_state['analyze'] = False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- def row1():
25
- col1, col2, col3, col4 = st.columns(4, border=True, gap="medium", vertical_alignment="top")
26
- with col1:
27
- txt = st.text_area(
28
  "Client Summary:",
29
- f"{st.session_state.nature}",help="Name of business, nature of business, location, products/services"
 
30
  )
31
- st.session_state.nature = txt
32
- if 'analyze' not in st.session_state:
33
- st.session_state['analyze'] = False
34
 
35
- analyze_button = st.button("Analyze", st.session_state['analyze'])
36
- if analyze_button:
37
- st.session_state['analyze'] = 'clicked'
38
-
39
- with col2:
40
- st.write("## Website Traffic")
41
- backlinks = SeoOffPageAnalyst(os.getenv('MODEL_Off_Page_Analyst'))
42
- #backlinks = SeoBacklinks(os.getenv('MODEL_SEO_Analyst'))
43
- keywords = Seo(os.getenv('MODEL_SEO_Analyst'))
 
 
 
 
 
44
 
45
- with col3:
46
- st.write("## Social Media")
47
- st.write("### Facebook")
48
- facebook = Facebook(os.getenv('MODEL_Social_Media_Analyst'))
49
 
50
- st.write('### Instagram')
51
- instagram = Instagram(os.getenv('MODEL_Social_Media_Analyst'))
52
 
53
- st.write('### Twitter')
54
- twitter = Twitter(os.getenv('MODEL_Social_Media_Analyst'))
55
 
56
- st.write('### YouTube')
57
- youtube = YouTube(os.getenv('MODEL_Social_Media_Analyst'))
 
 
 
58
 
59
- st.write('### Linkedin')
60
- linkedin = Linkedin(os.getenv('MODEL_Social_Media_Analyst'))
61
 
62
- st.write('### Tiktok')
63
- tiktok = Tiktok(os.getenv('MODEL_Social_Media_Analyst'))
 
 
64
 
65
- with col4:
66
- st.write("## Website Structure")
67
- crawl = SeoOnCrawl(os.getenv('MODEL_On_Page_Analyst'))
68
- gtmetrix = SeoOnGT(os.getenv('MODEL_On_Page_Analyst'))
69
-
70
 
71
- return col1, col2, col3, col4
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- row1()
 
 
 
74
 
 
 
 
 
 
1
  import os
2
  import streamlit as st
 
3
  from classes.Off_Page import SeoOffPageAnalyst
4
  from classes.On_Page_GT import SeoOnGT
5
  from classes.On_Page_Crawl import SeoOnCrawl
 
11
  from classes.Youtube import YouTube
12
  from classes.Linkedin import Linkedin
13
  from classes.Tiktok import Tiktok
14
+ import asyncio
15
+ import time
16
 
17
+ class DigitalFootprintDashboard:
18
+ def __init__(self):
19
+ # Set page configuration
20
+ st.set_page_config(layout="wide")
21
+
22
+ # Initialize session state variables
23
+ self._init_session_state()
24
+
25
+ # Create dashboard title
26
+ st.write("# Digital Footprint AI Team")
27
+
28
+ def _init_session_state(self):
29
+ """Initialize session state variables if they don't exist"""
30
+ if 'nature' not in st.session_state:
31
+ st.session_state['nature'] = ''
32
+ if 'analyze' not in st.session_state:
33
+ st.session_state['analyze'] = ''
34
+ if 'seo' not in st.session_state:
35
+ st.session_state['seo'] = ''
36
+ if 'twitter' not in st.session_state:
37
+ st.session_state['twitter'] = ''
38
+
39
+ async def create_row1(self):
40
+ """Create the first row with four columns"""
41
+ col1, col2, col3, col4 = st.columns(4, border=True, gap="medium", vertical_alignment="top")
42
 
43
+ with col1:
44
+ txt = st.text_area(
 
 
45
  "Client Summary:",
46
+ f"{st.session_state.nature}",
47
+ help="Name of business, nature of business, location, products/services"
48
  )
49
+ st.session_state.nature = txt
 
 
50
 
51
+ analyze_button = st.button("Analyze", st.session_state['analyze'])
52
+ if analyze_button == True:
53
+ st.session_state["analyze"] = 'clicked'
54
+ st.session_state['seo'] = 'clicked'
55
+ st.session_state['twitter'] = 'clicked'
56
+ else:
57
+ st.session_state["analyze"] = ''
58
+ st.session_state['seo'] = ''
59
+ st.session_state['twitter'] = ''
60
+
61
+ with col2:
62
+ st.write("## Website Traffic")
63
+ self.backlinks = SeoOffPageAnalyst(os.getenv('MODEL_Off_Page_Analyst'))
64
+ self.keywords = Seo(os.getenv('MODEL_SEO_Analyst'))
65
 
66
+ with col3:
67
+ st.write("## Social Media")
68
+ st.write("### Facebook")
69
+ self.facebook = Facebook(os.getenv('MODEL_Social_Media_Analyst'))
70
 
71
+ st.write('### Instagram')
72
+ self.instagram = Instagram(os.getenv('MODEL_Social_Media_Analyst'))
73
 
74
+ st.write('### Twitter')
75
+ self.twitter = Twitter(os.getenv('MODEL_Social_Media_Analyst'))
76
 
77
+ st.write('### YouTube')
78
+ self.youtube = YouTube(os.getenv('MODEL_Social_Media_Analyst'))
79
+
80
+ st.write('### Linkedin')
81
+ self.linkedin = Linkedin(os.getenv('MODEL_Social_Media_Analyst'))
82
 
83
+ st.write('### Tiktok')
84
+ self.tiktok = Tiktok(os.getenv('MODEL_Social_Media_Analyst'))
85
 
86
+ with col4:
87
+ st.write("## Website Structure")
88
+ self.crawl = SeoOnCrawl(os.getenv('MODEL_On_Page_Analyst'))
89
+ self.gtmetrix = SeoOnGT(os.getenv('MODEL_On_Page_Analyst'))
90
 
91
+ return col1, col2, col3, col4
 
 
 
 
92
 
93
+ async def run_analysis(self):
94
+ result = await asyncio.gather(
95
+ self.gtmetrix.process(),
96
+ self.backlinks.process(),
97
+ self.keywords.process(),
98
+ self.facebook.process(),
99
+ self.instagram.process(),
100
+ self.twitter.process(),
101
+ self.youtube.process(),
102
+ self.linkedin.process(),
103
+ self.tiktok.process(),
104
+ self.crawl.process()
105
+ )
106
+ st.session_state.analyze = False
107
 
108
+ async def main(self):
109
+ """Main method to run the dashboard"""
110
+ await self.create_row1()
111
+ self.run_analysis()
112
 
113
+ # Main execution
114
+ if __name__ == "__main__":
115
+ dashboard = DigitalFootprintDashboard()
116
+ asyncio.run(dashboard.main())