Commit 23a584fa authored by Joel's avatar Joel

fix: switch set max token tip

parent 8083df00
......@@ -13,6 +13,7 @@ import { AppType, ProviderType } from '@/types/app'
import { TONE_LIST } from '@/config'
import Toast from '@/app/components/base/toast'
import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
import { formatNumber } from '@/utils/format'
export type IConifgModelProps = {
mode: string
......@@ -72,6 +73,7 @@ const ConifgModel: FC<IConifgModelProps> = ({
const [isShowConfig, { setFalse: hideConfig, toggle: toogleShowConfig }] = useBoolean(false)
const [maxTokenSettingTipVisible, setMaxTokenSettingTipVisible] = useState(false)
const configContentRef = React.useRef(null)
const currModel = options.find(item => item.id === modelId)
useClickAway(() => {
hideConfig()
}, configContentRef)
......@@ -134,14 +136,15 @@ const ConifgModel: FC<IConifgModelProps> = ({
onShowUseGPT4Confirm()
return
}
if (id !== 'gpt-4' && completionParams.max_tokens > 4000) {
const nextSelectModelMaxToken = getMaxToken(id)
if (completionParams.max_tokens > nextSelectModelMaxToken) {
Toast.notify({
type: 'warning',
message: t('common.model.params.setToCurrentModelMaxTokenTip'),
message: t('common.model.params.setToCurrentModelMaxTokenTip', { maxToken: formatNumber(nextSelectModelMaxToken) }),
})
onCompletionParamsChange({
...completionParams,
max_tokens: 4000,
max_tokens: nextSelectModelMaxToken,
})
}
setModelId(id, provider)
......
......@@ -54,7 +54,7 @@ const translation = {
maxTokenTip:
'Max tokens depending on the model. Prompt and completion share this limit. One token is roughly 1 English character.',
maxTokenSettingTip: 'Your max token setting is high, potentially limiting space for prompts, queries, and data. Consider setting it below 2/3.',
setToCurrentModelMaxTokenTip: 'Max token is updated to the maximum token of the current model 4,000.',
setToCurrentModelMaxTokenTip: 'Max token is updated to the maximum token of the current model {{maxToken}}.',
},
tone: {
Creative: 'Creative',
......
......@@ -54,7 +54,7 @@ const translation = {
maxTokenTip:
'生成的最大令牌数取决于模型。提示和完成共享令牌数限制。一个令牌约等于 1 个英文或 半个中文字符。',
maxTokenSettingTip: '您设置的最大 tokens 数较大,可能会导致 prompt、用户问题、数据集内容没有 token 空间进行处理,建议设置到 2/3 以下。',
setToCurrentModelMaxTokenTip: '最大令牌数更新为当前模型最大的令牌数 4,000。',
setToCurrentModelMaxTokenTip: '最大令牌数更新为当前模型最大的令牌数 {{maxToken}}。',
},
tone: {
Creative: '创意',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment