diff --git a/web/.env.example b/web/.env.example index 78b4f33e8..c30064ffe 100644 --- a/web/.env.example +++ b/web/.env.example @@ -56,3 +56,5 @@ NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER=true NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL=true NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL=true +# The maximum number of tree node depth for workflow +NEXT_PUBLIC_MAX_TREE_DEPTH=50 diff --git a/web/app/components/plugins/install-plugin/base/use-get-icon.ts b/web/app/components/plugins/install-plugin/base/use-get-icon.ts index bb46f27f5..23d41aff0 100644 --- a/web/app/components/plugins/install-plugin/base/use-get-icon.ts +++ b/web/app/components/plugins/install-plugin/base/use-get-icon.ts @@ -1,11 +1,11 @@ import { useCallback } from 'react' -import { apiPrefix } from '@/config' +import { API_PREFIX } from '@/config' import { useSelector } from '@/context/app-context' const useGetIcon = () => { const currentWorkspace = useSelector(s => s.currentWorkspace) const getIconUrl = useCallback((fileName: string) => { - return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${currentWorkspace.id}&filename=${fileName}` + return `${API_PREFIX}/workspaces/current/plugin/icon?tenant_id=${currentWorkspace.id}&filename=${fileName}` }, [currentWorkspace.id]) return { diff --git a/web/app/components/plugins/plugin-page/index.tsx b/web/app/components/plugins/plugin-page/index.tsx index 1531e1789..bf2d327d3 100644 --- a/web/app/components/plugins/plugin-page/index.tsx +++ b/web/app/components/plugins/plugin-page/index.tsx @@ -35,7 +35,7 @@ import type { PluginDeclaration, PluginManifestInMarket } from '../types' import { sleep } from '@/utils' import { getDocsUrl } from '@/app/components/plugins/utils' import { fetchBundleInfoFromMarketPlace, fetchManifestFromMarketPlace } from '@/service/plugins' -import { marketplaceApiPrefix } from '@/config' +import { MARKETPLACE_API_PREFIX } from '@/config' import { SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS } from '@/config' import I18n from '@/context/i18n' import { noop } from 'lodash-es' @@ -106,7 +106,7 @@ const PluginPage = ({ setManifest({ ...plugin, version: version.version, - icon: `${marketplaceApiPrefix}/plugins/${plugin.org}/${plugin.name}/icon`, + icon: `${MARKETPLACE_API_PREFIX}/plugins/${plugin.org}/${plugin.name}/icon`, }) showInstallFromMarketplace() return diff --git a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx index 27cd2ae3e..019b32ae2 100644 --- a/web/app/components/workflow/block-selector/market-place-plugin/list.tsx +++ b/web/app/components/workflow/block-selector/market-place-plugin/list.tsx @@ -6,7 +6,7 @@ import Item from './item' import type { Plugin } from '@/app/components/plugins/types.ts' import cn from '@/utils/classnames' import Link from 'next/link' -import { marketplaceUrlPrefix } from '@/config' +import { MARKETPLACE_URL_PREFIX } from '@/config' import { RiArrowRightUpLine, RiSearchLine } from '@remixicon/react' import { noop } from 'lodash-es' @@ -32,7 +32,7 @@ const List = forwardRef(({ const { t } = useTranslation() const hasFilter = !searchText const hasRes = list.length > 0 - const urlWithSearchText = `${marketplaceUrlPrefix}/?q=${searchText}&tags=${tags.join(',')}` + const urlWithSearchText = `${MARKETPLACE_URL_PREFIX}/?q=${searchText}&tags=${tags.join(',')}` const nextToStickyELemRef = useRef(null) const { handleScroll, scrollPosition } = useStickyScroll({ @@ -71,7 +71,7 @@ const List = forwardRef(({ return ( {t('plugin.findMoreInMarketplace')} diff --git a/web/app/components/workflow/constants.ts b/web/app/components/workflow/constants.ts index cdfd963cf..b7432f120 100644 --- a/web/app/components/workflow/constants.ts +++ b/web/app/components/workflow/constants.ts @@ -408,7 +408,6 @@ export const NODE_WIDTH = 240 export const X_OFFSET = 60 export const NODE_WIDTH_X_OFFSET = NODE_WIDTH + X_OFFSET export const Y_OFFSET = 39 -export const MAX_TREE_DEPTH = 50 export const START_INITIAL_POSITION = { x: 80, y: 282 } export const AUTO_LAYOUT_OFFSET = { x: -42, diff --git a/web/app/components/workflow/hooks/use-checklist.ts b/web/app/components/workflow/hooks/use-checklist.ts index c1b0189b8..200bee1d2 100644 --- a/web/app/components/workflow/hooks/use-checklist.ts +++ b/web/app/components/workflow/hooks/use-checklist.ts @@ -18,7 +18,6 @@ import { } from '../utils' import { CUSTOM_NODE, - MAX_TREE_DEPTH, } from '../constants' import type { ToolNodeType } from '../nodes/tool/types' import { useIsChatMode } from './use-workflow' @@ -33,6 +32,7 @@ import { useDatasetsDetailStore } from '../datasets-detail-store/store' import type { KnowledgeRetrievalNodeType } from '../nodes/knowledge-retrieval/types' import type { DataSet } from '@/models/datasets' import { fetchDatasets } from '@/service/datasets' +import { MAX_TREE_DEPTH } from '@/config' export const useChecklist = (nodes: Node[], edges: Edge[]) => { const { t } = useTranslation() diff --git a/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx b/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx index ceb38fbcf..cddd529ae 100644 --- a/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx +++ b/web/app/components/workflow/nodes/_base/components/switch-plugin-version.tsx @@ -15,7 +15,7 @@ import { pluginManifestToCardPluginProps } from '@/app/components/plugins/instal import { Badge as Badge2, BadgeState } from '@/app/components/base/badge/index' import Link from 'next/link' import { useTranslation } from 'react-i18next' -import { marketplaceUrlPrefix } from '@/config' +import { MARKETPLACE_URL_PREFIX } from '@/config' export type SwitchPluginVersionProps = { uniqueIdentifier: string @@ -82,7 +82,7 @@ export const SwitchPluginVersion: FC = (props) => { modalBottomLeft={ diff --git a/web/app/layout.tsx b/web/app/layout.tsx index e39b4f3a1..f3b2ca7f7 100644 --- a/web/app/layout.tsx +++ b/web/app/layout.tsx @@ -9,6 +9,7 @@ import { ThemeProvider } from 'next-themes' import './styles/globals.css' import './styles/markdown.scss' import GlobalPublicStoreProvider from '@/context/global-public-context' +import { DatasetAttr } from '@/types/feature' export const viewport: Viewport = { width: 'device-width', @@ -25,6 +26,29 @@ const LocaleLayout = async ({ }) => { const locale = await getLocaleOnServer() + const datasetMap: Record = { + [DatasetAttr.DATA_API_PREFIX]: process.env.NEXT_PUBLIC_API_PREFIX, + [DatasetAttr.DATA_PUBLIC_API_PREFIX]: process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX, + [DatasetAttr.DATA_MARKETPLACE_API_PREFIX]: process.env.NEXT_PUBLIC_MARKETPLACE_API_PREFIX, + [DatasetAttr.DATA_MARKETPLACE_URL_PREFIX]: process.env.NEXT_PUBLIC_MARKETPLACE_URL_PREFIX, + [DatasetAttr.DATA_PUBLIC_EDITION]: process.env.NEXT_PUBLIC_EDITION, + [DatasetAttr.DATA_PUBLIC_SUPPORT_MAIL_LOGIN]: process.env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN, + [DatasetAttr.DATA_PUBLIC_SENTRY_DSN]: process.env.NEXT_PUBLIC_SENTRY_DSN, + [DatasetAttr.DATA_PUBLIC_MAINTENANCE_NOTICE]: process.env.NEXT_PUBLIC_MAINTENANCE_NOTICE, + [DatasetAttr.DATA_PUBLIC_SITE_ABOUT]: process.env.NEXT_PUBLIC_SITE_ABOUT, + [DatasetAttr.DATA_PUBLIC_TEXT_GENERATION_TIMEOUT_MS]: process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS, + [DatasetAttr.DATA_PUBLIC_MAX_TOOLS_NUM]: process.env.NEXT_PUBLIC_MAX_TOOLS_NUM, + [DatasetAttr.DATA_PUBLIC_MAX_PARALLEL_LIMIT]: process.env.NEXT_PUBLIC_MAX_PARALLEL_LIMIT, + [DatasetAttr.DATA_PUBLIC_TOP_K_MAX_VALUE]: process.env.NEXT_PUBLIC_TOP_K_MAX_VALUE, + [DatasetAttr.DATA_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH]: process.env.NEXT_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH, + [DatasetAttr.DATA_PUBLIC_LOOP_NODE_MAX_COUNT]: process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT, + [DatasetAttr.DATA_PUBLIC_MAX_ITERATIONS_NUM]: process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM, + [DatasetAttr.DATA_PUBLIC_MAX_TREE_DEPTH]: process.env.NEXT_PUBLIC_MAX_TREE_DEPTH, + [DatasetAttr.DATA_PUBLIC_ENABLE_WEBSITE_JINAREADER]: process.env.NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER, + [DatasetAttr.DATA_PUBLIC_ENABLE_WEBSITE_FIRECRAWL]: process.env.NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL, + [DatasetAttr.DATA_PUBLIC_ENABLE_WEBSITE_WATERCRAWL]: process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL, + } + return ( @@ -35,25 +59,7 @@ const LocaleLayout = async ({ diff --git a/web/app/signin/components/social-auth.tsx b/web/app/signin/components/social-auth.tsx index 39d7ceaa4..4ae0b7f1a 100644 --- a/web/app/signin/components/social-auth.tsx +++ b/web/app/signin/components/social-auth.tsx @@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next' import { useSearchParams } from 'next/navigation' import style from '../page.module.css' import Button from '@/app/components/base/button' -import { apiPrefix } from '@/config' +import { API_PREFIX } from '@/config' import classNames from '@/utils/classnames' import { getPurifyHref } from '@/utils' @@ -15,7 +15,7 @@ export default function SocialAuth(props: SocialAuthProps) { const searchParams = useSearchParams() const getOAuthLink = (href: string) => { - const url = getPurifyHref(`${apiPrefix}${href}`) + const url = getPurifyHref(`${API_PREFIX}${href}`) if (searchParams.has('invite_token')) return `${url}?${searchParams.toString()}` diff --git a/web/config/index.ts b/web/config/index.ts index e8aa404be..b2699b2df 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -1,49 +1,44 @@ import { InputVarType } from '@/app/components/workflow/types' import { AgentStrategy } from '@/types/app' import { PromptRole } from '@/models/debug' +import { DatasetAttr } from '@/types/feature' -export let apiPrefix = '' -export let publicApiPrefix = '' -export let marketplaceApiPrefix = '' -export let marketplaceUrlPrefix = '' - -// NEXT_PUBLIC_API_PREFIX=/console/api NEXT_PUBLIC_PUBLIC_API_PREFIX=/api npm run start -if (process.env.NEXT_PUBLIC_API_PREFIX && process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX) { - apiPrefix = process.env.NEXT_PUBLIC_API_PREFIX - publicApiPrefix = process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX -} -else if ( - globalThis.document?.body?.getAttribute('data-api-prefix') - && globalThis.document?.body?.getAttribute('data-pubic-api-prefix') -) { - // Not build can not get env from process.env.NEXT_PUBLIC_ in browser https://nextjs.org/docs/basic-features/environment-variables#exposing-environment-variables-to-the-browser - apiPrefix = globalThis.document.body.getAttribute('data-api-prefix') as string - publicApiPrefix = globalThis.document.body.getAttribute('data-pubic-api-prefix') as string -} -else { - // const domainParts = globalThis.location?.host?.split('.'); - // in production env, the host is dify.app . In other env, the host is [dev].dify.app - // const env = domainParts.length === 2 ? 'ai' : domainParts?.[0]; - apiPrefix = 'http://localhost:5001/console/api' - publicApiPrefix = 'http://localhost:5001/api' // avoid browser private mode api cross origin - marketplaceApiPrefix = 'http://localhost:5002/api' +const getBooleanConfig = (envVar: string | undefined, dataAttrKey: DatasetAttr, defaultValue: boolean = true) => { + if (envVar !== undefined && envVar !== '') + return envVar === 'true' + const attrValue = globalThis.document?.body?.getAttribute(dataAttrKey) + if (attrValue !== undefined && attrValue !== '') + return attrValue === 'true' + return defaultValue } -if (process.env.NEXT_PUBLIC_MARKETPLACE_API_PREFIX && process.env.NEXT_PUBLIC_MARKETPLACE_URL_PREFIX) { - marketplaceApiPrefix = process.env.NEXT_PUBLIC_MARKETPLACE_API_PREFIX - marketplaceUrlPrefix = process.env.NEXT_PUBLIC_MARKETPLACE_URL_PREFIX -} -else { - marketplaceApiPrefix = globalThis.document?.body?.getAttribute('data-marketplace-api-prefix') || '' - marketplaceUrlPrefix = globalThis.document?.body?.getAttribute('data-marketplace-url-prefix') || '' +const getNumberConfig = (envVar: string | undefined, dataAttrKey: DatasetAttr, defaultValue: number) => { + if (envVar) + return Number.parseInt(envVar) + + const attrValue = globalThis.document?.body?.getAttribute(dataAttrKey) + if (attrValue) + return Number.parseInt(attrValue) + return defaultValue } -export const API_PREFIX: string = apiPrefix -export const PUBLIC_API_PREFIX: string = publicApiPrefix -export const MARKETPLACE_API_PREFIX: string = marketplaceApiPrefix -export const MARKETPLACE_URL_PREFIX: string = marketplaceUrlPrefix +const getStringConfig = (envVar: string | undefined, dataAttrKey: DatasetAttr, defaultValue: string) => { + if (envVar) + return envVar + + const attrValue = globalThis.document?.body?.getAttribute(dataAttrKey) + if (attrValue) + return attrValue + return defaultValue +} + +export const API_PREFIX = getStringConfig(process.env.NEXT_PUBLIC_API_PREFIX, DatasetAttr.DATA_API_PREFIX, 'http://localhost:5001/console/api') +export const PUBLIC_API_PREFIX = getStringConfig(process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX, DatasetAttr.DATA_PUBLIC_API_PREFIX, 'http://localhost:5001/api') +export const MARKETPLACE_API_PREFIX = getStringConfig(process.env.NEXT_PUBLIC_MARKETPLACE_API_PREFIX, DatasetAttr.DATA_MARKETPLACE_API_PREFIX, 'http://localhost:5002/api') +export const MARKETPLACE_URL_PREFIX = getStringConfig(process.env.NEXT_PUBLIC_MARKETPLACE_URL_PREFIX, DatasetAttr.DATA_MARKETPLACE_URL_PREFIX, '') + +const EDITION = getStringConfig(process.env.NEXT_PUBLIC_EDITION, DatasetAttr.DATA_PUBLIC_EDITION, 'SELF_HOSTED') -const EDITION = process.env.NEXT_PUBLIC_EDITION || globalThis.document?.body?.getAttribute('data-public-edition') || 'SELF_HOSTED' export const IS_CE_EDITION = EDITION === 'SELF_HOSTED' export const IS_CLOUD_EDITION = EDITION === 'CLOUD' @@ -162,15 +157,6 @@ export const ANNOTATION_DEFAULT = { score_threshold: 0.9, } -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, max_iteration: 10, @@ -269,15 +255,6 @@ export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]\w{0,29}){1,10}#) export const resetReg = () => VAR_REGEX.lastIndex = 0 -export let textGenerationTimeoutMs = 60000 - -if (process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS && process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS !== '') - textGenerationTimeoutMs = Number.parseInt(process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS) -else if (globalThis.document?.body?.getAttribute('data-public-text-generation-timeout-ms') && globalThis.document.body.getAttribute('data-public-text-generation-timeout-ms') !== '') - textGenerationTimeoutMs = Number.parseInt(globalThis.document.body.getAttribute('data-public-text-generation-timeout-ms') as string) - -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 GITHUB_ACCESS_TOKEN = process.env.NEXT_PUBLIC_GITHUB_ACCESS_TOKEN || '' @@ -286,40 +263,13 @@ export const SUPPORT_INSTALL_LOCAL_FILE_EXTENSIONS = '.difypkg,.difybndl' export const FULL_DOC_PREVIEW_LENGTH = 50 export const JSON_SCHEMA_MAX_DEPTH = 10 -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 MAX_TOOLS_NUM = getNumberConfig(process.env.NEXT_PUBLIC_MAX_TOOLS_NUM, DatasetAttr.DATA_PUBLIC_MAX_TOOLS_NUM, 10) +export const TEXT_GENERATION_TIMEOUT_MS = getNumberConfig(process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS, DatasetAttr.DATA_PUBLIC_TEXT_GENERATION_TIMEOUT_MS, 60000) +export const LOOP_NODE_MAX_COUNT = getNumberConfig(process.env.NEXT_PUBLIC_LOOP_NODE_MAX_COUNT, DatasetAttr.DATA_PUBLIC_LOOP_NODE_MAX_COUNT, 100) +export const MAX_ITERATIONS_NUM = getNumberConfig(process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM, DatasetAttr.DATA_PUBLIC_MAX_ITERATIONS_NUM, 99) +export const MAX_TREE_DEPTH = getNumberConfig(process.env.NEXT_PUBLIC_MAX_TREE_DEPTH, DatasetAttr.DATA_PUBLIC_MAX_TREE_DEPTH, 50) -export const LOOP_NODE_MAX_COUNT = loopNodeMaxCount - -let maxIterationsNum = 99 - -if (process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM && process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM !== '') - maxIterationsNum = Number.parseInt(process.env.NEXT_PUBLIC_MAX_ITERATIONS_NUM) -else if (globalThis.document?.body?.getAttribute('data-public-max-iterations-num') && globalThis.document.body.getAttribute('data-public-max-iterations-num') !== '') - maxIterationsNum = Number.parseInt(globalThis.document.body.getAttribute('data-public-max-iterations-num') as string) - -export const MAX_ITERATIONS_NUM = maxIterationsNum - -let enableWebsiteJinaReader = true -let enableWebsiteFireCrawl = true -let enableWebsiteWaterCrawl = false - -const getBooleanConfig = (envVar: string | undefined, attr: string) => { - if (envVar !== undefined && envVar !== '') - return envVar === 'true' - const attrValue = globalThis.document?.body?.getAttribute(attr) - if (attrValue !== undefined && attrValue !== '') - return attrValue === 'true' - return false -} - -enableWebsiteJinaReader = getBooleanConfig(process.env.NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER, 'data-public-enable-website-jinareader') -enableWebsiteFireCrawl = getBooleanConfig(process.env.NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL, 'data-public-enable-website-firecrawl') -enableWebsiteWaterCrawl = getBooleanConfig(process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL, 'data-public-enable-website-watercrawl') -export const ENABLE_WEBSITE_JINAREADER = enableWebsiteJinaReader -export const ENABLE_WEBSITE_FIRECRAWL = enableWebsiteFireCrawl -export const ENABLE_WEBSITE_WATERCRAWL = enableWebsiteWaterCrawl +export const ENABLE_WEBSITE_JINAREADER = getBooleanConfig(process.env.NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER, DatasetAttr.DATA_PUBLIC_ENABLE_WEBSITE_JINAREADER, true) +export const ENABLE_WEBSITE_FIRECRAWL = getBooleanConfig(process.env.NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL, DatasetAttr.DATA_PUBLIC_ENABLE_WEBSITE_FIRECRAWL, true) +export const ENABLE_WEBSITE_WATERCRAWL = getBooleanConfig(process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL, DatasetAttr.DATA_PUBLIC_ENABLE_WEBSITE_WATERCRAWL, false) diff --git a/web/docker/entrypoint.sh b/web/docker/entrypoint.sh index 59e9c472b..c9acbdd42 100755 --- a/web/docker/entrypoint.sh +++ b/web/docker/entrypoint.sh @@ -35,4 +35,5 @@ export NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL=${ENABLE_WEBSITE_WATERCRAWL:-true} export NEXT_PUBLIC_LOOP_NODE_MAX_COUNT=${LOOP_NODE_MAX_COUNT} export NEXT_PUBLIC_MAX_PARALLEL_LIMIT=${MAX_PARALLEL_LIMIT} export NEXT_PUBLIC_MAX_ITERATIONS_NUM=${MAX_ITERATIONS_NUM} +export NEXT_PUBLIC_MAX_TREE_DEPTH=${MAX_TREE_DEPTH} pm2 start /app/web/server.js --name dify-web --cwd /app/web -i ${PM2_INSTANCES} --no-daemon diff --git a/web/service/refresh-token.ts b/web/service/refresh-token.ts index 4f295f3f8..7eff08b52 100644 --- a/web/service/refresh-token.ts +++ b/web/service/refresh-token.ts @@ -1,4 +1,4 @@ -import { apiPrefix } from '@/config' +import { API_PREFIX } from '@/config' import { fetchWithRetry } from '@/utils' const LOCAL_STORAGE_KEY = 'is_other_tab_refreshing' @@ -46,7 +46,7 @@ async function getNewAccessToken(timeout: number): Promise { // it can lead to an infinite loop if the refresh attempt also returns 401. // To avoid this, handle token refresh separately in a dedicated function // that does not call baseFetch and uses a single retry mechanism. - const [error, ret] = await fetchWithRetry(globalThis.fetch(`${apiPrefix}/refresh-token`, { + const [error, ret] = await fetchWithRetry(globalThis.fetch(`${API_PREFIX}/refresh-token`, { method: 'POST', headers: { 'Content-Type': 'application/json;utf-8', diff --git a/web/types/feature.ts b/web/types/feature.ts index e12ea8e6d..b2a80dbea 100644 --- a/web/types/feature.ts +++ b/web/types/feature.ts @@ -97,3 +97,26 @@ export const defaultSystemFeatures: SystemFeatures = { allow_email_password_login: false, }, } + +export enum DatasetAttr { + DATA_API_PREFIX = 'data-api-prefix', + DATA_PUBLIC_API_PREFIX = 'data-public-api-prefix', + DATA_MARKETPLACE_API_PREFIX = 'data-marketplace-api-prefix', + DATA_MARKETPLACE_URL_PREFIX = 'data-marketplace-url-prefix', + DATA_PUBLIC_EDITION = 'data-public-edition', + DATA_PUBLIC_SUPPORT_MAIL_LOGIN = 'data-public-support-mail-login', + DATA_PUBLIC_SENTRY_DSN = 'data-public-sentry-dsn', + DATA_PUBLIC_MAINTENANCE_NOTICE = 'data-public-maintenance-notice', + DATA_PUBLIC_SITE_ABOUT = 'data-public-site-about', + DATA_PUBLIC_TEXT_GENERATION_TIMEOUT_MS = 'data-public-text-generation-timeout-ms', + DATA_PUBLIC_MAX_TOOLS_NUM = 'data-public-max-tools-num', + DATA_PUBLIC_MAX_PARALLEL_LIMIT = 'data-public-max-parallel-limit', + DATA_PUBLIC_TOP_K_MAX_VALUE = 'data-public-top-k-max-value', + DATA_PUBLIC_INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH = 'data-public-indexing-max-segmentation-tokens-length', + DATA_PUBLIC_LOOP_NODE_MAX_COUNT = 'data-public-loop-node-max-count', + DATA_PUBLIC_MAX_ITERATIONS_NUM = 'data-public-max-iterations-num', + DATA_PUBLIC_MAX_TREE_DEPTH = 'data-public-max-tree-depth', + DATA_PUBLIC_ENABLE_WEBSITE_JINAREADER = 'data-public-enable-website-jinareader', + DATA_PUBLIC_ENABLE_WEBSITE_FIRECRAWL = 'data-public-enable-website-firecrawl', + DATA_PUBLIC_ENABLE_WEBSITE_WATERCRAWL = 'data-public-enable-website-watercrawl', +}