Illia56 commited on
Commit
883b37e
1 Parent(s): ffd3581

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -6
app.py CHANGED
@@ -27,9 +27,24 @@ def predict(message, system_prompt="", temperature=0.9, max_new_tokens=4096):
27
  st.title(TITLE)
28
  st.write(DESCRIPTION)
29
 
30
- prompt = st.chat_input("Ask llama 2...")
31
- if prompt:
32
- with st.chat_message("assistant"):
33
- st.write(prompt)
34
- with st.chat_message("llama", avatar='🦙'):
35
- st.write(predict(prompt, '',0.7,4096))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  st.title(TITLE)
28
  st.write(DESCRIPTION)
29
 
30
+ if "messages" not in st.session_state:
31
+ st.session_state.messages = []
32
+
33
+ # Display chat messages from history on app rerun
34
+ for message in st.session_state.messages:
35
+ with st.chat_message(message["role"]):
36
+ st.markdown(message["content"])
37
+
38
+ # React to user input
39
+ if prompt := st.chat_input("Ask LLama-2-70b anything..."):
40
+ # Display user message in chat message container
41
+ st.chat_message("human").markdown(prompt)
42
+ # Add user message to chat history
43
+ st.session_state.messages.append({"role": "human", "content": prompt})
44
+
45
+
46
+ # Display assistant response in chat message container
47
+ with st.chat_message("assistant", avatar='🦙'):
48
+ st.markdown(predict(prompt))
49
+ # Add assistant response to chat history
50
+ st.session_state.messages.append({"role": "assistant", "content": response})