mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-10 11:26:52 +08:00
feat: n to 1 retrieval legacy (#6554)
This commit is contained in:
29
web/hooks/use-knowledge.ts
Normal file
29
web/hooks/use-knowledge.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user