Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,21 @@ with st.sidebar:
|
|
27 |
Enjoy chatting with Meta's Llama3 model!
|
28 |
""")
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Add a button to clear the session state
|
31 |
if st.button("Clear Session"):
|
32 |
st.session_state.messages = []
|
@@ -57,4 +72,20 @@ if prompt := st.chat_input("What is up?"):
|
|
57 |
with st.chat_message("assistant"):
|
58 |
st.markdown(response)
|
59 |
# Add assistant response to chat history
|
60 |
-
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
Enjoy chatting with Meta's Llama3 model!
|
28 |
""")
|
29 |
|
30 |
+
# Example:
|
31 |
+
if st.button("Sample: What is Large Language Model?"):
|
32 |
+
sample_prompt = "What is Large Language Model?"
|
33 |
+
else:
|
34 |
+
sample_prompt = None
|
35 |
+
if st.button("Sample: Explain machine learning on high level terms."):
|
36 |
+
sample_prompt = "Explain machine learning on high level terms."
|
37 |
+
else:
|
38 |
+
sample_prompt = None
|
39 |
+
if st.button("Sample: What is supervised learning? And what data do I need?"):
|
40 |
+
sample_prompt = "What is supervised learning? And what data do I need?"
|
41 |
+
else:
|
42 |
+
sample_prompt = None
|
43 |
+
|
44 |
+
|
45 |
# Add a button to clear the session state
|
46 |
if st.button("Clear Session"):
|
47 |
st.session_state.messages = []
|
|
|
72 |
with st.chat_message("assistant"):
|
73 |
st.markdown(response)
|
74 |
# Add assistant response to chat history
|
75 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
76 |
+
elif sample_prompt is not None:
|
77 |
+
prompt = sample_prompt
|
78 |
+
# Display user message in chat message container
|
79 |
+
st.chat_message("user").markdown(prompt)
|
80 |
+
# Add user message to chat history
|
81 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
82 |
+
|
83 |
+
response = call_llama(prompt)
|
84 |
+
|
85 |
+
# Display assistant response in chat message container
|
86 |
+
with st.chat_message("assistant"):
|
87 |
+
st.markdown(response)
|
88 |
+
# Add assistant response to chat history
|
89 |
+
st.session_state.messages.append({"role": "assistant", "content": response})
|
90 |
+
else:
|
91 |
+
continue
|