mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix(ChatInput): add missing MaxTokens setting to params popover (#11412)
The MaxTokens setting was missing from the ChatInput ActionBar params popover after UI refactoring. This adds: - Enable MaxTokens toggle switch - MaxTokens slider (0-32000) that appears when enabled Fixes #11375 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Form, type FormItemProps, Tag } from '@lobehub/ui';
|
||||
import { Form, type FormItemProps, SliderWithInput, Tag } from '@lobehub/ui';
|
||||
import { Checkbox, Flexbox } from '@lobehub/ui';
|
||||
import { Form as AntdForm } from 'antd';
|
||||
import { Form as AntdForm, Switch } from 'antd';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { debounce } from 'es-toolkit/compat';
|
||||
import isEqual from 'fast-deep-equal';
|
||||
@@ -151,6 +151,7 @@ const Controls = memo<ControlsProps>(({ setUpdating }) => {
|
||||
const config = useAgentStore((s) => agentByIdSelectors.getAgentConfigById(agentId)(s), isEqual);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const enableMaxTokens = AntdForm.useWatch(['chatConfig', 'enableMaxTokens'], form);
|
||||
const { frequency_penalty, presence_penalty, temperature, top_p } = config.params ?? {};
|
||||
|
||||
const lastValuesRef = useRef<Record<ParamKey, number | undefined>>({
|
||||
@@ -289,6 +290,40 @@ const Controls = memo<ControlsProps>(({ setUpdating }) => {
|
||||
} satisfies FormItemProps;
|
||||
});
|
||||
|
||||
// MaxTokens items
|
||||
const maxTokensItems: FormItemProps[] = [
|
||||
{
|
||||
children: <Switch />,
|
||||
label: (
|
||||
<Flexbox align={'center'} className={styles.label} gap={8} horizontal>
|
||||
{t('settingModel.enableMaxTokens.title')}
|
||||
</Flexbox>
|
||||
),
|
||||
name: ['chatConfig', 'enableMaxTokens'],
|
||||
tag: 'max_tokens',
|
||||
valuePropName: 'checked',
|
||||
},
|
||||
...(enableMaxTokens
|
||||
? [
|
||||
{
|
||||
children: (
|
||||
<SliderWithInput max={32_000} min={0} step={100} unlimitedInput />
|
||||
),
|
||||
label: (
|
||||
<Flexbox align={'center'} className={styles.label} gap={8} horizontal>
|
||||
{t('settingModel.maxTokens.title')}
|
||||
<InfoTooltip title={t('settingModel.maxTokens.desc')} />
|
||||
</Flexbox>
|
||||
),
|
||||
name: ['params', 'max_tokens'],
|
||||
tag: 'max_tokens',
|
||||
} satisfies FormItemProps,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
|
||||
const allItems = [...baseItems, ...maxTokensItems];
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={form}
|
||||
@@ -296,11 +331,11 @@ const Controls = memo<ControlsProps>(({ setUpdating }) => {
|
||||
itemMinWidth={220}
|
||||
items={
|
||||
mobile
|
||||
? baseItems
|
||||
: baseItems.map(({ tag, ...item }) => ({
|
||||
...item,
|
||||
desc: <Tag size={'small'}>{tag}</Tag>,
|
||||
}))
|
||||
? allItems
|
||||
: allItems.map(({ tag, ...item }) => ({
|
||||
...item,
|
||||
desc: <Tag size={'small'}>{tag}</Tag>,
|
||||
}))
|
||||
}
|
||||
itemsType={'flat'}
|
||||
onValuesChange={handleValuesChange}
|
||||
|
||||
Reference in New Issue
Block a user