mirror of https://github.com/langgenius/dify.git
block selector
This commit is contained in:
parent
dc2b63b832
commit
28726b6cf3
|
|
@ -3,6 +3,7 @@ import {
|
|||
useCallback,
|
||||
useMemo,
|
||||
} from 'react'
|
||||
import { useStoreApi } from 'reactflow'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { groupBy } from 'lodash-es'
|
||||
import BlockIcon from '../block-icon'
|
||||
|
|
@ -26,6 +27,7 @@ const Blocks = ({
|
|||
blocks,
|
||||
}: BlocksProps) => {
|
||||
const { t } = useTranslation()
|
||||
const store = useStoreApi()
|
||||
|
||||
const groups = useMemo(() => {
|
||||
return BLOCK_CLASSIFICATIONS.reduce((acc, classification) => {
|
||||
|
|
@ -43,6 +45,14 @@ const Blocks = ({
|
|||
|
||||
const renderGroup = useCallback((classification: string) => {
|
||||
const list = groups[classification].sort((a, b) => a.metaData.sort - b.metaData.sort)
|
||||
const { getNodes } = store.getState()
|
||||
const nodes = getNodes()
|
||||
const hasKnowledgeBaseNode = nodes.some(node => node.data.type === BlockEnum.KnowledgeBase)
|
||||
const filteredList = list.filter((block) => {
|
||||
if (hasKnowledgeBaseNode)
|
||||
return block.metaData.type !== BlockEnum.KnowledgeBase
|
||||
return true
|
||||
})
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
@ -50,14 +60,14 @@ const Blocks = ({
|
|||
className='mb-1 last-of-type:mb-0'
|
||||
>
|
||||
{
|
||||
classification !== '-' && !!list.length && (
|
||||
classification !== '-' && !!filteredList.length && (
|
||||
<div className='flex h-[22px] items-start px-3 text-xs font-medium text-text-tertiary'>
|
||||
{t(`workflow.tabs.${classification}`)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
list.map(block => (
|
||||
filteredList.map(block => (
|
||||
<Tooltip
|
||||
key={block.metaData.type}
|
||||
position='right'
|
||||
|
|
@ -98,7 +108,7 @@ const Blocks = ({
|
|||
}
|
||||
</div>
|
||||
)
|
||||
}, [groups, onSelect, t])
|
||||
}, [groups, onSelect, t, store])
|
||||
|
||||
return (
|
||||
<div className='max-h-[480px] overflow-y-auto p-1'>
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@ const NodeSelector: FC<NodeSelectorProps> = ({
|
|||
|
||||
if (activeTab === TabsEnum.Tools)
|
||||
return t('workflow.tabs.searchTool')
|
||||
|
||||
if (activeTab === TabsEnum.Sources)
|
||||
return t('workflow.tabs.searchDataSource')
|
||||
return ''
|
||||
}, [activeTab, t])
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import type { DataSourceItem } from './types'
|
|||
|
||||
export const transformDataSourceToTool = (dataSourceItem: DataSourceItem) => {
|
||||
return {
|
||||
id: dataSourceItem.plugin_unique_identifier,
|
||||
id: dataSourceItem.plugin_id,
|
||||
name: dataSourceItem.declaration.identity.name,
|
||||
author: dataSourceItem.declaration.identity.author,
|
||||
description: dataSourceItem.declaration.identity.description,
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ const IndexMethod = ({
|
|||
<div className='flex items-center'>
|
||||
<div className='flex grow items-center'>
|
||||
<div className='system-xs-medium truncate text-text-secondary'>
|
||||
Number of Keywords
|
||||
{t('datasetSettings.form.numberOfKeywords')}
|
||||
</div>
|
||||
<Tooltip
|
||||
popupContent='number of keywords'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import {
|
||||
IndexMethodEnum,
|
||||
RetrievalSearchMethodEnum,
|
||||
} from '../types'
|
||||
|
||||
export const useSettingsDisplay = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return {
|
||||
[IndexMethodEnum.QUALIFIED]: t('datasetCreation.stepTwo.qualified'),
|
||||
[IndexMethodEnum.ECONOMICAL]: t('datasetSettings.form.indexMethodEconomy'),
|
||||
[RetrievalSearchMethodEnum.semantic]: t('dataset.retrieval.semantic_search.title'),
|
||||
[RetrievalSearchMethodEnum.fullText]: t('dataset.retrieval.full_text_search.title'),
|
||||
[RetrievalSearchMethodEnum.hybrid]: t('dataset.retrieval.hybrid_search.title'),
|
||||
[RetrievalSearchMethodEnum.invertedIndex]: t('dataset.retrieval.invertedIndex.title'),
|
||||
}
|
||||
}
|
||||
|
|
@ -2,19 +2,22 @@ import type { FC } from 'react'
|
|||
import { memo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import type { KnowledgeBaseNodeType } from './types'
|
||||
import { useSettingsDisplay } from './hooks/use-settings-display'
|
||||
import type { NodeProps } from '@/app/components/workflow/types'
|
||||
|
||||
const Node: FC<NodeProps<KnowledgeBaseNodeType>> = ({ data }) => {
|
||||
const { t } = useTranslation()
|
||||
const settingsDisplay = useSettingsDisplay()
|
||||
|
||||
return (
|
||||
<div className='mb-1 space-y-0.5 px-3 py-1'>
|
||||
<div className='flex h-6 items-center rounded-md bg-workflow-block-parma-bg px-1.5'>
|
||||
<div className='system-xs-medium-uppercase mr-2 shrink-0 text-text-tertiary'>{t('datasetCreation.stepTwo.indexMode')}</div>
|
||||
<div className='system-xs-medium grow truncate text-right text-text-secondary' title={data.indexing_technique}>{data.indexing_technique}</div>
|
||||
<div className='system-xs-medium grow truncate text-right text-text-secondary' title={data.indexing_technique}>{settingsDisplay[data.indexing_technique]}</div>
|
||||
</div>
|
||||
<div className='flex h-6 items-center rounded-md bg-workflow-block-parma-bg px-1.5'>
|
||||
<div className='system-xs-medium-uppercase mr-2 shrink-0 text-text-tertiary'>{t('datasetSettings.form.retrievalSetting.title')}</div>
|
||||
<div className='system-xs-medium grow truncate text-right text-text-secondary' title={data.retrieval_model.search_method}>{data.retrieval_model.search_method}</div>
|
||||
<div className='system-xs-medium grow truncate text-right text-text-secondary' title={data.retrieval_model.search_method}>{(settingsDisplay as Record<string, string>)[data.retrieval_model.search_method]}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -231,6 +231,7 @@ const translation = {
|
|||
'noResult': 'No match found',
|
||||
'agent': 'Agent Strategy',
|
||||
'sources': 'Sources',
|
||||
'searchDataSource': 'Search Data Source',
|
||||
},
|
||||
blocks: {
|
||||
'start': 'Start',
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ const translation = {
|
|||
'noResult': '未找到匹配项',
|
||||
'agent': 'Agent 策略',
|
||||
'sources': '数据源',
|
||||
'searchDataSource': '搜索数据源',
|
||||
},
|
||||
blocks: {
|
||||
'start': '开始',
|
||||
|
|
|
|||
Loading…
Reference in New Issue