Ronio Jerico Roque commited on
Commit
7b96aa1
·
1 Parent(s): e24d810

Refactor Amazon and eBay classes to implement marketplace questionnaires; update session state management and input handling in response marketplace.

Browse files
classes/amazon.py CHANGED
@@ -31,7 +31,7 @@ class Amazon:
31
  st.switch_page("./pages/home.py")
32
  except Exception:
33
  pass
34
- '''
35
  if 'product_title_amazon' not in st.session_state:
36
  st.session_state['product_title_amazon'] = ''
37
  if 'images_amazon' not in st.session_state:
@@ -40,20 +40,25 @@ class Amazon:
40
  st.session_state['bullet_points_amazon'] = ''
41
  if 'product_description_amazon' not in st.session_state:
42
  st.session_state['product_description_amazon'] = ''
 
 
 
43
 
44
  def process(self):
45
  session = st.session_state.analyze
46
- if (self.product_title_amazon or self.images_amazon or self.bullet_points_amazon or self.product_description_amazon) and session == 'clicked':
47
  try:
48
- product_title_amazon = ""
49
- images_amazon = ""
50
- bullet_points_amazon = ""
51
- product_description_amazon = ""
 
52
 
53
  with st.spinner('Aamzon...', show_time=True):
54
  st.write('')
55
  # INITIALIZING SESSIONS
56
  #combined_text += f"Client Summary: {st.session_state.nature}\n"
 
57
  try:
58
  product_title_amazon += f"\nProduct Title: {self.product_title_amazon}"
59
  except KeyError:
@@ -70,6 +75,11 @@ class Amazon:
70
  product_description_amazon += f"\nProduct Description: {self.product_description_amazon}"
71
  except KeyError:
72
  pass
 
 
 
 
 
73
 
74
  # OUTPUT FOR SEO ANALYST
75
  #payload_txt = {"question": combined_text}
@@ -77,11 +87,13 @@ class Amazon:
77
 
78
  #end_time = time.time()
79
  #time_lapsed = end_time - start_time
80
-
81
  debug_info_product_title_amazon = {'data_field' : 'Product Title - Amazon', 'result': self.product_title_amazon}
82
  debug_info_images_amazon = {'data_field' : 'Images - Amazon', 'result': self.images_amazon}
83
  debug_info_bullet_points_amazon = {'data_field' : 'Bullet Points - Amazon', 'result': self.bullet_points_amazon}
84
  debug_product_description_amazon = {'data_field' : 'Product Description - Amazon', 'result': self.product_description_amazon}
 
 
85
 
86
  '''
87
  debug_info = {
@@ -91,7 +103,6 @@ class Amazon:
91
  'payload': payload_txt,
92
  'result': result,
93
  }
94
- '''
95
  if self.product_title_amazon:
96
  st.session_state['product_title_amazon'] = 'uploaded'
97
  collect_telemetry(debug_info_product_title_amazon)
@@ -104,6 +115,10 @@ class Amazon:
104
  if self.product_description_amazon:
105
  st.session_state['product_description_amazon'] = 'uploaded'
106
  collect_telemetry(debug_product_description_amazon)
 
 
 
 
107
 
108
 
109
  st.session_state['analyzing'] = False
@@ -112,11 +127,38 @@ class Amazon:
112
  hide_button()
113
 
114
  def row1(self):
115
- self.product_title_amazon = st.text_input("Product Title - Amazon:", placeholder='Enter Product Title')
116
- self.images_amazon = st.text_input("Images - Amazon:", placeholder='Enter Images')
117
- self.bullet_points_amazon = st.text_input("Bullet Points - Amazon:", placeholder='Enter Bullet Points')
118
- self.product_description_amazon = st.text_input("Product Description - Amazon:", placeholder='Enter Product Description')
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  self.process()
121
 
122
  if __name__ == "__main__":
 
31
  st.switch_page("./pages/home.py")
32
  except Exception:
33
  pass
34
+
35
  if 'product_title_amazon' not in st.session_state:
36
  st.session_state['product_title_amazon'] = ''
37
  if 'images_amazon' not in st.session_state:
 
40
  st.session_state['bullet_points_amazon'] = ''
41
  if 'product_description_amazon' not in st.session_state:
42
  st.session_state['product_description_amazon'] = ''
43
+ '''
44
+ if 'amazon_marketplace_questionnaires' not in st.session_state:
45
+ st.session_state['amazon_marketplace_questionnaires'] = ''
46
 
47
  def process(self):
48
  session = st.session_state.analyze
49
+ if (self.amazon_marketplace_questionnaires) and session == 'clicked':
50
  try:
