J266501 commited on
Commit
e6cfea8
Β·
verified Β·
1 Parent(s): 67c0eca

Update src/ChatPage.tsx

Browse files
Files changed (1) hide show
  1. src/ChatPage.tsx +9 -1
src/ChatPage.tsx CHANGED
@@ -40,9 +40,17 @@ const ChatPage: React.FC = () => {
40
  if (!res.ok) throw new Error('Backend error');
41
 
42
  const data: AskResponse = await res.json();
 
 
 
 
 
43
 
44
- const aiText = `${data.answer}\n\nπŸ“š Source Snippets:\n${data.source_documents.slice(0, 2).join('\n\n')}`;
45
  const aiMessage: Message = { sender: 'ai', text: aiText };
 
 
 
 
46
 
47
  setMessages((prev) => [...prev, aiMessage]);
48
  } catch (err) {
 
40
  if (!res.ok) throw new Error('Backend error');
41
 
42
  const data: AskResponse = await res.json();
43
+
44
+ let aiText = data.answer;
45
+ if (aiText.includes("πŸ“š Source Snippets")) {
46
+ aiText = aiText.split("πŸ“š Source Snippets")[0].trim();
47
+ }
48
 
 
49
  const aiMessage: Message = { sender: 'ai', text: aiText };
50
+ setMessages((prev) => [...prev, aiMessage]);
51
+
52
+ // const aiText = `${data.answer}\n\nπŸ“š Source Snippets:\n${data.source_documents.slice(0, 2).join('\n\n')}`;
53
+ // const aiMessage: Message = { sender: 'ai', text: aiText };
54
 
55
  setMessages((prev) => [...prev, aiMessage]);
56
  } catch (err) {