Update app.py
Browse files
app.py
CHANGED
@@ -6,10 +6,11 @@ from io import StringIO
|
|
6 |
import csv
|
7 |
from dotenv import load_dotenv
|
8 |
|
|
|
9 |
# Load environment variables from .env file
|
10 |
load_dotenv()
|
11 |
|
12 |
-
# Set page configuration
|
13 |
st.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
|
14 |
|
15 |
# Initialize Gemini with the API key loaded from the .env file
|
@@ -73,10 +74,13 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
|
|
73 |
with st.spinner("Generating solar estimate with Gemini..."):
|
74 |
response = model.generate_content(prompt_text)
|
75 |
|
|
|
|
|
|
|
76 |
# Display structured output with only the requested points
|
77 |
st.subheader("Solar Project Estimate")
|
78 |
|
79 |
-
# Break down the response into structured points
|
80 |
estimated_data = response.text.strip().split("\n")
|
81 |
|
82 |
# Initialize values for each field
|
@@ -96,7 +100,7 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
|
|
96 |
elif "payback period" in point.lower():
|
97 |
payback_period = point.split(":")[1].strip()
|
98 |
|
99 |
-
#
|
100 |
if system_size and total_cost and monthly_savings and payback_period:
|
101 |
st.write(f"1. Estimated solar system size in kW: {system_size}")
|
102 |
st.write(f"2. Total system cost in ₹: {total_cost}")
|
|
|
6 |
import csv
|
7 |
from dotenv import load_dotenv
|
8 |
|
9 |
+
|
10 |
# Load environment variables from .env file
|
11 |
load_dotenv()
|
12 |
|
13 |
+
# Set page configuration
|
14 |
st.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
|
15 |
|
16 |
# Initialize Gemini with the API key loaded from the .env file
|
|
|
74 |
with st.spinner("Generating solar estimate with Gemini..."):
|
75 |
response = model.generate_content(prompt_text)
|
76 |
|
77 |
+
# Debug: Print the raw response to see the structure
|
78 |
+
st.write("Raw Response:", response.text)
|
79 |
+
|
80 |
# Display structured output with only the requested points
|
81 |
st.subheader("Solar Project Estimate")
|
82 |
|
83 |
+
# Break down the response into structured points
|
84 |
estimated_data = response.text.strip().split("\n")
|
85 |
|
86 |
# Initialize values for each field
|
|
|
100 |
elif "payback period" in point.lower():
|
101 |
payback_period = point.split(":")[1].strip()
|
102 |
|
103 |
+
# Ensure that we only display numeric values for the fields
|
104 |
if system_size and total_cost and monthly_savings and payback_period:
|
105 |
st.write(f"1. Estimated solar system size in kW: {system_size}")
|
106 |
st.write(f"2. Total system cost in ₹: {total_cost}")
|