From 83ef006a982be0b698f0575d1a0dfba98e3a658d Mon Sep 17 00:00:00 2001 From: Martin Sosic Date: Fri, 23 Jun 2023 12:09:09 +0200 Subject: [PATCH] Improved messaging for missing OpenAI Api key. --- .../cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs | 10 ++++++++-- waspc/src/Wasp/AI/GenerateNewProject/Operation.hs | 13 ++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs index fe0068dd1..13618cdbc 100644 --- a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs +++ b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs @@ -102,8 +102,14 @@ getOpenAIApiKey = throwMissingOpenAIApiKeyEnvVarError = throwError $ CommandError - "Missing OPENAI_API_KEY env var" - "You can obtain this key from your OpenAI profile." + "Missing OPENAI_API_KEY environment variable" + $ unlines + [ "Wasp AI uses ChatGPT to generate your project, and therefore requires you to provide it with an OpenAI API key.", + "You can obtain this key via your OpenAI account's user settings (https://platform.openai.com/account/api-keys).", + "Then, add", + " export OPENAI_API_KEY=", + "to .bash_profile or .profile, restart your shell, and you should be good to go." + ] newProjectDetails :: String -> String -> NewProjectDetails newProjectDetails webAppName webAppDescription = diff --git a/waspc/src/Wasp/AI/GenerateNewProject/Operation.hs b/waspc/src/Wasp/AI/GenerateNewProject/Operation.hs index 200a22322..60d515721 100644 --- a/waspc/src/Wasp/AI/GenerateNewProject/Operation.hs +++ b/waspc/src/Wasp/AI/GenerateNewProject/Operation.hs @@ -10,7 +10,6 @@ where import Data.Aeson (FromJSON) import Data.List (isPrefixOf) -import Data.Maybe (fromMaybe) import qualified Data.Text as T import GHC.Generics (Generic) import NeatInterpolation (trimming) @@ -180,16 +179,16 @@ instance Show OperationType where show Query = "query" data Operation = Operation - { opImpl :: OperationImpl, - opPlan :: Plan.Operation, - opType :: OperationType + { opImpl :: !OperationImpl, + opPlan :: !Plan.Operation, + opType :: !OperationType } deriving (Show) data OperationImpl = OperationImpl - { opWaspDecl :: String, - opJsImpl :: String, - opJsImports :: Maybe String + { opWaspDecl :: !String, + opJsImpl :: !String, + opJsImports :: !(Maybe String) } deriving (Generic, Show)