Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

📐 fix: Lay Out Agent Builder Model Parameters Like the Chat Panel (#16897)

Marco Berettafdcc932daa0f
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 }) => (
+ <div data-testid={`param-${settingKey}`} />
+ );
+ 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(
+ <TestForm
+ defaultProvider={EModelEndpoint.openAI}
+ defaultModel="gpt-4o"
+ models={{ [EModelEndpoint.openAI]: ['gpt-4o'] }}
+ modelsReady={true}
+ />,
+ );
+
+ expect(getByTestId('param-maxContextTokens').parentElement).toHaveClass('col-span-1');
+ });
+
+ it('gives a toggle one of the two columns', () => {
+ const { getByTestId } = render(
+ <TestForm
+ defaultProvider={EModelEndpoint.openAI}
+ defaultModel="gpt-4o"
+ models={{ [EModelEndpoint.openAI]: ['gpt-4o'] }}
+ modelsReady={true}
+ />,
+ );
+
+ expect(getByTestId('param-resendFiles').parentElement).toHaveClass('col-span-1');
+ });
+
+ it('gives free text the whole row', () => {
+ const { getByTestId } = render(
+ <TestForm
+ defaultProvider={EModelEndpoint.openAI}
+ defaultModel="gpt-4o"
+ models={{ [EModelEndpoint.openAI]: ['gpt-4o'] }}
+ modelsReady={true}
+ />,
+ );
+
+ expect(getByTestId('param-stop').parentElement).toHaveClass('col-span-2');
+ });
+
+ it('files the parameters under the same headings as the chat panel', () => {
+ const { getByRole } = render(
+ <TestForm
+ defaultProvider={EModelEndpoint.openAI}
+ defaultModel="gpt-4o"
+ models={{ [EModelEndpoint.openAI]: ['gpt-4o'] }}
+ modelsReady={true}
+ />,
+ );
+
+ 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({
</Alert>
)}
{/* Model Parameters */}
- {parameters && (
+ {sections.length > 0 && (
<div className="h-auto max-w-full">
- <div className="grid grid-cols-2 gap-3">
- {/* 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 (
- <Component
- key={key}
- settingKey={key}
- defaultValue={defaultValue}
- {...rest}
- setOption={setOption as t.TSetOption}
- conversation={modelParameters as Partial<t.TConversation>}
- />
- );
- })}
- </div>
+ <Sections
+ sections={sections}
+ setOption={setOption as t.TSetOption}
+ conversation={modelParameters as Partial<t.TConversation>}
+ />
</div>
)}
{/* 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 (
<div className="h-auto max-w-full px-3 pt-1 pb-3">
- {/* 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 (
- <section key={section.id} aria-labelledby={headingId} className="pt-4 first:pt-0">
- <h3
- id={headingId}
- className="text-text-secondary mb-2 flex items-center gap-1.5 text-xs font-semibold tracking-wide uppercase"
- >
- <span className="truncate">{localize(section.label)}</span>
- {/* Where this conversation's own answers are, which is what the owner
- scans for before reaching for Reset. */}
- {changed > 0 && (
- <>
- <span
- aria-hidden="true"
- className="bg-surface-tertiary text-text-primary shrink-0 rounded-full px-1.5 text-xs font-normal tracking-normal normal-case tabular-nums"
- >
- {changed}
- </span>
- <span className="sr-only">
- {localize(
- changed === 1
- ? 'com_ui_params_changed_count_one'
- : 'com_ui_params_changed_count',
- { count: changed },
- )}
- </span>
- </>
- )}
- </h3>
- <div className="grid grid-cols-2 gap-x-3 gap-y-2.5">
- {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 (
- <div
- key={key}
- className={cn(
- '*:h-full',
- isWideParameter(setting) ? 'col-span-2' : 'col-span-1',
- )}
- >
- <Component
- settingKey={key}
- defaultValue={defaultValue}
- {...rest}
- setOption={setOption}
- conversation={conversation}
- />
- </div>
- );
- })}
- </div>
- </section>
- );
- })}
+ <Sections sections={sections} setOption={setOption} conversation={conversation} />
{/* 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. */}
<div className="mt-5 flex flex-wrap gap-2">
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<TConversation> | Partial<TPreset> | 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 (
+ <section key={section.id} aria-labelledby={headingId} className="pt-4 first:pt-0">
+ <h3
+ id={headingId}
+ className="text-text-secondary mb-2 flex items-center gap-1.5 text-xs font-semibold tracking-wide uppercase"
+ >
+ <span className="truncate">{localize(section.label)}</span>
+ {/* Where this conversation's own answers are, which is what the owner
+ scans for before reaching for Reset. */}
+ {changed > 0 && (
+ <>
+ <span
+ aria-hidden="true"
+ className="bg-surface-tertiary text-text-primary shrink-0 rounded-full px-1.5 text-xs font-normal tracking-normal normal-case tabular-nums"
+ >
+ {changed}
+ </span>
+ <span className="sr-only">
+ {localize(
+ changed === 1
+ ? 'com_ui_params_changed_count_one'
+ : 'com_ui_params_changed_count',
+ { count: changed },
+ )}
+ </span>
+ </>
+ )}
+ </h3>
+ <div className="grid grid-cols-2 gap-x-3 gap-y-2.5">
+ {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 (
+ <div
+ key={key}
+ className={cn(
+ '*:h-full',
+ isWideParameter(setting) ? 'col-span-2' : 'col-span-1',
+ )}
+ >
+ <Component
+ settingKey={key}
+ defaultValue={defaultValue}
+ {...rest}
+ setOption={setOption}
+ conversation={conversation}
+ />
+ </div>
+ );
+ })}
+ </div>
+ </section>
+ );
+ })}
+ </>
+ );
+}