cryogenic22 commited on
Commit
a5bfc45
·
verified ·
1 Parent(s): fc81768

Update components/chat.py

Browse files
Files changed (1) hide show
  1. components/chat.py +4 -22
components/chat.py CHANGED
@@ -2,19 +2,6 @@ import streamlit as st
2
  from langchain_core.messages import HumanMessage, AIMessage
3
  from utils.database import verify_vector_store
4
 
5
- def clean_response_content(response_content):
6
- """Clean the response content of any technical metadata."""
7
- # Convert the response to string first
8
- content = str(response_content)
9
-
10
- # Clean up the content
11
- if "content='" in content:
12
- content = content.split("content='")[1].split("'")[0]
13
- elif 'content="' in content:
14
- content = content.split('content="')[1].split('"')[0]
15
-
16
- return content.replace('\\n', '\n')
17
-
18
  def display_chat_interface():
19
  """Display modern chat interface with clean formatting."""
20
 
@@ -88,9 +75,7 @@ def display_chat_interface():
88
  </div>
89
  """, unsafe_allow_html=True)
90
  elif isinstance(message, AIMessage):
91
- # Get the content and clean it
92
- content = clean_response_content(message.content)
93
-
94
  st.markdown(f"""
95
  <div class="assistant-message">
96
  🤖 <strong>Assistant:</strong><br>
@@ -113,10 +98,8 @@ def display_chat_interface():
113
  })
114
 
115
  if response:
116
- # Extract the content and then clean the response
117
- response_content = response.content
118
- cleaned_response = clean_response_content(response_content)
119
- ai_message = AIMessage(content=cleaned_response)
120
  st.session_state.messages.append(ai_message)
121
  st.rerun()
122
  else:
@@ -125,5 +108,4 @@ def display_chat_interface():
125
  except Exception as e:
126
  st.error(f"Error: {e}")
127
  import traceback
128
- st.error(traceback.format_exc())
129
-
 
2
  from langchain_core.messages import HumanMessage, AIMessage
3
  from utils.database import verify_vector_store
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  def display_chat_interface():
6
  """Display modern chat interface with clean formatting."""
7
 
 
75
  </div>
76
  """, unsafe_allow_html=True)
77
  elif isinstance(message, AIMessage):
78
+ content = str(message.content)
 
 
79
  st.markdown(f"""
80
  <div class="assistant-message">
81
  🤖 <strong>Assistant:</strong><br>
 
98
  })
99
 
100
  if response:
101
+ content = str(response)
102
+ ai_message = AIMessage(content=content)
 
 
103
  st.session_state.messages.append(ai_message)
104
  st.rerun()
105
  else:
 
108
  except Exception as e:
109
  st.error(f"Error: {e}")
110
  import traceback
111
+ st.error(traceback.format_exc())