Update app.py
Browse files6 unmodified lines7891011121357 unmodified lines71727374757677787980818283848586878889909192939495969798991001011021031041051061076 unmodified linesfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()57 unmodified linesprompt_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.")6 unmodified lines78910111257 unmodified lines7071727374757677787980818283848586878889909192939495969798991001016 unmodified linesfrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()57 unmodified linesprompt_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")# Extract the values for solar system size, cost, savings, and payback periodvalues = []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():# Extract the values and append to the listvalues.append(point.strip())# Display the values in 4 lines as requestedif 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