Spaces:
Sleeping
Sleeping
Download app.py from prasad799596/SmartROI-Generator: direct link, hf CLI and curl.
- Browser
- Download file 5.7 kB
-
https://huggingface.co/spaces/prasad799596/SmartROI-Generator/resolve/main/app.py
- Command line
-
hf download hf://spaces/prasad799596/SmartROI-Generator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/prasad799596/SmartROI-Generator/resolve/main/app.py
5.7 kB
| import streamlit as st | |
| import pandas as pd | |
| from calculations import calculate_roi | |
| from ai_synopsis import generate_synopsis | |
| from pdf_generator import generate_pdf | |
| from email_sender import send_email | |
| # ==================================== | |
| # PAGE CONFIG | |
| # ==================================== | |
| st.set_page_config( | |
| page_title="AI ROI Calculator", | |
| layout="wide" | |
| ) | |
| # ==================================== | |
| # TITLE | |
| # ==================================== | |
| st.title("AI ROI Calculator") | |
| st.markdown( | |
| "Generate ROI savings reports with AI-powered synopsis" | |
| ) | |
| st.divider() | |
| # ==================================== | |
| # CUSTOMER DETAILS | |
| # ==================================== | |
| st.subheader("Customer Details") | |
| customer_name = st.text_input("Full Name") | |
| customer_email = st.text_input("Email Address") | |
| company_name = st.text_input("Company Name") | |
| phone_number = st.text_input("Phone Number") | |
| st.divider() | |
| # ==================================== | |
| # MAIN LAYOUT | |
| # ==================================== | |
| col1, col2 = st.columns(2) | |
| # ==================================== | |
| # LEFT COLUMN | |
| # ==================================== | |
| with col1: | |
| st.subheader("Business Inputs") | |
| industry = st.selectbox( | |
| "Select Industry", | |
| [ | |
| "Retail", | |
| "Healthcare", | |
| "Manufacturing", | |
| "Logistics", | |
| "Education", | |
| ] | |
| ) | |
| num_assets = st.number_input( | |
| "Number of Assets", | |
| min_value=1, | |
| value=1000, | |
| ) | |
| asset_value = st.number_input( | |
| "Average Asset Value", | |
| min_value=1, | |
| value=150, | |
| ) | |
| num_employees = st.number_input( | |
| "Number of Employees", | |
| min_value=1, | |
| value=10, | |
| ) | |
| employee_salary = st.number_input( | |
| "Annual Employee Salary", | |
| min_value=1, | |
| value=32800, | |
| ) | |
| productivity_gain_percent = st.slider( | |
| "Productivity Gain (%)", | |
| 1, | |
| 100, | |
| 10, | |
| ) | |
| audit_days = st.number_input( | |
| "Audit Days Per Year", | |
| min_value=1, | |
| value=2, | |
| ) | |
| auditors = st.number_input( | |
| "Number of Auditors", | |
| min_value=1, | |
| value=3, | |
| ) | |
| auditor_cost = st.number_input( | |
| "Daily Auditor Cost", | |
| min_value=1, | |
| value=1500, | |
| ) | |
| # ==================================== | |
| # RIGHT COLUMN | |
| # ==================================== | |
| with col2: | |
| st.subheader("ROI Results") | |
| roi_data = calculate_roi( | |
| num_assets, | |
| asset_value, | |
| num_employees, | |
| employee_salary, | |
| productivity_gain_percent, | |
| audit_days, | |
| auditors, | |
| auditor_cost, | |
| ) | |
| df = pd.DataFrame( | |
| roi_data.items(), | |
| columns=["Category", "Amount"] | |
| ) | |
| st.dataframe(df) | |
| st.metric( | |
| label="Total Annual Savings", | |
| value=f"INR {roi_data['Total Savings']}" | |
| ) | |
| st.divider() | |
| # ==================================== | |
| # GENERATE REPORT BUTTON | |
| # ==================================== | |
| if st.button("Generate AI Report"): | |
| # ==================================== | |
| # VALIDATION | |
| # ==================================== | |
| if ( | |
| not customer_name.strip() | |
| or not customer_email.strip() | |
| or not company_name.strip() | |
| or not phone_number.strip() | |
| ): | |
| st.error("Please fill all customer details.") | |
| else: | |
| with st.spinner("Generating AI Synopsis..."): | |
| # ==================================== | |
| # USER DATA | |
| # ==================================== | |
| user_data = { | |
| "Customer Name": customer_name, | |
| "Customer Email": customer_email, | |
| "Company Name": company_name, | |
| "Phone Number": phone_number, | |
| "Industry": industry, | |
| "Number of Assets": num_assets, | |
| "Average Asset Value": asset_value, | |
| "Employees": num_employees, | |
| } | |
| # ==================================== | |
| # AI DATA | |
| # ==================================== | |
| ai_data = { | |
| "industry": industry, | |
| "num_assets": num_assets, | |
| "asset_value": asset_value, | |
| "num_employees": num_employees, | |
| "total_savings": roi_data['Total Savings'], | |
| } | |
| # ==================================== | |
| # GENERATE AI SYNOPSIS | |
| # ==================================== | |
| synopsis = generate_synopsis(ai_data) | |
| st.subheader("AI Generated Synopsis") | |
| st.write(synopsis) | |
| # ==================================== | |
| # GENERATE PDF | |
| # ==================================== | |
| pdf = generate_pdf( | |
| user_data, | |
| roi_data, | |
| synopsis, | |
| ) | |
| # ==================================== | |
| # SEND EMAIL | |
| # ==================================== | |
| email_status = send_email( | |
| user_data, | |
| roi_data | |
| ) | |
| if email_status: | |
| st.success( | |
| "Lead details sent successfully!" | |
| ) | |
| else: | |
| st.error( | |
| "Failed to send lead email." | |
| ) | |
| # ==================================== | |
| # DOWNLOAD PDF | |
| # ==================================== | |
| st.download_button( | |
| label="Download Report", | |
| data=pdf, | |
| file_name="ai_roi_report.pdf", | |
| mime="application/pdf", | |
| ) |