Spaces:
Build error
Build error
File size: 7,956 Bytes
d517f9a 87902a2 d517f9a 87902a2 540bd44 87902a2 540bd44 87902a2 d517f9a 87902a2 540bd44 87902a2 540bd44 87902a2 540bd44 87902a2 d517f9a 87902a2 540bd44 87902a2 d517f9a 87902a2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | import streamlit as st
from dotenv import load_dotenv
from helper.telemetry import collect_telemetry
from helper.upload_File import uploadFile
from helper.button_behaviour import hide_button
class Sem_PPC:
def __init__(self, model_url):
self.file_dict = {}
self.model_url = model_url
#self.analyst_name = analyst_name
#self.data_src = data_src
#self.analyst_description = analyst_description
self.initialize()
self.row1()
def initialize(self):
# FOR ENV
load_dotenv()
'''
# AGENT NAME
st.header(self.analyst_name)
# EVALUATION FORM LINK
url = os.getenv('Link')
st.write('Evaluation Form: [Link](%s)' % url)
# RETURN BUTTON
try:
if st.button("Return", type='primary'):
st.switch_page("./pages/home.py")
except Exception:
pass
'''
if 'account_set_up' not in st.session_state:
st.session_state['account_set_up'] = ''
if 'search_ads' not in st.session_state:
st.session_state['search_ads'] = ''
if 'display_ads' not in st.session_state:
st.session_state['display_ads'] = ''
if 'mobile_ads' not in st.session_state:
st.session_state['mobile_ads'] = ''
if 'video_ads' not in st.session_state:
st.session_state['video_ads'] = ''
if 'shopping_ads' not in st.session_state:
st.session_state['shopping_ads'] = ''
def process(self):
session = st.session_state.analyze
if (self.account_set_up or self.search_ads or self.display_ads or self.mobile_ads or self.video_ads or self.shopping_ads) and session == 'clicked':
try:
account_set_up = ""
search_ads = ""
display_ads = ""
mobile_ads = ""
video_ads = ""
shopping_ads = ""
with st.spinner('Uploading SEM/PPC...', show_time=True):
st.write('')
# INITIALIZING SESSIONS
#combined_text += f"Client Summary: {st.session_state.nature}\n"
try:
account_set_up += f"\nAccount Set Up: {self.account_set_up}"
except KeyError:
pass
try:
search_ads += f"\nSearch Ads: {self.search_ads}"
except KeyError:
pass
try:
display_ads += f"\nDisplay Ads: {self.display_ads}"
except KeyError:
pass
try:
mobile_ads += f"\nMobile Ads: {self.mobile_ads}"
except KeyError:
pass
try:
video_ads += f"\nVideo Ads: {self.video_ads}"
except KeyError:
pass
try:
shopping_ads += f"\nShopping Ads: {self.shopping_ads}"
except KeyError:
pass
# OUTPUT FOR SEO ANALYST
#payload_txt = {"question": combined_text}
#result = self.request_model(payload_txt)
#end_time = time.time()
#time_lapsed = end_time - start_time
debug_info_account_set_up = {'data_field' : 'Account Set Up - Google Ads', 'result': account_set_up}
debug_info_search_ads = {'data_field' : 'Search Ads - Google Ads/SEMRush', 'result': search_ads}
debug_info_display_ads = {'data_field' : 'Display Ads - Google Ads/SEMRush', 'result': display_ads}
debug_info_mobile_ads = {'data_field' : 'Mobile Ads - Google Ads', 'result': mobile_ads}
debug_info_video_ads = {'data_field' : 'Video Ads - Google Ads', 'result': video_ads}
debug_info_shopping_ads = {'data_field' : 'Shopping Ads - Google Ads/SEMRush', 'result': shopping_ads}
'''
debug_info = {
#'analyst': self.analyst_name,
'url_uuid': self.model_url.split("-")[-1],
'time_lapsed': time_lapsed,
'payload': payload_txt,
'result': result,
}
'''
if self.account_set_up:
st.session_state['account_set_up'] = 'uploaded'
collect_telemetry(debug_info_account_set_up)
if self.search_ads:
st.session_state['search_ads'] = 'uploaded'
collect_telemetry(debug_info_search_ads)
if self.display_ads:
st.session_state['display_ads'] = 'uploaded'
collect_telemetry(debug_info_display_ads)
if self.mobile_ads:
st.session_state['mobile_ads'] = 'uploaded'
collect_telemetry(debug_info_mobile_ads)
if self.video_ads:
st.session_state['video_ads'] = 'uploaded'
collect_telemetry(debug_info_video_ads)
if self.shopping_ads:
st.session_state['shopping_ads'] = 'uploaded'
collect_telemetry(debug_info_shopping_ads)
#with st.expander("Debug information", icon="⚙"):
# st.write(debug_info)
st.session_state['analyzing'] = False
except AttributeError:
st.info("Please upload CSV or PDF files first.")
hide_button()
def row1(self):
self.account_set_up = st.text_input("Account Set Up - Google Ads:", placeholder='Enter Account Set Up')
self.search_ads = st.checkbox("Search Ads - Google Ads/SEMRush")
self.display_ads = st.checkbox("Display Ads - Google Ads/SEMRush")
self.mobile_ads = st.checkbox("Mobile Ads - Google Ads")
self.video_ads = st.checkbox("Video Ads - Google Ads")
self.shopping_ads = st.checkbox("Shopping Ads - Google Ads/SEMRush")
'''
st.write("") # FOR THE HIDE BUTTON
st.write("") # FOR THE HIDE BUTTON
st.write("AI Analyst Output: ")
st.session_state['analyzing'] = False
st.write("") # FOR THE HIDE BUTTON'
'''
#analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
self.process()
if __name__ == "__main__":
st.set_page_config(layout="wide")
upload = uploadFile()
|