From 1d5ea80a2b4feda798263328982cf4fc66f34a06 Mon Sep 17 00:00:00 2001 From: Rafael Carvalho Date: Wed, 12 Mar 2025 01:57:05 -0300 Subject: [PATCH] feat: env MAX_TOOLS_NUM (#15431) Co-authored-by: crazywoola <427733928@qq.com> --- docker/.env.example | 3 +++ docker/docker-compose-template.yaml | 1 + docker/docker-compose.yaml | 2 ++ web/.env.example | 3 +++ web/app/layout.tsx | 1 + web/config/index.ts | 9 ++++++++- 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docker/.env.example b/docker/.env.example index 29073fa1b0..a3788ecada 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -723,6 +723,9 @@ SSRF_PROXY_HTTPS_URL=http://ssrf_proxy:3128 # Maximum loop count in the workflow LOOP_NODE_MAX_COUNT=100 +# The maximum number of tools that can be used in the agent. +MAX_TOOLS_NUM=10 + # ------------------------------ # Environment Variables for web Service # ------------------------------ diff --git a/docker/docker-compose-template.yaml b/docker/docker-compose-template.yaml index 59544600d0..2879f2194f 100644 --- a/docker/docker-compose-template.yaml +++ b/docker/docker-compose-template.yaml @@ -68,6 +68,7 @@ services: INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH:-} PM2_INSTANCES: ${PM2_INSTANCES:-2} LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100} + MAX_TOOLS_NUM: ${MAX_TOOLS_NUM:-10} # The postgres database. db: diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 6c95ddd1f2..1d7f0ac3d8 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -311,6 +311,7 @@ x-shared-env: &shared-api-worker-env 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} + MAX_TOOLS_NUM: ${MAX_TOOLS_NUM:-10} TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000} PGUSER: ${PGUSER:-${DB_USERNAME}} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-${DB_PASSWORD}} @@ -486,6 +487,7 @@ services: INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: ${INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH:-} PM2_INSTANCES: ${PM2_INSTANCES:-2} LOOP_NODE_MAX_COUNT: ${LOOP_NODE_MAX_COUNT:-100} + MAX_TOOLS_NUM: ${MAX_TOOLS_NUM:-10} # The postgres database. db: diff --git a/web/.env.example b/web/.env.example index 6738bfce07..fa1477ba79 100644 --- a/web/.env.example +++ b/web/.env.example @@ -40,3 +40,6 @@ NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=4000 # Maximum loop count in the workflow NEXT_PUBLIC_LOOP_NODE_MAX_COUNT=100 + +# Maximum number of tools in the agent/workflow +NEXT_PUBLIC_MAX_TOOLS_NUM=10 \ No newline at end of file diff --git a/web/app/layout.tsx b/web/app/layout.tsx index 72077567b3..8a5af7acfc 100644 --- a/web/app/layout.tsx +++ b/web/app/layout.tsx @@ -47,6 +47,7 @@ const LocaleLayout = ({ data-public-maintenance-notice={process.env.NEXT_PUBLIC_MAINTENANCE_NOTICE} data-public-site-about={process.env.NEXT_PUBLIC_SITE_ABOUT} data-public-text-generation-timeout-ms={process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS} + data-public-max-tools-num={process.env.NEXT_PUBLIC_MAX_TOOLS_NUM} 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} diff --git a/web/config/index.ts b/web/config/index.ts index 94eb0db948..3426222796 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -162,7 +162,14 @@ export const ANNOTATION_DEFAULT = { score_threshold: 0.9, } -export const MAX_TOOLS_NUM = 10 +export let maxToolsNum = 10 + +if (process.env.NEXT_PUBLIC_MAX_TOOLS_NUM && process.env.NEXT_PUBLIC_MAX_TOOLS_NUM !== '') + maxToolsNum = Number.parseInt(process.env.NEXT_PUBLIC_MAX_TOOLS_NUM) +else if (globalThis.document?.body?.getAttribute('data-public-max-tools-num') && globalThis.document.body.getAttribute('data-public-max-tools-num') !== '') + maxToolsNum = Number.parseInt(globalThis.document.body.getAttribute('data-public-max-tools-num') as string) + +export const MAX_TOOLS_NUM = maxToolsNum export const DEFAULT_AGENT_SETTING = { enabled: false,