Update app.py
Browse files69 unmodified lines70717273747573777879808182838485868788899091929394959697989910010169 unmodified lineselse: st.warning("Please fill out all fields to see your solar project estimate.")
# Batch CSV Exportst.markdown("### Export Solar Estimates")batch = st.number_input("How many estimates to generate?", min_value=1, max_value=100, value=5)
if st.button("Generate Batch & Download CSV"): if location and roof_size > 0 and electricity_bill >= 0: csv_buffer = StringIO() writer = csv.writer(csv_buffer) writer.writerow(["Sequence_no", "Solar Estimate"]) with st.spinner("Generating estimates..."): for i in range(1, batch + 1): state_data = df[df['State'].str.contains(location, case=False)].iloc[0] ghi = state_data['Avg_GHI (kWh/m²/day)'] solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)'] prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw) # Generate the estimate using Gemini response = model.generate_content(prompt_text) writer.writerow([i, response.text.strip()]) st.download_button( label="Download Solar Estimates CSV", data=csv_buffer.getvalue(), file_name="solar_estimates.csv", mime="text/csv" ) else: st.warning("Please fill out all fields to generate batch estimates.")app.py-28