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

Function sidebar

03-ai-agent-for-devops/code/12/app.py:162–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 8

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