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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: update TopK and Score Threshold components to use InputNumber and improve value handling (#27045)
Wu Tianwei64f55d55a1bb
diff --git a/web/app/components/base/param-item/top-k-item.tsx b/web/app/components/base/param-item/top-k-item.tsxindex f59c0f273ee..0bd552e48dd 100644--- a/web/app/components/base/param-item/top-k-item.tsx+++ b/web/app/components/base/param-item/top-k-item.tsx@@ -32,7 +32,7 @@ const TopKItem: FC<Props> = ({}) => {const { t } = useTranslation()const handleParamChange = (key: string, value: number) => {- let notOutRangeValue = Number.parseFloat(value.toFixed(2))+ let notOutRangeValue = Number.parseInt(value.toFixed(0))notOutRangeValue = Math.max(VALUE_LIMIT.min, notOutRangeValue)notOutRangeValue = Math.min(VALUE_LIMIT.max, notOutRangeValue)onChange(key, notOutRangeValue)diff --git a/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/top-k-and-score-threshold.tsx b/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/top-k-and-score-threshold.tsxindex 9d46037d848..9eb1cb39c99 100644--- a/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/top-k-and-score-threshold.tsx+++ b/web/app/components/workflow/nodes/knowledge-base/components/retrieval-setting/top-k-and-score-threshold.tsx@@ -1,8 +1,8 @@-import { memo } from 'react'+import { memo, useCallback } from 'react'import { useTranslation } from 'react-i18next'import Tooltip from '@/app/components/base/tooltip'-import Input from '@/app/components/base/input'import Switch from '@/app/components/base/switch'+import { InputNumber } from '@/app/components/base/input-number'export type TopKAndScoreThresholdProps = {topK: number@@ -14,6 +14,24 @@ export type TopKAndScoreThresholdProps = {readonly?: booleanhiddenScoreThreshold?: boolean}++const maxTopK = (() => {+ const configValue = Number.parseInt(globalThis.document?.body?.getAttribute('data-public-top-k-max-value') || '', 10)+ if (configValue && !isNaN(configValue))+ return configValue+ return 10+})()+const TOP_K_VALUE_LIMIT = {+ amount: 1,+ min: 1,+ max: maxTopK,+}+const SCORE_THRESHOLD_VALUE_LIMIT = {+ step: 0.01,+ min: 0,+ max: 1,+}+const TopKAndScoreThreshold = ({topK,onTopKChange,@@ -25,18 +43,18 @@ const TopKAndScoreThreshold = ({hiddenScoreThreshold,}: TopKAndScoreThresholdProps) => {const { t } = useTranslation()- const handleTopKChange = (e: React.ChangeEvent<HTMLInputElement>) => {- const value = Number(e.target.value)- if (Number.isNaN(value))- return- onTopKChange?.(value)- }+ const handleTopKChange = useCallback((value: number) => {+ let notOutRangeValue = Number.parseInt(value.toFixed(0))+ notOutRangeValue = Math.max(TOP_K_VALUE_LIMIT.min, notOutRangeValue)+ notOutRangeValue = Math.min(TOP_K_VALUE_LIMIT.max, notOutRangeValue)+ onTopKChange?.(notOutRangeValue)+ }, [onTopKChange])- const handleScoreThresholdChange = (e: React.ChangeEvent<HTMLInputElement>) => {- const value = Number(e.target.value)- if (Number.isNaN(value))- return- onScoreThresholdChange?.(value)+ const handleScoreThresholdChange = (value: number) => {+ let notOutRangeValue = Number.parseFloat(value.toFixed(2))+ notOutRangeValue = Math.max(SCORE_THRESHOLD_VALUE_LIMIT.min, notOutRangeValue)+ notOutRangeValue = Math.min(SCORE_THRESHOLD_VALUE_LIMIT.max, notOutRangeValue)+ onScoreThresholdChange?.(notOutRangeValue)}return (@@ -49,11 +67,13 @@ const TopKAndScoreThreshold = ({popupContent={t('appDebug.datasetConfig.top_kTip')}/></div>- <Input+ <InputNumber+ disabled={readonly}type='number'+ {...TOP_K_VALUE_LIMIT}+ size='regular'value={topK}onChange={handleTopKChange}- disabled={readonly}/></div>{@@ -74,11 +94,13 @@ const TopKAndScoreThreshold = ({popupContent={t('appDebug.datasetConfig.score_thresholdTip')}/></div>- <Input+ <InputNumber+ disabled={readonly || !isScoreThresholdEnabled}type='number'+ {...SCORE_THRESHOLD_VALUE_LIMIT}+ size='regular'value={scoreThreshold}onChange={handleScoreThresholdChange}- disabled={readonly || !isScoreThresholdEnabled}/></div>)