@lobehub/lobehub 2.0.0-next.266 → 2.0.0-next.267

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { Form, type FormItemProps, Tag } from '@lobehub/ui';
1
+ import { Form, type FormItemProps, SliderWithInput, Tag } from '@lobehub/ui';
2
2
  import { Checkbox, Flexbox } from '@lobehub/ui';
3
- import { Form as AntdForm } from 'antd';
3
+ import { Form as AntdForm, Switch } from 'antd';
4
4
  import { createStaticStyles } from 'antd-style';
5
5
  import { debounce } from 'es-toolkit/compat';
6
6
  import isEqual from 'fast-deep-equal';
@@ -151,6 +151,7 @@ const Controls = memo<ControlsProps>(({ setUpdating }) => {
151
151
  const config = useAgentStore((s) => agentByIdSelectors.getAgentConfigById(agentId)(s), isEqual);
152
152
  const [form] = Form.useForm();
153
153
 
154
+ const enableMaxTokens = AntdForm.useWatch(['chatConfig', 'enableMaxTokens'], form);
154
155
  const { frequency_penalty, presence_penalty, temperature, top_p } = config.params ?? {};
155
156
 
156
157
  const lastValuesRef = useRef<Record<ParamKey, number | undefined>>({
@@ -289,6 +290,40 @@ const Controls = memo<ControlsProps>(({ setUpdating }) => {
289
290
  } satisfies FormItemProps;
290
291
  });
291
292
 
293
+ // MaxTokens items
294
+ const maxTokensItems: FormItemProps[] = [
295
+ {
296
+ children: <Switch />,
297
+ label: (
298
+ <Flexbox align={'center'} className={styles.label} gap={8} horizontal>
299
+ {t('settingModel.enableMaxTokens.title')}
300
+ </Flexbox>
301
+ ),
302
+ name: ['chatConfig', 'enableMaxTokens'],
303
+ tag: 'max_tokens',
304
+ valuePropName: 'checked',
305
+ },
306
+ ...(enableMaxTokens
307
+ ? [
308
+ {
309
+ children: (
310
+ <SliderWithInput max={32_000} min={0} step={100} unlimitedInput />
311
+ ),
312
+ label: (
313
+ <Flexbox align={'center'} className={styles.label} gap={8} horizontal>
314
+ {t('settingModel.maxTokens.title')}
315
+ <InfoTooltip title={t('settingModel.maxTokens.desc')} />
316
+ </Flexbox>
317
+ ),
318
+ name: ['params', 'max_tokens'],
319
+ tag: 'max_tokens',
320
+ } satisfies FormItemProps,
321
+ ]
322
+ : []),
323
+ ];
324
+
325
+ const allItems = [...baseItems, ...maxTokensItems];
326
+
292
327
  return (
293
328
  <Form
294
329
  form={form}
@@ -296,11 +331,11 @@ const Controls = memo<ControlsProps>(({ setUpdating }) => {
296
331
  itemMinWidth={220}
297
332
  items={
298
333
  mobile
299
- ? baseItems
300
- : baseItems.map(({ tag, ...item }) => ({
301
- ...item,
302
- desc: <Tag size={'small'}>{tag}</Tag>,
303
- }))
334
+ ? allItems
335
+ : allItems.map(({ tag, ...item }) => ({
336
+ ...item,
337
+ desc: <Tag size={'small'}>{tag}</Tag>,
338
+ }))
304
339
  }
305
340
  itemsType={'flat'}
306
341
  onValuesChange={handleValuesChange}
@@ -40,6 +40,10 @@ export interface SidebarUIAction {
40
40
  * Remove an agent group (group chat)
41
41
  */
42
42
  removeAgentGroup: (groupId: string) => Promise<void>;
43
+ /**
44
+ * Rename an agent group (group chat)
45
+ */
46
+ renameAgentGroup: (groupId: string, title: string) => Promise<void>;
43
47
  /**
44
48
  * Update agent's group
45
49
  */
@@ -162,6 +166,11 @@ export const createSidebarUISlice: StateCreator<
162
166
  await get().refreshAgentList();
163
167
  },
164
168
 
169
+ renameAgentGroup: async (groupId, title) => {
170
+ await chatGroupService.updateGroup(groupId, { title });
171
+ await get().refreshAgentList();
172
+ },
173
+
165
174
  updateAgentGroup: async (agentId, groupId) => {
166
175
  await homeService.updateAgentSessionGroupId(agentId, groupId === 'default' ? null : groupId);
167
176
  await get().refreshAgentList();