File size: 4,840 Bytes
08b6ea7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import requests
import os

def main():

    BackendService=os.getenv("backend")
    input_data=None    
    submitted=None
    # Wrap everything inside a form
    with st.sidebar:
        uploaded_file = st.file_uploader("Kindly upload a CSV file that includes the names and websites of the companies", type=["csv"])
        if uploaded_file is not None:
            try:
                # Detect file type and read accordingly
                file_type = uploaded_file.name.split('.')[-1]
                if file_type == 'csv':
                    df = pd.read_csv(uploaded_file)
                elif file_type == 'xlsx':
                    df = pd.read_excel(uploaded_file)
    
               # Limiting the dataframe for processing
    
                # Check if 'Website' column exists
                if 'Website' not in df.columns:
                    all_columns = df.columns.tolist()
                    website_column  = st.selectbox("Select the column for Website:", all_columns)
                else:
                    website_column  = 'Website'
                    
                    
                    # Check if 'Company Name for Emails' column exists
                if 'Company Name for Emails' not in df.columns:
                    all_columns = df.columns.tolist()
                    company_column= st.selectbox("Select the column for Company Name for Emails:", all_columns)
                else:
                    company_column = 'Company Name for Emails'
                input_data=df  
            except Exception as E :
                st.error("An error occured while processing the file")
        with st.form(key='my_form'):
            # Fetch the filtered data
            prompt_notes= st.text_input("If applicable please mention the network name")
            
           # List of predefined email addresses
            email_options = [
                "[email protected]",
                "[email protected]",
                "[email protected]",
                "[email protected]",
                "[email protected]",
                "[email protected]",
                "[email protected]"
            ]
            
            # Streamlit select box for choosing an email
            email_receiver = st.selectbox("Please select an email address", email_options)

    # If the button is clicked, it will return True for this run
            button_clicked = st.form_submit_button("Submit")
            
            # 2. Update session state for the button
            if button_clicked:
                submitted = True
                # Set the session state to the new value
                prompt_notes = prompt_notes 
# 3. Use the session state variable to determine if the button was previously clicked
    if submitted and input_data is not None:
        df = input_data
        df[website_column] = df[website_column].astype(str)
        df=df[[website_column,company_column]]
        df.columns = ["Website","Company Name for Emails"]
    
        # Convert DataFrame to CSV for transmission
        csv = df.to_csv(index=False)
    
        # Construct the data to send
        data_to_send = {"prompt_notes": prompt_notes, "dataframe": csv,"email_receiver":email_receiver}
    
        # Sending the POST request to FastAPI
        response = requests.post("https://ppxt7uqbmw.us-east-2.awsapprunner.com/receive_data/", json=data_to_send)
    
        if response.status_code == 200:
            st.info(f"We're processing your request. You can close the app now. An email will be sent to {email_receiver} once the process is finished.")
        else:
            st.error("Data transmission failed. Please verify that your file contains the labels 'Company Website' and 'Company Name'. Additionally, ensure that your file is valid and contains records and try again , if the problem persists please contact us at [email protected]")
            

if __name__ == "__main__":
    st.markdown(
    """
    <style>
    .higher-title {
        font-size:35px !important;
        color: #4A90E2;  /* Shade of blue */
        text-align: center;
        font-weight: bold;
        margin-top: -20px;  /* Adjust this value to control the height */
    }
    </style>
    """, 
    unsafe_allow_html=True,
)

    st.markdown('<p class="higher-title">SalesIntel AI</p>', unsafe_allow_html=True)
    
    
    
    logo_url = "https://i.imgur.com/WYnv26e.jpeg"  # Replace this with your image's direct URL
    st.markdown(
        f"""
        <style>
        .logo {{
            position: fixed;
            bottom: 5px;
            right: 5px;
            width: 100px;  # Adjust width as needed
        }}
        </style>
        <img src="{logo_url}" class="logo">
        """,
        unsafe_allow_html=True,
    )
    main()