Update app.py
Browse files9 unmodified lines1011121314151650 unmodified lines6768697071727363 unmodified lines1371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801819 unmodified linesload_dotenv()# Set page configurationst.set_page_config(page_title="☀️AI-based Solar Project Estimation Tool", layout="centered")# Initialize Gemini with the API keyapi_key = os.getenv("GOOGLE_API_KEY")50 unmodified linesreturn prompt# UI - Form for user inputst.title("☀️ AI-based Solar Project Estimation Tool")st.write("### Enter Your Details Below:")with st.form("solar_form"):63 unmodified linesst.warning("There was an issue processing the response. Please try again.")# Show Graph if values are availableif total_system_cost is not None and monthly_savings_rs is not None and payback_period_years is not None:st.subheader("📊 Visual Summary")# Prepare data for Area Chartmonths = int(payback_period_years * 12)savings_cumulative = [monthly_savings_rs * month for month in range(1, months + 1)]fig = go.Figure()# Area plotfig.add_trace(go.Scatter(x=list(range(1, months + 1)),y=savings_cumulative,mode='lines',fill='tozeroy',name='Cumulative Savings (₹)',line=dict(color='#00CC96')))# Line for Total Costfig.add_trace(go.Scatter(x=[1, months],y=[total_system_cost, total_system_cost],mode='lines',name='Total System Cost (₹)',line=dict(color='red', dash='dash')))fig.update_layout(title="Cumulative Savings vs Total System Cost Over Time",xaxis_title="Months",yaxis_title="Amount (₹)",legend_title="Legend",template="plotly_white")st.plotly_chart(fig, use_container_width=True, key="solar_graph")else:st.error("Sorry, the location entered does not match any available data.")else:st.info("Please fill out all fields to get your solar project estimate.")9 unmodified lines1011121314151650 unmodified lines6768697071727363 unmodified lines1371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721739 unmodified linesload_dotenv()# Set page configurationst.set_page_config(page_title="☀️AI-Based Solar Project Estimation Tool", layout="centered")# Initialize Gemini with the API keyapi_key = os.getenv("GOOGLE_API_KEY")50 unmodified linesreturn prompt# UI - Form for user inputst.title("☀️ AI-Based Solar Project Estimation Tool")st.write("### Enter Your Details Below:")with st.form("solar_form"):63 unmodified linesst.warning("There was an issue processing the response. Please try again.")# Show Graph if values are available# Visual Summary - Grouped Bar Chartif system_size_kw is not None and total_system_cost is not None:st.subheader("📊 Visual Summary")# Grouped Bar chart for all the valuesfig = go.Figure(data=[go.Bar(name="System Size (kW)",x=["Solar System Size", "Daily Output", "Total Cost", "Monthly Savings", "Payback Period"],y=[system_size_kw, daily_output_kwh, total_system_cost, monthly_savings_rs, payback_period_years],marker_color='#636EFA'),go.Bar(name="Financials",x=["Solar System Size", "Daily Output", "Total Cost", "Monthly Savings", "Payback Period"],y=[0, 0, total_system_cost, monthly_savings_rs, payback_period_years],marker_color='#00CC96')])# Update layoutfig.update_layout(barmode='group',title="Comparison of Solar System Parameters",yaxis_title="Values",xaxis_title="Parameters")st.plotly_chart(fig, use_container_width=True)else:st.error("Sorry, the location entered does not match any available data.")else:st.warning("Please fill out all fields to see your solar project estimate.")
app.py+29-37