51
+ #product_title_amazon = ""
52
+ #images_amazon = ""
53
+ #bullet_points_amazon = ""
54
+ #product_description_amazon = ""
55
+ amazon_marketplace_questionnaires = ""
56
 
57
  with st.spinner('Aamzon...', show_time=True):
58
  st.write('')
59
  # INITIALIZING SESSIONS
60
  #combined_text += f"Client Summary: {st.session_state.nature}\n"
61
+ '''
62
  try:
63
  product_title_amazon += f"\nProduct Title: {self.product_title_amazon}"
64
  except KeyError:
 
75
  product_description_amazon += f"\nProduct Description: {self.product_description_amazon}"
76
  except KeyError:
77
  pass
78
+ '''
79
+ try:
80
+ amazon_marketplace_questionnaires += f"Marketplace Questionnaires - Amazon: {self.amazon_marketplace_questionnaires}"
81
+ except KeyError:
82
+ pass
83
 
84
  # OUTPUT FOR SEO ANALYST
85
  #payload_txt = {"question": combined_text}
 
87
 
88
  #end_time = time.time()
89
  #time_lapsed = end_time - start_time
90
+ '''
91
  debug_info_product_title_amazon = {'data_field' : 'Product Title - Amazon', 'result': self.product_title_amazon}
92
  debug_info_images_amazon = {'data_field' : 'Images - Amazon', 'result': self.images_amazon}
93
  debug_info_bullet_points_amazon = {'data_field' : 'Bullet Points - Amazon', 'result': self.bullet_points_amazon}
94
  debug_product_description_amazon = {'data_field' : 'Product Description - Amazon', 'result': self.product_description_amazon}
95
+ '''
96
+ debug_amazon_marketplace_questionnaires = {'data_field' : 'Marketplace Questionnaires - Amazon', 'result': self.amazon_marketplace_questionnaires}
97
 
98
  '''
99
  debug_info = {
 
103
  'payload': payload_txt,
104
  'result': result,
105
  }
 
106
  if self.product_title_amazon:
107
  st.session_state['product_title_amazon'] = 'uploaded'
108
  collect_telemetry(debug_info_product_title_amazon)
 
115
  if self.product_description_amazon:
116
  st.session_state['product_description_amazon'] = 'uploaded'
117
  collect_telemetry(debug_product_description_amazon)
118
+ '''
119
+ if self.amazon_marketplace_questionnaires:
120
+ st.session_state['amazon_marketplace_questionnaires'] = 'uploaded'
121
+ collect_telemetry(debug_amazon_marketplace_questionnaires)
122
 
123
 
124
  st.session_state['analyzing'] = False
 
127
  hide_button()
128
 
129
  def row1(self):
130
+ #self.product_title_amazon = st.text_input("Product Title - Amazon:", placeholder='Enter Product Title')
131
+ #self.images_amazon = st.text_input("Images - Amazon:", placeholder='Enter Images')
132
+ #self.bullet_points_amazon = st.text_input("Bullet Points - Amazon:", placeholder='Enter Bullet Points')
133
+ #self.product_description_amazon = st.text_input("Product Description - Amazon:", placeholder='Enter Product Description')
134
 
135
+ self.amazon_marketplace_questionnaires = st.text_area(
136
+ "Marketplace Questionnaires - Amazon:",
137
+ "Product Title:\n"
138
+ "a. Does the product title include relevant keywords (e.g., Product Brand/Description + Product Line + Material or Key Ingredient + Color + Size + Quantity)?\n"
139
+ "b. Is the title within Amazon’s recommended character limit (≤200 characters)?\n"
140
+ "c. Other Remarks:\n\n"
141
+ "Images:\n"
142
+ "a. Is the main image on a pure white background?\n"
143
+ "b. Are there any logos, watermarks, or text on any images?\n"
144
+ "c. Do the images showcase the product from multiple angles?\n"
145
+ "d. Are the images high-resolution and zoomable?\n"
146
+ "e. Other Remarks:\n\n"
147
+ "Bullet Points:\n"
148
+ "a. Do the bullets exceed 250 characters?\n"
149
+ "b. Are the bullet points clear and concise?\n"
150
+ "c. Do they highlight key features, benefits, and unique selling points?\n"
151
+ "d. Are keywords naturally included in the bullet points?\n"
152
+ "e. Other Remarks:\n\n"
153
+ "Product Description:\n"
154
+ "a. Is the product description complete and well-formatted?\n"
155
+ "b. Is it within the 2000-character limit?\n"
156
+ "c. Does it include important product specifications (size, material, compatibility)?\n"
157
+ "d. Are there any customer reviews or ratings?\n"
158
+ "e. If yes, is the average rating above 4 stars?\n"
159
+ "f. Other Remarks:",
160
+ height=600
161
+ )
162
  self.process()
