diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 52d8a10..125c258 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -32,6 +32,7 @@ import { SettingsModal } from "./SettingsModal"; import { config } from "../utils/config"; import { ChatContext, ChatsContext, PromptsContext, SettingsContext } from "../hooks/contexts"; import { ChatHeader } from "./ChatHeader"; +import { notifications } from "@mantine/notifications"; declare global { interface Window { @@ -236,6 +237,15 @@ export function Layout() { fullWidth leftIcon={} onClick={async () => { + if (!settings?.openAiApiKey) { + notifications.show({ + title: "Error", + color: "red", + message: "OpenAI API Key is not defined. Please set your API Key", + }); + return; + }; + const item = await detaDB.chats.put({ description: "New Chat", totalTokens: 0, diff --git a/src/components/Prompts.tsx b/src/components/Prompts.tsx index 7eb73b1..3cda42d 100644 --- a/src/components/Prompts.tsx +++ b/src/components/Prompts.tsx @@ -6,6 +6,7 @@ import { Chat, detaDB, generateKey } from "../db"; import { DeletePromptModal } from "./DeletePromptModal"; import { EditPromptModal } from "./EditPromptModal"; import { useChats, usePrompts, useSettings } from "../hooks/contexts"; +import { notifications } from "@mantine/notifications"; export function Prompts({ onPlay, @@ -82,7 +83,14 @@ export function Prompts({ { - if (!settings?.openAiApiKey) return; + if (!settings?.openAiApiKey) { + notifications.show({ + title: "Error", + color: "red", + message: "OpenAI API Key is not defined. Please set your API Key", + }); + return; + }; const item = await detaDB.chats.put({ description: prompt.title ? `New ${prompt.title} Chat` : "New Chat",