mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-15 00:45:57 +08:00
### What problem does this PR solve? Feat: Display inline (non-quoted) images in the chat and search modules #7623 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
5a0273e3ea
commit
5d5dbb3bcb
@ -86,6 +86,7 @@ export interface IReferenceChunk {
|
|||||||
vector_similarity: number;
|
vector_similarity: number;
|
||||||
term_similarity: number;
|
term_similarity: number;
|
||||||
positions: number[];
|
positions: number[];
|
||||||
|
doc_type?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IReference {
|
export interface IReference {
|
||||||
|
@ -20,6 +20,7 @@ import {
|
|||||||
} from '@/hooks/knowledge-hooks';
|
} from '@/hooks/knowledge-hooks';
|
||||||
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
||||||
import { api_host } from '@/utils/api';
|
import { api_host } from '@/utils/api';
|
||||||
|
import { showImage } from '@/utils/chat';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useState } from 'react';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
@ -49,12 +50,6 @@ interface IProps {
|
|||||||
handleTesting: (documentIds?: string[]) => Promise<any>;
|
handleTesting: (documentIds?: string[]) => Promise<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ShowImageFields = ['image', 'table'];
|
|
||||||
|
|
||||||
function showImage(filed: string) {
|
|
||||||
return ShowImageFields.some((x) => x === filed);
|
|
||||||
}
|
|
||||||
|
|
||||||
const TestingResult = ({ handleTesting }: IProps) => {
|
const TestingResult = ({ handleTesting }: IProps) => {
|
||||||
const [selectedDocumentIds, setSelectedDocumentIds] = useState<string[]>([]);
|
const [selectedDocumentIds, setSelectedDocumentIds] = useState<string[]>([]);
|
||||||
const { documents, chunks, total } = useSelectTestingResult();
|
const { documents, chunks, total } = useSelectTestingResult();
|
||||||
|
@ -20,7 +20,11 @@ import { useTranslation } from 'react-i18next';
|
|||||||
|
|
||||||
import 'katex/dist/katex.min.css'; // `rehype-katex` does not import the CSS for you
|
import 'katex/dist/katex.min.css'; // `rehype-katex` does not import the CSS for you
|
||||||
|
|
||||||
import { preprocessLaTeX, replaceThinkToSection } from '@/utils/chat';
|
import {
|
||||||
|
preprocessLaTeX,
|
||||||
|
replaceThinkToSection,
|
||||||
|
showImage,
|
||||||
|
} from '@/utils/chat';
|
||||||
import { replaceTextByOldReg } from '../utils';
|
import { replaceTextByOldReg } from '../utils';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
@ -108,10 +112,11 @@ const MarkdownContent = ({
|
|||||||
const fileThumbnail = documentId ? fileThumbnails[documentId] : '';
|
const fileThumbnail = documentId ? fileThumbnails[documentId] : '';
|
||||||
const fileExtension = documentId ? getExtension(document?.doc_name) : '';
|
const fileExtension = documentId ? getExtension(document?.doc_name) : '';
|
||||||
const imageId = chunkItem?.image_id;
|
const imageId = chunkItem?.image_id;
|
||||||
|
const docType = chunkItem?.doc_type;
|
||||||
|
|
||||||
return (
|
return showImage(docType) ? (
|
||||||
<Image id={imageId} className={styles.referenceChunkImage}></Image>
|
<Image id={imageId} className={styles.referenceChunkImage}></Image>
|
||||||
);
|
) : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={chunkItem?.id} className="flex gap-2">
|
<div key={chunkItem?.id} className="flex gap-2">
|
||||||
|
@ -66,3 +66,9 @@ export function setInitialChatVariableEnabledFieldValue(
|
|||||||
) {
|
) {
|
||||||
return field !== ChatVariableEnabledField.MaxTokensEnabled;
|
return field !== ChatVariableEnabledField.MaxTokensEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ShowImageFields = ['image', 'table'];
|
||||||
|
|
||||||
|
export function showImage(filed?: string) {
|
||||||
|
return ShowImageFields.some((x) => x === filed);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user