import { FC, useState } from "react"; import { Controller, useForm } from "react-hook-form"; import { Eye, EyeOff } from "lucide-react"; // ui import { Button, Input, TOAST_TYPE, setToast } from "@plane/ui"; // types // hooks import { useApplication } from "hooks/store"; export interface IInstanceAIForm { config: IFormattedInstanceConfiguration; } export interface AIFormValues { OPENAI_API_KEY: string; GPT_ENGINE: string; } export const InstanceAIForm: FC = (props) => { const { config } = props; // states const [showPassword, setShowPassword] = useState(false); // store const { instance: instanceStore } = useApplication(); // form data const { handleSubmit, control, formState: { errors, isSubmitting }, } = useForm({ defaultValues: { OPENAI_API_KEY: config["OPENAI_API_KEY"], GPT_ENGINE: config["GPT_ENGINE"], }, }); const onSubmit = async (formData: AIFormValues) => { const payload: Partial = { ...formData }; await instanceStore .updateInstanceConfigurations(payload) .then(() => setToast({ title: "Success", type: TOAST_TYPE.SUCCESS, message: "AI Settings updated successfully", }) ) .catch((err) => console.error(err)); }; return ( <>

GPT_ENGINE

( )} />

Choose an OpenAI engine.{" "} Learn more

API key

( )} /> {showPassword ? ( ) : ( )}

You will find your API key{" "} here.

); };