mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-23 06:46:40 +08:00
### What problem does this PR solve? Feat: Add Tavily Api Key to chat configuration modal. #5198 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -2,7 +2,7 @@ import KnowledgeBaseItem from '@/components/knowledge-base-item';
|
||||
import { useTranslate } from '@/hooks/common-hooks';
|
||||
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import { Form, Input, message, Select, Switch, Upload } from 'antd';
|
||||
import { Form, Input, message, Select, Switch, Typography, Upload } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import { useCallback } from 'react';
|
||||
import { ISegmentedContentProps } from '../interface';
|
||||
@ -147,6 +147,16 @@ const AssistantSetting = ({
|
||||
>
|
||||
<Switch onChange={handleTtsChange} />
|
||||
</Form.Item>
|
||||
<Form.Item label={'Tavily Api Key'} tooltip={t('tavilyApiKeyTip')}>
|
||||
<div className="flex flex-col gap-1">
|
||||
<Form.Item name={['prompt_config', 'tavily_api_key']} noStyle>
|
||||
<Input.Password placeholder={t('tavilyApiKeyMessage')} />
|
||||
</Form.Item>
|
||||
<Typography.Link href="https://app.tavily.com/home" target={'_blank'}>
|
||||
{t('tavilyApiKeyHelp')}
|
||||
</Typography.Link>
|
||||
</div>
|
||||
</Form.Item>
|
||||
<KnowledgeBaseItem
|
||||
required={false}
|
||||
onChange={handleChange}
|
||||
|
||||
@ -59,12 +59,22 @@ const MarkdownContent = ({
|
||||
}, [reference, setDocumentIds]);
|
||||
|
||||
const handleDocumentButtonClick = useCallback(
|
||||
(documentId: string, chunk: IReferenceChunk, isPdf: boolean) => () => {
|
||||
if (!isPdf) {
|
||||
return;
|
||||
}
|
||||
clickDocumentButton?.(documentId, chunk);
|
||||
},
|
||||
(
|
||||
documentId: string,
|
||||
chunk: IReferenceChunk,
|
||||
isPdf: boolean,
|
||||
documentUrl?: string,
|
||||
) =>
|
||||
() => {
|
||||
if (!isPdf) {
|
||||
if (!documentUrl) {
|
||||
return;
|
||||
}
|
||||
window.open(documentUrl, '_blank');
|
||||
} else {
|
||||
clickDocumentButton?.(documentId, chunk);
|
||||
}
|
||||
},
|
||||
[clickDocumentButton],
|
||||
);
|
||||
|
||||
@ -93,6 +103,7 @@ const MarkdownContent = ({
|
||||
(x) => x?.doc_id === chunkItem?.document_id,
|
||||
);
|
||||
const documentId = document?.doc_id;
|
||||
const documentUrl = document?.url;
|
||||
const fileThumbnail = documentId ? fileThumbnails[documentId] : '';
|
||||
const fileExtension = documentId ? getExtension(document?.doc_name) : '';
|
||||
const imageId = chunkItem?.image_id;
|
||||
@ -146,6 +157,7 @@ const MarkdownContent = ({
|
||||
documentId,
|
||||
chunkItem,
|
||||
fileExtension === 'pdf',
|
||||
documentUrl,
|
||||
)}
|
||||
>
|
||||
{document?.doc_name}
|
||||
|
||||
Reference in New Issue
Block a user