MLDeveloper commited on
Commit
d36a0d6
·
verified ·
1 Parent(s): 4efe5ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -20
app.py CHANGED
@@ -68,6 +68,7 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
68
  solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']
69
 
70
  prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw)
 
71
  # Call Gemini API once for all the batch generation
72
  with st.spinner("Generating solar estimate with Gemini..."):
73
  response = model.generate_content(prompt_text)
@@ -75,31 +76,14 @@ if submitted and location and roof_size > 0 and electricity_bill >= 0:
75
  # Display structured output with only the requested points
76
  st.subheader("Solar Project Estimate")
77
 
78
- # Log the full response to check its structure
79
- st.write("Raw response from Gemini:", response.text.strip())
80
-
81
  # Break down the response into structured points
82
  estimated_data = response.text.strip().split("\n")
83
 
84
- # Extract the values for solar system size, cost, savings, and payback period
85
- values = []
86
  for point in estimated_data:
87
  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():
88
- # Extract the values and append to the list
89
- values.append(point.strip())
90
-
91
- # Log the extracted values
92
- st.write("Extracted values:", values)
93
-
94
- # Display the values in 4 lines as requested
95
- if len(values) == 4:
96
- st.write(f"1. {values[0]}")
97
- st.write(f"2. {values[1]}")
98
- st.write(f"3. {values[2]}")
99
- st.write(f"4. {values[3]}")
100
- else:
101
- st.error("Could not extract the expected values.")
102
  else:
103
  st.error("Sorry, the location entered does not match any available data.")
104
  else:
105
- st.warning("Please fill out all fields to see your solar project estimate.")
 
68
  solar_cost_per_kw = state_data['Solar_Cost_per_kW (₹)']
69
 
70
  prompt_text = build_prompt(location, roof_size, electricity_bill, ghi, solar_cost_per_kw)
71
+
72
  # Call Gemini API once for all the batch generation
73
  with st.spinner("Generating solar estimate with Gemini..."):
74
  response = model.generate_content(prompt_text)
 
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
+ # Display only the required points: system size, cost, savings, and payback period
 
83
  for point in estimated_data:
84
  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():
85
+ st.write(f"{point.strip()}")
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  else:
87
  st.error("Sorry, the location entered does not match any available data.")
88
  else:
89
+ st.warning("Please fill out all fields to see your solar project estimate.")