Spaces:
Build error
Build error
Ronio Jerico Roque commited on
Commit ·
3a2bd5f
1
Parent(s): 52412d3
Integrate Client Summary into multiple response classes
Browse files- classes/client_summary.py +0 -6
- classes/response_content.py +2 -0
- classes/response_lld_pm_ln.py +2 -0
- classes/response_marketplace.py +2 -0
- classes/response_off.py +42 -27
- classes/response_on_page.py +2 -0
- classes/response_pull_through_offers.py +2 -0
- classes/response_sem_ppc.py +2 -0
- classes/response_seo.py +2 -1
- classes/response_social_media.py +2 -0
- classes/response_website_and_tools.py +2 -1
classes/client_summary.py
CHANGED
|
@@ -1,11 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
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
|
| 10 |
from helper.upload_File import uploadFile
|
| 11 |
from helper.button_behaviour import hide_button
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
from dotenv import load_dotenv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from helper.telemetry import collect_telemetry
|
| 4 |
from helper.upload_File import uploadFile
|
| 5 |
from helper.button_behaviour import hide_button
|
classes/response_content.py
CHANGED
|
@@ -138,6 +138,8 @@ class Content:
|
|
| 138 |
pass
|
| 139 |
|
| 140 |
if count >= 1:
|
|
|
|
|
|
|
| 141 |
self.process()
|
| 142 |
|
| 143 |
if __name__ == "__main__":
|
|
|
|
| 138 |
pass
|
| 139 |
|
| 140 |
if count >= 1:
|
| 141 |
+
summary = self.fetch_data("Client Summary")
|
| 142 |
+
self.payload = summary + self.payload
|
| 143 |
self.process()
|
| 144 |
|
| 145 |
if __name__ == "__main__":
|
classes/response_lld_pm_ln.py
CHANGED
|
@@ -122,6 +122,8 @@ class LLD_PM_LN:
|
|
| 122 |
except Exception as e:
|
| 123 |
pass
|
| 124 |
if count >= 1:
|
|
|
|
|
|
|
| 125 |
self.process()
|
| 126 |
|
| 127 |
if __name__ == "__main__":
|
|
|
|
| 122 |
except Exception as e:
|
| 123 |
pass
|
| 124 |
if count >= 1:
|
| 125 |
+
summary = self.fetch_data("Client Summary")
|
| 126 |
+
self.payload = summary + self.payload
|
| 127 |
self.process()
|
| 128 |
|
| 129 |
if __name__ == "__main__":
|
classes/response_marketplace.py
CHANGED
|
@@ -157,6 +157,8 @@ class Marketplace:
|
|
| 157 |
pass
|
| 158 |
|
| 159 |
if count >= 1:
|
|
|
|
|
|
|
| 160 |
self.process()
|
| 161 |
|
| 162 |
|
|
|
|
| 157 |
pass
|
| 158 |
|
| 159 |
if count >= 1:
|
| 160 |
+
summary = self.fetch_data("Client Summary")
|
| 161 |
+
self.payload = summary + self.payload
|
| 162 |
self.process()
|
| 163 |
|
| 164 |
|
classes/response_off.py
CHANGED
|
@@ -45,38 +45,53 @@ class SeoOffPageAnalyst:
|
|
| 45 |
|
| 46 |
return text
|
| 47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def process(self):
|
| 49 |
-
|
| 50 |
-
if session == 'uploaded':
|
| 51 |
-
with st.spinner('SEO Off Page Analyst...', show_time=True):
|
| 52 |
st.write('')
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
#time_lapsed = end_time - start_time
|
| 66 |
-
|
| 67 |
-
debug_info = {'data_field' : 'Off Page Analyst', 'result': result}
|
| 68 |
-
#debug_info = {'url_uuid': self.model_url.split("-")[-1],'time_lapsed' : time_lapsed, 'files': [*st.session_state['uploaded_files']],'payload': payload_txt, 'result': result}
|
| 69 |
-
upload_response(debug_info)
|
| 70 |
-
|
| 71 |
-
#with st.expander("Debug information", icon="⚙"):
|
| 72 |
-
# st.write(debug_info)
|
| 73 |
-
st.session_state["off_page_file_uploaded"] = ''
|
| 74 |
-
st.session_state['analyzing'] = False
|
| 75 |
|
| 76 |
def row1(self):
|
| 77 |
st.session_state['analyzing'] = False
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
self.process()
|
| 81 |
|
| 82 |
|
|
|
|
| 45 |
|
| 46 |
return text
|
| 47 |
|
| 48 |
+
def fetch_data(self, data_field):
|
| 49 |
+
mongodb_uri = os.getenv("MONGODB_URI")
|
| 50 |
+
myclient = MongoClient(mongodb_uri)
|
| 51 |
+
mydb = myclient.get_database()
|
| 52 |
+
mycol = mydb["df_data"]
|
| 53 |
+
|
| 54 |
+
# Sort by timestamp field in descending order
|
| 55 |
+
x = mycol.find_one(
|
| 56 |
+
{"data_field": data_field},
|
| 57 |
+
sort=[("timestamp", -1)]
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
x = x["result"]
|
| 61 |
+
return x
|
| 62 |
+
|
| 63 |
def process(self):
|
| 64 |
+
with st.spinner('SEO Off Page Analyst...', show_time=True):
|
|
|
|
|
|
|
| 65 |
st.write('')
|
| 66 |
+
headers = {"Content-Type": "application/json", "x-api-key": f"{os.getenv('x-api-key')}"}
|
| 67 |
+
try:
|
| 68 |
+
payload_txt = {"input_value": self.payload, "output_type": "text", "input_type": "chat"}
|
| 69 |
+
payload_txt_model = self.request_model(payload_txt, headers)
|
| 70 |
+
debug_info = {'data_field' : 'SEO Off Page Analyst', 'result': payload_txt_model}
|
| 71 |
+
upload_response(debug_info)
|
| 72 |
+
|
| 73 |
+
st.session_state['off_page_file_uploaded'] = ''
|
| 74 |
+
count = 0
|
| 75 |
+
except Exception as e:
|
| 76 |
+
pass
|
| 77 |
+
st.session_state['analyzing'] = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
def row1(self):
|
| 80 |
st.session_state['analyzing'] = False
|
| 81 |
+
self.payload = ""
|
| 82 |
+
count = 0
|
| 83 |
+
try:
|
| 84 |
+
session_off_page_file_uploaded = st.session_state['off_page_file_uploaded']
|
| 85 |
+
if session_off_page_file_uploaded == 'uploaded':
|
| 86 |
+
count += 1
|
| 87 |
+
self.payload += self.fetch_data("Backlinks")
|
| 88 |
+
|
| 89 |
+
except Exception as e:
|
| 90 |
+
pass
|
| 91 |
+
|
| 92 |
+
if count >= 1:
|
| 93 |
+
summary = self.fetch_data("Client Summary")
|
| 94 |
+
self.payload = summary + self.payload
|
| 95 |
self.process()
|
| 96 |
|
| 97 |
|
classes/response_on_page.py
CHANGED
|
@@ -112,6 +112,8 @@ class SeoOn:
|
|
| 112 |
except Exception as e:
|
| 113 |
pass
|
| 114 |
if count >= 1:
|
|
|
|
|
|
|
| 115 |
self.process()
|
| 116 |
|
| 117 |
|
|
|
|
| 112 |
except Exception as e:
|
| 113 |
pass
|
| 114 |
if count >= 1:
|
| 115 |
+
summary = self.fetch_data("Client Summary")
|
| 116 |
+
self.payload = summary + self.payload
|
| 117 |
self.process()
|
| 118 |
|
| 119 |
|
classes/response_pull_through_offers.py
CHANGED
|
@@ -128,6 +128,8 @@ class PullThroughOffers:
|
|
| 128 |
pass
|
| 129 |
|
| 130 |
if count >= 1:
|
|
|
|
|
|
|
| 131 |
self.process()
|
| 132 |
|
| 133 |
if __name__ == "__main__":
|
|
|
|
| 128 |
pass
|
| 129 |
|
| 130 |
if count >= 1:
|
| 131 |
+
summary = self.fetch_data("Client Summary")
|
| 132 |
+
self.payload = summary + self.payload
|
| 133 |
self.process()
|
| 134 |
|
| 135 |
if __name__ == "__main__":
|
classes/response_sem_ppc.py
CHANGED
|
@@ -149,6 +149,8 @@ class Sem_PPC:
|
|
| 149 |
pass
|
| 150 |
|
| 151 |
if count >= 1:
|
|
|
|
|
|
|
| 152 |
self.process()
|
| 153 |
|
| 154 |
|
|
|
|
| 149 |
pass
|
| 150 |
|
| 151 |
if count >= 1:
|
| 152 |
+
summary = self.fetch_data("Client Summary")
|
| 153 |
+
self.payload = summary + self.payload
|
| 154 |
self.process()
|
| 155 |
|
| 156 |
|
classes/response_seo.py
CHANGED
|
@@ -213,12 +213,13 @@ class Seo:
|
|
| 213 |
try:
|
| 214 |
session_backlinks = st.session_state["off_page_file_uploaded"]
|
| 215 |
if session_backlinks == 'uploaded':
|
| 216 |
-
count += 1
|
| 217 |
self.payload += self.fetch_backlinks("Backlinks")
|
| 218 |
except Exception as e:
|
| 219 |
pass
|
| 220 |
|
| 221 |
if count >= 1:
|
|
|
|
|
|
|
| 222 |
self.process()
|
| 223 |
|
| 224 |
|
|
|
|
| 213 |
try:
|
| 214 |
session_backlinks = st.session_state["off_page_file_uploaded"]
|
| 215 |
if session_backlinks == 'uploaded':
|
|
|
|
| 216 |
self.payload += self.fetch_backlinks("Backlinks")
|
| 217 |
except Exception as e:
|
| 218 |
pass
|
| 219 |
|
| 220 |
if count >= 1:
|
| 221 |
+
summary = self.fetch_data("Client Summary")
|
| 222 |
+
self.payload = summary + self.payload
|
| 223 |
self.process()
|
| 224 |
|
| 225 |
|
classes/response_social_media.py
CHANGED
|
@@ -146,6 +146,8 @@ class SocialMedia:
|
|
| 146 |
except Exception as e:
|
| 147 |
pass
|
| 148 |
if count >= 1:
|
|
|
|
|
|
|
| 149 |
self.process()
|
| 150 |
|
| 151 |
|
|
|
|
| 146 |
except Exception as e:
|
| 147 |
pass
|
| 148 |
if count >= 1:
|
| 149 |
+
summary = self.fetch_data("Client Summary")
|
| 150 |
+
self.payload = summary + self.payload
|
| 151 |
self.process()
|
| 152 |
|
| 153 |
|
classes/response_website_and_tools.py
CHANGED
|
@@ -126,7 +126,6 @@ class WebsiteAndTools:
|
|
| 126 |
def row1(self):
|
| 127 |
st.session_state['analyzing'] = False
|
| 128 |
self.payload = ""
|
| 129 |
-
|
| 130 |
count = 0
|
| 131 |
try:
|
| 132 |
session_website_responsiveness = st.session_state['website_responsiveness']
|
|
@@ -195,6 +194,8 @@ class WebsiteAndTools:
|
|
| 195 |
|
| 196 |
|
| 197 |
if count >= 1:
|
|
|
|
|
|
|
| 198 |
self.process()
|
| 199 |
|
| 200 |
if __name__ == "__main__":
|
|
|
|
| 126 |
def row1(self):
|
| 127 |
st.session_state['analyzing'] = False
|
| 128 |
self.payload = ""
|
|
|
|
| 129 |
count = 0
|
| 130 |
try:
|
| 131 |
session_website_responsiveness = st.session_state['website_responsiveness']
|
|
|
|
| 194 |
|
| 195 |
|
| 196 |
if count >= 1:
|
| 197 |
+
summary = self.fetch_data("Client Summary")
|
| 198 |
+
self.payload = summary + self.payload
|
| 199 |
self.process()
|
| 200 |
|
| 201 |
if __name__ == "__main__":
|