163
 
164
  if __name__ == "__main__":
classes/ebay.py CHANGED
@@ -31,7 +31,7 @@ class eBay:
31
  st.switch_page("./pages/home.py")
32
  except Exception:
33
  pass
34
- '''
35
  if 'product_title_ebay' not in st.session_state:
36
  st.session_state['product_title_ebay'] = ''
37
  if 'category_ebay' not in st.session_state:
@@ -40,20 +40,25 @@ class eBay:
40
  st.session_state['images_ebay'] = ''
41
  if 'product_description_ebay' not in st.session_state:
42
  st.session_state['product_description_ebay'] = ''
 
 
 
43
 
44
  def process(self):
45
  session = st.session_state.analyze
46
- if (self.product_title_ebay or self.category_ebay or self.images_ebay or self.product_description_ebay) and session == 'clicked':
47
  try:
48
- product_title_ebay = ""
49
- category_ebay = ""
50
- images_ebay = ""
51
- product_description_ebay = ""
 
52
 
53
  with st.spinner('eBay...', show_time=True):
54
  st.write('')
55
  # INITIALIZING SESSIONS
56
  #combined_text += f"Client Summary: {st.session_state.nature}\n"
 
57
  try:
58
  product_title_ebay += f"\nProduct Title: {self.product_title_ebay}"
59
  except KeyError:
@@ -70,6 +75,11 @@ class eBay:
70
  product_description_ebay += f"\nProduct Description: {self.product_description_ebay}"
71
  except KeyError:
72
  pass
 
 
 
 
 
73
 
74
  # OUTPUT FOR SEO ANALYST
75
  #payload_txt = {"question": combined_text}
@@ -78,10 +88,12 @@ class eBay:
78
  #end_time = time.time()
79
  #time_lapsed = end_time - start_time
80
 
81
- debug_info_product_title_ebay = {'data_field' : 'Product Title - eBay', 'result': self.product_title_ebay}
82
- debug_category_ebay = {'data_field' : 'Category - eBay', 'result': self.category_ebay}
83
- debug_images_ebay = {'data_field' : 'Images - eBay', 'result': self.images_ebay}
84
- debug_product_description_ebay = {'data_field' : 'Product Description - eBay', 'result': self.product_description_ebay}
 
 
85
 
86
  '''
87
  debug_info = {
@@ -91,7 +103,7 @@ class eBay:
91
  'payload': payload_txt,
92
  'result': result,
93
  }
94
- '''
95
  if self.product_title_ebay:
96
  st.session_state['product_title_ebay'] = 'uploaded'
97
  collect_telemetry(debug_info_product_title_ebay)
@@ -104,7 +116,10 @@ class eBay:
104
  if self.product_description_ebay:
105
  st.session_state['product_description_ebay'] = 'uploaded'
106
  collect_telemetry(debug_product_description_ebay)
107
-
 
 
 
108
 
109
  st.session_state['analyzing'] = False
110
  except AttributeError:
@@ -112,11 +127,35 @@ class eBay:
112
  hide_button()
113
 
114
  def row1(self):
115
- self.product_title_ebay = st.text_input("Product Title - eBay:", placeholder='Enter Product Title')
116
- self.category_ebay = st.text_input("Images - eBay:", placeholder='Enter Images')
117
- self.images_ebay = st.text_input("Bullet Points - eBay:", placeholder='Enter Bullet Points')
118
- self.product_description_ebay = st.text_input("Product Description - eBay:", placeholder='Enter Product Description')
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  self.process()
121
 
122
  if __name__ == "__main__":
 
31
  st.switch_page("./pages/home.py")
32
  except Exception:
33
  pass
34
+
35
  if 'product_title_ebay' not in st.session_state:
36
  st.session_state['product_title_ebay'] = ''
37
  if 'category_ebay' not in st.session_state:
 
40
  st.session_state['images_ebay'] = ''
41
  if 'product_description_ebay' not in st.session_state:
42
  st.session_state['product_description_ebay'] = ''
43
+ '''
44
+ if 'ebay_marketplace_questionnaires' not in st.session_state:
45
+ st.session_state['ebay_marketplace_questionnaires'] = ''
46
 
47
  def process(self):
48
  session = st.session_state.analyze
49
+ if (self.ebay_marketplace_questionnaires) and session == 'clicked':
50
  try:
51
+ #product_title_ebay = ""
52
+ #category_ebay = ""
53
+ #images_ebay = ""
54
+ #product_description_ebay = ""
55
+ ebay_marketplace_questionnaires = ""
56
 
