"use client"; import type { FC } from "react"; import { useForm } from "react-hook-form"; import { Lightbulb } from "lucide-react"; import { Button } from "@plane/propel/button"; import { TOAST_TYPE, setToast } from "@plane/propel/toast"; import type { IFormattedInstanceConfiguration, TInstanceAIConfigurationKeys } from "@plane/types"; // components import type { TControllerInputFormField } from "@/components/common/controller-input"; import { ControllerInput } from "@/components/common/controller-input"; // hooks import { useInstance } from "@/hooks/store"; type IInstanceAIForm = { config: IFormattedInstanceConfiguration; }; type AIFormValues = Record; export const InstanceAIForm: FC = (props) => { const { config } = props; // store const { updateInstanceConfigurations } = useInstance(); // form data const { handleSubmit, control, formState: { errors, isSubmitting }, } = useForm({ defaultValues: { LLM_API_KEY: config["LLM_API_KEY"], LLM_MODEL: config["LLM_MODEL"], }, }); const aiFormFields: TControllerInputFormField[] = [ { key: "LLM_MODEL", type: "text", label: "LLM Model", description: ( <> Choose an OpenAI engine.{" "} Learn more ), placeholder: "gpt-4o-mini", error: Boolean(errors.LLM_MODEL), required: false, }, { key: "LLM_API_KEY", type: "password", label: "API key", description: ( <> You will find your API key{" "} here. ), placeholder: "sk-asddassdfasdefqsdfasd23das3dasdcasd", error: Boolean(errors.LLM_API_KEY), required: false, }, ]; const onSubmit = async (formData: AIFormValues) => { const payload: Partial = { ...formData }; await updateInstanceConfigurations(payload) .then(() => setToast({ type: TOAST_TYPE.SUCCESS, title: "Success", message: "AI Settings updated successfully", }) ) .catch((err) => console.error(err)); }; return (
OpenAI
If you use ChatGPT, this is for you.
{aiFormFields.map((field) => ( ))}
If you have a preferred AI models vendor, please get in{" "} touch with us.
); };