Ronio Jerico Roque commited on
Commit
d517f9a
·
1 Parent(s): 62ad563

Add Sem_PPC class for managing Google Ads input and telemetry collection

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