Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import pandas as pd
|
|
3 |
import google.generativeai as genai
|
4 |
import os
|
5 |
from dotenv import load_dotenv
|
|
|
6 |
|
7 |
# Load environment variables from .env file
|
8 |
load_dotenv()
|
@@ -85,6 +86,40 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
|
|
85 |
if ":" in point:
|
86 |
key, value = point.split(":", 1)
|
87 |
st.write(f"**{key.strip()}**: {value.strip()}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
else:
|
89 |
st.error("Sorry, the location entered does not match any available data.")
|
90 |
else:
|
|
|
3 |
import google.generativeai as genai
|
4 |
import os
|
5 |
from dotenv import load_dotenv
|
6 |
+
import plotly.graph_objects as go
|
7 |
|
8 |
# Load environment variables from .env file
|
9 |
load_dotenv()
|
|
|
86 |
if ":" in point:
|
87 |
key, value = point.split(":", 1)
|
88 |
st.write(f"**{key.strip()}**: {value.strip()}")
|
89 |
+
|
90 |
+
# Variables to store extracted values for graph
|
91 |
+
system_size_kw = None
|
92 |
+
monthly_savings_rs = None
|
93 |
+
|
94 |
+
for point in estimated_data:
|
95 |
+
if ":" in point:
|
96 |
+
try:
|
97 |
+
key, value = point.split(":", 1)
|
98 |
+
key = key.strip()
|
99 |
+
value = value.strip()
|
100 |
+
|
101 |
+
st.write(f"**{key}**: {value}")
|
102 |
+
|
103 |
+
if "Estimated solar system size" in key:
|
104 |
+
system_size_kw = float(value.split()[0])
|
105 |
+
if "Monthly savings" in key:
|
106 |
+
monthly_savings_rs = float(value.split()[0])
|
107 |
+
except ValueError:
|
108 |
+
st.warning("There was an issue processing the response.")
|
109 |
+
|
110 |
+
# Show Graph if available
|
111 |
+
if system_size_kw is not None and monthly_savings_rs is not None:
|
112 |
+
st.subheader("📊 Visual Summary")
|
113 |
+
|
114 |
+
fig = go.Figure(data=[
|
115 |
+
go.Bar(name='Estimate',
|
116 |
+
x=['Solar System Size (kW)', 'Monthly Savings (₹)'],
|
117 |
+
y=[system_size_kw, monthly_savings_rs],
|
118 |
+
marker_color=['#636EFA', '#00CC96'])
|
119 |
+
])
|
120 |
+
fig.update_layout(title="Solar Project Estimates", yaxis_title="Values", xaxis_title="Parameters")
|
121 |
+
st.plotly_chart(fig)
|
122 |
+
|
123 |
else:
|
124 |
st.error("Sorry, the location entered does not match any available data.")
|
125 |
else:
|