Update app.py
Browse files
app.py
CHANGED
|
@@ -80,9 +80,12 @@ models =[key for key in model_links.keys()]
|
|
| 80 |
# Create the sidebar with the dropdown for model selection
|
| 81 |
selected_model = st.sidebar.selectbox("Select Model", models)
|
| 82 |
|
| 83 |
-
#Create a temperature slider
|
| 84 |
temp_values = st.sidebar.slider('Select a temperature value', 0.0, 1.0, (0.5))
|
| 85 |
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
#Add reset button to clear conversation
|
| 88 |
st.sidebar.button('Reset Chat', on_click=reset_conversation) #Reset button
|
|
@@ -132,17 +135,18 @@ for message in st.session_state.messages:
|
|
| 132 |
|
| 133 |
# Accept user input
|
| 134 |
if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
| 135 |
-
|
| 136 |
# Display user message in chat message container
|
| 137 |
with st.chat_message("user"):
|
| 138 |
st.markdown(prompt)
|
| 139 |
# Add user message to chat history
|
| 140 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 141 |
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
# Display assistant response in chat message container
|
| 144 |
with st.chat_message("assistant"):
|
| 145 |
-
|
| 146 |
try:
|
| 147 |
stream = client.chat.completions.create(
|
| 148 |
model=model_links[selected_model],
|
|
@@ -171,7 +175,4 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
| 171 |
st.write("This was the error message:")
|
| 172 |
st.write(e)
|
| 173 |
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
st.session_state.messages.append({"role": "assistant", "content": response})
|
|
|
|
| 80 |
# Create the sidebar with the dropdown for model selection
|
| 81 |
selected_model = st.sidebar.selectbox("Select Model", models)
|
| 82 |
|
| 83 |
+
# Create a temperature slider
|
| 84 |
temp_values = st.sidebar.slider('Select a temperature value', 0.0, 1.0, (0.5))
|
| 85 |
|
| 86 |
+
# Add a system prompt input
|
| 87 |
+
system_prompt = st.sidebar.text_input("System Prompt")
|
| 88 |
+
|
| 89 |
|
| 90 |
#Add reset button to clear conversation
|
| 91 |
st.sidebar.button('Reset Chat', on_click=reset_conversation) #Reset button
|
|
|
|
| 135 |
|
| 136 |
# Accept user input
|
| 137 |
if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
|
|
| 138 |
# Display user message in chat message container
|
| 139 |
with st.chat_message("user"):
|
| 140 |
st.markdown(prompt)
|
| 141 |
# Add user message to chat history
|
| 142 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 143 |
|
| 144 |
+
# Add system prompt to chat history if it exists
|
| 145 |
+
if system_prompt:
|
| 146 |
+
st.session_state.messages.append({"role": "system", "content": system_prompt})
|
| 147 |
|
| 148 |
# Display assistant response in chat message container
|
| 149 |
with st.chat_message("assistant"):
|
|
|
|
| 150 |
try:
|
| 151 |
stream = client.chat.completions.create(
|
| 152 |
model=model_links[selected_model],
|
|
|
|
| 175 |
st.write("This was the error message:")
|
| 176 |
st.write(e)
|
| 177 |
|
|
|
|
|
|
|
|
|
|
| 178 |
st.session_state.messages.append({"role": "assistant", "content": response})
|