Main application logic
()
| 132 | |
| 133 | |
| 134 | def 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 | |
| 184 | if __name__ == "__main__": |
no test coverage detected