Skip to content

Commit 0f7e54e

Browse files
committed
Show pdf rag file as markdown in UI
1 parent 4825757 commit 0f7e54e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/client/components/Rag/Chunk.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const Chunk: React.FC<{
1616
<Typography variant="subtitle1" fontFamily="monospace" mb={2}>
1717
{JSON.stringify(doc.metadata, null, 2)}
1818
</Typography>
19-
{doc.metadata?.type === 'md' ? (
19+
{doc.metadata?.type === 'md' || doc.metadata?.type === 'pdf' ? (
2020
<Markdown>{doc.content}</Markdown>
2121
) : (
2222
<Typography whiteSpace="pre-line" variant="body1">

src/client/components/Rag/RagFile.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { RagIndexAttributes } from '../../../server/db/models/ragIndex'
88
import { Chunk } from './Chunk'
99
import { useDeleteRagFileMutation } from './api'
1010
import { useTranslation } from 'react-i18next'
11+
import Markdown from 'react-markdown'
1112

1213
type RagFile = RagFileAttributes & {
1314
fileContent: string
@@ -69,14 +70,12 @@ export const RagFile: React.FC = () => {
6970
<Typography variant="h4">{t('rag:content')}</Typography>
7071
{ragFile.fileContent.length === 0 ? (
7172
<Typography variant="body1">{t('rag:noContent')}</Typography>
73+
) : ragFile.fileType === 'application/pdf' || ragFile.fileType === 'text/markdown' ? (
74+
<Markdown>{ragFile.fileContent}</Markdown>
7275
) : (
73-
<Chunk
74-
doc={{
75-
title: ragFile.filename,
76-
content: ragFile.fileContent,
77-
metadata: ragFile.metadata,
78-
}}
79-
/>
76+
<Typography variant="body1" style={{ whiteSpace: 'pre-wrap', fontFamily: 'monospace' }}>
77+
{ragFile.fileContent}
78+
</Typography>
8079
)}
8180
</Container>
8281
)

0 commit comments

Comments
 (0)