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

Function main

03-ai-agent-for-devops/code/09/app.py:134–181  ·  view source on GitHub ↗

Main application logic

()

Source from the content-addressed store, hash-verified

132
133
134def main():
135 """Main application logic"""
136 # Initialize session state
137 initialize_session_state()
138
139 # Display sidebar
140 display_sidebar()
141
142 # Main content area
143 st.markdown("Analyze pod logs and manage incidents with intelligent automation")
144
145 # Info banner
146 st.info("""
147 💡 **Tip**: Ask me to check `app.log` to see intelligent incident analysis!
148 I will analyze the issue, recommend actions, and wait for your confirmation before executing.
149 """)
150
151 # Display chat messages
152 display_chat_messages()
153
154 # Chat input
155 if prompt := st.chat_input("Ask about Kubernetes logs or pod status..."):
156 # Add user message to chat
157 st.session_state.messages.append({"role": "user", "content": prompt})
158
159 # Display user message
160 with st.chat_message("user"):
161 st.markdown(prompt)
162
163 # Get agent response
164 with st.chat_message("assistant"):
165 with st.spinner("Analyzing logs and checking pod status..."):
166 # Convert chat history to LangChain format
167 chat_history = convert_to_langchain_messages(
168 st.session_state.messages[:-1] # Exclude the current message
169 )
170
171 # Get response from agent
172 response = st.session_state.agent.process_query(
173 user_input=prompt,
174 chat_history=chat_history
175 )
176
177 # Display response
178 st.markdown(response)
179
180 # Add assistant response to chat history
181 st.session_state.messages.append({"role": "assistant", "content": response})
182
183
184if __name__ == "__main__":

Callers 1

app.pyFile · 0.70

Calls 5

initialize_session_stateFunction · 0.70
display_sidebarFunction · 0.70
display_chat_messagesFunction · 0.70
process_queryMethod · 0.45

Tested by

no test coverage detected