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

Function main

03-ai-agent-for-devops/code/08/app.py:109–151  ·  view source on GitHub ↗

Main application logic

()

Source from the content-addressed store, hash-verified

107
108
109def main():
110 """Main application logic"""
111 # Initialize session state
112 initialize_session_state()
113
114 # Display sidebar
115 display_sidebar()
116
117 # Main content area
118 st.title("Chat with AI Log Analyzer")
119 st.markdown("Ask me anything about your log files!")
120
121 # Display chat messages
122 display_chat_messages()
123
124 # Chat input
125 if prompt := st.chat_input("Ask about your logs..."):
126 # Add user message to chat
127 st.session_state.messages.append({"role": "user", "content": prompt})
128
129 # Display user message
130 with st.chat_message("user"):
131 st.markdown(prompt)
132
133 # Get agent response
134 with st.chat_message("assistant"):
135 with st.spinner("Analyzing..."):
136 # Convert chat history to LangChain format
137 chat_history = convert_to_langchain_messages(
138 st.session_state.messages[:-1] # Exclude the current message
139 )
140
141 # Get response from agent
142 response = st.session_state.agent.process_query(
143 user_input=prompt,
144 chat_history=chat_history
145 )
146
147 # Display response
148 st.markdown(response)
149
150 # Add assistant response to chat history
151 st.session_state.messages.append({"role": "assistant", "content": response})
152
153
154if __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