Merge pull request #1022 from SuanmoSuanyangTechnology/fix/v0.3.2_zy
fix(web): thinking_budget_tokens add min & default value
This commit is contained in:
@@ -1538,6 +1538,7 @@ export const en = {
|
|||||||
json_output: 'Support JSON formatted output',
|
json_output: 'Support JSON formatted output',
|
||||||
thinking_budget_tokens: 'thinking budget tokens',
|
thinking_budget_tokens: 'thinking budget tokens',
|
||||||
thinking_budget_tokens_max_error: "Cannot exceed the max tokens limit ({{max}})",
|
thinking_budget_tokens_max_error: "Cannot exceed the max tokens limit ({{max}})",
|
||||||
|
thinking_budget_tokens_min_error: "Cannot be less than {{min}}",
|
||||||
logSearchPlaceholder: 'Search log content',
|
logSearchPlaceholder: 'Search log content',
|
||||||
},
|
},
|
||||||
userMemory: {
|
userMemory: {
|
||||||
|
|||||||
@@ -868,6 +868,7 @@ export const zh = {
|
|||||||
json_output: '支持JSON格式化输出',
|
json_output: '支持JSON格式化输出',
|
||||||
thinking_budget_tokens: '深度思考预算Token数',
|
thinking_budget_tokens: '深度思考预算Token数',
|
||||||
thinking_budget_tokens_max_error: "不能超过 最大令牌数 ({{max}})",
|
thinking_budget_tokens_max_error: "不能超过 最大令牌数 ({{max}})",
|
||||||
|
thinking_budget_tokens_min_error: "不能小于 {{min}}",
|
||||||
logSearchPlaceholder: '搜索日志内容',
|
logSearchPlaceholder: '搜索日志内容',
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ const configFields = [
|
|||||||
{ key: 'n', max: 10, min: 1, step: 1, defaultValue: 1 },
|
{ key: 'n', max: 10, min: 1, step: 1, defaultValue: 1 },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const minThinkingBudgetTokens = 128;
|
||||||
|
const defaultThinkingBudgetTokens = 1000;
|
||||||
const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(({
|
const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(({
|
||||||
refresh,
|
refresh,
|
||||||
data,
|
data,
|
||||||
@@ -108,7 +110,7 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
const newValues: ModelConfig = {
|
const newValues: ModelConfig = {
|
||||||
capability: (option as Model).capability,
|
capability: (option as Model).capability,
|
||||||
deep_thinking: false,
|
deep_thinking: false,
|
||||||
thinking_budget_tokens: undefined,
|
thinking_budget_tokens: defaultThinkingBudgetTokens,
|
||||||
json_output: false,
|
json_output: false,
|
||||||
}
|
}
|
||||||
if (source === 'chat') {
|
if (source === 'chat') {
|
||||||
@@ -128,6 +130,12 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
form.setFieldsValue({ ...rest })
|
form.setFieldsValue({ ...rest })
|
||||||
}, [data?.default_model_config_id])
|
}, [data?.default_model_config_id])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (values?.deep_thinking && !values?.thinking_budget_tokens) {
|
||||||
|
form.setFieldValue('thinking_budget_tokens', defaultThinkingBudgetTokens)
|
||||||
|
}
|
||||||
|
}, [values?.deep_thinking])
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
if (!id) return
|
if (!id) return
|
||||||
resetAppModelConfig(id).then((res) => {
|
resetAppModelConfig(id).then((res) => {
|
||||||
@@ -178,15 +186,20 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
name="thinking_budget_tokens"
|
name="thinking_budget_tokens"
|
||||||
label={t('application.thinking_budget_tokens')}
|
label={t('application.thinking_budget_tokens')}
|
||||||
hidden={!['model', 'chat'].includes(source) || !(values?.deep_thinking || values?.capability?.includes('thinking'))}
|
hidden={!['model', 'chat'].includes(source) || !(values?.deep_thinking || values?.capability?.includes('thinking'))}
|
||||||
extra={<>{t('application.range')}: [{0}, {t(`application.max_tokens`)}: {values?.max_tokens}]</>}
|
extra={<>{t('application.range')}: [{minThinkingBudgetTokens}, {t(`application.max_tokens`)}: {values?.max_tokens}]</>}
|
||||||
rules={[
|
rules={[
|
||||||
{ required: values?.deep_thinking, message: t('common.pleaseEnter') },
|
{ required: values?.deep_thinking, message: t('common.pleaseEnter') },
|
||||||
{
|
{
|
||||||
validator: (_, value) => {
|
validator: (_, value) => {
|
||||||
const maxTokens = values?.max_tokens
|
const maxTokens = values?.max_tokens
|
||||||
const deep_thinking = values?.deep_thinking;
|
const deep_thinking = values?.deep_thinking;
|
||||||
if (deep_thinking && value !== undefined && maxTokens !== undefined && value > maxTokens) {
|
if (deep_thinking && value !== undefined) {
|
||||||
return Promise.reject(t('application.thinking_budget_tokens_max_error', { max: maxTokens }))
|
if (value < minThinkingBudgetTokens) {
|
||||||
|
return Promise.reject(t('application.thinking_budget_tokens_min_error', { min: minThinkingBudgetTokens }))
|
||||||
|
}
|
||||||
|
if (maxTokens !== undefined && value > maxTokens) {
|
||||||
|
return Promise.reject(t('application.thinking_budget_tokens_max_error', { max: maxTokens }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
@@ -195,7 +208,7 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
>
|
>
|
||||||
<RbSlider
|
<RbSlider
|
||||||
step={1}
|
step={1}
|
||||||
min={0}
|
min={minThinkingBudgetTokens}
|
||||||
max={32000}
|
max={32000}
|
||||||
isInput={true}
|
isInput={true}
|
||||||
disabled={!values?.deep_thinking}
|
disabled={!values?.deep_thinking}
|
||||||
|
|||||||
Reference in New Issue
Block a user