Omer Danziger commited on
Commit
f1478d9
1 Parent(s): bb96974

working with demo question

Browse files
Files changed (1) hide show
  1. chatbot.py +11 -8
chatbot.py CHANGED
@@ -14,8 +14,11 @@ st.set_page_config(
14
  st.header("Streamlit Chat - Demo")
15
  # st.markdown("[Github](https://github.com/ai-yash/st-chat)")
16
 
17
- generated = []
18
- past = []
 
 
 
19
 
20
  def query(chat, payload):
21
  response = chat.answerStoreHistory(qn=payload)
@@ -34,11 +37,11 @@ chat = llm.get_chat(context="You are an helpfully assistant in a school. You are
34
  if user_input:
35
  output = chat.answerStoreHistory(qn=user_input)
36
 
37
- past.append(user_input)
38
- generated.append(output)
39
 
40
- if generated:
41
 
42
- for i in range(len(generated) - 1, -1, -1):
43
- message(generated[i], key=str(i))
44
- message(past[i], is_user=True, key=str(i) + '_user')
 
14
  st.header("Streamlit Chat - Demo")
15
  # st.markdown("[Github](https://github.com/ai-yash/st-chat)")
16
 
17
+ if 'generated' not in st.session_state:
18
+ st.session_state['generated'] = ['new']
19
+
20
+ if 'past' not in st.session_state:
21
+ st.session_state['past'] = ['new']
22
 
23
  def query(chat, payload):
24
  response = chat.answerStoreHistory(qn=payload)
 
37
  if user_input:
38
  output = chat.answerStoreHistory(qn=user_input)
39
 
40
+ st.session_state.past.append(user_input)
41
+ st.session_state.generated.append(output)
42
 
43
+ if st.session_state['generated']:
44
 
45
+ for i in range(len(st.session_state['generated'])-1, -1, -1):
46
+ message(st.session_state["generated"][i], key=str(i))
47
+ message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')