Update app.py
Browse files67 unmodified lines686970717273741 unmodified line76777879808182838485868788899067 unmodified linessolar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']prompt_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)1 unmodified line# 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(f"{point.strip()}")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.")67 unmodified lines6869707172731 unmodified line7576777879808182838485868788899091929394959697989910010110210310410567 unmodified linessolar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']prompt_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)1 unmodified line# Display structured output with only the requested pointsst.subheader("Solar Project Estimate")# Log the full response to check its structurest.write("Raw response from Gemini:", response.text.strip())# 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())# Log the extracted valuesst.write("Extracted values:", values)# 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("Could not extract the expected values.")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+19-4