Update app.py
Browse files5 unmodified lines6789101112131415161764 unmodified lines828384858687888990919293945 unmodified linesimport csvfrom dotenv import load_dotenvimport streamlit as stimport pandas as pdimport google.generativeai as genaiimport osfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()64 unmodified lines# 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(point.strip())else:st.error("Sorry, the location entered does not match any available data.")else:5 unmodified lines6789101164 unmodified lines7677787980818283848586878889909192939495969798991001011021031041051061071081095 unmodified linesimport csvfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()64 unmodified lines# Display structured output with only the requested pointsst.subheader("Solar Project Estimate")# Break down the response into structured points and extract only the numeric valuesestimated_data = response.text.strip().split("\n")# Initialize values for each fieldsystem_size = Nonetotal_cost = Nonemonthly_savings = Nonepayback_period = None# Parse the response to find and assign the correct valuesfor point in estimated_data:if "solar system size" in point.lower():system_size = point.split(":")[1].strip()elif "total system cost" in point.lower():total_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 values without any additional explanationif system_size and total_cost and monthly_savings and payback_period:st.write(f"1. Estimated solar system size in kW: {system_size}")st.write(f"2. Total system cost in ₹: {total_cost}")st.write(f"3. Monthly savings in ₹: {monthly_savings}")st.write(f"4. Payback period in years: {payback_period}")else:st.error("Unable to extract valid data from the response.")else:st.error("Sorry, the location entered does not match any available data.")else:
app.py+25-10