| | |
| | | /* eslint-disable import/no-mutable-exports */ |
| | | import { InputVarType } from '@/app/components/workflow/types' |
| | | import { AgentStrategy } from '@/types/app' |
| | | import { PromptRole } from '@/models/debug' |
| | | |
| | | export let apiPrefix = '' |
| | | export let webPrefix = '' |
| | | export let publicApiPrefix = '' |
| | | export let publicWebPrefix = '' |
| | | 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_WEB_PREFIX |
| | | && process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX |
| | | && process.env.NEXT_PUBLIC_PUBLIC_WEB_PREFIX |
| | | ) { |
| | | if (process.env.NEXT_PUBLIC_API_PREFIX && process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX) { |
| | | apiPrefix = process.env.NEXT_PUBLIC_API_PREFIX |
| | | webPrefix = process.env.NEXT_PUBLIC_WEB_PREFIX |
| | | publicApiPrefix = process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX |
| | | publicWebPrefix = process.env.NEXT_PUBLIC_PUBLIC_WEB_PREFIX |
| | | } |
| | | else if ( |
| | | globalThis.document?.body?.getAttribute('data-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 |
| | | webPrefix = (globalThis.document.body.getAttribute('data-web-prefix') as string || globalThis.location.origin) |
| | | publicApiPrefix = globalThis.document.body.getAttribute('data-pubic-api-prefix') as string |
| | | publicWebPrefix = (globalThis.document.body.getAttribute('data-pubic-web-prefix') as string || globalThis.location.origin) |
| | | } |
| | | 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' |
| | | webPrefix = 'http://localhost:3000' |
| | | publicApiPrefix = 'http://localhost:5001/api' // avoid browser private mode api cross origin |
| | | publicWebPrefix = 'http://localhost:3000' |
| | | marketplaceApiPrefix = 'http://localhost:5002/api' |
| | | } |
| | | |
| | | 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') || '' |
| | | } |
| | | |
| | | export const API_PREFIX: string = apiPrefix |
| | | export const WEB_PREFIX: string = webPrefix |
| | | export const PUBLIC_API_PREFIX: string = publicApiPrefix |
| | | export const PUBLIC_WEB_PREFIX: string = publicWebPrefix |
| | | export const MARKETPLACE_API_PREFIX: string = marketplaceApiPrefix |
| | | export const MARKETPLACE_URL_PREFIX: string = marketplaceUrlPrefix |
| | | |
| | | 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' |
| | | |
| | | export const SUPPORT_MAIL_LOGIN = !!(process.env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN || globalThis.document?.body?.getAttribute('data-public-support-mail-login')) |
| | | |
| | |
| | | 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 MAX_TOOLS_NUM = 10 |
| | | |
| | | export const DEFAULT_AGENT_SETTING = { |
| | | enabled: false, |
| | |
| | | `, |
| | | } |
| | | |
| | | export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_]\w{0,29}){1,10}#)\}\}/gi |
| | | export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_][a-zA-Z0-9_]{0,29}){1,10}#)\}\}/gi |
| | | |
| | | 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) |
| | | textGenerationTimeoutMs = 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) |
| | | textGenerationTimeoutMs = 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 || '' |
| | | |
| | | 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 LOOP_NODE_MAX_COUNT = loopNodeMaxCount |
| | | |
| | | let maxIterationsNum = 5 |
| | | |
| | | 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 |
| | | |
| | | export const ENABLE_WEBSITE_JINAREADER = process.env.NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER !== undefined |
| | | ? process.env.NEXT_PUBLIC_ENABLE_WEBSITE_JINAREADER === 'true' |
| | | : globalThis.document?.body?.getAttribute('data-public-enable-website-jinareader') === 'true' || true |
| | | |
| | | export const ENABLE_WEBSITE_FIRECRAWL = process.env.NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL !== undefined |
| | | ? process.env.NEXT_PUBLIC_ENABLE_WEBSITE_FIRECRAWL === 'true' |
| | | : globalThis.document?.body?.getAttribute('data-public-enable-website-firecrawl') === 'true' || true |
| | | |
| | | export const ENABLE_WEBSITE_WATERCRAWL = process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL !== undefined |
| | | ? process.env.NEXT_PUBLIC_ENABLE_WEBSITE_WATERCRAWL === 'true' |
| | | : globalThis.document?.body?.getAttribute('data-public-enable-website-watercrawl') === 'true' || true |