57
  with st.spinner('eBay...', show_time=True):
58
  st.write('')
59
  # INITIALIZING SESSIONS
60
  #combined_text += f"Client Summary: {st.session_state.nature}\n"
61
+ '''
62
  try:
63
  product_title_ebay += f"\nProduct Title: {self.product_title_ebay}"
64
  except KeyError:
 
75
  product_description_ebay += f"\nProduct Description: {self.product_description_ebay}"
76
  except KeyError:
77
  pass
78
+ '''
79
+ try:
80
+ ebay_marketplace_questionnaires += f"Marketplace Questionnaires - eBay: {self.ebay_marketplace_questionnaires}"
81
+ except KeyError:
82
+ pass
83
 
84
  # OUTPUT FOR SEO ANALYST
85
  #payload_txt = {"question": combined_text}
 
88
  #end_time = time.time()
89
  #time_lapsed = end_time - start_time
90
 
91
+ #debug_info_product_title_ebay = {'data_field' : 'Product Title - eBay', 'result': self.product_title_ebay}
92
+ #debug_category_ebay = {'data_field' : 'Category - eBay', 'result': self.category_ebay}
93
+ #debug_images_ebay = {'data_field' : 'Images - eBay', 'result': self.images_ebay}
94
+ #debug_product_description_ebay = {'data_field' : 'Product Description - eBay', 'result': self.product_description_ebay}
95
+
96
+ debug_ebay_marketplace_questionnaires = {'data_field' : 'Marketplace Questionnaires - eBay', 'result': self.ebay_marketplace_questionnaires}
97
 
98
  '''
99
  debug_info = {
 
103
  'payload': payload_txt,
104
  'result': result,
105
  }
106
+
107
  if self.product_title_ebay:
108
  st.session_state['product_title_ebay'] = 'uploaded'
109
  collect_telemetry(debug_info_product_title_ebay)
 
116
  if self.product_description_ebay:
117
  st.session_state['product_description_ebay'] = 'uploaded'
118
  collect_telemetry(debug_product_description_ebay)
119
+ '''
120
+ if self.ebay_marketplace_questionnaires:
121
+ st.session_state['ebay_marketplace_questionnaires'] = 'uploaded'
122
+ collect_telemetry(debug_ebay_marketplace_questionnaires)
123
 
124
  st.session_state['analyzing'] = False
125
  except AttributeError:
 
127
  hide_button()
128
 
129
  def row1(self):
130
+ #self.product_title_ebay = st.text_input("Product Title - eBay:", placeholder='Enter Product Title')
131
+ #self.category_ebay = st.text_input("Images - eBay:", placeholder='Enter Images')
132
+ #self.images_ebay = st.text_input("Bullet Points - eBay:", placeholder='Enter Bullet Points')
133
+ #self.product_description_ebay = st.text_input("Product Description - eBay:", placeholder='Enter Product Description')
134
 
135
+ self.ebay_marketplace_questionnaires = st.text_area(
136
+ "Marketplace Questionnaires - eBay:",
137
+ "Product Title:\n"
138
+ "a. Is the title within the 80-character limit?\n"
139
+ "b. Does the title include important details (e.g., brand, color, quantity, compatibility)?\n"
140
+ "c. Are search keywords used effectively in the title?\n"
141
+ "d. Other Remarks:\n\n"
142
+ "Category:\n"
143
+ "a. Is the product listed under the correct eBay category?\n"
144
+ "b. Other Remarks:\n\n"
145
+ "Images:\n"
146
+ "a. Are the product images on a white background?\n"
147
+ "b. Are there any text, logos, or watermarks on the images?\n"
148
+ "c. Are the images high-resolution and zoomable?\n"
149
+ "d. Other Remarks:\n\n"
150
+ "Product Description:\n"
151
+ "a. Is the product description complete and detailed?\n"
152
+ "b. Are bullet points used to highlight features and benefits?\n"
153
+ "c. Are there images embedded in the description?\n"
154
+ "d. Are there any technical issues (e.g., broken images, loading errors)?\n"
155
+ "e. Is there consistent keyword usage in the description?\n"
156
+ "f. Other Remarks:",
157
+ height=600
158
+ )
159
  self.process()
160
 
161
  if __name__ == "__main__":
classes/response_marketplace.py CHANGED
@@ -80,7 +80,7 @@ class Marketplace:
80
  payload_txt_model = self.request_model(payload_txt, headers)
81
  debug_info = {'data_field' : 'Marketplace Analyst', 'result': payload_txt_model}
82
  upload_response(debug_info)
