Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,20 +4,60 @@ import pandas as pd
|
|
| 4 |
from calculations import calculate_roi
|
| 5 |
from ai_synopsis import generate_synopsis
|
| 6 |
from pdf_generator import generate_pdf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
st.set_page_config(
|
| 9 |
page_title="AI ROI Calculator",
|
| 10 |
layout="wide"
|
| 11 |
)
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
st.title("AI ROI Calculator")
|
| 14 |
|
| 15 |
-
st.markdown(
|
|
|
|
|
|
|
| 16 |
|
| 17 |
st.divider()
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
col1, col2 = st.columns(2)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
with col1:
|
| 22 |
|
| 23 |
st.subheader("Business Inputs")
|
|
@@ -82,6 +122,11 @@ with col1:
|
|
| 82 |
value=1500,
|
| 83 |
)
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
with col2:
|
| 86 |
|
| 87 |
st.subheader("ROI Results")
|
|
@@ -109,42 +154,105 @@ with col2:
|
|
| 109 |
value=f"INR {roi_data['Total Savings']}"
|
| 110 |
)
|
| 111 |
|
|
|
|
| 112 |
st.divider()
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
if st.button("Generate AI Report"):
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from calculations import calculate_roi
|
| 5 |
from ai_synopsis import generate_synopsis
|
| 6 |
from pdf_generator import generate_pdf
|
| 7 |
+
from email_sender import send_email
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# ====================================
|
| 11 |
+
# PAGE CONFIG
|
| 12 |
+
# ====================================
|
| 13 |
|
| 14 |
st.set_page_config(
|
| 15 |
page_title="AI ROI Calculator",
|
| 16 |
layout="wide"
|
| 17 |
)
|
| 18 |
|
| 19 |
+
|
| 20 |
+
# ====================================
|
| 21 |
+
# TITLE
|
| 22 |
+
# ====================================
|
| 23 |
+
|
| 24 |
st.title("AI ROI Calculator")
|
| 25 |
|
| 26 |
+
st.markdown(
|
| 27 |
+
"Generate ROI savings reports with AI-powered synopsis"
|
| 28 |
+
)
|
| 29 |
|
| 30 |
st.divider()
|
| 31 |
|
| 32 |
+
|
| 33 |
+
# ====================================
|
| 34 |
+
# CUSTOMER DETAILS
|
| 35 |
+
# ====================================
|
| 36 |
+
|
| 37 |
+
st.subheader("Customer Details")
|
| 38 |
+
|
| 39 |
+
customer_name = st.text_input("Full Name")
|
| 40 |
+
|
| 41 |
+
customer_email = st.text_input("Email Address")
|
| 42 |
+
|
| 43 |
+
company_name = st.text_input("Company Name")
|
| 44 |
+
|
| 45 |
+
phone_number = st.text_input("Phone Number")
|
| 46 |
+
|
| 47 |
+
st.divider()
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# ====================================
|
| 51 |
+
# MAIN LAYOUT
|
| 52 |
+
# ====================================
|
| 53 |
+
|
| 54 |
col1, col2 = st.columns(2)
|
| 55 |
|
| 56 |
+
|
| 57 |
+
# ====================================
|
| 58 |
+
# LEFT COLUMN
|
| 59 |
+
# ====================================
|
| 60 |
+
|
| 61 |
with col1:
|
| 62 |
|
| 63 |
st.subheader("Business Inputs")
|
|
|
|
| 122 |
value=1500,
|
| 123 |
)
|
| 124 |
|
| 125 |
+
|
| 126 |
+
# ====================================
|
| 127 |
+
# RIGHT COLUMN
|
| 128 |
+
# ====================================
|
| 129 |
+
|
| 130 |
with col2:
|
| 131 |
|
| 132 |
st.subheader("ROI Results")
|
|
|
|
| 154 |
value=f"INR {roi_data['Total Savings']}"
|
| 155 |
)
|
| 156 |
|
| 157 |
+
|
| 158 |
st.divider()
|
| 159 |
|
| 160 |
+
|
| 161 |
+
# ====================================
|
| 162 |
+
# GENERATE REPORT BUTTON
|
| 163 |
+
# ====================================
|
| 164 |
+
|
| 165 |
if st.button("Generate AI Report"):
|
| 166 |
|
| 167 |
+
# Validation
|
| 168 |
+
if (
|
| 169 |
+
customer_name == ""
|
| 170 |
+
or customer_email == ""
|
| 171 |
+
or company_name == ""
|
| 172 |
+
or phone_number == ""
|
| 173 |
+
):
|
| 174 |
+
|
| 175 |
+
st.error("Please fill all customer details.")
|
| 176 |
+
|
| 177 |
+
else:
|
| 178 |
+
|
| 179 |
+
with st.spinner("Generating AI Synopsis..."):
|
| 180 |
+
|
| 181 |
+
# ====================================
|
| 182 |
+
# USER DATA
|
| 183 |
+
# ====================================
|
| 184 |
+
|
| 185 |
+
user_data = {
|
| 186 |
+
"Customer Name": customer_name,
|
| 187 |
+
"Customer Email": customer_email,
|
| 188 |
+
"Company Name": company_name,
|
| 189 |
+
"Phone Number": phone_number,
|
| 190 |
+
"Industry": industry,
|
| 191 |
+
"Number of Assets": num_assets,
|
| 192 |
+
"Average Asset Value": asset_value,
|
| 193 |
+
"Employees": num_employees,
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
# ====================================
|
| 197 |
+
# AI DATA
|
| 198 |
+
# ====================================
|
| 199 |
+
|
| 200 |
+
ai_data = {
|
| 201 |
+
"industry": industry,
|
| 202 |
+
"num_assets": num_assets,
|
| 203 |
+
"asset_value": asset_value,
|
| 204 |
+
"num_employees": num_employees,
|
| 205 |
+
"total_savings": roi_data['Total Savings'],
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
# ====================================
|
| 209 |
+
# GENERATE AI SYNOPSIS
|
| 210 |
+
# ====================================
|
| 211 |
+
|
| 212 |
+
synopsis = generate_synopsis(ai_data)
|
| 213 |
+
|
| 214 |
+
st.subheader("AI Generated Synopsis")
|
| 215 |
+
|
| 216 |
+
st.write(synopsis)
|
| 217 |
+
|
| 218 |
+
# ====================================
|
| 219 |
+
# GENERATE PDF
|
| 220 |
+
# ====================================
|
| 221 |
+
|
| 222 |
+
pdf = generate_pdf(
|
| 223 |
+
user_data,
|
| 224 |
+
roi_data,
|
| 225 |
+
synopsis,
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
# ====================================
|
| 229 |
+
# SEND EMAIL TO COMPANY
|
| 230 |
+
# ====================================
|
| 231 |
+
|
| 232 |
+
email_status = send_email(
|
| 233 |
+
user_data,
|
| 234 |
+
roi_data
|
| 235 |
+
)
|
| 236 |
+
|
| 237 |
+
if email_status:
|
| 238 |
+
|
| 239 |
+
st.success(
|
| 240 |
+
"Lead details sent successfully!"
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
else:
|
| 244 |
+
|
| 245 |
+
st.error(
|
| 246 |
+
"Failed to send lead email."
|
| 247 |
+
)
|
| 248 |
+
|
| 249 |
+
# ====================================
|
| 250 |
+
# DOWNLOAD BUTTON
|
| 251 |
+
# ====================================
|
| 252 |
+
|
| 253 |
+
st.download_button(
|
| 254 |
+
label="Download Report",
|
| 255 |
+
data=pdf,
|
| 256 |
+
file_name="ai_roi_report.pdf",
|
| 257 |
+
mime="application/pdf",
|
| 258 |
+
)
|