Update src/ChatPage.tsx
Browse files- 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) {
|