ogegadavis254 commited on
Commit
5f43718
·
verified ·
1 Parent(s): d46a0d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -13
app.py CHANGED
@@ -83,7 +83,6 @@ st.sidebar.write("A product proudly developed by Kisii University")
83
  # Initialize chat history
84
  if "messages" not in st.session_state:
85
  st.session_state.messages = []
86
- st.session_state.message_count = 0
87
 
88
  # Keywords for intervention
89
  intervention_keywords = [
@@ -100,7 +99,6 @@ if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
100
  st.markdown(prompt)
101
  # Add user message to chat history
102
  st.session_state.messages.append(("user", prompt))
103
- st.session_state.message_count += 1
104
 
105
  # Check if intervention is needed based on bot response
106
  if any(keyword in prompt.lower() for keyword in intervention_keywords):
@@ -111,15 +109,5 @@ if prompt := st.chat_input(f"Hi, I'm {selected_model}, ask me a question"):
111
  assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
112
 
113
  # Display assistant response in chat message container
114
- with st.empty():
115
- st.markdown("AI is typing...")
116
- st.empty()
117
  st.markdown(assistant_response)
118
-
119
- # Add assistant response to chat history
120
- st.session_state.messages.append(("assistant", assistant_response))
121
-
122
- # Display chat history
123
- for role, message in st.session_state.messages:
124
- with st.chat_message(role):
125
- st.markdown(message)
 
83
  # Initialize chat history
84
  if "messages" not in st.session_state:
85
  st.session_state.messages = []
 
86
 
87
  # Keywords for intervention
88
  intervention_keywords = [
 
99
  st.markdown(prompt)
100
  # Add user message to chat history
101
  st.session_state.messages.append(("user", prompt))
 
102
 
103
  # Check if intervention is needed based on bot response
104
  if any(keyword in prompt.lower() for keyword in intervention_keywords):
 
109
  assistant_response = interact_with_together_api(st.session_state.messages, model_links[selected_model])
110
 
111
  # Display assistant response in chat message container
112
+ with st.chat_message("assistant"):
 
 
113
  st.markdown(assistant_response)