mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 12:39:14 +08:00
feat: allow users to specify timeout for text generations and workflows by environment variable (#8395)
This commit is contained in:
parent
032dd93b2f
commit
52857dc0a6
@ -568,6 +568,13 @@ SSRF_PROXY_HTTP_URL=http://ssrf_proxy:3128
|
|||||||
# SSRF Proxy server HTTPS URL
|
# SSRF Proxy server HTTPS URL
|
||||||
SSRF_PROXY_HTTPS_URL=http://ssrf_proxy:3128
|
SSRF_PROXY_HTTPS_URL=http://ssrf_proxy:3128
|
||||||
|
|
||||||
|
# ------------------------------
|
||||||
|
# Environment Variables for web Service
|
||||||
|
# ------------------------------
|
||||||
|
|
||||||
|
# The timeout for the text generation in millisecond
|
||||||
|
TEXT_GENERATION_TIMEOUT_MS=60000
|
||||||
|
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
# Environment Variables for db Service
|
# Environment Variables for db Service
|
||||||
# ------------------------------
|
# ------------------------------
|
||||||
|
@ -254,6 +254,7 @@ services:
|
|||||||
APP_API_URL: ${APP_API_URL:-}
|
APP_API_URL: ${APP_API_URL:-}
|
||||||
SENTRY_DSN: ${WEB_SENTRY_DSN:-}
|
SENTRY_DSN: ${WEB_SENTRY_DSN:-}
|
||||||
NEXT_TELEMETRY_DISABLED: ${NEXT_TELEMETRY_DISABLED:-0}
|
NEXT_TELEMETRY_DISABLED: ${NEXT_TELEMETRY_DISABLED:-0}
|
||||||
|
TEXT_GENERATION_TIMEOUT_MS: ${TEXT_GENERATION_TIMEOUT_MS:-60000}
|
||||||
|
|
||||||
# The postgres database.
|
# The postgres database.
|
||||||
db:
|
db:
|
||||||
|
@ -19,3 +19,6 @@ NEXT_TELEMETRY_DISABLED=1
|
|||||||
|
|
||||||
# Disable Upload Image as WebApp icon default is false
|
# Disable Upload Image as WebApp icon default is false
|
||||||
NEXT_PUBLIC_UPLOAD_IMAGE_AS_ICON=false
|
NEXT_PUBLIC_UPLOAD_IMAGE_AS_ICON=false
|
||||||
|
|
||||||
|
# The timeout for the text generation in millisecond
|
||||||
|
NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS=60000
|
||||||
|
@ -269,8 +269,10 @@ const Result: FC<IResultProps> = ({
|
|||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
onWorkflowFinished: ({ data }) => {
|
onWorkflowFinished: ({ data }) => {
|
||||||
if (isTimeout)
|
if (isTimeout) {
|
||||||
|
notify({ type: 'warning', message: t('appDebug.warningMessage.timeoutExceeded') })
|
||||||
return
|
return
|
||||||
|
}
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
notify({ type: 'error', message: data.error })
|
notify({ type: 'error', message: data.error })
|
||||||
setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => {
|
setWorkflowProcessData(produce(getWorkflowProcessData()!, (draft) => {
|
||||||
@ -326,8 +328,10 @@ const Result: FC<IResultProps> = ({
|
|||||||
setCompletionRes(res.join(''))
|
setCompletionRes(res.join(''))
|
||||||
},
|
},
|
||||||
onCompleted: () => {
|
onCompleted: () => {
|
||||||
if (isTimeout)
|
if (isTimeout) {
|
||||||
|
notify({ type: 'warning', message: t('appDebug.warningMessage.timeoutExceeded') })
|
||||||
return
|
return
|
||||||
|
}
|
||||||
setRespondingFalse()
|
setRespondingFalse()
|
||||||
setMessageId(tempMessageId)
|
setMessageId(tempMessageId)
|
||||||
onCompleted(getCompletionRes(), taskId, true)
|
onCompleted(getCompletionRes(), taskId, true)
|
||||||
@ -338,8 +342,10 @@ const Result: FC<IResultProps> = ({
|
|||||||
setCompletionRes(res.join(''))
|
setCompletionRes(res.join(''))
|
||||||
},
|
},
|
||||||
onError() {
|
onError() {
|
||||||
if (isTimeout)
|
if (isTimeout) {
|
||||||
|
notify({ type: 'warning', message: t('appDebug.warningMessage.timeoutExceeded') })
|
||||||
return
|
return
|
||||||
|
}
|
||||||
setRespondingFalse()
|
setRespondingFalse()
|
||||||
onCompleted(getCompletionRes(), taskId, false)
|
onCompleted(getCompletionRes(), taskId, false)
|
||||||
isEnd = true
|
isEnd = true
|
||||||
|
@ -43,6 +43,7 @@ const LocaleLayout = ({
|
|||||||
data-public-sentry-dsn={process.env.NEXT_PUBLIC_SENTRY_DSN}
|
data-public-sentry-dsn={process.env.NEXT_PUBLIC_SENTRY_DSN}
|
||||||
data-public-maintenance-notice={process.env.NEXT_PUBLIC_MAINTENANCE_NOTICE}
|
data-public-maintenance-notice={process.env.NEXT_PUBLIC_MAINTENANCE_NOTICE}
|
||||||
data-public-site-about={process.env.NEXT_PUBLIC_SITE_ABOUT}
|
data-public-site-about={process.env.NEXT_PUBLIC_SITE_ABOUT}
|
||||||
|
data-public-text-generation-timeout-ms={process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS}
|
||||||
>
|
>
|
||||||
<Topbar />
|
<Topbar />
|
||||||
<BrowserInitor>
|
<BrowserInitor>
|
||||||
|
@ -246,6 +246,13 @@ Thought: {{agent_scratchpad}}
|
|||||||
|
|
||||||
export const VAR_REGEX = /\{\{(#[a-zA-Z0-9_-]{1,50}(\.[a-zA-Z_][a-zA-Z0-9_]{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 TEXT_GENERATION_TIMEOUT_MS = 60000
|
export let textGenerationTimeoutMs = 60000
|
||||||
|
|
||||||
|
if (process.env.NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS && 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 = 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 DISABLE_UPLOAD_IMAGE_AS_ICON = process.env.NEXT_PUBLIC_DISABLE_UPLOAD_IMAGE_AS_ICON === 'true'
|
||||||
|
@ -21,4 +21,6 @@ export NEXT_PUBLIC_SENTRY_DSN=${SENTRY_DSN}
|
|||||||
export NEXT_PUBLIC_SITE_ABOUT=${SITE_ABOUT}
|
export NEXT_PUBLIC_SITE_ABOUT=${SITE_ABOUT}
|
||||||
export NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED}
|
export NEXT_TELEMETRY_DISABLED=${NEXT_TELEMETRY_DISABLED}
|
||||||
|
|
||||||
|
export NEXT_PUBLIC_TEXT_GENERATION_TIMEOUT_MS=${TEXT_GENERATION_TIMEOUT_MS}
|
||||||
|
|
||||||
pm2 start ./pm2.json --no-daemon
|
pm2 start ./pm2.json --no-daemon
|
||||||
|
@ -268,6 +268,9 @@ const translation = {
|
|||||||
notSelectModel: 'Please choose a model',
|
notSelectModel: 'Please choose a model',
|
||||||
waitForImgUpload: 'Please wait for the image to upload',
|
waitForImgUpload: 'Please wait for the image to upload',
|
||||||
},
|
},
|
||||||
|
warningMessage: {
|
||||||
|
timeoutExceeded: 'Results are not displayed due to timeout. Please refer to the logs to gather complete results.',
|
||||||
|
},
|
||||||
chatSubTitle: 'Instructions',
|
chatSubTitle: 'Instructions',
|
||||||
completionSubTitle: 'Prefix Prompt',
|
completionSubTitle: 'Prefix Prompt',
|
||||||
promptTip:
|
promptTip:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user