eagle0504 commited on
Commit
e42e6c0
·
verified ·
1 Parent(s): acfbaea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -53,6 +53,9 @@ with st.sidebar:
53
  Enjoy chatting with Meta's Llama3 model!
54
  """)
55
 
 
 
 
56
  # Add a button to clear the session state
57
  if st.button("Clear Session"):
58
  st.session_state.messages = []
@@ -74,16 +77,23 @@ for message in st.session_state.messages:
74
 
75
 
76
  # React to user input
77
- if prompt := st.chat_input("What is up?"):
 
 
 
 
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})
 
53
  Enjoy chatting with Meta's Llama3 model!
54
  """)
55
 
56
+ # Add a button to submit
57
+ submit_button = st.button("Submit")
58
+
59
  # Add a button to clear the session state
60
  if st.button("Clear Session"):
61
  st.session_state.messages = []
 
77
 
78
 
79
  # React to user input
80
+ if submit_button:
81
+
82
+ # Initiatization
83
+ prompt = "Ask a data science question"
84
+
85
  # Display user message in chat message container
86
  st.chat_message("user").markdown(prompt)
87
+
88
  # Add user message to chat history
89
  st.session_state.messages.append({"role": "user", "content": prompt})
90
 
91
+ # API call to Llama
92
  response = call_llama(prompt)
93
 
94
  # Display assistant response in chat message container
95
  with st.chat_message("assistant"):
96
  st.markdown(response)
97
+
98
  # Add assistant response to chat history
99
+ st.session_state.messages.append({"role": "assistant", "content": response})