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
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
import { Input, Label } from '@librechat/client';
import { Controller, useWatch, useFormContext } from 'react-hook-form';
import type { InstructionsPromptStatus } from './Instructions';
import type { AgentForm } from '~/common';
import { ResolvedProviderIcon } from '~/components/Endpoints/ResolvedProviderIcon';
import AgentCategorySelector from './AgentCategorySelector';
import { useLocalize, useAgentCapabilities } from '~/hooks';
import { useAgentFileEntries } from './Tools/hooks';
import { useAgentPanelContext } from '~/Providers';
import { useProviderIcon } from '~/hooks/Endpoint';
import ToolsSection from './Tools/ToolsSection';
import { validateEmail, cn } from '~/utils';
import Instructions from './Instructions';
import FileContext from './FileContext';
import AgentAvatar from './AgentAvatar';
import Starters from './Starters';
import { Panel } from '~/common';
const fieldClass = 'h-9';
export default function AgentConfig({
instructionsPromptStatus,
onRetryInstructionsPrompt,
}: {
instructionsPromptStatus?: InstructionsPromptStatus;
onRetryInstructionsPrompt?: () => void;
}) {
const localize = useLocalize();
const methods = useFormContext<AgentForm>();
const { setActivePanel, endpointsConfig, agentsConfig } = useAgentPanelContext();
const { contextEnabled } = useAgentCapabilities(agentsConfig?.capabilities);
const {
control,
formState: { errors },
} = methods;
const provider = useWatch({ control, name: 'provider' });
const model = useWatch({ control, name: 'model' });
const agent = useWatch({ control, name: 'agent' });
const agent_id = useWatch({ control, name: 'id' });
const { contextFiles } = useAgentFileEntries();
const providerValue = typeof provider === 'string' ? provider : provider?.value;
const { provider: providerId, imageURL } = useProviderIcon({
endpoint: providerValue as string,
endpointsConfig,
});
return (
<div className="h-auto pt-1">
{/* IDENTITY — flat header, always visible, avatar inline */}
<div className="mt-1 mb-3 flex items-center gap-3">
<div className="shrink-0">
<AgentAvatar avatar={agent?.['avatar'] ?? null} />
</div>
<div className="flex min-w-0 flex-1 flex-col gap-2">
<Controller
name="name"
rules={{ required: localize('com_ui_agent_name_is_required') }}
control={control}
render={({ field }) => (
<div className="flex flex-col">
<Input
{...field}
value={field.value ?? ''}
maxLength={256}
className={cn(fieldClass, 'font-medium')}
id="name"
type="text"
placeholder={localize('com_agents_name_placeholder')}
aria-label={localize('com_ui_agent_name')}
aria-invalid={!!errors.name}
aria-describedby={errors.name ? 'agent-name-error' : undefined}
/>
{errors.name && (
<div
id="agent-name-error"
className="text-text-destructive mt-1 text-xs"
role="alert"
>
{errors.name.message}
</div>
)}
</div>
)}
/>
<Controller
name="description"
control={control}
render={({ field }) => (
<Input
{...field}
value={field.value ?? ''}
maxLength={512}
className={fieldClass}
id="description"
type="text"
placeholder={localize('com_agents_description_placeholder')}
aria-label={localize('com_ui_agent_description')}
/>
)}
/>
</div>
</div>
{/* MODEL + CATEGORY — balanced 2-column grid */}
<div className="mb-3 grid grid-cols-2 gap-2">
<div className="flex min-w-0 flex-col">
<Label
variant="secondary"
className="text-2xs mb-1 block font-medium tracking-wide uppercase"
htmlFor="provider"
>
{localize('com_ui_model')} <span className="text-text-destructive">*</span>
</Label>
<button
id="provider"
type="button"
onClick={() => setActivePanel(Panel.model)}
title={model || undefined}
className={cn(
'border-border-control bg-surface-secondary text-text-primary hover:bg-surface-tertiary focus-visible:ring-ring-primary relative flex h-9 w-full min-w-0 items-center overflow-hidden rounded-lg border text-sm font-medium transition-colors focus:outline-hidden focus-visible:ring-2',
model != null && model ? 'px-1' : 'px-3',
)}
>
<div className="flex w-full min-w-0 items-center gap-2">
{providerValue !== undefined && (
<div className="avatar-stroke bg-surface-primary text-text-primary relative flex h-6 w-6 shrink-0 items-center justify-center rounded-full">
<ResolvedProviderIcon
provider={providerId}
imageURL={imageURL}
size={16}
className="h-2/3 w-2/3"
/>
</div>
)}
<span className="truncate">
{model != null && model ? model : localize('com_ui_select_model')}
</span>
</div>
</button>
</div>
<div className="flex flex-col">
<Label
variant="secondary"
className="text-2xs mb-1 block font-medium tracking-wide uppercase"
htmlFor="category-selector"
>
{localize('com_ui_category')} <span className="text-text-destructive">*</span>
</Label>
<AgentCategorySelector className="w-full rounded-lg" />
</div>
</div>
{/* INSTRUCTIONS */}
<Instructions
promptStatus={instructionsPromptStatus}
onRetryLoad={onRetryInstructionsPrompt}
/>
{/* TOOLS — unified built-ins / tools / actions / mcp / skills */}
<ToolsSection agentId={agent_id} />
{/* FILE CONTEXT — standalone section, separate from the tool library */}
{contextEnabled && (
<div className="mb-3">
<FileContext agent_id={agent_id} files={contextFiles} />
</div>
)}
{/* CONVERSATION STARTERS */}
<Starters />
{/* SUPPORT CONTACT */}
<div className="mb-3 flex flex-col">
<Label
variant="secondary"
className="text-2xs mb-1 block font-medium tracking-wide uppercase"
>
{localize('com_ui_support_contact')}
</Label>
<div className="space-y-2">
<Controller
name="support_contact.name"
control={control}
rules={{
minLength: {
value: 3,
message: localize('com_ui_support_contact_name_min_length', { minLength: 3 }),
},
}}
render={({ field, fieldState: { error } }) => (
<div className="flex flex-col">
<Input
{...field}
value={field.value ?? ''}
className={cn(fieldClass, error && 'border-border-destructive border-2')}
id="support-contact-name"
type="text"
placeholder={localize('com_ui_support_contact_name_placeholder')}
aria-label={localize('com_ui_support_contact_name')}
aria-invalid={error ? 'true' : 'false'}
aria-describedby={error ? 'support-contact-name-error' : undefined}
/>
{error && (
<span
id="support-contact-name-error"
className="text-text-destructive mt-1 text-xs"
role="alert"
aria-live="polite"
>
{error.message}
</span>
)}
</div>
)}
/>
<Controller
name="support_contact.email"
control={control}
rules={{
validate: (value) =>
validateEmail(value ?? '', localize('com_ui_support_contact_email_invalid')),
}}
render={({ field, fieldState: { error } }) => (
<div className="flex flex-col">
<Input
{...field}
value={field.value ?? ''}
className={cn(fieldClass, error && 'border-border-destructive border-2')}
id="support-contact-email"
type="email"
placeholder={localize('com_ui_support_contact_email_placeholder')}
aria-label={localize('com_ui_support_contact_email')}
aria-invalid={error ? 'true' : 'false'}
aria-describedby={error ? 'support-contact-email-error' : undefined}
/>
{error && (
<span
id="support-contact-email-error"
className="text-text-destructive mt-1 text-xs"
role="alert"
aria-live="polite"
>
{error.message}
</span>
)}
</div>
)}
/>
</div>
</div>
</div>
);
}