Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -90,7 +90,7 @@ st.subheader('Upload a PDF and ask questions about its content!')
|
|
90 |
|
91 |
# Display the welcome prompt if chat history is only the initial prompt
|
92 |
if len(st.session_state.chat_history) == 1:
|
93 |
-
with st.chat_message(SPEAKER_TYPES
|
94 |
st.write(initial_prompt['content'])
|
95 |
|
96 |
# Get user input
|
@@ -111,20 +111,20 @@ def get_rag_response(prompt):
|
|
111 |
# Handle the user prompt and generate response
|
112 |
if prompt:
|
113 |
# Add user prompt to chat history
|
114 |
-
st.session_state.chat_history.append({'role': SPEAKER_TYPES
|
115 |
|
116 |
# Display chat messages from the chat history
|
117 |
for message in st.session_state.chat_history[1:]:
|
118 |
-
with st.chat_message(message["role"], avatar="π€" if message['role'] == SPEAKER_TYPES
|
119 |
st.write(message["content"])
|
120 |
|
121 |
# Get the response using the RAG chain
|
122 |
with st.spinner(text='Generating response...'):
|
123 |
response_text = get_rag_response(prompt)
|
124 |
-
st.session_state.chat_history.append({'role': SPEAKER_TYPES
|
125 |
|
126 |
# Display the bot response
|
127 |
-
with st.chat_message(SPEAKER_TYPES
|
128 |
st.write(response_text)
|
129 |
|
130 |
# Add footer for additional information or credits
|
|
|
90 |
|
91 |
# Display the welcome prompt if chat history is only the initial prompt
|
92 |
if len(st.session_state.chat_history) == 1:
|
93 |
+
with st.chat_message(SPEAKER_TYPES["BOT"], avatar="π"):
|
94 |
st.write(initial_prompt['content'])
|
95 |
|
96 |
# Get user input
|
|
|
111 |
# Handle the user prompt and generate response
|
112 |
if prompt:
|
113 |
# Add user prompt to chat history
|
114 |
+
st.session_state.chat_history.append({'role': SPEAKER_TYPES["USER"], 'content': prompt})
|
115 |
|
116 |
# Display chat messages from the chat history
|
117 |
for message in st.session_state.chat_history[1:]:
|
118 |
+
with st.chat_message(message["role"], avatar="π€" if message['role'] == SPEAKER_TYPES["USER"] else "π"):
|
119 |
st.write(message["content"])
|
120 |
|
121 |
# Get the response using the RAG chain
|
122 |
with st.spinner(text='Generating response...'):
|
123 |
response_text = get_rag_response(prompt)
|
124 |
+
st.session_state.chat_history.append({'role': SPEAKER_TYPES["BOT"], 'content': response_text})
|
125 |
|
126 |
# Display the bot response
|
127 |
+
with st.chat_message(SPEAKER_TYPES["BOT"], avatar="π"):
|
128 |
st.write(response_text)
|
129 |
|
130 |
# Add footer for additional information or credits
|