import { FC } from "react"; import { Controller, useForm } from "react-hook-form"; // ui import { Button, Input } from "@plane/ui"; // types import { IFormattedInstanceConfiguration } from "types/instance"; // hooks import useToast from "hooks/use-toast"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; export interface IInstanceOpenAIForm { config: IFormattedInstanceConfiguration; } export interface OpenAIFormValues { OPENAI_API_BASE: string; OPENAI_API_KEY: string; GPT_ENGINE: string; } export const InstanceOpenAIForm: FC = (props) => { const { config } = props; // store const { instance: instanceStore } = useMobxStore(); // toast const { setToastAlert } = useToast(); // form data const { handleSubmit, control, formState: { errors, isSubmitting }, } = useForm({ defaultValues: { OPENAI_API_BASE: config["OPENAI_API_BASE"], OPENAI_API_KEY: config["OPENAI_API_KEY"], GPT_ENGINE: config["GPT_ENGINE"], }, }); const onSubmit = async (formData: OpenAIFormValues) => { const payload: Partial = { ...formData }; await instanceStore .updateInstanceConfigurations(payload) .then(() => setToastAlert({ title: "Success", type: "success", message: "Open AI Settings updated successfully", }) ) .catch((err) => console.error(err)); }; return (
OpenAI
AI is everywhere make use it as much as you can! Learn more.

OpenAI API Base

( )} />

OpenAI API Key

( )} />

GPT Engine

( )} />
); };