import { zodResolver } from "@hookform/resolvers/zod"; import { t, Trans } from "@lingui/macro"; import { LockSimple, LockSimpleOpen, TrashSimple } from "@phosphor-icons/react"; import { Alert, Button, Form, FormControl, FormField, FormItem, FormLabel, FormMessage, Input, } from "@reactive-resume/ui"; import { cn } from "@reactive-resume/utils"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { useOpenAiStore } from "@/client/stores/openai"; const formSchema = z.object({ apiKey: z .string() // eslint-disable-next-line lingui/t-call-in-function .regex(/^sk-.+$/, t`That doesn't look like a valid OpenAI API key.`) .default(""), }); type FormValues = z.infer; export const OpenAISettings = () => { const { apiKey, setApiKey } = useOpenAiStore(); const isEnabled = !!apiKey; const form = useForm({ resolver: zodResolver(formSchema), defaultValues: { apiKey: apiKey ?? "" }, }); const onSubmit = ({ apiKey }: FormValues) => { setApiKey(apiKey); }; const onRemove = () => { setApiKey(null); form.reset({ apiKey: "" }); }; return (

{t`OpenAI Integration`}

{t`You can make use of the OpenAI API to help you generate content, or improve your writing while composing your resume.`}

You have the option to{" "} obtain your own OpenAI API key . This key empowers you to leverage the API as you see fit. Alternatively, if you wish to disable the AI features in Reactive Resume altogether, you can simply remove the key from your settings.

( {t`API Key`} )} />
{isEnabled && ( )}

Your API key is securely stored in the browser's local storage and is only utilized when making requests to OpenAI via their official SDK. Rest assured that your key is not transmitted to any external server except when interacting with OpenAI's services.

Note: By utilizing the OpenAI API, you acknowledge and accept the{" "} terms of use {" "} and{" "} privacy policy {" "} outlined by OpenAI. Please note that Reactive Resume bears no responsibility for any improper or unauthorized utilization of the service, and any resulting repercussions or liabilities solely rest on the user.
); };