File size: 10,493 Bytes
fb0a511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b96aa1
fb0a511
 
 
 
 
 
 
 
7b96aa1
 
 
fb0a511
 
 
7b96aa1
fb0a511
7b96aa1
 
 
 
 
fb0a511
c75d56b
fb0a511
 
 
7b96aa1
fb0a511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b96aa1
 
 
 
 
fb0a511
 
 
 
 
 
 
7b96aa1
fb0a511
 
 
 
7b96aa1
 
fb0a511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7b96aa1
 
4f561f7
 
 
 
 
fb0a511
 
 
 
 
 
 
7b96aa1
 
 
 
4f561f7
7b96aa1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4f561f7
 
 
 
7b96aa1
 
fb0a511
 
 
 
 
 
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
163
164
165
166
167
168
169
170
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 Amazon:
    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 'product_title_amazon' not in st.session_state:
            st.session_state['product_title_amazon'] = ''
        if 'images_amazon' not in st.session_state:
            st.session_state['images_amazon'] = ''
        if 'bullet_points_amazon' not in st.session_state:
            st.session_state['bullet_points_amazon'] = ''
        if 'product_description_amazon' not in st.session_state:
            st.session_state['product_description_amazon'] = ''
        '''
        if 'amazon_marketplace_questionnaires' not in st.session_state:
            st.session_state['amazon_marketplace_questionnaires'] = ''

    def process(self):
        session = st.session_state.analyze
        if (self.amazon_marketplace_questionnaires) and session == 'clicked':
                    try:
                        #product_title_amazon = ""
                        #images_amazon = ""
                        #bullet_points_amazon = ""
                        #product_description_amazon = ""
                        amazon_marketplace_questionnaires = ""

                        with st.spinner('Uploading Amazon Files...', show_time=True):
                                st.write('')
                                # INITIALIZING SESSIONS
                                #combined_text += f"Client Summary: {st.session_state.nature}\n"
                                '''
                                try:
                                    product_title_amazon += f"\nProduct Title: {self.product_title_amazon}"
                                except KeyError:
                                    pass
                                try:
                                    images_amazon += f"\nImages: {self.images_amazon}"
                                except KeyError:
                                    pass
                                try:
                                    bullet_points_amazon += f"\nBullet Points: {self.bullet_points_amazon}"
                                except KeyError:
                                    pass
                                try:
                                    product_description_amazon += f"\nProduct Description: {self.product_description_amazon}"
                                except KeyError:
                                    pass
                                '''
                                try:
                                    amazon_marketplace_questionnaires += f"Marketplace Questionnaires - Amazon: {self.amazon_marketplace_questionnaires}"
                                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_product_title_amazon = {'data_field' : 'Product Title - Amazon', 'result': self.product_title_amazon}
                                debug_info_images_amazon = {'data_field' : 'Images - Amazon', 'result': self.images_amazon}
                                debug_info_bullet_points_amazon = {'data_field' : 'Bullet Points - Amazon', 'result': self.bullet_points_amazon}
                                debug_product_description_amazon = {'data_field' : 'Product Description - Amazon', 'result': self.product_description_amazon}
                                '''
                                debug_amazon_marketplace_questionnaires = {'data_field' : 'Marketplace Questionnaires - Amazon', 'result': self.amazon_marketplace_questionnaires}

                                '''
                                debug_info = {
                                    #'analyst': self.analyst_name,
                                    'url_uuid': self.model_url.split("-")[-1],
                                    'time_lapsed': time_lapsed,
                                    'payload': payload_txt,
                                    'result': result,
                                }
                                if self.product_title_amazon:
                                    st.session_state['product_title_amazon'] = 'uploaded'
                                    collect_telemetry(debug_info_product_title_amazon)
                                if self.images_amazon:
                                    st.session_state['images_amazon'] = 'uploaded'
                                    collect_telemetry(debug_info_images_amazon)
                                if self.bullet_points_amazon:
                                    st.session_state['bullet_points_amazon'] = 'uploaded'
                                    collect_telemetry(debug_info_bullet_points_amazon)
                                if self.product_description_amazon:
                                    st.session_state['product_description_amazon'] = 'uploaded'
                                    collect_telemetry(debug_product_description_amazon)
                                '''
                                if self.amazon_marketplace_questionnaires:
                                    if self.amazon_marketplace_questionnaires != self.template:
                                        st.session_state['amazon_marketplace_questionnaires'] = 'uploaded'
                                        collect_telemetry(debug_amazon_marketplace_questionnaires)
                                    else:
                                         pass
                                
                                st.session_state['analyzing'] = False 
                    except AttributeError:
                        st.info("Please upload CSV or PDF files first.")
                        hide_button() 

    def row1(self):
            #self.product_title_amazon = st.text_input("Product Title - Amazon:", placeholder='Enter Product Title')
            #self.images_amazon = st.text_input("Images - Amazon:", placeholder='Enter Images')
            #self.bullet_points_amazon = st.text_input("Bullet Points - Amazon:", placeholder='Enter Bullet Points')
            #self.product_description_amazon = st.text_input("Product Description - Amazon:", placeholder='Enter Product Description')
            self.template = ("Product Title:\n"
                                                            "a. Does the product title include relevant keywords (e.g., Product Brand/Description + Product Line + Material or Key Ingredient + Color + Size + Quantity)?\n"
                                                            "b. Is the title within Amazon’s recommended character limit (≤200 characters)?\n"
                                                            "c. Other Remarks:\n\n"
                                                            "Images:\n"
                                                            "a. Is the main image on a pure white background?\n"
                                                            "b. Are there any logos, watermarks, or text on any images?\n"
                                                            "c. Do the images showcase the product from multiple angles?\n"
                                                            "d. Are the images high-resolution and zoomable?\n"
                                                            "e. Other Remarks:\n\n"
                                                            "Bullet Points:\n"
                                                            "a. Do the bullets exceed 250 characters?\n"
                                                            "b. Are the bullet points clear and concise?\n"
                                                            "c. Do they highlight key features, benefits, and unique selling points?\n"
                                                            "d. Are keywords naturally included in the bullet points?\n"
                                                            "e. Other Remarks:\n\n"
                                                            "Product Description:\n"
                                                            "a. Is the product description complete and well-formatted?\n"
                                                            "b. Is it within the 2000-character limit?\n"
                                                            "c. Does it include important product specifications (size, material, compatibility)?\n"
                                                            "d. Are there any customer reviews or ratings?\n"
                                                            "e. If yes, is the average rating above 4 stars?\n"
                                                            "f. Other Remarks:")
            self.amazon_marketplace_questionnaires = st.text_area(
                                                            "Marketplace Questionnaires - Amazon:",
                                                            value=self.template,
                                                            height=600
                                                        )                                                    
            self.process()
            
if __name__ == "__main__":
    st.set_page_config(layout="wide")

upload = uploadFile()