Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: comment out unused segmentation rule properties in RuleDetail component (#26031)

Wu Tianweia39b18562749
diff --git a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
index cb036def623..c8b1375069c 100644
--- a/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
+++ b/web/app/components/datasets/documents/create-from-pipeline/processing/embedding-process/rule-detail.tsx
@@ -20,35 +20,8 @@ const RuleDetail = ({
}: RuleDetailProps) => {
const { t } = useTranslation()
- const segmentationRuleMap = {
- mode: t('datasetDocuments.embedding.mode'),
- segmentLength: t('datasetDocuments.embedding.segmentLength'),
- textCleaning: t('datasetDocuments.embedding.textCleaning'),
- }
-
- const getRuleName = useCallback((key: string) => {
- if (key === 'remove_extra_spaces')
- return t('datasetCreation.stepTwo.removeExtraSpaces')
-
- if (key === 'remove_urls_emails')
- return t('datasetCreation.stepTwo.removeUrlEmails')
-
- if (key === 'remove_stopwords')
- return t('datasetCreation.stepTwo.removeStopwords')
- }, [t])
-
- const isNumber = useCallback((value: unknown) => {
- return typeof value === 'number'
- }, [])
-
const getValue = useCallback((field: string) => {
- let value: string | number | undefined = '-'
- const maxTokens = isNumber(sourceData?.rules?.segmentation?.max_tokens)
- ? sourceData.rules.segmentation.max_tokens
- : value
- const childMaxTokens = isNumber(sourceData?.rules?.subchunk_segmentation?.max_tokens)
- ? sourceData.rules.subchunk_segmentation.max_tokens
- : value
+ let value = '-'
switch (field) {
case 'mode':
value = !sourceData?.mode
@@ -61,33 +34,16 @@ const RuleDetail = ({
? t('dataset.parentMode.paragraph')
: t('dataset.parentMode.fullDoc')}`
break
- case 'segmentLength':
- value = !sourceData?.mode
- ? value
- // eslint-disable-next-line sonarjs/no-nested-conditional
- : sourceData.mode === ProcessMode.general
- ? maxTokens
- : `${t('datasetDocuments.embedding.parentMaxTokens')} ${maxTokens}; ${t('datasetDocuments.embedding.childMaxTokens')} ${childMaxTokens}`
- break
- default:
- value = !sourceData?.mode
- ? value
- : sourceData?.rules?.pre_processing_rules?.filter(rule =>
- rule.enabled).map(rule => getRuleName(rule.id)).join(',')
- break
}
return value
- }, [getRuleName, isNumber, sourceData, t])
+ }, [sourceData, t])
return (
<div className='flex flex-col gap-1'>
- {Object.keys(segmentationRuleMap).map((field) => {
- return <FieldInfo
- key={field}
- label={segmentationRuleMap[field as keyof typeof segmentationRuleMap]}
- displayedValue={String(getValue(field))}
- />
- })}
+ <FieldInfo
+ label={t('datasetDocuments.embedding.mode')}
+ displayedValue={getValue('mode')}
+ />
<FieldInfo
label={t('datasetCreation.stepTwo.indexMode')}
displayedValue={t(`datasetCreation.stepTwo.${indexingType === IndexingType.ECONOMICAL ? 'economical' : 'qualified'}`) as string}