Update app.py
Browse files5 unmodified lines6789101153 unmodified lines65666768697071727374757677787980818283848586878889905 unmodified linesimport csvfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()53 unmodified linesif state_data is not None:ghi = state_data['Avg_GHI (kWh/m²/day)']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 generationwith st.spinner("Generating solar estimate with Gemini..."):response = model.generate_content(prompt_text)# Display structured output with only the requested pointsst.subheader("Solar Project Estimate")# Break down the response into structured pointsestimated_data = response.text.strip().split("\n")# Display only the required points: system size, cost, savings, and payback periodfor 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()}")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.")5 unmodified lines67891011121353 unmodified lines6768697071727374757677787980818283848586878889909192939495969798991001011021031041051061075 unmodified linesimport csvfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()53 unmodified linesif state_data is not None:ghi = state_data['Avg_GHI (kWh/m²/day)']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 the batch generationwith st.spinner("Generating solar estimate with Gemini..."):response = model.generate_content(prompt_text)# Display structured output with only the requested pointsst.subheader("Solar Project Estimate")# Break down the response into structured points and display directlyestimated_data = response.text.strip().split("\n")solar_system_size = ""total_system_cost = ""monthly_savings = ""payback_period = ""for point in estimated_data: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 linesst.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