ageraustine commited on
Commit
b60483e
·
verified ·
1 Parent(s): 5c301da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
app.py CHANGED
@@ -108,24 +108,24 @@ message.write("Good to see you. Please tell me your latest career")
108
 
109
 
110
  user_input = st.chat_input("Enter your Response")
 
 
 
111
 
112
  if st.button("Send"):
113
  if user_input:
114
  # Execute LangChain logic
115
- outputs = execute_langchain(user_input)
116
-
117
- # Update conversation history
118
- conversation_history.append(("You", user_input))
119
- for key, value in outputs:
120
- if key == "Output from node 'info':":
121
- conversation_history.append(("Bot", value))
122
- message.write(value)
123
- elif key == "Output from node 'profile':":
124
- conversation_history.append(("Bot", value))
125
- message.write(value)
126
-
127
  # Allow the user to quit the chat
128
  if st.button("Quit"):
129
  st.text("Bot: Byebye")
130
- break
131
 
 
108
 
109
 
110
  user_input = st.chat_input("Enter your Response")
111
+
112
+ if "chat_history" not in st.session_state:
113
+ st.session_state["chat_history"] = []
114
 
115
  if st.button("Send"):
116
  if user_input:
117
  # Execute LangChain logic
118
+ outputs = execute_langchain(user_input)
119
+ # Update chat history
120
+ st.session_state["chat_history"].append({"message": user_input, "role": "user"})
121
+ st.session_state["chat_history"].append({"message": outputs, "role": "bot"})
122
+
123
+ # Display chat history
124
+ for message in st.session_state["chat_history"]:
125
+ st.chat_message(message["message"], key=message["message"])
126
+
 
 
 
127
  # Allow the user to quit the chat
128
  if st.button("Quit"):
129
  st.text("Bot: Byebye")
130
+
131