Update app.py
Browse files67 unmodified lines686970717172731 unmodified line7576777879808182838284858687858889909192939495969798991001011021031041059067 unmodified lines solar_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 generation with st.spinner("Generating solar estimate with Gemini..."): response = model.generate_content(prompt_text)1 unmodified line # Display structured output with only the requested points st.subheader("Solar Project Estimate") # Log the full response to check its structure st.write("Raw response from Gemini:", response.text.strip()) # Break down the response into structured points estimated_data = response.text.strip().split("\n") # Display only the required points: system size, cost, savings, and 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() or "total system cost" in point.lower() or "monthly savings" in point.lower() or "payback period" in point.lower(): st.write(f"{point.strip()}") # Extract the values and append to the list values.append(point.strip()) # Log the extracted values st.write("Extracted values:", values) # 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("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