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

Function main

03-ai-agent-for-devops/code/10/app.py:184–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182# Main
183# ─────────────────────────────────────────────────────────────
184def main():
185 init_session()
186 sidebar()
187
188 st.info("**Try:** *Analyze backend pod logs and detect issues*")
189 display_history()
190
191 if prompt := st.chat_input("Ask about backend logs, database issues, or pod status..."):
192 # Save and show user message
193 st.session_state.messages.append({"role": "user", "content": prompt})
194 with st.chat_message("user"):
195 st.markdown(prompt)
196
197 # Generate assistant response
198 with st.chat_message("assistant"):
199 status = st.status("Analyzing...", expanded=True)
200 progress = StreamlitProgress(status)
201
202 history = to_langchain(st.session_state.messages[:-1])
203
204 try:
205 response = st.session_state.agent.process_query(
206 user_input=prompt,
207 chat_history=history,
208 callbacks=progress,
209 )
210 if not response or not response.strip():
211 response = "No response generated. Try a different question."
212 progress.complete()
213 except Exception as e:
214 progress.error(str(e))
215 response = f"Error: {e}"
216
217 st.markdown(response)
218
219 st.session_state.messages.append({
220 "role": "assistant",
221 "content": response,
222 "steps": progress.steps,
223 })
224
225
226if __name__ == "__main__":

Callers 1

app.pyFile · 0.70

Calls 8

completeMethod · 0.95
errorMethod · 0.95
init_sessionFunction · 0.70
sidebarFunction · 0.70
display_historyFunction · 0.70
StreamlitProgressClass · 0.70
to_langchainFunction · 0.70
process_queryMethod · 0.45

Tested by

no test coverage detected