83
-
84
  st.session_state['product_title_amazon'] = ''
85
  st.session_state['images_amazon'] = ''
86
  st.session_state['bullet_points_amazon'] = ''
@@ -89,6 +89,9 @@ class Marketplace:
89
  st.session_state['category_ebay'] = ''
90
  st.session_state['images_ebay'] = ''
91
  st.session_state['product_description_ebay'] = ''
 
 
 
92
  count = 0
93
  except Exception as e:
94
  pass
@@ -100,6 +103,7 @@ class Marketplace:
100
  #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
101
  self.payload = ""
102
  count = 0
 
103
  try:
104
  session_product_title_amazon = st.session_state['product_title_amazon']
105
  if session_product_title_amazon == 'uploaded':
@@ -158,6 +162,22 @@ class Marketplace:
158
  self.payload += self.fetch_data("Product Description - eBay")
159
  except Exception as e:
160
  pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
  if count >= 1:
163
  summary = self.fetch_data("Client Summary")
 
80
  payload_txt_model = self.request_model(payload_txt, headers)
81
  debug_info = {'data_field' : 'Marketplace Analyst', 'result': payload_txt_model}
82
  upload_response(debug_info)
83
+ '''
84
  st.session_state['product_title_amazon'] = ''
85
  st.session_state['images_amazon'] = ''
86
  st.session_state['bullet_points_amazon'] = ''
 
89
  st.session_state['category_ebay'] = ''
90
  st.session_state['images_ebay'] = ''
91
  st.session_state['product_description_ebay'] = ''
92
+ '''
93
+ st.session_state['amazon_marketplace_questionnaires'] = ''
94
+ st.session_state['ebay_marketplace_questionnaires'] = ''
95
  count = 0
96
  except Exception as e:
97
  pass
 
103
  #analyze_button = st.button("Analyze", disabled=initialize_analyze_session())
104
  self.payload = ""
105
  count = 0
106
+ '''
107
  try:
108
  session_product_title_amazon = st.session_state['product_title_amazon']
109
  if session_product_title_amazon == 'uploaded':
 
162
  self.payload += self.fetch_data("Product Description - eBay")
163
  except Exception as e:
164
  pass
165
+ '''
166
+ try:
167
+ session_amazon_marketplace_questionnaires = st.session_state['amazon_marketplace_questionnaires']
168
+ if session_amazon_marketplace_questionnaires == 'uploaded':
169
+ count += 1
170
+ self.payload += self.fetch_data("Marketplace Questionnaires - Amazon")
171
+ except Exception as e:
172
+ pass
173
+
174
+ try:
175
+ session_ebay_marketplace_questionnaires = st.session_state['ebay_marketplace_questionnaires']
176
+ if session_ebay_marketplace_questionnaires == 'uploaded':
177
+ count += 1
178
+ self.payload += self.fetch_data("Marketplace Questionnaires - eBay")
179
+ except Exception as e:
180
+ pass
181
 
182
  if count >= 1:
183
  summary = self.fetch_data("Client Summary")
pages/analyzing_page.py CHANGED
@@ -180,7 +180,7 @@ def run_analysis():
180
  handler = handlers["marketplace"]
181
  try:
182
  handler.update_info("Running Marketplace Analysis...")
183
- result = Marketplace(os.getenv('Model_Target_Market_Analyst'))
184
  handler.update_success("Marketplace Analysis completed successfully.")
185
  return result
186
  except Exception as e:
 
180
  handler = handlers["marketplace"]
181
  try:
182
  handler.update_info("Running Marketplace Analysis...")
183
+ result = Marketplace(os.getenv('Model_Marketplace_Analyst'))
184
  handler.update_success("Marketplace Analysis completed successfully.")
185
  return result
186
  except Exception as e:
pages/output.py CHANGED
@@ -254,7 +254,7 @@ Regardless, it is still a great channel worth investing to improve a business’
254
  st.markdown("<a href='#top'>Go to top</a>", unsafe_allow_html=True)
255
  st.markdown("---")
256
 
257
- if (get_analyst_response("Marketplace Analyst")):
258
  st.markdown("### MARKET PLACE")
259
  marketpalce_data = get_marketplace_response("Marketplace Analyst")
260
  write_table(marketpalce_data)
 
254
  st.markdown("<a href='#top'>Go to top</a>", unsafe_allow_html=True)
255
  st.markdown("---")
256
 
257
+ if (get_marketplace_response("Marketplace Analyst")):
258
  st.markdown("### MARKET PLACE")
259
  marketpalce_data = get_marketplace_response("Marketplace Analyst")
260
  write_table(marketpalce_data)