Update app.py
Browse files6 unmodified lines7891010111257 unmodified lines707172747374757677787981808182848586878883848590919293949596978687888999100101102103909192939495969798991001016 unmodified linesfrom dotenv import load_dotenv
# Load environment variables from .env fileload_dotenv()
57 unmodified lines prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw) # Call Gemini API once for the batch generation # Call Gemini API once for all 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 and display directly # Break down the response into structured points estimated_data = response.text.strip().split("\n") solar_system_size = "" total_system_cost = "" monthly_savings = "" payback_period = "" # Extract the values for solar system size, cost, savings, and payback period values = [] 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() 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(): # Extract the values and append to the list values.append(point.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}") # Display the values in 4 lines as requested if len(values) == 4: st.write(f"1. {values[0]}") st.write(f"2. {values[1]}") st.write(f"3. {values[2]}") st.write(f"4. {values[3]}") 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+15-21