Update app.py
Browse files
app.py
CHANGED
@@ -5,12 +5,24 @@ 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 |
-
#
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Load solar data
|
16 |
@st.cache_data
|
@@ -84,7 +96,7 @@ if st.button("Generate Batch & Download CSV"):
|
|
84 |
if location and roof_size > 0 and electricity_bill >= 0:
|
85 |
csv_buffer = StringIO()
|
86 |
writer = csv.writer(csv_buffer)
|
87 |
-
writer.writerow(["Sequence_no", "Solar Estimate"])
|
88 |
|
89 |
# Call Gemini API once for the batch generation
|
90 |
with st.spinner("Generating batch estimates..."):
|
@@ -103,3 +115,5 @@ if st.button("Generate Batch & Download CSV"):
|
|
103 |
)
|
104 |
else:
|
105 |
st.warning("Please fill out all fields to generate batch estimates.")
|
|
|
|
|
|
5 |
from io import StringIO
|
6 |
import csv
|
7 |
|
8 |
+
import streamlit as st
|
9 |
+
import pandas as pd
|
10 |
+
import google.generativeai as genai
|
11 |
+
import os
|
12 |
+
from io import StringIO
|
13 |
+
import csv
|
14 |
+
|
15 |
# Set page configuration first
|
16 |
st.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
|
17 |
|
18 |
+
# Get API key from environment variable
|
19 |
+
api_key = os.getenv("GOOGLE_API_KEY")
|
20 |
+
if not api_key:
|
21 |
+
st.error("Google API Key not set. Please set the GOOGLE_API_KEY environment variable.")
|
22 |
+
else:
|
23 |
+
# Initialize Gemini with the API key
|
24 |
+
genai.configure(api_key=api_key) # Ensure your Gemini API key is set correctly
|
25 |
+
model = genai.GenerativeModel("gemini-1.5-flash")
|
26 |
|
27 |
# Load solar data
|
28 |
@st.cache_data
|
|
|
96 |
if location and roof_size > 0 and electricity_bill >= 0:
|
97 |
csv_buffer = StringIO()
|
98 |
writer = csv.writer(csv_buffer)
|
99 |
+
writer.writerow(["Sequence_no", "Solar Estimate"] )
|
100 |
|
101 |
# Call Gemini API once for the batch generation
|
102 |
with st.spinner("Generating batch estimates..."):
|
|
|
115 |
)
|
116 |
else:
|
117 |
st.warning("Please fill out all fields to generate batch estimates.")
|
118 |
+
|
119 |
+
|