Spaces:
Build error
Build error
Ronio Jerico Roque commited on
Commit ·
b231615
1
Parent(s): fb0a511
Add eBay class for handling product data input and telemetry collection
Browse files- classes/ebay.py +125 -0
classes/ebay.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
class eBay:
|
| 8 |
+
def __init__(self, model_url):
|
| 9 |
+
self.file_dict = {}
|
| 10 |
+
self.model_url = model_url
|
| 11 |
+
#self.analyst_name = analyst_name
|
| 12 |
+
#self.data_src = data_src
|
| 13 |
+
#self.analyst_description = analyst_description
|
| 14 |
+
self.initialize()
|
| 15 |
+
self.row1()
|
| 16 |
+
|
| 17 |
+
def initialize(self):
|
| 18 |
+
# FOR ENV
|
| 19 |
+
load_dotenv()
|
| 20 |
+
'''
|
| 21 |
+
# AGENT NAME
|
| 22 |
+
st.header(self.analyst_name)
|
| 23 |
+
|
| 24 |
+
# EVALUATION FORM LINK
|
| 25 |
+
url = os.getenv('Link')
|
| 26 |
+
st.write('Evaluation Form: [Link](%s)' % url)
|
| 27 |
+
|
| 28 |
+
# RETURN BUTTON
|
| 29 |
+
try:
|
| 30 |
+
if st.button("Return", type='primary'):
|
| 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:
|
| 38 |
+
st.session_state['category_ebay'] = ''
|
| 39 |
+
if 'images_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 |
+
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:
|
| 60 |
+
pass
|
| 61 |
+
try:
|
| 62 |
+
category_ebay += f"\nImages: {self.category_ebay}"
|
| 63 |
+
except KeyError:
|
| 64 |
+
pass
|
| 65 |
+
try:
|
| 66 |
+
images_ebay += f"\nBullet Points: {self.images_ebay}"
|
| 67 |
+
except KeyError:
|
| 68 |
+
pass
|
| 69 |
+
try:
|
| 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}
|
| 76 |
+
#result = self.request_model(payload_txt)
|
| 77 |
+
|
| 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', 'result - eBay': self.category_ebay}
|
| 83 |
+
debug_images_ebay = {'data_field' : 'Images', 'result - eBay': self.images_ebay}
|
| 84 |
+
debug_product_description_ebay = {'data_field' : 'Product Description - eBay', 'result': self.product_description_ebay}
|
| 85 |
+
|
| 86 |
+
'''
|
| 87 |
+
debug_info = {
|
| 88 |
+
#'analyst': self.analyst_name,
|
| 89 |
+
'url_uuid': self.model_url.split("-")[-1],
|
| 90 |
+
'time_lapsed': time_lapsed,
|
| 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)
|
| 98 |
+
if self.category_ebay:
|
| 99 |
+
st.session_state['category_ebay'] = 'uploaded'
|
| 100 |
+
collect_telemetry(debug_category_ebay)
|
| 101 |
+
if self.images_ebay:
|
| 102 |
+
st.session_state['images_ebay'] = 'uploaded'
|
| 103 |
+
collect_telemetry(debug_images_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:
|
| 111 |
+
st.info("Please upload CSV or PDF files first.")
|
| 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__":
|
| 123 |
+
st.set_page_config(layout="wide")
|
| 124 |
+
|
| 125 |
+
upload = uploadFile()
|