Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,10 @@ import pandas as pd
|
|
3 |
import google.generativeai as genai
|
4 |
import os
|
5 |
from io import StringIO
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Initialize Gemini
|
8 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
@@ -17,7 +21,6 @@ def load_data():
|
|
17 |
df = load_data()
|
18 |
|
19 |
# UI - Form for user input
|
20 |
-
st.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
|
21 |
st.title("AI-based Solar Project Estimation Tool")
|
22 |
st.write("### Enter Your Details Below:")
|
23 |
|
@@ -58,6 +61,7 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
|
|
58 |
|
59 |
prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw)
|
60 |
|
|
|
61 |
if prompt_text:
|
62 |
with st.spinner("Generating solar estimate with Gemini..."):
|
63 |
response = model.generate_content(prompt_text)
|
@@ -68,6 +72,4 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
|
|
68 |
else:
|
69 |
st.error("Sorry, the location entered does not match any available data.")
|
70 |
else:
|
71 |
-
st.warning("Please fill out all fields to see your solar project estimate.")
|
72 |
-
|
73 |
-
|
|
|
3 |
import google.generativeai as genai
|
4 |
import os
|
5 |
from io import StringIO
|
6 |
+
import csv
|
7 |
+
|
8 |
+
# Set page configuration first
|
9 |
+
st.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
|
10 |
|
11 |
# Initialize Gemini
|
12 |
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
|
|
|
21 |
df = load_data()
|
22 |
|
23 |
# UI - Form for user input
|
|
|
24 |
st.title("AI-based Solar Project Estimation Tool")
|
25 |
st.write("### Enter Your Details Below:")
|
26 |
|
|
|
61 |
|
62 |
prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw)
|
63 |
|
64 |
+
# Call Gemini API once for all the batch generation
|
65 |
if prompt_text:
|
66 |
with st.spinner("Generating solar estimate with Gemini..."):
|
67 |
response = model.generate_content(prompt_text)
|
|
|
72 |
else:
|
73 |
st.error("Sorry, the location entered does not match any available data.")
|
74 |
else:
|
75 |
+
st.warning("Please fill out all fields to see your solar project estimate.")
|
|
|
|