Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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})
|