Update app.py
Browse files5 unmodified lines67891011121353 unmodified lines676869687071727372747576777879807981828382848586878889848590919293949596979899100101102103104105106107905 unmodified linesimport csvfrom dotenv import load_dotenv
# Load environment variables from .env fileload_dotenv()
53 unmodified lines if state_data is not None: ghi = state_data['Avg_GHI (kWh/m²/day)'] solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)'] solar_cost_per_kw = state_data['Solar_Cost_per_KW (₹)'] prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw) # Call Gemini API once for all the batch generation # Call Gemini API once for the batch generation with st.spinner("Generating solar estimate with Gemini..."): response = model.generate_content(prompt_text) # Display structured output with only the requested points st.subheader("Solar Project Estimate") # Break down the response into structured points # Break down the response into structured points and display directly estimated_data = response.text.strip().split("\n") # Display only the required points: system size, cost, savings, and payback period solar_system_size = "" total_system_cost = "" monthly_savings = "" payback_period = "" for point in estimated_data: if "solar system size" in point.lower() or "total system cost" in point.lower() or "monthly savings" in point.lower() or "payback period" in point.lower(): st.write(f"{point.strip()}") if "solar system size" in point.lower(): solar_system_size = point.split(":")[-1].strip() elif "total system cost" in point.lower(): total_system_cost = point.split(":")[-1].strip() elif "monthly savings" in point.lower(): monthly_savings = point.split(":")[-1].strip() elif "payback period" in point.lower(): payback_period = point.split(":")[-1].strip() # Display the results in 4 separate lines st.write(f"1. Solar System Size: {solar_system_size}") st.write(f"2. Estimated Cost: {total_system_cost}") st.write(f"3. Monthly Savings: {monthly_savings}") st.write(f"4. Payback Period: {payback_period}") 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+24-7