| METADATA_FILTER_USER_PROMPT_2, | METADATA_FILTER_USER_PROMPT_2, | ||||
| METADATA_FILTER_USER_PROMPT_3, | METADATA_FILTER_USER_PROMPT_3, | ||||
| ) | ) | ||||
| from core.tools.entities.common_entities import I18nObject | |||||
| from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool | from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool | ||||
| from extensions.ext_database import db | from extensions.ext_database import db | ||||
| from libs.json_in_md_parser import parse_and_check_json_markdown | from libs.json_in_md_parser import parse_and_check_json_markdown | ||||
| for dataset in available_datasets: | for dataset in available_datasets: | ||||
| description = dataset.description | description = dataset.description | ||||
| if not description: | if not description: | ||||
| description = "useful for when you want to answer queries about the " + dataset.name | |||||
| description = I18nObject( | |||||
| en_US="useful for when you want to answer queries about the " + dataset.name, | |||||
| zh_Hans="用于回答关于 " + dataset.name + " 的查询", | |||||
| ) | |||||
| description = description.replace("\n", "").replace("\r", "") | description = description.replace("\n", "").replace("\r", "") | ||||
| message_tool = PromptMessageTool( | message_tool = PromptMessageTool( |
| from core.rag.entities.context_entities import DocumentContext | from core.rag.entities.context_entities import DocumentContext | ||||
| from core.rag.models.document import Document as RetrievalDocument | from core.rag.models.document import Document as RetrievalDocument | ||||
| from core.rag.retrieval.retrieval_methods import RetrievalMethod | from core.rag.retrieval.retrieval_methods import RetrievalMethod | ||||
| from core.tools.entities.common_entities import I18nObject | |||||
| from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool | from core.tools.utils.dataset_retriever.dataset_retriever_base_tool import DatasetRetrieverBaseTool | ||||
| from extensions.ext_database import db | from extensions.ext_database import db | ||||
| from models.dataset import Dataset | from models.dataset import Dataset | ||||
| def from_dataset(cls, dataset: Dataset, **kwargs): | def from_dataset(cls, dataset: Dataset, **kwargs): | ||||
| description = dataset.description | description = dataset.description | ||||
| if not description: | if not description: | ||||
| description = "useful for when you want to answer queries about the " + dataset.name | |||||
| description = I18nObject( | |||||
| en_US="useful for when you want to answer queries about the " + dataset.name, | |||||
| zh_Hans="用于回答关于 " + dataset.name + " 的查询", | |||||
| ) | |||||
| description = description.replace("\n", "").replace("\r", "") | description = description.replace("\n", "").replace("\r", "") | ||||
| return cls( | return cls( |
| from core.rag.index_processor.constant.built_in_field import BuiltInField | from core.rag.index_processor.constant.built_in_field import BuiltInField | ||||
| from core.rag.index_processor.constant.index_type import IndexType | from core.rag.index_processor.constant.index_type import IndexType | ||||
| from core.rag.retrieval.retrieval_methods import RetrievalMethod | from core.rag.retrieval.retrieval_methods import RetrievalMethod | ||||
| from core.tools.entities.common_entities import I18nObject | |||||
| from events.dataset_event import dataset_was_deleted | from events.dataset_event import dataset_was_deleted | ||||
| from events.document_event import document_was_deleted | from events.document_event import document_was_deleted | ||||
| from extensions.ext_database import db | from extensions.ext_database import db | ||||
| cut_length = 18 | cut_length = 18 | ||||
| cut_name = documents[0].name[:cut_length] | cut_name = documents[0].name[:cut_length] | ||||
| dataset.name = cut_name + "..." | dataset.name = cut_name + "..." | ||||
| dataset.description = "useful for when you want to answer queries about the " + documents[0].name | |||||
| dataset.description = I18nObject( | |||||
| en_US="useful for when you want to answer queries about the " + documents[0].name, | |||||
| zh_Hans="用于回答关于 " + documents[0].name + " 的查询", | |||||
| ) | |||||
| db.session.commit() | db.session.commit() | ||||
| return dataset, documents, batch | return dataset, documents, batch |
| const { showExternalApiPanel, setShowExternalApiPanel } = useExternalApiPanel() | const { showExternalApiPanel, setShowExternalApiPanel } = useExternalApiPanel() | ||||
| const [includeAll, { toggle: toggleIncludeAll }] = useBoolean(false) | const [includeAll, { toggle: toggleIncludeAll }] = useBoolean(false) | ||||
| document.title = `${t('dataset.knowledge')} - Dify` | |||||
| const options = useMemo(() => { | const options = useMemo(() => { | ||||
| return [ | return [ | ||||
| { value: 'dataset', text: t('dataset.datasets') }, | { value: 'dataset', text: t('dataset.datasets') }, |
| return <Container /> | return <Container /> | ||||
| } | } | ||||
| export const metadata = { | |||||
| title: 'Datasets - Dify', | |||||
| } | |||||
| export default AppList | export default AppList |
| ) | ) | ||||
| } | } | ||||
| export const metadata = { | |||||
| title: 'Plugins - Dify', | |||||
| } | |||||
| export default PluginList | export default PluginList |
| import { createRef, useEffect, useState } from 'react' | import { createRef, useEffect, useState } from 'react' | ||||
| import Cropper, { type Area, type CropperProps } from 'react-easy-crop' | import Cropper, { type Area, type CropperProps } from 'react-easy-crop' | ||||
| import classNames from 'classnames' | import classNames from 'classnames' | ||||
| import { useTranslation } from 'react-i18next' | |||||
| import { ImagePlus } from '../icons/src/vender/line/images' | import { ImagePlus } from '../icons/src/vender/line/images' | ||||
| import { useDraggableUploader } from './hooks' | import { useDraggableUploader } from './hooks' | ||||
| cropShape, | cropShape, | ||||
| onImageInput, | onImageInput, | ||||
| }) => { | }) => { | ||||
| const { t } = useTranslation() | |||||
| const [inputImage, setInputImage] = useState<{ file: File; url: string }>() | const [inputImage, setInputImage] = useState<{ file: File; url: string }>() | ||||
| const [isAnimatedImage, setIsAnimatedImage] = useState<boolean>(false) | const [isAnimatedImage, setIsAnimatedImage] = useState<boolean>(false) | ||||
| useEffect(() => { | useEffect(() => { | ||||
| ? <> | ? <> | ||||
| <ImagePlus className="pointer-events-none mb-3 h-[30px] w-[30px]" /> | <ImagePlus className="pointer-events-none mb-3 h-[30px] w-[30px]" /> | ||||
| <div className="mb-[2px] text-sm font-medium"> | <div className="mb-[2px] text-sm font-medium"> | ||||
| <span className="pointer-events-none">Drop your image here, or </span> | |||||
| <button className="text-components-button-primary-bg" onClick={() => inputRef.current?.click()}>browse</button> | |||||
| <span className="pointer-events-none">{t('common.imageInput.dropImageHere')} </span> | |||||
| <button className="text-components-button-primary-bg" onClick={() => inputRef.current?.click()}>{t('common.imageInput.browse')}</button> | |||||
| <input | <input | ||||
| ref={inputRef} type="file" className="hidden" | ref={inputRef} type="file" className="hidden" | ||||
| onClick={e => ((e.target as HTMLInputElement).value = '')} | onClick={e => ((e.target as HTMLInputElement).value = '')} | ||||
| onChange={handleLocalFileInput} | onChange={handleLocalFileInput} | ||||
| /> | /> | ||||
| </div> | </div> | ||||
| <div className="pointer-events-none text-xs">Supports PNG, JPG, JPEG, WEBP and GIF</div> | |||||
| <div className="pointer-events-none">{t('common.imageInput.supportedFormats')}</div> | |||||
| </> | </> | ||||
| : handleShowImage() | : handleShowImage() | ||||
| } | } |
| const searchParams = useSearchParams() | const searchParams = useSearchParams() | ||||
| const { replace } = useRouter() | const { replace } = useRouter() | ||||
| document.title = `${t('plugin.metadata.title')} - Dify` | |||||
| // just support install one package now | // just support install one package now | ||||
| const packageId = useMemo(() => { | const packageId = useMemo(() => { | ||||
| const idStrings = searchParams.get(PACKAGE_IDS_KEY) | const idStrings = searchParams.get(PACKAGE_IDS_KEY) |
| pagination: { | pagination: { | ||||
| perPage: 'Items per page', | perPage: 'Items per page', | ||||
| }, | }, | ||||
| imageInput: { | |||||
| dropImageHere: 'Drop your image here, or', | |||||
| browse: 'browse', | |||||
| supportedFormats: 'Supports PNG, JPG, JPEG, WEBP and GIF', | |||||
| }, | |||||
| } | } | ||||
| export default translation | export default translation |
| const translation = { | const translation = { | ||||
| metadata: { | |||||
| title: 'Plugins', | |||||
| }, | |||||
| category: { | category: { | ||||
| all: 'All', | all: 'All', | ||||
| models: 'Models', | models: 'Models', |
| pagination: { | pagination: { | ||||
| perPage: '每页显示', | perPage: '每页显示', | ||||
| }, | }, | ||||
| imageInput: { | |||||
| dropImageHere: '将图片拖放到此处,或', | |||||
| browse: '浏览', | |||||
| supportedFormats: '支持PNG、JPG、JPEG、WEBP和GIF格式', | |||||
| }, | |||||
| } | } | ||||
| export default translation | export default translation |
| const translation = { | const translation = { | ||||
| metadata: { | |||||
| title: '插件', | |||||
| }, | |||||
| category: { | category: { | ||||
| all: '全部', | all: '全部', | ||||
| models: '模型', | models: '模型', |