rishabh5752 commited on
Commit
b2fe490
·
verified ·
1 Parent(s): b50c102

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +0 -40
src/streamlit_app.py CHANGED
@@ -104,43 +104,3 @@ with right_col:
104
  b2.metric("DER Bill", f"${bill_der:,.0f}", delta=f"${bill_der-bill_nonder:,.0f}")
105
  b3.metric("Payback Period", f"{payback:.1f} yrs" if payback != math.inf else "N/A")
106
 
107
- st.markdown("---")
108
-
109
-
110
- st.markdown("### 🤖 Analysis")
111
-
112
- if os.getenv("OPENAI_API_KEY"):
113
- try:
114
- import openai
115
- openai.api_key = os.getenv("OPENAI_API_KEY")
116
-
117
- prompt = (
118
- f"Write a clear, well-formatted summary in 2-3 complete sentences with proper spacing:\n\n"
119
- f"A {owner} with a {pv_kw} kW solar system and {batt_kwh} kWh battery "
120
- f"earns {coins_total:.1f} GridCoins valued at ${coin_dollars:.2f} annually. "
121
- f"Their annual electricity bill is ${bill_der:,.0f} (DER) compared to ${bill_nonder:,.0f} (Non-DER), "
122
- f"with a payback period of {payback:.1f} years.\n\n"
123
- "Explain the financial benefits clearly and concisely. Use proper sentence structure with spaces between words."
124
- )
125
-
126
- with st.spinner("Generating..."):
127
- resp = openai.ChatCompletion.create(
128
- model="gpt-4o",
129
- messages=[
130
- {"role": "system", "content": "You are a helpful energy policy assistant. Provide clear, concise summaries."},
131
- {"role": "user", "content": prompt}
132
- ],
133
- max_tokens=150,
134
- temperature=0.7
135
- )
136
- summary = resp.choices[0].message.content.strip()
137
-
138
- st.markdown(f"""
139
- <div style="background-color: #e8f4f8; padding: 1rem; border-radius: 0.5rem; border-left: 4px solid #0068c9;">
140
- <p style="margin: 0; line-height: 1.6; color: #0c0c0c;">{summary}</p>
141
- </div>
142
- """, unsafe_allow_html=True)
143
- except Exception as e:
144
- st.warning(f"AI summary unavailable: {e}")
145
- else:
146
- st.caption("Set OPENAI_API_KEY to enable AI summaries.")
 
104
  b2.metric("DER Bill", f"${bill_der:,.0f}", delta=f"${bill_der-bill_nonder:,.0f}")
105
  b3.metric("Payback Period", f"{payback:.1f} yrs" if payback != math.inf else "N/A")
106