linden-li commited on
Commit
01bb522
1 Parent(s): 2c9ce84

Add button

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -71,8 +71,6 @@ EXAMPLE_PROMPTS = [
71
  "Code a python function that can run merge sort on a list.",
72
  "Give me the character profile of a gumdrop obsessed knight in JSON.",
73
  "Write a rap battle between Alan Turing and Claude Shannon.",
74
- "Write a sarcastic joke about spoiled milk to make my day.",
75
-
76
  ]
77
 
78
  TITLE = "DBRX Instruct"
@@ -250,11 +248,22 @@ def handle_user_input(user_input):
250
  st.session_state["messages"].append({"role": "assistant", "content": response, "warning": stream_warning,"error": stream_error})
251
  print(st.session_state["messages"])
252
 
 
 
 
253
  if prompt := st.chat_input("Type a message!", max_chars=1000):
254
  handle_user_input(prompt)
255
 
 
 
256
  with st.sidebar:
257
  with st.container():
258
  st.title("Examples")
259
  for prompt in EXAMPLE_PROMPTS:
260
- st.button(prompt, args=(prompt,), on_click=handle_user_input)
 
 
 
 
 
 
 
71
  "Code a python function that can run merge sort on a list.",
72
  "Give me the character profile of a gumdrop obsessed knight in JSON.",
73
  "Write a rap battle between Alan Turing and Claude Shannon.",
 
 
74
  ]
75
 
76
  TITLE = "DBRX Instruct"
 
248
  st.session_state["messages"].append({"role": "assistant", "content": response, "warning": stream_warning,"error": stream_error})
249
  print(st.session_state["messages"])
250
 
251
+ def clear_chat_history():
252
+ st.session_state["messages"] = []
253
+
254
  if prompt := st.chat_input("Type a message!", max_chars=1000):
255
  handle_user_input(prompt)
256
 
257
+
258
+
259
  with st.sidebar:
260
  with st.container():
261
  st.title("Examples")
262
  for prompt in EXAMPLE_PROMPTS:
263
+ st.button(prompt, args=(prompt,), on_click=handle_user_input)
264
+ for _ in range(5):
265
+ st.write("")
266
+ col1, col2, col3 = st.columns([1, 2, 1])
267
+ with col2:
268
+ st.button('Clear Chat History', on_click=clear_chat_history)
269
+