feat(web): agent model config add thinking_budget_tokens
This commit is contained in:
@@ -1534,6 +1534,8 @@ export const en = {
|
|||||||
uploadCover: 'Import and Overwrite',
|
uploadCover: 'Import and Overwrite',
|
||||||
refresh: 'Refresh Current Page',
|
refresh: 'Refresh Current Page',
|
||||||
json_output: 'Support JSON formatted output',
|
json_output: 'Support JSON formatted output',
|
||||||
|
thinking_budget_tokens: 'thinking budget tokens',
|
||||||
|
thinking_budget_tokens_max_error: "Cannot exceed the max tokens limit ({{max}})",
|
||||||
},
|
},
|
||||||
userMemory: {
|
userMemory: {
|
||||||
userMemory: 'User Memory',
|
userMemory: 'User Memory',
|
||||||
|
|||||||
@@ -864,6 +864,8 @@ export const zh = {
|
|||||||
uploadCover: '导入并覆盖',
|
uploadCover: '导入并覆盖',
|
||||||
refresh: '刷新当前页',
|
refresh: '刷新当前页',
|
||||||
json_output: '支持JSON格式化输出',
|
json_output: '支持JSON格式化输出',
|
||||||
|
thinking_budget_tokens: '深度思考预算Token数',
|
||||||
|
thinking_budget_tokens_max_error: "不能超过 最大令牌数 ({{max}})",
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
totalRecords: '共 {{total}} 条记录'
|
totalRecords: '共 {{total}} 条记录'
|
||||||
|
|||||||
@@ -218,17 +218,22 @@ const Chat: FC<ChatProps> = ({
|
|||||||
const modelChatList = [...prev]
|
const modelChatList = [...prev]
|
||||||
const curModelChat = modelChatList[targetIndex]
|
const curModelChat = modelChatList[targetIndex]
|
||||||
const curChatMsgList = curModelChat.list || []
|
const curChatMsgList = curModelChat.list || []
|
||||||
const lastMsg = curChatMsgList[curChatMsgList.length - 2]
|
const lastUserMsg = curChatMsgList[curChatMsgList.length - 2]
|
||||||
modelChatList[targetIndex] = {
|
const lastAssistantMsg = curChatMsgList[curChatMsgList.length - 1]
|
||||||
...modelChatList[targetIndex],
|
|
||||||
list: [
|
if (!lastAssistantMsg.meta_data?.reasoning_content || lastAssistantMsg.meta_data?.reasoning_content.length === 0) {
|
||||||
...curChatMsgList.slice(0, curChatMsgList.length - 2),
|
modelChatList[targetIndex] = {
|
||||||
{
|
...modelChatList[targetIndex],
|
||||||
...lastMsg,
|
list: [
|
||||||
...(lastMsg.role === 'user' ? { status: 'error' } : { content: null })
|
...curChatMsgList.slice(0, curChatMsgList.length - 2),
|
||||||
}
|
{
|
||||||
]
|
...lastUserMsg,
|
||||||
|
...(lastUserMsg.role === 'user' ? { status: 'error' } : { content: null })
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...modelChatList]
|
return [...modelChatList]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ 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,
|
||||||
json_output: false
|
thinking_budget_tokens: undefined,
|
||||||
|
json_output: false,
|
||||||
}
|
}
|
||||||
if (source === 'chat') {
|
if (source === 'chat') {
|
||||||
newValues.label = (option as Model).name
|
newValues.label = (option as Model).name
|
||||||
@@ -124,8 +125,8 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { deep_thinking: _, json_output: __, ...rest } = data?.model_parameters || {}
|
const { deep_thinking: _, json_output: __, ...rest } = data?.model_parameters || {}
|
||||||
form.setFieldsValue(rest)
|
form.setFieldsValue({ ...rest })
|
||||||
}, [values?.default_model_config_id])
|
}, [data?.default_model_config_id])
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
if (!id) return
|
if (!id) return
|
||||||
@@ -167,11 +168,36 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
{['model', 'chat'].includes(source) && <>
|
{['model', 'chat'].includes(source) && <>
|
||||||
<FormItem name="capability" hidden />
|
<FormItem name="capability" hidden />
|
||||||
</>}
|
</>}
|
||||||
|
<FormItem name="json_output" valuePropName="checked" hidden={!(values?.capability?.includes('json_output'))}>
|
||||||
|
<Checkbox>{t('application.json_output')}</Checkbox>
|
||||||
|
</FormItem>
|
||||||
<FormItem name="deep_thinking" valuePropName="checked" hidden={!['model', 'chat'].includes(source) || !(values?.deep_thinking || values?.capability?.includes('thinking'))}>
|
<FormItem name="deep_thinking" valuePropName="checked" hidden={!['model', 'chat'].includes(source) || !(values?.deep_thinking || values?.capability?.includes('thinking'))}>
|
||||||
<Checkbox>{t('application.deep_thinking')}</Checkbox>
|
<Checkbox>{t('application.deep_thinking')}</Checkbox>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem name="json_output" valuePropName="checked" hidden={!(values?.capability?.includes('json_output'))}>
|
<FormItem
|
||||||
<Checkbox>{t('application.json_output')}</Checkbox>
|
name="thinking_budget_tokens"
|
||||||
|
label={t('application.thinking_budget_tokens')}
|
||||||
|
hidden={!['model', 'chat'].includes(source) || !(values?.deep_thinking || values?.capability?.includes('thinking'))}
|
||||||
|
rules={[
|
||||||
|
{ required: values?.deep_thinking, message: t('common.pleaseEnter') },
|
||||||
|
{
|
||||||
|
validator: (_, value) => {
|
||||||
|
const maxTokens = values?.max_tokens
|
||||||
|
if (value !== undefined && maxTokens !== undefined && value > maxTokens) {
|
||||||
|
return Promise.reject(t('application.thinking_budget_tokens_max_error', { max: maxTokens }))
|
||||||
|
}
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<RbSlider
|
||||||
|
step={0}
|
||||||
|
min={0}
|
||||||
|
max={32000}
|
||||||
|
isInput={true}
|
||||||
|
disabled={!values?.deep_thinking}
|
||||||
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
{source === 'chat' && <FormItem name="label" hidden />}
|
{source === 'chat' && <FormItem name="label" hidden />}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export interface ModelConfig {
|
|||||||
/** Stop sequences */
|
/** Stop sequences */
|
||||||
stop?: string;
|
stop?: string;
|
||||||
deep_thinking?: boolean;
|
deep_thinking?: boolean;
|
||||||
|
thinking_budget_tokens?: number;
|
||||||
json_output?: boolean;
|
json_output?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user