Update app.py
Browse files2 unmodified lines345678976 unmodified lines86878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241252 unmodified linesimport google.generativeai as genaiimport osfrom dotenv import load_dotenvimport plotly.graph_objects as go
# Load environment variables from .env fileload_dotenv()76 unmodified lines if ":" in point: key, value = point.split(":", 1) st.write(f"**{key.strip()}**: {value.strip()}") # Variables to store extracted values for graph system_size_kw = None monthly_savings_rs = None
for point in estimated_data: if ":" in point: try: key, value = point.split(":", 1) key = key.strip() value = value.strip()
st.write(f"**{key}**: {value}")
if "Estimated solar system size" in key: system_size_kw = float(value.split()[0]) if "Monthly savings" in key: monthly_savings_rs = float(value.split()[0]) except ValueError: st.warning("There was an issue processing the response.")
# Show Graph if available if system_size_kw is not None and monthly_savings_rs is not None: st.subheader("📊 Visual Summary") fig = go.Figure(data=[ go.Bar(name='Estimate', x=['Solar System Size (kW)', 'Monthly Savings (₹)'], y=[system_size_kw, monthly_savings_rs], marker_color=['#636EFA', '#00CC96']) ]) fig.update_layout(title="Solar Project Estimates", yaxis_title="Values", xaxis_title="Parameters") st.plotly_chart(fig) else: st.error("Sorry, the location entered does not match any available data.")else:app.py+35