diff --git a/web/src/components/api-service/hooks.ts b/web/src/components/api-service/hooks.ts index 7b87877a4..922fc522e 100644 --- a/web/src/components/api-service/hooks.ts +++ b/web/src/components/api-service/hooks.ts @@ -11,8 +11,8 @@ import { } from '@/hooks/use-user-setting-request'; import { IStats } from '@/interfaces/database/chat'; import { useQueryClient } from '@tanstack/react-query'; -import { message } from 'antd'; import { useCallback } from 'react'; +import message from '../ui/message'; export const useOperateApiKey = (idKey: string, dialogId?: string) => { const { removeToken } = useRemoveSystemToken(); diff --git a/web/src/components/copy-to-clipboard.tsx b/web/src/components/copy-to-clipboard.tsx index 50db68435..38b2128d4 100644 --- a/web/src/components/copy-to-clipboard.tsx +++ b/web/src/components/copy-to-clipboard.tsx @@ -1,8 +1,8 @@ import { useTranslate } from '@/hooks/common-hooks'; import { CheckOutlined, CopyOutlined } from '@ant-design/icons'; -import { Tooltip } from 'antd'; import { useState } from 'react'; import { CopyToClipboard as Clipboard, Props } from 'react-copy-to-clipboard'; +import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'; const CopyToClipboard = ({ text }: Props) => { const [copied, setCopied] = useState(false); @@ -16,10 +16,13 @@ const CopyToClipboard = ({ text }: Props) => { }; return ( - - - {copied ? : } - + + + + {copied ? : } + + + {copied ? t('copied') : t('copy')} ); }; diff --git a/web/src/components/editable-cell.tsx b/web/src/components/editable-cell.tsx deleted file mode 100644 index f2ad85708..000000000 --- a/web/src/components/editable-cell.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { Form, FormInstance, Input, InputRef, Typography } from 'antd'; -import { omit } from 'lodash'; -import React, { useContext, useEffect, useRef, useState } from 'react'; - -const EditableContext = React.createContext | null>(null); -const { Text } = Typography; - -interface EditableRowProps { - index: number; -} - -interface Item { - key: string; - name: string; - age: string; - address: string; -} - -export const EditableRow: React.FC = ({ ...props }) => { - const [form] = Form.useForm(); - return ( -
- - - -
- ); -}; - -interface EditableCellProps { - title: React.ReactNode; - editable: boolean; - children: React.ReactNode; - dataIndex: keyof Item; - record: Item; - handleSave: (record: Item) => void; -} - -export const EditableCell: React.FC = ({ - title, - editable, - children, - dataIndex, - record, - handleSave, - ...restProps -}) => { - const [editing, setEditing] = useState(false); - const inputRef = useRef(null); - const form = useContext(EditableContext)!; - - useEffect(() => { - if (editing) { - inputRef.current!.focus(); - } - }, [editing]); - - const toggleEdit = () => { - setEditing(!editing); - form.setFieldsValue({ [dataIndex]: record[dataIndex] }); - }; - - const save = async () => { - try { - const values = await form.validateFields(); - - toggleEdit(); - handleSave({ ...record, ...values }); - } catch (errInfo) { - console.log('Save failed:', errInfo); - } - }; - - let childNode = children; - - if (editable) { - childNode = editing ? ( - - - - ) : ( -
- {children} -
- ); - } - - return {childNode}; -}; diff --git a/web/src/components/floating-chat-widget-markdown.tsx b/web/src/components/floating-chat-widget-markdown.tsx index 8d7227a33..89aa51663 100644 --- a/web/src/components/floating-chat-widget-markdown.tsx +++ b/web/src/components/floating-chat-widget-markdown.tsx @@ -15,12 +15,12 @@ import { } from '@/utils/chat'; import { getExtension } from '@/utils/document-util'; import { InfoCircleOutlined } from '@ant-design/icons'; -import { Button, Flex, Popover, Tooltip } from 'antd'; import classNames from 'classnames'; import DOMPurify from 'dompurify'; import 'katex/dist/katex.min.css'; import { omit } from 'lodash'; import { pipe } from 'lodash/fp'; +import { Info } from 'lucide-react'; import { useCallback, useEffect, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import Markdown from 'react-markdown'; @@ -37,6 +37,9 @@ import remarkMath from 'remark-math'; import { visitParents } from 'unist-util-visit-parents'; import styles from './floating-chat-widget-markdown.module.less'; import { useIsDarkTheme } from './theme-provider'; +import { Button } from './ui/button'; +import { Popover, PopoverContent, PopoverTrigger } from './ui/popover'; +import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'; const getChunkIndex = (match: string) => Number(match.replace(/\[|\]/g, '')); @@ -161,19 +164,19 @@ const FloatingChatWidgetMarkdown = ({ className="flex gap-2 widget-citation-content" > {imageId && ( - + + + + - } - > - + )}
@@ -184,7 +187,7 @@ const FloatingChatWidgetMarkdown = ({ className="max-h-[250px] overflow-y-auto text-xs leading-relaxed p-2 bg-gray-50 dark:bg-gray-800 rounded prose-sm" >
{documentId && ( - +
{fileThumbnail ? ( )} - + + + + + {!documentUrl && fileExtension !== 'pdf' ? 'Document link unavailable' - : document.doc_name - } - > - + : document.doc_name} + - +
)} @@ -236,8 +240,11 @@ const FloatingChatWidgetMarkdown = ({ if (!info) { return ( - - + + + + + Reference unavailable ); } @@ -262,8 +269,11 @@ const FloatingChatWidgetMarkdown = ({ } return ( - - + + + + + {getPopoverContent(chunkIndex)} ); }); diff --git a/web/src/components/indented-tree/modal.tsx b/web/src/components/indented-tree/modal.tsx deleted file mode 100644 index d7d7a4a21..000000000 --- a/web/src/components/indented-tree/modal.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { useTranslation } from 'react-i18next'; -import IndentedTree from './indented-tree'; - -import { useFetchKnowledgeGraph } from '@/hooks/use-knowledge-request'; -import { IModalProps } from '@/interfaces/common'; -import { Modal } from 'antd'; - -const IndentedTreeModal = ({ - visible, - hideModal, -}: IModalProps & { documentId: string }) => { - const { data } = useFetchKnowledgeGraph(); - const { t } = useTranslation(); - - return ( - -
- -
-
- ); -}; - -export default IndentedTreeModal; diff --git a/web/src/components/llm-select/index.tsx b/web/src/components/llm-select/index.tsx deleted file mode 100644 index 93a81b94f..000000000 --- a/web/src/components/llm-select/index.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { LlmModelType } from '@/constants/knowledge'; -import { useComposeLlmOptionsByModelTypes } from '@/hooks/use-llm-request'; -import { Popover as AntPopover, Select as AntSelect } from 'antd'; -import LlmSettingItems from '../llm-setting-items'; - -interface IProps { - id?: string; - value?: string; - onInitialValue?: (value: string, option: any) => void; - onChange?: (value: string, option: any) => void; - disabled?: boolean; -} - -const LLMSelect = ({ - id, - value, - onInitialValue, - onChange, - disabled, -}: IProps) => { - const modelOptions = useComposeLlmOptionsByModelTypes([ - LlmModelType.Chat, - LlmModelType.Image2text, - ]); - - if (onInitialValue && value) { - for (const modelOption of modelOptions) { - for (const option of modelOption.options) { - if (option.value === value) { - onInitialValue(value, option); - break; - } - } - } - } - - const content = ( -
- -
- ); - - return ( - - - - ); -}; - -export default LLMSelect; diff --git a/web/src/components/llm-setting-items/index.tsx b/web/src/components/llm-setting-items/index.tsx deleted file mode 100644 index cf007bf44..000000000 --- a/web/src/components/llm-setting-items/index.tsx +++ /dev/null @@ -1,350 +0,0 @@ -import { - LlmModelType, - ModelVariableType, - settledModelVariableMap, -} from '@/constants/knowledge'; -import { Flex, Form, InputNumber, Select, Slider, Switch, Tooltip } from 'antd'; -import camelCase from 'lodash/camelCase'; - -import { useTranslate } from '@/hooks/common-hooks'; -import { useComposeLlmOptionsByModelTypes } from '@/hooks/use-llm-request'; -import { setChatVariableEnabledFieldValuePage } from '@/utils/chat'; -import { QuestionCircleOutlined } from '@ant-design/icons'; -import { useCallback, useMemo } from 'react'; -import styles from './index.module.less'; - -interface IProps { - prefix?: string; - formItemLayout?: any; - handleParametersChange?(value: ModelVariableType): void; - onChange?(value: string, option: any): void; -} - -const LlmSettingItems = ({ prefix, formItemLayout = {}, onChange }: IProps) => { - const form = Form.useFormInstance(); - const { t } = useTranslate('chat'); - const parameterOptions = Object.values(ModelVariableType).map((x) => ({ - label: t(camelCase(x)), - value: x, - })); - - const handleParametersChange = useCallback( - (value: ModelVariableType) => { - const variable = settledModelVariableMap[value]; - let nextVariable: Record = variable; - if (prefix) { - nextVariable = { [prefix]: variable }; - } - const variableCheckBoxFieldMap = setChatVariableEnabledFieldValuePage(); - form.setFieldsValue({ ...nextVariable, ...variableCheckBoxFieldMap }); - }, - [form, prefix], - ); - - const memorizedPrefix = useMemo(() => (prefix ? [prefix] : []), [prefix]); - - const modelOptions = useComposeLlmOptionsByModelTypes([ - LlmModelType.Chat, - LlmModelType.Image2text, - ]); - - return ( - <> - - } - allowClear - onChange={handleInputChange} - onBlur={handleSearchBlur} - value={searchString} - /> - ) : ( - -
- {isShowSearchBox ? ( - } - allowClear - onChange={handleInputChange} - onBlur={handleSearchBlur} - value={searchString} - /> - ) : ( -