neuralleap commited on
Commit
4ef3643
1 Parent(s): 4190897

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -15,6 +15,11 @@ from langchain_groq import ChatGroq
15
  from langchain.prompts import PromptTemplate
16
 
17
 
 
 
 
 
 
18
  def main():
19
  """
20
  This function is the main entry point of the application. It sets up the Groq client, the Streamlit interface, and handles the chat interaction.
@@ -38,7 +43,8 @@ def main():
38
 
39
  memory = ConversationBufferWindowMemory(k=7, memory_key="chat_history", return_messages=True)
40
 
41
- user_question = st.text_input("Ask a question:")
 
42
 
43
  # session state variable
44
  if 'chat_history' not in st.session_state:
 
15
  from langchain.prompts import PromptTemplate
16
 
17
 
18
+ def on_message_change():
19
+ st.session_state.history.append(st.session_state.message)
20
+ st.session_state.message = ""
21
+
22
+
23
  def main():
24
  """
25
  This function is the main entry point of the application. It sets up the Groq client, the Streamlit interface, and handles the chat interaction.
 
43
 
44
  memory = ConversationBufferWindowMemory(k=7, memory_key="chat_history", return_messages=True)
45
 
46
+ user_question = st.text_input("Ask a question:", on_change=on_message_change)
47
+
48
 
49
  # session state variable
50
  if 'chat_history' not in st.session_state: