Spestly commited on
Commit
e88412a
·
verified ·
1 Parent(s): ef25ed1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -29,7 +29,7 @@ model_info = {
29
  "output": "4K"
30
  },
31
  "command-r-plus": {
32
- "description": "command-r-plus is an alias for command-r-plus-04-2024, so if you use command-r-plus in the API, thats the model youre pointing to.",
33
  "context": "128K",
34
  "output": "4K"
35
  },
@@ -76,18 +76,28 @@ with st.sidebar:
76
  st.title("Settings")
77
  api_key = st.text_input("Cohere API Key", type="password")
78
  selected_model = st.selectbox("Model", options=list(model_info.keys()))
 
 
 
 
 
 
79
  st.divider()
80
  st.image(AI_PFP, width=60)
81
  st.subheader(selected_model)
82
  st.markdown(model_info[selected_model]["description"])
83
  st.caption(f"Context: {model_info[selected_model]['context']}")
84
  st.caption(f"Output: {model_info[selected_model]['output']}")
85
- st.markdown("Powerd by Cohere's API")
86
-
87
- st.title(f"Chat - {selected_model}")
88
 
89
  if "messages" not in st.session_state:
90
  st.session_state.messages = []
 
 
 
 
 
 
91
 
92
  for msg in st.session_state.messages:
93
  with st.chat_message(msg["role"], avatar=USER_PFP if msg["role"] == "user" else AI_PFP):
@@ -98,6 +108,8 @@ if prompt := st.chat_input("Message..."):
98
  st.error("API key required")
99
  st.stop()
100
 
 
 
101
  st.session_state.messages.append({"role": "user", "content": prompt})
102
  with st.chat_message("user", avatar=USER_PFP):
103
  st.markdown(prompt)
@@ -120,4 +132,4 @@ if prompt := st.chat_input("Message..."):
120
  st.session_state.messages.append({"role": "assistant", "content": reply})
121
 
122
  except Exception as e:
123
- st.error(f"Error: {str(e)}")
 
29
  "output": "4K"
30
  },
31
  "command-r-plus": {
32
+ "description": "command-r-plus is an alias for command-r-plus-04-2024, so if you use command-r-plus in the API, that's the model you're pointing to.",
33
  "context": "128K",
34
  "output": "4K"
35
  },
 
76
  st.title("Settings")
77
  api_key = st.text_input("Cohere API Key", type="password")
78
  selected_model = st.selectbox("Model", options=list(model_info.keys()))
79
+
80
+ if st.button("Clear Chat"):
81
+ st.session_state.messages = []
82
+ st.session_state.first_message_sent = False
83
+ st.rerun()
84
+
85
  st.divider()
86
  st.image(AI_PFP, width=60)
87
  st.subheader(selected_model)
88
  st.markdown(model_info[selected_model]["description"])
89
  st.caption(f"Context: {model_info[selected_model]['context']}")
90
  st.caption(f"Output: {model_info[selected_model]['output']}")
91
+ st.markdown("Powered by Cohere's API")
 
 
92
 
93
  if "messages" not in st.session_state:
94
  st.session_state.messages = []
95
+
96
+ if "first_message_sent" not in st.session_state:
97
+ st.session_state.first_message_sent = False
98
+
99
+ if not st.session_state.first_message_sent:
100
+ st.markdown("<h1 style='text-align: center; color: #4a4a4a; margin-top: 100px;'>How can Cohere help you today?</h1>", unsafe_allow_html=True)
101
 
102
  for msg in st.session_state.messages:
103
  with st.chat_message(msg["role"], avatar=USER_PFP if msg["role"] == "user" else AI_PFP):
 
108
  st.error("API key required")
109
  st.stop()
110
 
111
+ st.session_state.first_message_sent = True
112
+
113
  st.session_state.messages.append({"role": "user", "content": prompt})
114
  with st.chat_message("user", avatar=USER_PFP):
115
  st.markdown(prompt)
 
132
  st.session_state.messages.append({"role": "assistant", "content": reply})
133
 
134
  except Exception as e:
135
+ st.error(f"Error: {str(e)}")