MCPcopy Create free account
hub / github.com/VersusControl/devops-ai-guidelines / sidebar

Function sidebar

03-ai-agent-for-devops/code/14/app.py:169–266  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

167# Sidebar
168# ─────────────────────────────────────────────────────────────
169def sidebar():
170 with st.sidebar:
171 st.title("AI Logging Agent")
172 st.markdown("---")
173
174 st.subheader("Configuration")
175 provider = {"gemini": "Gemini", "github": "GitHub Models", "minimax": "MiniMax"}.get(
176 Config.LLM_PROVIDER, Config.LLM_PROVIDER,
177 )
178 st.markdown(f"- Provider: **{provider}**")
179 st.markdown(f"- AWS: {'Connected' if Config.is_aws_configured() else 'Placeholder mode'}")
180 st.markdown(f"- Slack: {'Connected' if Config.is_slack_configured() else 'Placeholder mode'}")
181 st.markdown(f"- Elasticsearch: {'Connected' if Config.is_elasticsearch_configured() else 'Placeholder mode'}")
182
183 # ── Memory section ──────────────────────────────────
184 st.markdown("---")
185 st.subheader("Memory")
186 incident_store: IncidentStore = st.session_state.incident_store
187 n_incidents = incident_store.count()
188 n_messages = len(st.session_state.messages)
189 st.markdown(f"- Chat messages: **{n_messages}**")
190 st.markdown(f"- Past incidents: **{n_incidents}**")
191
192 if n_incidents > 0:
193 with st.expander("Recent incidents", expanded=False):
194 for inc in incident_store.get_recent(3):
195 st.write(
196 f"**[{inc['severity']}]** {inc['summary']} \n"
197 f"_{inc['timestamp'][:10]}_"
198 )
199
200 # ── Save incident ───────────────────────────────────
201 st.markdown("---")
202 st.subheader("Save Incident")
203 with st.form("save_incident", clear_on_submit=True):
204 summary = st.text_input("Summary", placeholder="RDS connection exhaustion on orders-db-prod")
205 severity = st.selectbox("Severity", ["P1", "P2", "P3", "info"])
206 root_cause = st.text_input("Root cause", placeholder="3 pods × 50 conn = 150 max")
207 resolution = st.text_input("Resolution", placeholder="RDS reboot, pool resize to 30")
208 affected = st.text_input("Affected systems", placeholder="orders-db-prod, backend pods")
209 submitted = st.form_submit_button("Save to memory")
210 if submitted and summary:
211 incident_store.add(
212 summary=summary,
213 severity=severity,
214 root_cause=root_cause,
215 resolution=resolution,
216 affected_systems=affected,
217 session_id=st.session_state.chat_store.session_id,
218 )
219 # Rebuild agent so it picks up the new incident
220 recent = incident_store.get_recent(5)
221 context = incident_store.format_for_prompt(recent)
222 st.session_state.agent = LogAnalyzerAgent(incident_context=context)
223 st.rerun()
224
225 # ── Tools ───────────────────────────────────────────
226 st.markdown("---")

Callers 1

mainFunction · 0.70

Calls 9

LogAnalyzerAgentClass · 0.90
is_aws_configuredMethod · 0.45
is_slack_configuredMethod · 0.45
countMethod · 0.45
get_recentMethod · 0.45
addMethod · 0.45
format_for_promptMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected