tushar310 commited on
Commit
49d1ffe
·
1 Parent(s): 427d774
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -13,7 +13,10 @@ if "messages" not in st.session_state:
13
  for message in st.session_state.messages:
14
  with st.chat_message(message["role"]):
15
  st.markdown(message["content"])
16
-
 
 
 
17
  openai.api_key = st.sidebar.text_input("OpenAI API Key", type="password")
18
 
19
  if "openai.api_key" not in st.session_state:
@@ -37,6 +40,7 @@ if prompt := st.chat_input("What is up?"):
37
  {"role": m["role"], "content": m["content"]}
38
  for m in st.session_state.messages
39
  ],
 
40
  max_tokens=12000,
41
  stream=True,
42
  ):
 
13
  for message in st.session_state.messages:
14
  with st.chat_message(message["role"]):
15
  st.markdown(message["content"])
16
+
17
+ if "messages" not in st.session_state or st.sidebar.button("Clear message history"):
18
+ st.session_state["messages"] = [{"role": "assistant", "content": "How can I help you?"}]
19
+
20
  openai.api_key = st.sidebar.text_input("OpenAI API Key", type="password")
21
 
22
  if "openai.api_key" not in st.session_state:
 
40
  {"role": m["role"], "content": m["content"]}
41
  for m in st.session_state.messages
42
  ],
43
+ openai_api_key = openai.api_key,
44
  max_tokens=12000,
45
  stream=True,
46
  ):