diff --git a/packages/web/i18n/en/chat.json b/packages/web/i18n/en/chat.json index 631f78f6f..21deccc98 100644 --- a/packages/web/i18n/en/chat.json +++ b/packages/web/i18n/en/chat.json @@ -1,13 +1,15 @@ { + "Delete_all": "Delete all", "chat_input_guide_lexicon_is_empty": "The lexicon has not been configured", "config_input_guide": "Configure input boot", "config_input_guide_lexicon": "Config", "config_input_guide_lexicon_title": "Config lexicon", "csv_input_lexicon_tip": "Only CSV can be imported in batches. Click to download the template", "custom_input_guide_url": "Custom lexicon url", + "delete_all_input_guide_confirm": "Confirm to delete all input guide lexicons", "input_guide": "Input guide", "input_guide_lexicon": "Lexicon", "input_guide_tip": "You can configure some preset questions. When the user enters a question, the relevant question is retrieved from these preset questions for prompt.", "insert_input_guide,_some_data_already_exists": "Duplicate data, automatically filtered, insert: {{len}} data", "new_input_guide_lexicon": "New lexicon" -} \ No newline at end of file +} diff --git a/packages/web/i18n/zh/chat.json b/packages/web/i18n/zh/chat.json index 761042c80..ad6a6f850 100644 --- a/packages/web/i18n/zh/chat.json +++ b/packages/web/i18n/zh/chat.json @@ -1,13 +1,15 @@ { + "Delete_all": "清空词库", "chat_input_guide_lexicon_is_empty": "还没有配置词库", "config_input_guide": "配置输入引导", "config_input_guide_lexicon": "配置词库", "config_input_guide_lexicon_title": "配置词库", "csv_input_lexicon_tip": "仅支持 CSV 批量导入,点击下载模板", "custom_input_guide_url": "自定义词库地址", + "delete_all_input_guide_confirm": "确定要清空输入引导词库吗?", "input_guide": "输入引导", "input_guide_lexicon": "词库", "input_guide_tip": "可以配置一些预设的问题。在用户输入问题时,会从这些预设问题中获取相关问题进行提示。", "insert_input_guide,_some_data_already_exists": "有重复数据,已自动过滤,共插入 {{len}} 条数据", "new_input_guide_lexicon": "新词库" -} \ No newline at end of file +} diff --git a/projects/app/src/components/core/app/InputGuideConfig.tsx b/projects/app/src/components/core/app/InputGuideConfig.tsx index 5e2702aba..d8d5d2c56 100644 --- a/projects/app/src/components/core/app/InputGuideConfig.tsx +++ b/projects/app/src/components/core/app/InputGuideConfig.tsx @@ -8,8 +8,7 @@ import { useDisclosure, Switch, Textarea, - Checkbox, - HStack + Checkbox } from '@chakra-ui/react'; import React, { useMemo, useState } from 'react'; import { useTranslation } from 'next-i18next'; @@ -21,6 +20,7 @@ import { useI18n } from '@/web/context/I18n'; import { fileDownload } from '@/web/common/file/utils'; import { getDocPath } from '@/web/common/system/doc'; import { + delAllChatInputGuide, delChatInputGuide, getChatInputGuideList, getCountChatInputGuideTotal, @@ -38,6 +38,7 @@ import HighlightText from '@fastgpt/web/components/common/String/HighlightText'; import { defaultChatInputGuideConfig } from '@fastgpt/global/core/app/constants'; import ChatFunctionTip from './Tip'; import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; +import { useConfirm } from '@fastgpt/web/hooks/useConfirm'; const csvTemplate = `"第一列内容" "只会将第一列内容导入,其余列会被忽略" @@ -192,6 +193,10 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () => const [searchKey, setSearchKey] = useState(''); + const { openConfirm: openConfirmDel, ConfirmModal: DelConfirmModal } = useConfirm({ + type: 'delete' + }); + const { list, setData, @@ -275,6 +280,12 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () => dataIdList }); }; + const onDeleteAllData = () => { + setData([]); + delAllChatInputGuide({ + appId + }); + }; const onSelectFile = async (files: File[]) => { const file = files?.[0]; @@ -346,6 +357,24 @@ const LexiconConfigModal = ({ appId, onClose }: { appId: string; onClose: () => > {commonT('common.Delete')} +