Update app.py
Browse files3 unmodified lines456789101112131412131415151617181917181920212223242567 unmodified lines939495939697989912 unmodified lines1121131141121133 unmodified linesimport osfrom io import StringIOimport csvfrom dotenv import load_dotenv
# Load environment variables from .env fileload_dotenv()
# Set page configuration firstst.set_page_config(page_title="AI-based Solar Project Estimation Tool", layout="centered")
# Get API key from environment variableapi_key = os.getenv("AIzaSyCVRGVxIe1vESoAgykgHWOej-jZxiU-RKE")if not api_key: st.error("Google API Key not set. Please set the GOOGLE_API_KEY environment variable.")# Initialize Gemini with the API key loaded from the .env fileapi_key = os.getenv("GOOGLE_API_KEY")if api_key: genai.configure(api_key=api_key)else: # Initialize Gemini with the API key genai.configure(api_key=api_key) # Ensure your Gemini API key is set correctly model = genai.GenerativeModel("gemini-1.5-flash") st.error("API key is missing. Please set the GOOGLE_API_KEY environment variable.")
model = genai.GenerativeModel("gemini-1.5-flash")
# Load solar data@st.cache_data67 unmodified lines if location and roof_size > 0 and electricity_bill >= 0: csv_buffer = StringIO() writer = csv.writer(csv_buffer) writer.writerow(["Sequence_no", "Solar Estimate"] ) writer.writerow(["Sequence_no", "Solar Estimate"]) # Call Gemini API once for the batch generation with st.spinner("Generating batch estimates..."):12 unmodified lines ) else: st.warning("Please fill out all fields to generate batch estimates.")
app.py+11-10