Skip to content

Commit

Permalink
Updated GPT models in Wasp AI (3.5 -> 4o).
Browse files Browse the repository at this point in the history
  • Loading branch information
Martinsos committed Sep 9, 2024
1 parent 23366a3 commit ed19fcc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 39 deletions.
6 changes: 6 additions & 0 deletions waspc/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.14.2 (2024-09-09)

Updated GPT models used in Wasp AI to latest models, since 3.5 are getting deprecated.

Default model used is now 4o (instead of old 4 + 3.5-turbo combo).

## 0.14.1 (2024-08-26)

### 🎉 New Features
Expand Down
16 changes: 8 additions & 8 deletions waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ createNewProjectInteractiveOnDisk waspProjectDir appName = do
"Choose GPT model(s) you want to use:"
$ NE.fromList
[ Interactive.Option
"gpt-4 (planning) + gpt-3.5-turbo (coding)"
(Just "Ok results. Cheap and fast. Best cost/benefit ratio.")
(ChatGPT.GPT_4_0613, ChatGPT.GPT_3_5_turbo_0125),
"gpt-4o (planning + coding)"
(Just "Good results. Cheap and fast. Best cost/benefit ratio.")
(ChatGPT.GPT_4o, ChatGPT.GPT_4o),
Interactive.Option
"gpt-4 (planning) + gpt-4-turbo-preview (coding)"
(Just "Possibly better results, but somewhat slower and somewhat more expensive (~2-3x).")
(ChatGPT.GPT_4_0613, ChatGPT.GPT_4_turbo_Preview),
"gpt-4 (planning) + gpt-4o (coding)"
(Just "Possibly better results, but somewhat slower and somewhat more expensive.")
(ChatGPT.GPT_4, ChatGPT.GPT_4o),
Interactive.Option
"gpt-4 (planning + coding)"
(Just "Best results, but quite slower and quite more expensive (~5x).")
(ChatGPT.GPT_4_0613, ChatGPT.GPT_4_0613)
(Just "Possibly best results, but quite slower and quite more expensive.")
(ChatGPT.GPT_4, ChatGPT.GPT_4)
]
temperature <-
liftIO $
Expand Down
4 changes: 2 additions & 2 deletions waspc/src/Wasp/AI/GenerateNewProject/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ codingChatGPTParams projectDetails =
GPT._temperature = Just $ fromMaybe 0.7 (projectDefaultGptTemperature $ _projectConfig projectDetails)
}
where
defaultCodingGptModel = GPT.GPT_3_5_turbo_0125
defaultCodingGptModel = GPT.GPT_4o

planningChatGPTParams :: NewProjectDetails -> ChatGPTParams
planningChatGPTParams projectDetails =
Expand All @@ -166,7 +166,7 @@ planningChatGPTParams projectDetails =
GPT._temperature = Just $ fromMaybe 0.7 (projectDefaultGptTemperature $ _projectConfig projectDetails)
}
where
defaultPlanningGptModel = GPT.GPT_4_0613
defaultPlanningGptModel = GPT.GPT_4o

fixingChatGPTParams :: ChatGPTParams -> ChatGPTParams
fixingChatGPTParams params = params {GPT._temperature = subtract 0.2 <$> GPT._temperature params}
Expand Down
44 changes: 16 additions & 28 deletions waspc/src/Wasp/AI/OpenAI/ChatGPT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module Wasp.AI.OpenAI.ChatGPT
ChatMessage (..),
ChatRole (..),
getChatResponseContent,
checkIfGpt4IsAvailable,
)
where

Expand Down Expand Up @@ -70,13 +69,6 @@ queryChatGPT apiKey params requestMessages = do
getChatResponseContent :: ChatResponse -> Text
getChatResponseContent = content . message . head . choices

checkIfGpt4IsAvailable :: OpenAIApiKey -> IO Bool
checkIfGpt4IsAvailable apiKey = do
let request =
HTTP.setRequestHeader "Authorization" [BSU.fromString $ "Bearer " <> apiKey] $
HTTP.parseRequest_ $ "GET https://api.openai.com/v1/models/" <> show GPT_4
(200 ==) . HTTP.getResponseStatusCode <$> HTTP.httpNoBody request

data ChatGPTParams = ChatGPTParams
{ _model :: !Model,
_temperature :: !(Maybe Float)
Expand All @@ -87,37 +79,33 @@ data ChatGPTParams = ChatGPTParams
deriving (Show)

data Model
= --
GPT_3_5_turbo -- Alias model
| GPT_3_5_turbo_0125
| GPT_3_5_turbo_1106
| --
GPT_4_turbo_Preview -- Alias model
| GPT_4_0125_Preview
| GPT_4_1106_Preview
| --
= -- New flagship model.
GPT_4o -- Alias model
| GPT_4o_2024_08_06
| -- Faster & cheaper version of the new flagship model.
GPT_4o_mini -- Alias model
| GPT_4o_mini_2024_07_18
| -- Old flagship model.
GPT_4 -- Alias model
| GPT_4_0613
| --
GPT_4_32k -- Alias model
| GPT_4_32k_0613
| -- Faster & cheaper version of the old flagship model.
GPT_4_turbo -- Alias model
| GPT_4_turbo_2024_04_09
deriving (Eq, Bounded, Enum)

instance Show Model where
show = modelOpenAiId

modelOpenAiId :: Model -> String
modelOpenAiId = \case
GPT_3_5_turbo -> "gpt-3.5-turbo"
GPT_3_5_turbo_0125 -> "gpt-3.5-turbo-0125"
GPT_3_5_turbo_1106 -> "gpt-3.5-turbo-1106"
GPT_4_turbo_Preview -> "gpt-4-turbo-preview"
GPT_4_0125_Preview -> "gpt-4-0125-preview"
GPT_4_1106_Preview -> "gpt-4-1106-preview"
GPT_4o -> "gpt-4o"
GPT_4o_2024_08_06 -> "gpt-4o-2024-08-06"
GPT_4o_mini -> "gpt-4o-mini"
GPT_4o_mini_2024_07_18 -> "gpt-4o-mini-2024-07-18"
GPT_4 -> "gpt-4"
GPT_4_0613 -> "gpt-4-0613"
GPT_4_32k -> "gpt-4-32k"
GPT_4_32k_0613 -> "gpt-4-32k-0613"
GPT_4_turbo -> "gpt-4-turbo"
GPT_4_turbo_2024_04_09 -> "gpt-4-turbo-2024-04-09"

instance FromJSON Model where
parseJSON = Aeson.withText "Model" $ \t ->
Expand Down
2 changes: 1 addition & 1 deletion waspc/waspc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cabal-version: 2.4
-- Consider using hpack, or maybe even hpack-dhall.

name: waspc
version: 0.14.1
version: 0.14.2
description: Please see the README on GitHub at <https://github.com/wasp-lang/wasp/waspc#readme>
homepage: https://github.com/wasp-lang/wasp/waspc#readme
bug-reports: https://github.com/wasp-lang/wasp/issues
Expand Down

0 comments on commit ed19fcc

Please sign in to comment.