diff --git a/client/src/components/SidePanel/Agents/ModelPanel.test.tsx b/client/src/components/SidePanel/Agents/ModelPanel.test.tsx
index c5ea12be0d..18c9b86201 100644
--- a/client/src/components/SidePanel/Agents/ModelPanel.test.tsx
+++ b/client/src/components/SidePanel/Agents/ModelPanel.test.tsx
@@ -61,9 +61,23 @@ jest.mock('@librechat/client', () => ({
),
}));
-jest.mock('~/components/SidePanel/Parameters/components', () => ({
- componentMapping: {},
-}));
+jest.mock('~/components/SidePanel/Parameters/components', () => {
+ const Stub = ({ settingKey }: { settingKey: string }) => (
+
+ );
+ return {
+ componentMapping: {
+ slider: Stub,
+ switch: Stub,
+ input: Stub,
+ tags: Stub,
+ textarea: Stub,
+ combobox: Stub,
+ dropdown: Stub,
+ checkbox: Stub,
+ },
+ };
+});
jest.mock('~/data-provider', () => ({
useGetEndpointsQuery: () => ({ data: {} }),
@@ -436,6 +450,58 @@ describe('ModelPanel', () => {
});
});
+ it('gives a numeric parameter one of the two columns', () => {
+ const { getByTestId } = render(
+ ,
+ );
+
+ expect(getByTestId('param-maxContextTokens').parentElement).toHaveClass('col-span-1');
+ });
+
+ it('gives a toggle one of the two columns', () => {
+ const { getByTestId } = render(
+ ,
+ );
+
+ expect(getByTestId('param-resendFiles').parentElement).toHaveClass('col-span-1');
+ });
+
+ it('gives free text the whole row', () => {
+ const { getByTestId } = render(
+ ,
+ );
+
+ expect(getByTestId('param-stop').parentElement).toHaveClass('col-span-2');
+ });
+
+ it('files the parameters under the same headings as the chat panel', () => {
+ const { getByRole } = render(
+ ,
+ );
+
+ expect(getByRole('heading', { name: 'com_ui_params_limits' })).toBeInTheDocument();
+ });
+
it('prunes saved model_parameters when every known setting is dropped', async () => {
mockStartupConfig.mockReturnValue({
endpointsDropParamsMap: {
diff --git a/client/src/components/SidePanel/Agents/ModelPanel.tsx b/client/src/components/SidePanel/Agents/ModelPanel.tsx
index 64560d4aab..fad80f8e91 100644
--- a/client/src/components/SidePanel/Agents/ModelPanel.tsx
+++ b/client/src/components/SidePanel/Agents/ModelPanel.tsx
@@ -12,9 +12,11 @@ import {
import type * as t from 'librechat-data-provider';
import type { AgentForm, AgentModelPanelProps, StringOption } from '~/common';
import { pruneAgentModelParameters, resolveAgentParameterSettings } from './parameters';
+import { groupParameters, hasControl } from '~/components/SidePanel/Parameters/groups';
import { componentMapping } from '~/components/SidePanel/Parameters/components';
import { useGetEndpointsQuery, useGetStartupConfig } from '~/data-provider';
import { useModelReasoning } from '~/hooks/Endpoint/useModelReasoning';
+import Sections from '~/components/SidePanel/Parameters/Sections';
import { useLocalize, useHasAccess } from '~/hooks';
import { useLiveAnnouncer } from '~/Providers';
import { Panel } from '~/common';
@@ -112,6 +114,22 @@ export default function ModelPanel({
setValue('model_parameters', prunedParameters);
}, [parameterSettings, getValues, setValue]);
+ /** Same grouping as the chat panel: region choices are filled in first, and a
+ * control with nothing to render is dropped so no section stands empty. */
+ const sections = useMemo(
+ () =>
+ groupParameters(
+ (parameters ?? [])
+ .map((setting) =>
+ setting.key === 'region' && bedrockRegions.length > 0
+ ? { ...setting, options: bedrockRegions }
+ : setting,
+ )
+ .filter((setting) => componentMapping[setting.component] != null && hasControl(setting)),
+ ),
+ [parameters, bedrockRegions],
+ );
+
const setOption = (optionKey: keyof t.AgentModelParameters) => (value: t.AgentParameterValue) => {
setValue(`model_parameters.${optionKey}`, value);
};
@@ -279,34 +297,13 @@ export default function ModelPanel({
)}
{/* Model Parameters */}
- {parameters && (
+ {sections.length > 0 && (
-
- {/* This is the parent element containing all settings */}
- {/* Below is an example of an applied dynamic setting, each be contained by a div with the column span specified */}
- {parameters.map((setting) => {
- const Component = componentMapping[setting.component];
- if (!Component) {
- return null;
- }
- const { key, default: defaultValue, ...rest } = setting;
-
- if (key === 'region' && bedrockRegions.length) {
- rest.options = bedrockRegions;
- }
-
- return (
- }
- />
- );
- })}
-
+
}
+ />
)}
{/* Reset Parameters Button */}
diff --git a/client/src/components/SidePanel/Parameters/Panel.tsx b/client/src/components/SidePanel/Parameters/Panel.tsx
index e71eb14576..1f41bf40f9 100644
--- a/client/src/components/SidePanel/Parameters/Panel.tsx
+++ b/client/src/components/SidePanel/Parameters/Panel.tsx
@@ -1,4 +1,4 @@
-import React, { useId, useMemo, useState, useEffect, useCallback } from 'react';
+import React, { useMemo, useState, useEffect, useCallback } from 'react';
import keyBy from 'lodash/keyBy';
import { RotateCcw } from 'lucide-react';
import { Button } from '@librechat/client';
@@ -14,17 +14,17 @@ import {
resolveDropParamsUIKeys,
} from 'librechat-data-provider';
import type { TPreset } from 'librechat-data-provider';
-import { groupParameters, countModified, hasControl, isWideParameter } from './groups';
import { useGetEndpointsQuery, useGetStartupConfig } from '~/data-provider';
import { useModelReasoning } from '~/hooks/Endpoint/useModelReasoning';
import { useChatContext, useLiveAnnouncer } from '~/Providers';
import { SaveAsPresetDialog } from '~/components/Endpoints';
import { useSetIndexOptions, useLocalize } from '~/hooks';
+import { groupParameters, hasControl } from './groups';
import { componentMapping } from './components';
import { logger, cn } from '~/utils';
+import Sections from './Sections';
export default function Parameters() {
- const panelId = useId();
const localize = useLocalize();
const { data: startupConfig } = useGetStartupConfig();
const { conversation, setConversation } = useChatContext();
@@ -200,78 +200,7 @@ export default function Parameters() {
return (
- {/* Every parameter this model can act on is on screen. A disclosure would
- trade the one thing a settings panel is for, seeing the current state at a
- glance, for vertical space that pairing and quieter headings give back
- anyway. */}
- {sections.map((section) => {
- const changed = countModified(section.settings, conversation);
- const headingId = `${panelId}-${section.id}`;
-
- return (
-
-
- {localize(section.label)}
- {/* Where this conversation's own answers are, which is what the owner
- scans for before reaching for Reset. */}
- {changed > 0 && (
- <>
-
- {changed}
-
-
- {localize(
- changed === 1
- ? 'com_ui_params_changed_count_one'
- : 'com_ui_params_changed_count',
- { count: changed },
- )}
-
- >
- )}
-
-
- {section.settings.map((setting) => {
- const Component = componentMapping[setting.component];
- if (!Component) {
- return null;
- }
- const { key, default: defaultValue, ...rest } = setting;
-
- /** The cell owns the span, not the control. The definitions carry a
- * columnSpan written for the four-column preset dialog, which says
- * nothing about a panel this narrow. */
- /** The cell stretches its control to the row, so a pair whose labels
- * wrap differently still lines their inputs up. Applied here rather
- * than in the shared controls, which the preset editors reuse. */
- return (
-
-
-
- );
- })}
-
-
- );
- })}
+
{/* The two share a row while their labels fit, stack when a translation is too
long for the panel, and a label longer than the panel itself wraps. */}
diff --git a/client/src/components/SidePanel/Parameters/Sections.tsx b/client/src/components/SidePanel/Parameters/Sections.tsx
new file mode 100644
index 0000000000..90d215e0a0
--- /dev/null
+++ b/client/src/components/SidePanel/Parameters/Sections.tsx
@@ -0,0 +1,101 @@
+import { useId } from 'react';
+import type { TSetOption, TConversation, TPreset } from 'librechat-data-provider';
+import type { ParameterSection } from './groups';
+import { countModified, isWideParameter } from './groups';
+import { componentMapping } from './components';
+import { useLocalize } from '~/hooks';
+import { cn } from '~/utils';
+
+/**
+ * The grouped parameter grid shared by the chat panel and the agent builder, so a
+ * parameter takes the same space and sits under the same heading in both.
+ */
+export default function Sections({
+ sections,
+ setOption,
+ conversation,
+}: {
+ sections: ParameterSection[];
+ setOption: TSetOption;
+ conversation: Partial
| Partial | null;
+}) {
+ const panelId = useId();
+ const localize = useLocalize();
+
+ return (
+ <>
+ {/* Every parameter this model can act on is on screen. A disclosure would
+ trade the one thing a settings panel is for, seeing the current state at a
+ glance, for vertical space that pairing and quieter headings give back
+ anyway. */}
+ {sections.map((section) => {
+ const changed = countModified(section.settings, conversation);
+ const headingId = `${panelId}-${section.id}`;
+
+ return (
+
+
+ {localize(section.label)}
+ {/* Where this conversation's own answers are, which is what the owner
+ scans for before reaching for Reset. */}
+ {changed > 0 && (
+ <>
+
+ {changed}
+
+
+ {localize(
+ changed === 1
+ ? 'com_ui_params_changed_count_one'
+ : 'com_ui_params_changed_count',
+ { count: changed },
+ )}
+
+ >
+ )}
+
+
+ {section.settings.map((setting) => {
+ const Component = componentMapping[setting.component];
+ if (!Component) {
+ return null;
+ }
+ const { key, default: defaultValue, ...rest } = setting;
+
+ /** The cell owns the span, not the control. The definitions carry a
+ * columnSpan written for the four-column preset dialog, which says
+ * nothing about a panel this narrow. */
+ /** The cell stretches its control to the row, so a pair whose labels
+ * wrap differently still lines their inputs up. Applied here rather
+ * than in the shared controls, which the preset editors reuse. */
+ return (
+
+
+
+ );
+ })}
+
+
+ );
+ })}
+ >
+ );
+}