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

Function sidebar

03-ai-agent-for-devops/code/13/app.py:166–258  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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