amine-01 commited on
Commit
1ba1943
Β·
verified Β·
1 Parent(s): 067fc57

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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.BOT, avatar="πŸ”"):
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.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
 
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