mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-18 01:06:57 +08:00
30 lines
891 B
TypeScript
30 lines
891 B
TypeScript
import { useCallback } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
export const useKnowledge = () => {
|
|
const { t } = useTranslation()
|
|
|
|
const formatIndexingTechnique = useCallback((indexingTechnique: string) => {
|
|
return t(`dataset.indexingTechnique.${indexingTechnique}`)
|
|
}, [t])
|
|
|
|
const formatIndexingMethod = useCallback((indexingMethod: string) => {
|
|
return t(`dataset.indexingMethod.${indexingMethod}`)
|
|
}, [t])
|
|
|
|
const formatIndexingTechniqueAndMethod = useCallback((indexingTechnique: string, indexingMethod: string) => {
|
|
let result = formatIndexingTechnique(indexingTechnique)
|
|
|
|
if (indexingMethod)
|
|
result += ` · ${formatIndexingMethod(indexingMethod)}`
|
|
|
|
return result
|
|
}, [formatIndexingTechnique, formatIndexingMethod])
|
|
|
|
return {
|
|
formatIndexingTechnique,
|
|
formatIndexingMethod,
|
|
formatIndexingTechniqueAndMethod,
|
|
}
|
|
}
|