feat: configure maximum loop count using environment variable.
This commit is contained in:
parent
6588bfddb9
commit
d6169e0afe
@ -720,6 +720,9 @@ SSRF_PROXY_HTTP_URL=http://ssrf_proxy:3128
|
||||
# SSRF Proxy server HTTPS URL
|
||||
SSRF_PROXY_HTTPS_URL=http://ssrf_proxy:3128
|
||||
|
||||
# Maximum loop count in the workflow
|
||||
LOOP_NODE_MAX_COUNT=100
|
||||
|
||||
# ------------------------------
|
||||
# Environment Variables for web Service
|
||||
# ------------------------------
|
||||
|
@ -67,6 +67,7 @@ services:
|
||||
TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-}
|
||||
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH:-}
|
||||
PM2_INSTANCES: ${PM2_INSTANCES:-2}
|
||||
LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100}
|
||||
|
||||
# The postgres database.
|
||||
db:
|
||||
|
@ -310,6 +310,7 @@ x-shared-env: &shared-api-worker-env
|
||||
HTTP_REQUEST_NODE_MAX_TEXT_SIZE: ${HTTP_REQUEST_NODE_MAX_TEXT_SIZE:-1048576}
|
||||
SSRF_PROXY_HTTP_URL: ${SSRF_PROXY_HTTP_URL:-http://ssrf_proxy:3128}
|
||||
SSRF_PROXY_HTTPS_URL: ${SSRF_PROXY_HTTPS_URL:-http://ssrf_proxy:3128}
|
||||
LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100}
|
||||
TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000}
|
||||
PGUSER: ${PGUSER:-${DB_USERNAME}}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-${DB_PASSWORD}}
|
||||
@ -481,6 +482,7 @@ services:
|
||||
TOP_K_MAX_VALUE: ${TOP_K_MAX_VALUE:-}
|
||||
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH:-}
|
||||
PM2_INSTANCES: ${PM2_INSTANCES:-2}
|
||||
LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100}
|
||||
|
||||
# The postgres database.
|
||||
db:
|
||||
|
@ -37,3 +37,6 @@ NEXT_PUBLIC_TOP_K_MAX_VALUE=10
|
||||
|
||||
# The maximum number of tokens for segmentation
|
||||
NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=4000
|
||||
|
||||
# Maximum loop count in the workflow
|
||||
NEXT_PUBLIC_LOOP_NODE_MAX_COUNT=100
|
||||
|
@ -4,6 +4,7 @@ import { ComparisonOperator, LogicalOperator, type LoopNodeType } from './types'
|
||||
import { isEmptyRelatedOperator } from './utils'
|
||||
import { TransferMethod } from '@/types/app'
|
||||
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/blocks'
|
||||
import { LOOP_NODE_MAX_COUNT } from '@/config'
|
||||
const i18nPrefix = 'workflow.errorMsg'
|
||||
|
||||
const nodeDefault: NodeDefault<LoopNodeType> = {
|
||||
@ -62,9 +63,9 @@ const nodeDefault: NodeDefault<LoopNodeType> = {
|
||||
Number.isNaN(Number(payload.loop_count))
|
||||
|| !Number.isInteger(Number(payload.loop_count))
|
||||
|| payload.loop_count < 1
|
||||
|| payload.loop_count > 100
|
||||
|| payload.loop_count > LOOP_NODE_MAX_COUNT
|
||||
))
|
||||
errorMessages = t('workflow.nodes.loop.loopMaxCountError')
|
||||
errorMessages = t('workflow.nodes.loop.loopMaxCountError', { maxCount: LOOP_NODE_MAX_COUNT })
|
||||
|
||||
return {
|
||||
isValid: !errorMessages,
|
||||
|
@ -14,6 +14,7 @@ import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/befo
|
||||
import formatTracing from '@/app/components/workflow/run/utils/format-log'
|
||||
|
||||
import { useLogs } from '@/app/components/workflow/run/hooks'
|
||||
import { LOOP_NODE_MAX_COUNT } from '@/config'
|
||||
|
||||
const i18nPrefix = 'workflow.nodes.loop'
|
||||
|
||||
@ -80,7 +81,7 @@ const Panel: FC<NodePanelProps<LoopNodeType>> = ({
|
||||
<div className='px-3 py-2'>
|
||||
<InputNumberWithSlider
|
||||
min={1}
|
||||
max={100}
|
||||
max={LOOP_NODE_MAX_COUNT}
|
||||
value={inputs.loop_count}
|
||||
onChange={(val) => {
|
||||
const roundedVal = Math.round(val)
|
||||
|
@ -49,6 +49,7 @@ const LocaleLayout = ({
|
||||
data-public-text-generation-timeout-ms={process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS}
|
||||
data-public-top-k-max-value={process.env.NEXT_PUBLIC_TOP_K_MAX_VALUE}
|
||||
data-public-indexing-max-segmentation-tokens-length={process.env.NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH}
|
||||
data-public-loop-node-max-count={process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT}
|
||||
>
|
||||
<BrowserInitor>
|
||||
<SentryInitor>
|
||||
|
@ -276,3 +276,12 @@ export const GITHUB_ACCESS_TOKEN = process.env.NEXT_PUBLIC_GITHUB_ACCESS_TOKEN |
|
||||
|
||||
export const SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS = '.difypkg,.difybndl'
|
||||
export const FULL_DOC_PREVIEW_LENGTH = 50
|
||||
|
||||
let loopNodeMaxCount = 100
|
||||
|
||||
if (process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT && process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT !== '')
|
||||
loopNodeMaxCount = Number.parseInt(process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT)
|
||||
else if (globalThis.document?.body?.getAttribute('data-public-loop-node-max-count') && globalThis.document.body.getAttribute('data-public-loop-node-max-count') !== '')
|
||||
loopNodeMaxCount = Number.parseInt(globalThis.document.body.getAttribute('data-public-loop-node-max-count') as string)
|
||||
|
||||
export const LOOP_NODE_MAX_COUNT = loopNodeMaxCount
|
||||
|
@ -671,7 +671,7 @@ const translation = {
|
||||
currentLoop: 'Current Loop',
|
||||
breakCondition: 'Loop Termination Condition',
|
||||
loopMaxCount: 'Maximum Loop Count',
|
||||
loopMaxCountError: 'Please enter a valid maximum loop count, ranging from 1 to 100',
|
||||
loopMaxCountError: 'Please enter a valid maximum loop count, ranging from 1 to {{maxCount}}',
|
||||
errorResponseMethod: 'Error Response Method',
|
||||
ErrorMethod: {
|
||||
operationTerminated: 'Terminated',
|
||||
|
@ -672,7 +672,7 @@ const translation = {
|
||||
currentLoop: '当前循环',
|
||||
breakCondition: '循环终止条件',
|
||||
loopMaxCount: '最大循环次数',
|
||||
loopMaxCountError: '请输入正确的 最大循环次数,范围为 1 到 100',
|
||||
loopMaxCountError: '请输入正确的 最大循环次数,范围为 1 到 {{maxCount}}',
|
||||
errorResponseMethod: '错误响应方法',
|
||||
ErrorMethod: {
|
||||
operationTerminated: '错误时终止',
|
||||
|
Loading…
Reference in New Issue
Block a user