MLDeveloper commited on
Commit
24c1abd
·
verified ·
1 Parent(s): fdd0b88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -10
app.py CHANGED
@@ -6,12 +6,6 @@ from io import StringIO
6
  import csv
7
  from dotenv import load_dotenv
8
 
9
- import streamlit as st
10
- import pandas as pd
11
- import google.generativeai as genai
12
- import os
13
- from dotenv import load_dotenv
14
-
15
  # Load environment variables from .env file
16
  load_dotenv()
17
 
@@ -82,13 +76,34 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
82
  # Display structured output with only the requested points
83
  st.subheader("Solar Project Estimate")
84
 
85
- # Break down the response into structured points
86
  estimated_data = response.text.strip().split("\n")
87
 
88
- # Display only the required points: system size, cost, savings, and payback period
 
 
 
 
 
 
89
  for point in estimated_data:
90
- if "solar system size" in point.lower() or "total system cost" in point.lower() or "monthly savings" in point.lower() or "payback period" in point.lower():
91
- st.write(point.strip())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  else:
93
  st.error("Sorry, the location entered does not match any available data.")
94
  else:
 
6
  import csv
7
  from dotenv import load_dotenv
8
 
 
 
 
 
 
 
9
  # Load environment variables from .env file
10
  load_dotenv()
11
 
 
76
  # Display structured output with only the requested points
77
  st.subheader("Solar Project Estimate")
78
 
79
+ # Break down the response into structured points and extract only the numeric values
80
  estimated_data = response.text.strip().split("\n")
81
 
82
+ # Initialize values for each field
83
+ system_size = None
84
+ total_cost = None
85
+ monthly_savings = None
86
+ payback_period = None
87
+
88
+ # Parse the response to find and assign the correct values
89
  for point in estimated_data:
90
+ if "solar system size" in point.lower():
91
+ system_size = point.split(":")[1].strip()
92
+ elif "total system cost" in point.lower():
93
+ total_cost = point.split(":")[1].strip()
94
+ elif "monthly savings" in point.lower():
95
+ monthly_savings = point.split(":")[1].strip()
96
+ elif "payback period" in point.lower():
97
+ payback_period = point.split(":")[1].strip()
98
+
99
+ # Display the values without any additional explanation
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}")
103
+ st.write(f"3. Monthly savings in ₹: {monthly_savings}")
104
+ st.write(f"4. Payback period in years: {payback_period}")
105
+ else:
106
+ st.error("Unable to extract valid data from the response.")
107
  else:
108
  st.error("Sorry, the location entered does not match any available data.")
109
  else: