choizhang
commited on
Commit
·
9c9baf5
1
Parent(s):
245987a
refactor: Fixed redundant blank characters in message content
Browse files
lightrag_webui/src/api/lightrag.ts
CHANGED
@@ -333,7 +333,6 @@ export const queryTextStream = async (
|
|
333 |
try {
|
334 |
const parsed = JSON.parse(line);
|
335 |
if (parsed.response) {
|
336 |
-
console.log('Received chunk:', parsed.response); // Log for debugging
|
337 |
onChunk(parsed.response);
|
338 |
} else if (parsed.error && onError) {
|
339 |
onError(parsed.error);
|
|
|
333 |
try {
|
334 |
const parsed = JSON.parse(line);
|
335 |
if (parsed.response) {
|
|
|
336 |
onChunk(parsed.response);
|
337 |
} else if (parsed.error && onError) {
|
338 |
onError(parsed.error);
|
lightrag_webui/src/components/retrieval/ChatMessage.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import { ReactNode, useCallback, useEffect,
|
2 |
import { Message } from '@/api/lightrag'
|
3 |
import useTheme from '@/hooks/useTheme'
|
4 |
import Button from '@/components/ui/Button'
|
@@ -24,6 +24,8 @@ export type MessageWithError = Message & {
|
|
24 |
|
25 |
export const ChatMessage = ({ message }: { message: MessageWithError }) => {
|
26 |
const { t } = useTranslation()
|
|
|
|
|
27 |
|
28 |
const handleCopyMarkdown = useCallback(async () => {
|
29 |
if (message.content) {
|
@@ -47,9 +49,9 @@ export const ChatMessage = ({ message }: { message: MessageWithError }) => {
|
|
47 |
>
|
48 |
<pre className="relative break-words whitespace-pre-wrap">
|
49 |
<ReactMarkdown
|
50 |
-
className="dark:prose-invert max-w-none text-
|
51 |
remarkPlugins={[remarkGfm, remarkMath]}
|
52 |
-
|
53 |
skipHtml={false}
|
54 |
components={{
|
55 |
code: CodeHighlight
|
@@ -168,8 +170,6 @@ const CodeHighlight = ({ className, children, node, ...props }: CodeHighlightPro
|
|
168 |
.filter(line => !line.trim().startsWith('linkStyle')) // Keep filtering linkStyle
|
169 |
.join('\n');
|
170 |
|
171 |
-
console.log("Rendering Mermaid with debounced, filtered content:", processedContent);
|
172 |
-
|
173 |
const mermaidId = `mermaid-${Date.now()}`;
|
174 |
mermaid.render(mermaidId, processedContent)
|
175 |
.then(({ svg, bindFunctions }) => {
|
|
|
1 |
+
import { ReactNode, useCallback, useEffect, useRef } from 'react'
|
2 |
import { Message } from '@/api/lightrag'
|
3 |
import useTheme from '@/hooks/useTheme'
|
4 |
import Button from '@/components/ui/Button'
|
|
|
24 |
|
25 |
export const ChatMessage = ({ message }: { message: MessageWithError }) => {
|
26 |
const { t } = useTranslation()
|
27 |
+
// Remove extra spaces around bold text
|
28 |
+
message.content = message.content.replace(/\*\ {3}/g, '').replace(/\ {4}\*\*/g, '**')
|
29 |
|
30 |
const handleCopyMarkdown = useCallback(async () => {
|
31 |
if (message.content) {
|
|
|
49 |
>
|
50 |
<pre className="relative break-words whitespace-pre-wrap">
|
51 |
<ReactMarkdown
|
52 |
+
className="dark:prose-invert max-w-none text-base text-sm"
|
53 |
remarkPlugins={[remarkGfm, remarkMath]}
|
54 |
+
rehypePlugins={[rehypeReact]}
|
55 |
skipHtml={false}
|
56 |
components={{
|
57 |
code: CodeHighlight
|
|
|
170 |
.filter(line => !line.trim().startsWith('linkStyle')) // Keep filtering linkStyle
|
171 |
.join('\n');
|
172 |
|
|
|
|
|
173 |
const mermaidId = `mermaid-${Date.now()}`;
|
174 |
mermaid.render(mermaidId, processedContent)
|
175 |
.then(({ svg, bindFunctions }) => {
|