Spaces:
Build error
Build error
Ronio Jerico Roque commited on
Commit ·
15ad021
1
Parent(s): 086d004
Add SEM/PPC analysis functionality and integrate into concurrent execution
Browse files- pages/analyzing_page.py +22 -2
pages/analyzing_page.py
CHANGED
|
@@ -10,6 +10,7 @@ from classes.response_social_media import SocialMedia
|
|
| 10 |
from classes.response_lld_pm_ln import LLD_PM_LN
|
| 11 |
from classes.response_pull_through_offers import PullThroughOffers
|
| 12 |
from classes.response_content import Content
|
|
|
|
| 13 |
|
| 14 |
def run_analysis():
|
| 15 |
# Placeholders for status updates
|
|
@@ -21,7 +22,8 @@ def run_analysis():
|
|
| 21 |
lld_pm_ln_status = st.empty()
|
| 22 |
pull_through_offers_status = st.empty()
|
| 23 |
content_status = st.empty()
|
| 24 |
-
|
|
|
|
| 25 |
def run_off_page_analysis():
|
| 26 |
try:
|
| 27 |
off_page_status.info("Starting SEO Off Page Analysis...")
|
|
@@ -32,7 +34,6 @@ def run_analysis():
|
|
| 32 |
off_page_status.error(f"SEO Off Page Analysis failed: {e}")
|
| 33 |
return None
|
| 34 |
|
| 35 |
-
# Function to run On Page Analysis
|
| 36 |
def run_on_page_analysis():
|
| 37 |
try:
|
| 38 |
on_page_status.info("Starting On Page Analysis...")
|
|
@@ -52,6 +53,7 @@ def run_analysis():
|
|
| 52 |
except Exception as e:
|
| 53 |
on_page_status.error(f"Website and Tools Analysis failed: {e}")
|
| 54 |
return None
|
|
|
|
| 55 |
def run_seo_analysis():
|
| 56 |
try:
|
| 57 |
seo_status.info("Starting SEO Analysis...")
|
|
@@ -71,6 +73,7 @@ def run_analysis():
|
|
| 71 |
except Exception as e:
|
| 72 |
social_media_status.error(f"Social Media Analysis failed: {e}")
|
| 73 |
return None
|
|
|
|
| 74 |
def run_lld_pm_ln():
|
| 75 |
try:
|
| 76 |
lld_pm_ln_status.info("Starting LLD/PM/LN Analysis...")
|
|
@@ -80,6 +83,7 @@ def run_analysis():
|
|
| 80 |
except Exception as e:
|
| 81 |
lld_pm_ln_status.error(f"LLD/PM/LN Analysis failed: {e}")
|
| 82 |
return None
|
|
|
|
| 83 |
def run_pull_through_offers():
|
| 84 |
try:
|
| 85 |
pull_through_offers_status.info("Starting Pull through offer Analysis...")
|
|
@@ -89,6 +93,7 @@ def run_analysis():
|
|
| 89 |
except Exception as e:
|
| 90 |
pull_through_offers_status.error(f"Pull through offer Analysis failed: {e}")
|
| 91 |
return None
|
|
|
|
| 92 |
def run_content():
|
| 93 |
try:
|
| 94 |
content_status.info("Starting Content Analysis...")
|
|
@@ -98,6 +103,16 @@ def run_analysis():
|
|
| 98 |
except Exception as e:
|
| 99 |
content_status.error(f"Content Analysis failed: {e}")
|
| 100 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
# Create threads for concurrent execution
|
| 103 |
off_page_thread = threading.Thread(target=run_off_page_analysis)
|
|
@@ -108,6 +123,7 @@ def run_analysis():
|
|
| 108 |
llm_pm_ln_thread = threading.Thread(target=run_lld_pm_ln)
|
| 109 |
pull_through_offers_thread = threading.Thread(target=run_pull_through_offers)
|
| 110 |
content_thread = threading.Thread(target=run_content)
|
|
|
|
| 111 |
|
| 112 |
# Attach Streamlit context to threads
|
| 113 |
add_script_run_ctx(off_page_thread)
|
|
@@ -118,6 +134,7 @@ def run_analysis():
|
|
| 118 |
add_script_run_ctx(llm_pm_ln_thread)
|
| 119 |
add_script_run_ctx(pull_through_offers_thread)
|
| 120 |
add_script_run_ctx(content_thread)
|
|
|
|
| 121 |
|
| 122 |
# Start threads
|
| 123 |
off_page_thread.start()
|
|
@@ -128,6 +145,8 @@ def run_analysis():
|
|
| 128 |
llm_pm_ln_thread.start()
|
| 129 |
pull_through_offers_thread.start()
|
| 130 |
content_thread.start()
|
|
|
|
|
|
|
| 131 |
|
| 132 |
# Wait for threads to complete
|
| 133 |
off_page_thread.join()
|
|
@@ -138,6 +157,7 @@ def run_analysis():
|
|
| 138 |
llm_pm_ln_thread.join()
|
| 139 |
pull_through_offers_thread.join()
|
| 140 |
content_thread.join()
|
|
|
|
| 141 |
|
| 142 |
st.success("🎉 All analyses completed!") # Final success message
|
| 143 |
# --- Display Button After Completion ---
|
|
|
|
| 10 |
from classes.response_lld_pm_ln import LLD_PM_LN
|
| 11 |
from classes.response_pull_through_offers import PullThroughOffers
|
| 12 |
from classes.response_content import Content
|
| 13 |
+
from classes.response_sem_ppc import Sem_PPC
|
| 14 |
|
| 15 |
def run_analysis():
|
| 16 |
# Placeholders for status updates
|
|
|
|
| 22 |
lld_pm_ln_status = st.empty()
|
| 23 |
pull_through_offers_status = st.empty()
|
| 24 |
content_status = st.empty()
|
| 25 |
+
sem_ppc = st.empty()
|
| 26 |
+
|
| 27 |
def run_off_page_analysis():
|
| 28 |
try:
|
| 29 |
off_page_status.info("Starting SEO Off Page Analysis...")
|
|
|
|
| 34 |
off_page_status.error(f"SEO Off Page Analysis failed: {e}")
|
| 35 |
return None
|
| 36 |
|
|
|
|
| 37 |
def run_on_page_analysis():
|
| 38 |
try:
|
| 39 |
on_page_status.info("Starting On Page Analysis...")
|
|
|
|
| 53 |
except Exception as e:
|
| 54 |
on_page_status.error(f"Website and Tools Analysis failed: {e}")
|
| 55 |
return None
|
| 56 |
+
|
| 57 |
def run_seo_analysis():
|
| 58 |
try:
|
| 59 |
seo_status.info("Starting SEO Analysis...")
|
|
|
|
| 73 |
except Exception as e:
|
| 74 |
social_media_status.error(f"Social Media Analysis failed: {e}")
|
| 75 |
return None
|
| 76 |
+
|
| 77 |
def run_lld_pm_ln():
|
| 78 |
try:
|
| 79 |
lld_pm_ln_status.info("Starting LLD/PM/LN Analysis...")
|
|
|
|
| 83 |
except Exception as e:
|
| 84 |
lld_pm_ln_status.error(f"LLD/PM/LN Analysis failed: {e}")
|
| 85 |
return None
|
| 86 |
+
|
| 87 |
def run_pull_through_offers():
|
| 88 |
try:
|
| 89 |
pull_through_offers_status.info("Starting Pull through offer Analysis...")
|
|
|
|
| 93 |
except Exception as e:
|
| 94 |
pull_through_offers_status.error(f"Pull through offer Analysis failed: {e}")
|
| 95 |
return None
|
| 96 |
+
|
| 97 |
def run_content():
|
| 98 |
try:
|
| 99 |
content_status.info("Starting Content Analysis...")
|
|
|
|
| 103 |
except Exception as e:
|
| 104 |
content_status.error(f"Content Analysis failed: {e}")
|
| 105 |
return None
|
| 106 |
+
|
| 107 |
+
def run_sem_ppc_analysis():
|
| 108 |
+
try:
|
| 109 |
+
sem_ppc.info("Starting SEM/PPC Analysis...")
|
| 110 |
+
result = Sem_PPC(os.getenv('Model_SEM_PPC_Analyst'))
|
| 111 |
+
sem_ppc.success("SEM/PPC Analysis completed successfully.")
|
| 112 |
+
return result
|
| 113 |
+
except Exception as e:
|
| 114 |
+
sem_ppc.error(f"SEM/PPC Analysis failed: {e}")
|
| 115 |
+
return None
|
| 116 |
|
| 117 |
# Create threads for concurrent execution
|
| 118 |
off_page_thread = threading.Thread(target=run_off_page_analysis)
|
|
|
|
| 123 |
llm_pm_ln_thread = threading.Thread(target=run_lld_pm_ln)
|
| 124 |
pull_through_offers_thread = threading.Thread(target=run_pull_through_offers)
|
| 125 |
content_thread = threading.Thread(target=run_content)
|
| 126 |
+
content_sem_ppc_thread = threading.Thread(target=run_sem_ppc_analysis)
|
| 127 |
|
| 128 |
# Attach Streamlit context to threads
|
| 129 |
add_script_run_ctx(off_page_thread)
|
|
|
|
| 134 |
add_script_run_ctx(llm_pm_ln_thread)
|
| 135 |
add_script_run_ctx(pull_through_offers_thread)
|
| 136 |
add_script_run_ctx(content_thread)
|
| 137 |
+
add_script_run_ctx(content_sem_ppc_thread)
|
| 138 |
|
| 139 |
# Start threads
|
| 140 |
off_page_thread.start()
|
|
|
|
| 145 |
llm_pm_ln_thread.start()
|
| 146 |
pull_through_offers_thread.start()
|
| 147 |
content_thread.start()
|
| 148 |
+
content_sem_ppc_thread.start()
|
| 149 |
+
|
| 150 |
|
| 151 |
# Wait for threads to complete
|
| 152 |
off_page_thread.join()
|
|
|
|
| 157 |
llm_pm_ln_thread.join()
|
| 158 |
pull_through_offers_thread.join()
|
| 159 |
content_thread.join()
|
| 160 |
+
content_sem_ppc_thread.join()
|
| 161 |
|
| 162 |
st.success("🎉 All analyses completed!") # Final success message
|
| 163 |
# --- Display Button After Completion ---
|