import { Controller, useWatch } from 'react-hook-form'; import { Tools, EModelEndpoint } from 'librechat-data-provider'; import { useCreateAssistantMutation } from 'librechat-data-provider/react-query'; import type { CreationForm, Actions } from '~/common'; import type { Tool } from 'librechat-data-provider'; import { Separator } from '~/components/ui/Separator'; import { useAssistantsContext } from '~/Providers'; import { Switch } from '~/components/ui/Switch'; import CreationHeader from './CreationHeader'; import { useNewConvo } from '~/hooks'; export default function CreationPanel({ index = 0 }) { const { switchToConversation } = useNewConvo(index); const create = useCreateAssistantMutation(); const { control, handleSubmit, reset, setValue } = useAssistantsContext(); const onSubmit = (data: CreationForm) => { const tools: Tool[] = []; console.log(data); if (data.function) { tools.push({ type: Tools.function }); } if (data.code_interpreter) { tools.push({ type: Tools.code_interpreter }); } if (data.retrieval) { tools.push({ type: Tools.retrieval }); } const { name, description, instructions, model, // file_ids, } = data; create.mutate({ name, description, instructions, model, tools, }); }; const assistant_id = useWatch({ control, name: 'id' }); // Render function for the Switch component const renderSwitch = (name: keyof Actions) => ( ( )} /> ); return (
( )} />
{/* Name */}
( )} /> (

{field.value ?? ''}

)} />
{/* Description */}
( )} />
{/* Instructions */}
(