From c4ca97c0ae508d7e6ab28c2cc3e6e1f1448d925f Mon Sep 17 00:00:00 2001 From: kazuhisa-wada Date: Wed, 15 Jan 2025 21:08:40 +0900 Subject: [PATCH 1/5] add flexibility on upper bounds of max_retry and retry intervals --- .../_base/components/retry/retry-on-panel.tsx | 42 +++++++++++-------- .../nodes/_base/components/retry/types.ts | 2 + web/config/index.ts | 14 +++++++ 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/web/app/components/workflow/nodes/_base/components/retry/retry-on-panel.tsx b/web/app/components/workflow/nodes/_base/components/retry/retry-on-panel.tsx index dc877a632c5d15..a19c9339555eec 100644 --- a/web/app/components/workflow/nodes/_base/components/retry/retry-on-panel.tsx +++ b/web/app/components/workflow/nodes/_base/components/retry/retry-on-panel.tsx @@ -8,6 +8,7 @@ import type { Node, } from '@/app/components/workflow/types' import Split from '@/app/components/workflow/nodes/_base/components/split' +import { MAX_RETRIES_DEFAULT, MAX_RETRIES_UPPER_BOUND_DEFAULT, RETRY_INTERVAL_DEFAULT, RETRY_INTERVAL_UPPER_BOUND_DEFAULT } from '@/config' type RetryOnPanelProps = Pick const RetryOnPanel = ({ @@ -21,32 +22,39 @@ const RetryOnPanel = ({ const handleRetryEnabledChange = (value: boolean) => { handleRetryConfigChange({ retry_enabled: value, - max_retries: retry_config?.max_retries || 3, - retry_interval: retry_config?.retry_interval || 1000, + max_retries: retry_config?.max_retries || MAX_RETRIES_DEFAULT, + retry_interval: retry_config?.retry_interval || RETRY_INTERVAL_DEFAULT, + max_retries_upper_bound: retry_config?.max_retries_upper_bound || MAX_RETRIES_UPPER_BOUND_DEFAULT, + retry_interval_upper_bound: retry_config?.retry_interval_upper_bound || RETRY_INTERVAL_UPPER_BOUND_DEFAULT, }) } const handleMaxRetriesChange = (value: number) => { - if (value > 10) - value = 10 + if (value > (retry_config?.max_retries_upper_bound || MAX_RETRIES_UPPER_BOUND_DEFAULT)) + value = (retry_config?.max_retries_upper_bound || MAX_RETRIES_UPPER_BOUND_DEFAULT) else if (value < 1) value = 1 handleRetryConfigChange({ retry_enabled: true, max_retries: value, - retry_interval: retry_config?.retry_interval || 1000, + retry_interval: retry_config?.retry_interval || RETRY_INTERVAL_DEFAULT, + max_retries_upper_bound: retry_config?.max_retries_upper_bound || MAX_RETRIES_UPPER_BOUND_DEFAULT, + retry_interval_upper_bound: retry_config?.retry_interval_upper_bound || RETRY_INTERVAL_UPPER_BOUND_DEFAULT, }) } const handleRetryIntervalChange = (value: number) => { - if (value > 5000) - value = 5000 + // リトライインターバルの制限をデフォルト値に基づき変更 + if (value > (retry_config?.retry_interval_upper_bound || RETRY_INTERVAL_UPPER_BOUND_DEFAULT)) + value = (retry_config?.retry_interval_upper_bound || RETRY_INTERVAL_UPPER_BOUND_DEFAULT) else if (value < 100) value = 100 handleRetryConfigChange({ retry_enabled: true, - max_retries: retry_config?.max_retries || 3, + max_retries: retry_config?.max_retries || MAX_RETRIES_DEFAULT, retry_interval: value, + max_retries_upper_bound: retry_config?.max_retries_upper_bound || MAX_RETRIES_UPPER_BOUND_DEFAULT, + retry_interval_upper_bound: retry_config?.retry_interval_upper_bound || RETRY_INTERVAL_UPPER_BOUND_DEFAULT, }) } @@ -58,7 +66,7 @@ const RetryOnPanel = ({
{t('workflow.nodes.common.retry.retryOnFailure')}
handleRetryEnabledChange(v)} /> @@ -69,18 +77,18 @@ const RetryOnPanel = ({
{t('workflow.nodes.common.retry.maxRetries')}
handleMaxRetriesChange(e.target.value as any)} min={1} - max={10} + max={retry_config?.max_retries_upper_bound || MAX_RETRIES_UPPER_BOUND_DEFAULT} unit={t('workflow.nodes.common.retry.times') || ''} className={s.input} /> @@ -89,18 +97,18 @@ const RetryOnPanel = ({
{t('workflow.nodes.common.retry.retryInterval')}
handleRetryIntervalChange(e.target.value as any)} min={100} - max={5000} + max={retry_config?.retry_interval_upper_bound || RETRY_INTERVAL_UPPER_BOUND_DEFAULT} unit={t('workflow.nodes.common.retry.ms') || ''} className={s.input} /> diff --git a/web/app/components/workflow/nodes/_base/components/retry/types.ts b/web/app/components/workflow/nodes/_base/components/retry/types.ts index bb5f593fd545ae..d1f081f220240f 100644 --- a/web/app/components/workflow/nodes/_base/components/retry/types.ts +++ b/web/app/components/workflow/nodes/_base/components/retry/types.ts @@ -2,4 +2,6 @@ export type WorkflowRetryConfig = { max_retries: number retry_interval: number retry_enabled: boolean + max_retries_upper_bound?: number + retry_interval_upper_bound?: number } diff --git a/web/config/index.ts b/web/config/index.ts index b87c027de16831..4b43a29a54cf7a 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -260,3 +260,17 @@ export const TEXT_GENERATION_TIMEOUT_MS = textGenerationTimeoutMs export const DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true' export const FULL_DOC_PREVIEW_LENGTH = 50 + +// System default upper bounds of max retry and retry intervals +export const MAX_RETRIES_DEFAULT = 3 +export const RETRY_INTERVAL_DEFAULT = 500 +export const RETRY_ENABLED_DEFAULT = false +export const MAX_RETRIES_UPPER_BOUND_DEFAULT = 10 +export const RETRY_INTERVAL_UPPER_BOUND_DEFAULT = 5000 + +// Retries related parameters of LLM Node +export const MAX_RETRIES_DEFAULT_LLM_NODE = 3 +export const RETRY_INTERVAL_DEFAULT_LLM_NODE = 500 +export const RETRY_ENABLED_DEFAULT_LLM_NODE = false +export const MAX_RETRIES_UPPER_BOUND_LLM_NODE = 10 +export const RETRY_INTERVAL_UPPER_BOUND_LLM_NODE = 5000 From 7a6f56eb73a9ae884bcd9542a7f8bbe8132daa9e Mon Sep 17 00:00:00 2001 From: kazuhisa-wada Date: Wed, 15 Jan 2025 21:15:14 +0900 Subject: [PATCH 2/5] add flexibility on upper bounds of max_retry and retry intervals for HTTP node and tool node --- web/app/components/workflow/nodes/http/default.ts | 9 ++++++--- web/app/components/workflow/nodes/llm/default.ts | 8 ++++++++ web/app/components/workflow/nodes/tool/default.ts | 9 +++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/web/app/components/workflow/nodes/http/default.ts b/web/app/components/workflow/nodes/http/default.ts index f506c934a23f60..09d4ab2327c0e2 100644 --- a/web/app/components/workflow/nodes/http/default.ts +++ b/web/app/components/workflow/nodes/http/default.ts @@ -6,6 +6,7 @@ import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS, } from '@/app/components/workflow/constants' +import { MAX_RETRIES_DEFAULT_HTTP_NODE, MAX_RETRIES_UPPER_BOUND_HTTP_NODE, RETRY_ENABLED_DEFAULT_HTTP_NODE, RETRY_INTERVAL_DEFAULT_HTTP_NODE, RETRY_INTERVAL_UPPER_BOUND_HTTP_NODE } from '@/config' const nodeDefault: NodeDefault = { defaultValue: { @@ -28,9 +29,11 @@ const nodeDefault: NodeDefault = { max_write_timeout: 0, }, retry_config: { - retry_enabled: true, - max_retries: 3, - retry_interval: 100, + retry_enabled: RETRY_ENABLED_DEFAULT_HTTP_NODE, + max_retries: MAX_RETRIES_DEFAULT_HTTP_NODE, + retry_interval: RETRY_INTERVAL_DEFAULT_HTTP_NODE, + max_retries_upper_bound: MAX_RETRIES_UPPER_BOUND_HTTP_NODE, + retry_interval_upper_bound: RETRY_INTERVAL_UPPER_BOUND_HTTP_NODE, }, }, getAvailablePrevNodes(isChatMode: boolean) { diff --git a/web/app/components/workflow/nodes/llm/default.ts b/web/app/components/workflow/nodes/llm/default.ts index cddfafcb1253ed..439bf0f60b0725 100644 --- a/web/app/components/workflow/nodes/llm/default.ts +++ b/web/app/components/workflow/nodes/llm/default.ts @@ -2,6 +2,7 @@ import { BlockEnum, EditionType } from '../../types' import { type NodeDefault, type PromptItem, PromptRole } from '../../types' import type { LLMNodeType } from './types' import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants' +import { MAX_RETRIES_DEFAULT_LLM_NODE, MAX_RETRIES_UPPER_BOUND_LLM_NODE, RETRY_ENABLED_DEFAULT_LLM_NODE, RETRY_INTERVAL_DEFAULT_LLM_NODE, RETRY_INTERVAL_UPPER_BOUND_LLM_NODE } from '@/config' const i18nPrefix = 'workflow.errorMsg' @@ -26,6 +27,13 @@ const nodeDefault: NodeDefault = { vision: { enabled: false, }, + retry_config: { + retry_enabled: RETRY_ENABLED_DEFAULT_LLM_NODE, + max_retries: MAX_RETRIES_DEFAULT_LLM_NODE, + retry_interval: RETRY_INTERVAL_DEFAULT_LLM_NODE, + max_retries_upper_bound: MAX_RETRIES_UPPER_BOUND_LLM_NODE, + retry_interval_upper_bound: RETRY_INTERVAL_UPPER_BOUND_LLM_NODE, + }, }, getAvailablePrevNodes(isChatMode: boolean) { const nodes = isChatMode diff --git a/web/app/components/workflow/nodes/tool/default.ts b/web/app/components/workflow/nodes/tool/default.ts index 3b7f990a9f7d61..795dc3da64f86f 100644 --- a/web/app/components/workflow/nodes/tool/default.ts +++ b/web/app/components/workflow/nodes/tool/default.ts @@ -3,6 +3,7 @@ import type { NodeDefault } from '../../types' import type { ToolNodeType } from './types' import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants' +import { MAX_RETRIES_DEFAULT_TOOL_NODE, MAX_RETRIES_UPPER_BOUND_TOOL_NODE, RETRY_ENABLED_DEFAULT_TOOL_NODE, RETRY_INTERVAL_DEFAULT_TOOL_NODE, RETRY_INTERVAL_UPPER_BOUND_TOOL_NODE } from '@/config' const i18nPrefix = 'workflow.errorMsg' @@ -10,6 +11,14 @@ const nodeDefault: NodeDefault = { defaultValue: { tool_parameters: {}, tool_configurations: {}, + retry_config: { + retry_enabled: RETRY_ENABLED_DEFAULT_TOOL_NODE, + max_retries: MAX_RETRIES_DEFAULT_TOOL_NODE, + retry_interval: RETRY_INTERVAL_DEFAULT_TOOL_NODE, + max_retries_upper_bound: MAX_RETRIES_UPPER_BOUND_TOOL_NODE, + retry_interval_upper_bound: RETRY_INTERVAL_UPPER_BOUND_TOOL_NODE, + }, + }, getAvailablePrevNodes(isChatMode: boolean) { const nodes = isChatMode From 109ef7d582ea537b5a1444efb6745433504398f0 Mon Sep 17 00:00:00 2001 From: kazuhisa-wada Date: Wed, 15 Jan 2025 21:16:46 +0900 Subject: [PATCH 3/5] add constraints related parameters in config about retry --- web/config/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/config/index.ts b/web/config/index.ts index 4b43a29a54cf7a..7e2558f619b667 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -274,3 +274,17 @@ export const RETRY_INTERVAL_DEFAULT_LLM_NODE = 500 export const RETRY_ENABLED_DEFAULT_LLM_NODE = false export const MAX_RETRIES_UPPER_BOUND_LLM_NODE = 10 export const RETRY_INTERVAL_UPPER_BOUND_LLM_NODE = 5000 + +// Retries related parameters of HTTP Node +export const MAX_RETRIES_DEFAULT_HTTP_NODE = 3 +export const RETRY_INTERVAL_DEFAULT_HTTP_NODE = 500 +export const RETRY_ENABLED_DEFAULT_HTTP_NODE = true +export const MAX_RETRIES_UPPER_BOUND_HTTP_NODE = 10 +export const RETRY_INTERVAL_UPPER_BOUND_HTTP_NODE = 5000 + +// Retries related parameters of Tool Node +export const MAX_RETRIES_DEFAULT_TOOL_NODE = 3 +export const RETRY_INTERVAL_DEFAULT_TOOL_NODE = 500 +export const RETRY_ENABLED_DEFAULT_TOOL_NODE = true +export const MAX_RETRIES_UPPER_BOUND_TOOL_NODE = 10 +export const RETRY_INTERVAL_UPPER_BOUND_TOOL_NODE = 5000 From 71c71094813e998bdc543f18669dfe7e9ff81178 Mon Sep 17 00:00:00 2001 From: kazuhisa-wada Date: Wed, 15 Jan 2025 21:21:12 +0900 Subject: [PATCH 4/5] changing initialNode on retry related initiation in response to changes on retry default settings related change --- web/app/components/workflow/utils.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/app/components/workflow/utils.ts b/web/app/components/workflow/utils.ts index da2848277f4db4..b5cab1c0021270 100644 --- a/web/app/components/workflow/utils.ts +++ b/web/app/components/workflow/utils.ts @@ -41,6 +41,7 @@ import type { ToolNodeType } from './nodes/tool/types' import type { IterationNodeType } from './nodes/iteration/types' import { CollectionType } from '@/app/components/tools/types' import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' +import { MAX_RETRIES_UPPER_BOUND_DEFAULT, RETRY_INTERVAL_UPPER_BOUND_DEFAULT } from '@/config' const WHITE = 'WHITE' const GRAY = 'GRAY' @@ -286,6 +287,8 @@ export const initialNodes = (originNodes: Node[], originEdges: Edge[]) => { retry_enabled: true, max_retries: DEFAULT_RETRY_MAX, retry_interval: DEFAULT_RETRY_INTERVAL, + max_retries_upper_bound: MAX_RETRIES_UPPER_BOUND_DEFAULT, + retry_interval_upper_bound: RETRY_INTERVAL_UPPER_BOUND_DEFAULT, } } From 6f7c91b0a6065ebd23f88bc3289d57be11ffea69 Mon Sep 17 00:00:00 2001 From: kazuhisa-wada Date: Thu, 16 Jan 2025 14:42:49 +0900 Subject: [PATCH 5/5] optimize config file so behavior is exatly the same as-is --- web/config/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/config/index.ts b/web/config/index.ts index 7e2558f619b667..a80de800e10844 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -263,28 +263,28 @@ export const FULL_DOC_PREVIEW_LENGTH = 50 // System default upper bounds of max retry and retry intervals export const MAX_RETRIES_DEFAULT = 3 -export const RETRY_INTERVAL_DEFAULT = 500 +export const RETRY_INTERVAL_DEFAULT = 1000 export const RETRY_ENABLED_DEFAULT = false export const MAX_RETRIES_UPPER_BOUND_DEFAULT = 10 export const RETRY_INTERVAL_UPPER_BOUND_DEFAULT = 5000 // Retries related parameters of LLM Node export const MAX_RETRIES_DEFAULT_LLM_NODE = 3 -export const RETRY_INTERVAL_DEFAULT_LLM_NODE = 500 +export const RETRY_INTERVAL_DEFAULT_LLM_NODE = 1000 export const RETRY_ENABLED_DEFAULT_LLM_NODE = false export const MAX_RETRIES_UPPER_BOUND_LLM_NODE = 10 export const RETRY_INTERVAL_UPPER_BOUND_LLM_NODE = 5000 // Retries related parameters of HTTP Node export const MAX_RETRIES_DEFAULT_HTTP_NODE = 3 -export const RETRY_INTERVAL_DEFAULT_HTTP_NODE = 500 -export const RETRY_ENABLED_DEFAULT_HTTP_NODE = true +export const RETRY_INTERVAL_DEFAULT_HTTP_NODE = 100 +export const RETRY_ENABLED_DEFAULT_HTTP_NODE = false export const MAX_RETRIES_UPPER_BOUND_HTTP_NODE = 10 export const RETRY_INTERVAL_UPPER_BOUND_HTTP_NODE = 5000 // Retries related parameters of Tool Node export const MAX_RETRIES_DEFAULT_TOOL_NODE = 3 -export const RETRY_INTERVAL_DEFAULT_TOOL_NODE = 500 -export const RETRY_ENABLED_DEFAULT_TOOL_NODE = true +export const RETRY_INTERVAL_DEFAULT_TOOL_NODE = 1000 +export const RETRY_ENABLED_DEFAULT_TOOL_NODE = false export const MAX_RETRIES_UPPER_BOUND_TOOL_NODE = 10 export const RETRY_INTERVAL_UPPER_BOUND_TOOL_NODE = 5000