Update app.py
Browse files
app.py
CHANGED
@@ -108,10 +108,15 @@ if not isinstance(st.session_state.messages, list):
|
|
108 |
if not all(isinstance(msg, dict) for msg in st.session_state.messages):
|
109 |
st.session_state.messages = []
|
110 |
|
111 |
-
#
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
# Display chat messages from history on app rerun
|
117 |
for message in st.session_state.messages:
|
@@ -119,12 +124,6 @@ for message in st.session_state.messages:
|
|
119 |
with st.chat_message(message["role"]):
|
120 |
st.markdown(message["content"])
|
121 |
|
122 |
-
# Path to the Markdown file
|
123 |
-
md_file_path = 'docs/yiqiao_yin.md'
|
124 |
-
|
125 |
-
# Get the content of the Markdown file
|
126 |
-
yiqiaoyin_profile = read_markdown_file(md_file_path)
|
127 |
-
|
128 |
# React to user input
|
129 |
if prompt := st.chat_input("π Ask any question or feel free to use the examples provided in the left sidebar."):
|
130 |
|
@@ -132,7 +131,6 @@ if prompt := st.chat_input("π Ask any question or feel free to use the exampl
|
|
132 |
st.chat_message("user").markdown(prompt)
|
133 |
|
134 |
# Add user message to chat history
|
135 |
-
st.session_state.messages.append({"role": "system", "content": f"You know the following about Mr. Yiqiao Yin: {yiqiaoyin_profile}"})
|
136 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
137 |
|
138 |
# API Call
|
|
|
108 |
if not all(isinstance(msg, dict) for msg in st.session_state.messages):
|
109 |
st.session_state.messages = []
|
110 |
|
111 |
+
# Path to the Markdown file
|
112 |
+
md_file_path = 'docs/yiqiao_yin.md'
|
113 |
+
|
114 |
+
# Get the content of the Markdown file
|
115 |
+
yiqiaoyin_profile = read_markdown_file(md_file_path)
|
116 |
+
|
117 |
+
# Add the system message with the profile information to the chat history if it hasn't been added yet
|
118 |
+
if not any(msg["role"] == "system" for msg in st.session_state.messages):
|
119 |
+
st.session_state.messages.append({"role": "system", "content": f"You know the following about Mr. Yiqiao Yin: {yiqiaoyin_profile}"})
|
120 |
|
121 |
# Display chat messages from history on app rerun
|
122 |
for message in st.session_state.messages:
|
|
|
124 |
with st.chat_message(message["role"]):
|
125 |
st.markdown(message["content"])
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
# React to user input
|
128 |
if prompt := st.chat_input("π Ask any question or feel free to use the examples provided in the left sidebar."):
|
129 |
|
|
|
131 |
st.chat_message("user").markdown(prompt)
|
132 |
|
133 |
# Add user message to chat history
|
|
|
134 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
135 |
|
136 |
# API Call
|