diff --git a/frontend/lib/api/brain/types.ts b/frontend/lib/api/brain/types.ts index ddd8437ba..46877ac0b 100644 --- a/frontend/lib/api/brain/types.ts +++ b/frontend/lib/api/brain/types.ts @@ -1,5 +1,5 @@ import { BrainRoleType } from "@/lib/components/BrainUsers/types"; -import { BrainStatus } from "@/lib/types/brainConfig"; +import { BrainStatus, BrainType } from "@/lib/types/brainConfig"; export type SubscriptionUpdatableProperties = { role: BrainRoleType | null; @@ -14,6 +14,7 @@ export type CreateBrainInput = { max_tokens?: number; openai_api_key?: string; prompt_id?: string | null; + brain_type?: BrainType; }; export type UpdateBrainInput = Partial; diff --git a/frontend/lib/components/AddBrainModal/AddBrainModal.tsx b/frontend/lib/components/AddBrainModal/AddBrainModal.tsx index e985ac68d..c5da1053e 100644 --- a/frontend/lib/components/AddBrainModal/AddBrainModal.tsx +++ b/frontend/lib/components/AddBrainModal/AddBrainModal.tsx @@ -1,21 +1,9 @@ -/* eslint-disable max-lines */ -/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import { FormProvider, useForm } from "react-hook-form"; -import { useTranslation } from "react-i18next"; -import { MdAdd } from "react-icons/md"; +import { defaultBrainConfig } from "@/lib/config/defaultBrainConfig"; +import { BrainConfig } from "@/lib/types/brainConfig"; -import { PublicPrompts } from "@/app/brains-management/[brainId]/components/BrainManagementTabs/components/SettingsTab/components/PublicPrompts"; -import Button from "@/lib/components/ui/Button"; -import Field from "@/lib/components/ui/Field"; -import { Modal } from "@/lib/components/ui/Modal"; -import { defineMaxTokens } from "@/lib/helpers/defineMaxTokens"; -import { cn } from "@/lib/utils"; - -import { PublicAccessConfirmationModal } from "./components/PublicAccessConfirmationModal"; -import { useAddBrainModal } from "./hooks/useAddBrainModal"; -import { Divider } from "../ui/Divider"; -import { Radio } from "../ui/Radio"; -import { TextArea } from "../ui/TextArea"; +import { AddBrainConfig } from "./components/AddBrainConfig/AddBrainConfig"; type AddBrainModalProps = { triggerClassName?: string; @@ -24,176 +12,13 @@ type AddBrainModalProps = { export const AddBrainModal = ({ triggerClassName, }: AddBrainModalProps): JSX.Element => { - const { t } = useTranslation(["translation", "brain", "config"]); - const { - handleSubmit, - isShareModalOpen, - setIsShareModalOpen, - register, - temperature, - maxTokens, - model, - isPending, - pickPublicPrompt, - accessibleModels, - brainStatusOptions, - status, - isPublicAccessConfirmationModalOpened, - onCancelPublicAccess, - onConfirmPublicAccess, - } = useAddBrainModal(); + const methods = useForm({ + defaultValues: defaultBrainConfig, + }); return ( - <> - void 0} - variant={"tertiary"} - className={cn("border-0", triggerClassName)} - data-testid="add-brain-button" - > - {t("newBrain", { ns: "brain" })} - - - } - title={t("newBrainTitle", { ns: "brain" })} - desc={t("newBrainSubtitle", { ns: "brain" })} - isOpen={isShareModalOpen} - setOpen={setIsShareModalOpen} - CloseTrigger={
} - > -
{ - e.preventDefault(); - void handleSubmit(); - }} - className="my-10 flex flex-col items-center gap-2" - > - - -