Update app.py
Browse files5 unmodified lines678910111213141516171819132021222325 unmodified lines49505145465253545513 unmodified lines69707166676869707172727374757677787980818283845 unmodified linesimport csv
import streamlit as stimport pandas as pdimport google.generativeai as genaiimport osfrom io import StringIOimport csv
# Set page configuration firstst.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
# Initialize Geminigenai.configure(api_key=os.getenv("AIzaSyBFXjq_kfYbOon_XdW2EXN24KHd4NCefOE"))genai.configure(api_key=os.getenv("GEMINI_API_KEY")) # Ensure your Gemini API key is set as an environment variablemodel = genai.GenerativeModel("gemini-1.5-flash")
# Load solar data25 unmodified lines - Monthly electricity bill: ₹{electricity_bill} - Average GHI (solar radiation) for {location}: {ghi} kWh/m²/day - Solar system cost per kW in {location}: ₹{solar_cost_per_kw}
Provide: Provide the following: 1. Estimated solar system size in kW 2. Estimated daily solar output in kWh 3. Total system cost in ₹13 unmodified lines prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw) # Call Gemini API once for all the batch generation if prompt_text: with st.spinner("Generating solar estimate with Gemini..."): response = model.generate_content(prompt_text) st.subheader("Solar Project Estimate") st.text_area("Generated Estimate", response.text, height=200) else: st.warning("Please check the inputs again.") with st.spinner("Generating solar estimate with Gemini..."): response = model.generate_content(prompt_text) # Display structured output st.subheader("Solar Project Estimate") # Break down the response into structured points estimated_data = response.text.strip().split("\n") for point in estimated_data: st.write(f"- {point}") else: st.error("Sorry, the location entered does not match any available data.")else:app.py+19-10