Update app.py
Browse files5 unmodified lines678910111213149101164 unmodified lines767778857980818882838485868788899091909192939495969798991001011021031041051061071081095 unmodified linesimport csvfrom dotenv import load_dotenv
import 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 points st.subheader("Solar Project Estimate") # Break down the response into structured points # Break down the response into structured points and extract only the numeric values estimated_data = response.text.strip().split("\n") # Display only the required points: system size, cost, savings, and payback period # Initialize values for each field system_size = None total_cost = None monthly_savings = None payback_period = None # Parse the response to find and assign the correct values 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(point.strip()) 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 explanation if 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