Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ import os
|
|
5 |
from dotenv import load_dotenv
|
6 |
import plotly.graph_objects as go
|
7 |
|
8 |
-
|
9 |
# Load environment variables from .env file
|
10 |
load_dotenv()
|
11 |
|
@@ -35,16 +34,13 @@ def build_prompt(location, project_type, roof_size=None, desired_kwh=None, elect
|
|
35 |
if project_type == "Rooftop Solar":
|
36 |
prompt = f"""
|
37 |
You are an AI-based solar project estimator.
|
38 |
-
|
39 |
Use the following calculation methods:
|
40 |
-
|
41 |
- Estimated system size (kW) = Roof size (sq meters) × 0.15
|
42 |
- Estimated daily solar output (kWh) = System size (kW) × Average GHI (kWh/m²/day)
|
43 |
- Total system cost (₹) = System size (kW) × Solar system cost per kW
|
44 |
- Assume tariff rate = ₹7/kWh
|
45 |
- Monthly savings (₹) = Estimated daily output × 30 × 7
|
46 |
- Payback period (years) = Total system cost ÷ (Monthly savings × 12)
|
47 |
-
|
48 |
Inputs:
|
49 |
- Project Type: Rooftop Solar
|
50 |
- Location: {location}
|
@@ -52,7 +48,6 @@ Inputs:
|
|
52 |
- Monthly Electricity Bill: ₹{electricity_bill}
|
53 |
- Average GHI: {ghi} kWh/m²/day
|
54 |
- Solar System Cost per kW: ₹{solar_cost_per_kw}
|
55 |
-
|
56 |
Now, calculate and return strictly in this format:
|
57 |
Estimated solar system size in kW: <value>
|
58 |
Estimated daily solar output in kWh: <value>
|
@@ -63,16 +58,13 @@ Payback period in years: <value>
|
|
63 |
else:
|
64 |
prompt = f"""
|
65 |
You are an AI-based solar project estimator.
|
66 |
-
|
67 |
Use the following calculation methods:
|
68 |
-
|
69 |
- Required system size (kW) = Desired monthly solar production ÷ (30 × Average GHI)
|
70 |
- Estimated daily solar output (kWh) = System size (kW) × Average GHI (kWh/m²/day)
|
71 |
- Total system cost (₹) = System size (kW) × Solar system cost per kW
|
72 |
- Assume tariff rate = ₹7/kWh
|
73 |
- Monthly savings (₹) = Estimated daily output × 30 × 7
|
74 |
- Payback period (years) = Total system cost ÷ (Monthly savings × 12)
|
75 |
-
|
76 |
Inputs:
|
77 |
- Project Type: Ground Mount Solar
|
78 |
- Location: {location}
|
@@ -80,7 +72,6 @@ Inputs:
|
|
80 |
- Monthly Electricity Bill: ₹{electricity_bill}
|
81 |
- Average GHI: {ghi} kWh/m²/day
|
82 |
- Solar System Cost per kW: ₹{solar_cost_per_kw}
|
83 |
-
|
84 |
Now, calculate and return strictly in this format:
|
85 |
Required solar system size in kW: <value>
|
86 |
Estimated daily solar output in kWh: <value>
|
@@ -124,6 +115,14 @@ if submitted and location:
|
|
124 |
ghi = state_data['Avg_GHI (kWh/m²/day)']
|
125 |
solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
prompt_text = build_prompt(location, project_type, roof_size=roof_size, desired_kwh=desired_kwh, electricity_bill=electricity_bill, ghi=ghi, solar_cost_per_kw=solar_cost_per_kw)
|
128 |
|
129 |
# Call Gemini API
|
|
|
5 |
from dotenv import load_dotenv
|
6 |
import plotly.graph_objects as go
|
7 |
|
|
|
8 |
# Load environment variables from .env file
|
9 |
load_dotenv()
|
10 |
|
|
|
34 |
if project_type == "Rooftop Solar":
|
35 |
prompt = f"""
|
36 |
You are an AI-based solar project estimator.
|
|
|
37 |
Use the following calculation methods:
|
|
|
38 |
- Estimated system size (kW) = Roof size (sq meters) × 0.15
|
39 |
- Estimated daily solar output (kWh) = System size (kW) × Average GHI (kWh/m²/day)
|
40 |
- Total system cost (₹) = System size (kW) × Solar system cost per kW
|
41 |
- Assume tariff rate = ₹7/kWh
|
42 |
- Monthly savings (₹) = Estimated daily output × 30 × 7
|
43 |
- Payback period (years) = Total system cost ÷ (Monthly savings × 12)
|
|
|
44 |
Inputs:
|
45 |
- Project Type: Rooftop Solar
|
46 |
- Location: {location}
|
|
|
48 |
- Monthly Electricity Bill: ₹{electricity_bill}
|
49 |
- Average GHI: {ghi} kWh/m²/day
|
50 |
- Solar System Cost per kW: ₹{solar_cost_per_kw}
|
|
|
51 |
Now, calculate and return strictly in this format:
|
52 |
Estimated solar system size in kW: <value>
|
53 |
Estimated daily solar output in kWh: <value>
|
|
|
58 |
else:
|
59 |
prompt = f"""
|
60 |
You are an AI-based solar project estimator.
|
|
|
61 |
Use the following calculation methods:
|
|
|
62 |
- Required system size (kW) = Desired monthly solar production ÷ (30 × Average GHI)
|
63 |
- Estimated daily solar output (kWh) = System size (kW) × Average GHI (kWh/m²/day)
|
64 |
- Total system cost (₹) = System size (kW) × Solar system cost per kW
|
65 |
- Assume tariff rate = ₹7/kWh
|
66 |
- Monthly savings (₹) = Estimated daily output × 30 × 7
|
67 |
- Payback period (years) = Total system cost ÷ (Monthly savings × 12)
|
|
|
68 |
Inputs:
|
69 |
- Project Type: Ground Mount Solar
|
70 |
- Location: {location}
|
|
|
72 |
- Monthly Electricity Bill: ₹{electricity_bill}
|
73 |
- Average GHI: {ghi} kWh/m²/day
|
74 |
- Solar System Cost per kW: ₹{solar_cost_per_kw}
|
|
|
75 |
Now, calculate and return strictly in this format:
|
76 |
Required solar system size in kW: <value>
|
77 |
Estimated daily solar output in kWh: <value>
|
|
|
115 |
ghi = state_data['Avg_GHI (kWh/m²/day)']
|
116 |
solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']
|
117 |
|
118 |
+
# Check roof size limit for rooftop solar
|
119 |
+
if project_type == "Rooftop Solar" and roof_size:
|
120 |
+
max_allowed_kw = roof_size * 0.15
|
121 |
+
if max_allowed_kw > 5: # Maximum 5 kW limit
|
122 |
+
st.warning(f"Roof size exceeds the maximum allowed capacity of 5 kW. The system size will be limited to 5 kW.")
|
123 |
+
max_allowed_kw = 5
|
124 |
+
roof_size = max_allowed_kw / 0.15 # Adjust roof size to fit within the limit
|
125 |
+
|
126 |
prompt_text = build_prompt(location, project_type, roof_size=roof_size, desired_kwh=desired_kwh, electricity_bill=electricity_bill, ghi=ghi, solar_cost_per_kw=solar_cost_per_kw)
|
127 |
|
128 |
# Call Gemini API
|