Skip to content

Commit 2b5af3a

Browse files
committed
Simplify message rendering and update citation format in views
1 parent e6d66a2 commit 2b5af3a

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

frontend/src/components/Header/Chat.tsx

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import "../../components/Header/chat.css";
44
import { useState, useEffect, useRef } from "react";
55
import TypingAnimation from "./components/TypingAnimation";
66
import ErrorMessage from "../ErrorMessage";
7-
import ParseStringWithLinks from "../../services/parsing/ParseWithSource";
87
import axios from "axios";
98
import {
109
FaPlus,
@@ -321,30 +320,15 @@ const Chat: React.FC<ChatDropDownProps> = ({ showChat, setShowChat }) => {
321320
<FaComment className="chat_text_icon" />
322321
</div>
323322
<div className="chat_text_wrap">
324-
{message.is_user ? (
325-
<pre
326-
style={{
327-
fontFamily: "inherit",
328-
whiteSpace: "pre-wrap",
329-
wordWrap: "break-word",
330-
}}
331-
>
332-
{message.content}
333-
</pre>
334-
) : (
335-
<div
336-
style={{
337-
fontFamily: "inherit",
338-
whiteSpace: "pre-wrap",
339-
wordWrap: "break-word",
340-
}}
341-
>
342-
<ParseStringWithLinks
343-
text={message.content}
344-
chunkData={[]}
345-
/>
346-
</div>
347-
)}
323+
<pre
324+
style={{
325+
fontFamily: "inherit",
326+
whiteSpace: "pre-wrap",
327+
wordWrap: "break-word",
328+
}}
329+
>
330+
{message.content}
331+
</pre>
348332
</div>
349333
</div>
350334
))

server/api/views/assistant/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def search_documents(query: str, user=user) -> str:
186186

187187
# Format results with clear structure and metadata
188188
prompt_texts = [
189-
f"[Document {i + 1} - File: {obj['file_id']}, Page: {obj['page_number']}, Chunk: {obj['chunk_number']}, Similarity: {1 - obj['distance']:.3f}]\n{obj['text']}\n[End Document {i + 1}]"
189+
f"[Document {i + 1} - File: {obj['file_id']}, Name: {obj['name']}, Page: {obj['page_number']}, Chunk: {obj['chunk_number']}, Similarity: {1 - obj['distance']:.3f}]\n{obj['text']}\n[End Document {i + 1}]"
190190
for i, obj in enumerate(embeddings_results)
191191
]
192192

@@ -214,7 +214,7 @@ def search_documents(query: str, user=user) -> str:
214214
After gathering information through semantic searches, provide responses that:
215215
1. Answer the user's question directly using only the found information
216216
2. Structure responses with clear sections and paragraphs
217-
3. Include citations after EACH sentence using this exact format: ***[File ID {file_id}, Page {page_number}, Chunk {chunk_number}]***
217+
3. Include citations using this exact format: ***[Name {name}, Page {page_number}]***
218218
4. Only cite information that directly supports your statements
219219
220220
If no relevant information is found in the documents, clearly state that the information is not available in the uploaded documents.

0 commit comments

Comments
 (0)