Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: gpt4 max token set to 8k (#67)

Joelce492d13f110
diff --git a/web/app/components/app/configuration/config-model/index.tsx b/web/app/components/app/configuration/config-model/index.tsx
index 999e9896826..a4f7b6a6369 100644
--- a/web/app/components/app/configuration/config-model/index.tsx
+++ b/web/app/components/app/configuration/config-model/index.tsx
@@ -11,6 +11,7 @@ import type { CompletionParams } from '@/models/debug'
import { Cog8ToothIcon, InformationCircleIcon, ChevronDownIcon } from '@heroicons/react/24/outline'
import { AppType } from '@/types/app'
import { TONE_LIST } from '@/config'
+import Toast from '@/app/components/base/toast'
export type IConifgModelProps = {
mode: string
@@ -93,7 +94,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
key: 'max_tokens',
tip: t('common.model.params.maxTokenTip'),
step: 100,
- max: 4000,
+ max: modelId === 'gpt-4' ? 8000 : 4000,
},
]
@@ -114,6 +115,16 @@ const ConifgModel: FC<IConifgModelProps> = ({
onShowUseGPT4Confirm()
return
}
+ if(id !== 'gpt-4' && completionParams.max_tokens > 4000) {
+ Toast.notify({
+ type: 'warning',
+ message: t('common.model.params.setToCurrentModelMaxTokenTip')
+ })
+ onCompletionParamsChange({
+ ...completionParams,
+ max_tokens: 4000
+ })
+ }
setModelId(id)
}
}
diff --git a/web/i18n/lang/common.en.ts b/web/i18n/lang/common.en.ts
index 6771cbc42c2..f0106477c28 100644
--- a/web/i18n/lang/common.en.ts
+++ b/web/i18n/lang/common.en.ts
@@ -50,6 +50,7 @@ const translation = {
maxToken: 'Max token',
maxTokenTip:
'Max tokens generated is 2,048 or 4,000, depending on the model. Prompt and completion share this limit. One token is roughly 1 English character.',
+ setToCurrentModelMaxTokenTip: 'Max token is updated to the maximum token of the current model 4,000.',
},
tone: {
Creative: 'Creative',
diff --git a/web/i18n/lang/common.zh.ts b/web/i18n/lang/common.zh.ts
index a2f03a1bc16..f96bdfa89d1 100644
--- a/web/i18n/lang/common.zh.ts
+++ b/web/i18n/lang/common.zh.ts
@@ -50,6 +50,7 @@ const translation = {
maxToken: '最大 Token',
maxTokenTip:
'生成的最大令牌数为 2,048 或 4,000,取决于模型。提示和完成共享令牌数限制。一个令牌约等于 1 个英文或 4 个中文字符。',
+ setToCurrentModelMaxTokenTip: '最大令牌数更新为当前模型最大的令牌数 4,000。',
},
tone: {
Creative: '创意',