cryogenic22 commited on
Commit
06ff5eb
·
verified ·
1 Parent(s): 92a5f2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -33
app.py CHANGED
@@ -142,37 +142,6 @@ def display_top_bar():
142
  if st.session_state.current_collection:
143
  st.info(f"📁 Active Collection: {st.session_state.current_collection['name']}")
144
 
145
- def display_chat_interface():
146
- """Display the chat interface with formatted responses."""
147
- # Initialize chat history if needed
148
- if "messages" not in st.session_state:
149
- st.session_state.messages = []
150
-
151
- # Display chat history
152
- for message in st.session_state.messages:
153
- is_user = isinstance(message, HumanMessage)
154
- display_styled_chat_message(message, is_user=is_user)
155
-
156
- # Chat input
157
- if prompt := st.chat_input("Ask about your documents..."):
158
- # Add user message
159
- st.session_state.messages.append(HumanMessage(content=prompt))
160
- display_styled_chat_message(prompt, is_user=True)
161
-
162
- with st.spinner("Thinking..."):
163
- # Get AI response
164
- response = st.session_state.qa_system.invoke({
165
- "input": prompt,
166
- "chat_history": st.session_state.messages
167
- })
168
-
169
- # Add AI message with metadata
170
- ai_message = AIMessage(
171
- content=response.content,
172
- metadata={'sources': response.metadata.get('sources', [])}
173
- )
174
- st.session_state.messages.append(ai_message)
175
- display_styled_chat_message(ai_message)
176
 
177
  def display_collection_sidebar():
178
  """Display the document management sidebar."""
@@ -327,11 +296,12 @@ def main():
327
  display_collection_sidebar()
328
  display_top_bar()
329
 
330
- # Main content area with tabs
331
- tab1, tab2 = st.tabs(["Chat", "Document Store"])
332
 
333
  with tab1:
334
  if st.session_state.chat_ready:
 
 
335
  display_chat_interface()
336
  else:
337
  display_welcome_screen()
 
142
  if st.session_state.current_collection:
143
  st.info(f"📁 Active Collection: {st.session_state.current_collection['name']}")
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  def display_collection_sidebar():
147
  """Display the document management sidebar."""
 
296
  display_collection_sidebar()
297
  display_top_bar()
298
 
299
+ tab1, tab2 = st.tabs(["Chat", "Document Store"])
 
300
 
301
  with tab1:
302
  if st.session_state.chat_ready:
303
+ # Use the chat component from components/chat.py
304
+ from components.chat import display_chat_interface
305
  display_chat_interface()
306
  else:
307
  display_welcome_screen()