import { Button } from '@/components/ui/button'; import { FormControl, FormField, FormItem, FormLabel, FormMessage, } from '@/components/ui/form'; import { BlurInput } from '@/components/ui/input'; import { Separator } from '@/components/ui/separator'; import { Switch } from '@/components/ui/switch'; import { Plus, X } from 'lucide-react'; import { useCallback } from 'react'; import { useFieldArray, useFormContext } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; export function DynamicVariableForm() { const { t } = useTranslation(); const form = useFormContext(); const name = 'prompt_config.parameters'; const { fields, remove, append } = useFieldArray({ name, control: form.control, }); const add = useCallback(() => { append({ key: undefined, optional: false, }); }, [append]); return (
{t('chat.variable')}
Key Optional
{fields.map((field, index) => { const typeField = `${name}.${index}.key`; return (
( )} /> ( )} />
); })}
); }