dify/web/app/components/rag-pipeline/hooks/use-pipeline-template.ts
Stephen Zhou 6d0e36479b
refactor(i18n): use JSON with flattened key and namespace (#30114)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-29 14:52:32 +08:00

31 lines
954 B
TypeScript

import type { KnowledgeBaseNodeType } from '@/app/components/workflow/nodes/knowledge-base/types'
import { useTranslation } from 'react-i18next'
import {
START_INITIAL_POSITION,
} from '@/app/components/workflow/constants'
import knowledgeBaseDefault from '@/app/components/workflow/nodes/knowledge-base/default'
import { generateNewNode } from '@/app/components/workflow/utils'
export const usePipelineTemplate = () => {
const { t } = useTranslation()
const { newNode: knowledgeBaseNode } = generateNewNode({
id: 'knowledgeBase',
data: {
...knowledgeBaseDefault.defaultValue as KnowledgeBaseNodeType,
type: knowledgeBaseDefault.metaData.type,
title: t(`blocks.${knowledgeBaseDefault.metaData.type}`, { ns: 'workflow' }),
selected: true,
},
position: {
x: START_INITIAL_POSITION.x + 500,
y: START_INITIAL_POSITION.y,
},
})
return {
nodes: [knowledgeBaseNode],
edges: [],
}
}