eagle0504 commited on
Commit
a80cfa9
·
verified ·
1 Parent(s): 47954f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -91,14 +91,9 @@ if not isinstance(st.session_state.messages, list):
91
  if not all(isinstance(msg, dict) for msg in st.session_state.messages):
92
  st.session_state.messages = []
93
 
94
- # Display chat messages from history on app rerun
95
  for message in st.session_state.messages:
96
- with st.chat_message(message["role"]):
97
- st.markdown(message["content"])
98
-
99
- # Display chat messages from history on app rerun
100
- for message in st.session_state.messages:
101
- if message["role"] != "system": # Skip system messages
102
  with st.chat_message(message["role"]):
103
  st.markdown(message["content"])
104
 
@@ -108,8 +103,10 @@ if prompt := st.chat_input("😉 Ask any question or feel free to use the exampl
108
  # Display user message in chat message container
109
  st.chat_message("user").markdown(prompt)
110
 
111
- # Add user message to chat history
112
  st.session_state.messages.append({"role": "system", "content": f"You are a helpful assistant. Year now is {current_year}"})
 
 
113
  st.session_state.messages.append({"role": "user", "content": prompt})
114
 
115
  # API Call
 
91
  if not all(isinstance(msg, dict) for msg in st.session_state.messages):
92
  st.session_state.messages = []
93
 
94
+ # Display chat messages from history on app rerun, excluding system messages
95
  for message in st.session_state.messages:
96
+ if message["role"] != "system": # Skip displaying system messages
 
 
 
 
 
97
  with st.chat_message(message["role"]):
98
  st.markdown(message["content"])
99
 
 
103
  # Display user message in chat message container
104
  st.chat_message("user").markdown(prompt)
105
 
106
+ # Add a system message to the chat history, but don't display it
107
  st.session_state.messages.append({"role": "system", "content": f"You are a helpful assistant. Year now is {current_year}"})
108
+
109
+ # Add user message to chat history
110
  st.session_state.messages.append({"role": "user", "content": prompt})
111
 
112
  # API Call