From 8250afeb8efd3716230159daac617123de191dd5 Mon Sep 17 00:00:00 2001
From: Martin Sosic
Date: Mon, 9 Sep 2024 16:27:04 +0200
Subject: [PATCH 1/2] Updated GPT models in Wasp AI (3.5 -> 4o).
---
mage/Dockerfile | 2 +-
mage/src/client/components/Faq.jsx | 15 ++-----
mage/src/client/pages/ResultPage.jsx | 8 ++--
waspc/ChangeLog.md | 6 +++
.../Wasp/Cli/Command/CreateNewProject/AI.hs | 16 +++----
.../waspBuild-golden/waspBuild/main.wasp | 2 +-
.../waspCompile-golden/waspCompile/main.wasp | 2 +-
.../waspComplexTest/main.wasp | 2 +-
.../waspJob-golden/waspJob/main.wasp | 2 +-
.../waspMigrate-golden/waspMigrate/main.wasp | 2 +-
.../waspNew-golden/waspNew/main.wasp | 2 +-
.../src/Wasp/AI/GenerateNewProject/Common.hs | 4 +-
waspc/src/Wasp/AI/GenerateNewProject/Plan.hs | 2 +-
.../Wasp/AI/GenerateNewProject/WaspFile.hs | 1 +
waspc/src/Wasp/AI/OpenAI/ChatGPT.hs | 44 +++++++------------
waspc/waspc.cabal | 2 +-
16 files changed, 50 insertions(+), 62 deletions(-)
diff --git a/mage/Dockerfile b/mage/Dockerfile
index 951bec52c0..5f59214d0d 100644
--- a/mage/Dockerfile
+++ b/mage/Dockerfile
@@ -41,7 +41,7 @@ RUN cd .wasp/build/server && npm run bundle
# TODO: Use pm2?
# TODO: Use non-root user (node).
FROM base AS server-production
-RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.14.0
+RUN curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v 0.14.2
ENV PATH "$PATH:/root/.local/bin"
ENV NODE_ENV production
WORKDIR /app
diff --git a/mage/src/client/components/Faq.jsx b/mage/src/client/components/Faq.jsx
index b472e668e5..045e6de292 100644
--- a/mage/src/client/components/Faq.jsx
+++ b/mage/src/client/components/Faq.jsx
@@ -75,23 +75,16 @@ const faqs = [
- We use GPT4 during the planning phase, since that is the most critical step, and then use GPT3.5 for the rest of the steps.
- Although using GPT4 exclusively does give better results, we use a mix to keep the costs, generation time, and bandwidth acceptable (due to pricing and rate limits of GPT4).
+ We use GPT4o for all the phases at the moment of writing, as it gives the best ratio of quality / cost.
-
-
- However, in the future, when GPT4 becomes cheaper / faster, it would make sense to switch to it completely, since it does generate better code!
},
{
- question: '[Advanced] Can I use GPT4 for the whole app? / Can I run Mage locally?',
+ question: '[Advanced] Can I choose GPT model? / Can I run Mage locally?',
answer:
- As mentioned above, we use GPT4 + GPT3.5 for practical reasons, even though using GPT4 exclusively does give better results.
-
- However, if you have access yourself to the OpenAI API, you can use GPT4 for the whole app, or play with adjusting the temperature, by running the Wasp GPT code agent locally! So same thing like Mage, but via CLI.
- Note: generating an app usually consumes from 20k to 50k tokens, which is then approximately $1 to $2 per app with the current GPT4 pricing (Jul 11th 2023).
+ If you have access yourself to the OpenAI API, you can choose GPT model for the whole app, or play with adjusting the temperature, by running the Wasp GPT code agent locally! So same thing like Mage, but via CLI.
- To run Wasp AI (Mage) locally, make sure you have wasp {'>='}v0.12 installed and just run:
+ To run Wasp AI (Mage) locally, make sure you have wasp installed and just run:
wasp new
diff --git a/mage/src/client/pages/ResultPage.jsx b/mage/src/client/pages/ResultPage.jsx
index 768e1ef3dd..33fced6e6a 100644
--- a/mage/src/client/pages/ResultPage.jsx
+++ b/mage/src/client/pages/ResultPage.jsx
@@ -455,11 +455,11 @@ export function OnSuccessModal({ isOpen, setIsOpen, appGenerationResult }) {
return {children};
}
- function calcCostForGpt_3_5_Turbo_0125(numTokensSpent) {
+ function calcCostForGpt_4o(numTokensSpent) {
const estimatedInputTokenShare = 0.8;
const estimatedOutputTokenShare = 1 - estimatedInputTokenShare;
- const costInUsdForMillionInputTokens = 0.5; // This is price for GPT 3.5 Turbo 0125.
- const costInUsdForMillionOutputTokens = 1.5; // This is price for GPT 3.5 Turbo 0125.
+ const costInUsdForMillionInputTokens = 5.0; // This is price for gpt-4o-2024-05-13.
+ const costInUsdForMillionOutputTokens = 15.0; // This is price for gpt-4o-2024-05-13.
const costInUsdForMillionTokens =
costInUsdForMillionInputTokens * estimatedInputTokenShare +
costInUsdForMillionOutputTokens * estimatedOutputTokenShare;
@@ -491,7 +491,7 @@ export function OnSuccessModal({ isOpen, setIsOpen, appGenerationResult }) {
Cost to generate your app: |
{" "}
- {`~$${calcCostForGpt_3_5_Turbo_0125(
+ {`~$${calcCostForGpt_4o(
Number(numTokensSpent)
)}`}{" "}
|
diff --git a/waspc/ChangeLog.md b/waspc/ChangeLog.md
index 3ee26f32fc..64605414ac 100644
--- a/waspc/ChangeLog.md
+++ b/waspc/ChangeLog.md
@@ -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
diff --git a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs
index 64fa8237cd..45a3ae5b03 100644
--- a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs
+++ b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs
@@ -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 $
diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/main.wasp b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/main.wasp
index 1d5e7fc6a1..94891d4615 100644
--- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/main.wasp
+++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/main.wasp
@@ -1,6 +1,6 @@
app waspBuild {
wasp: {
- version: "^0.14.1"
+ version: "^0.14.2"
},
title: "waspBuild"
}
diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/main.wasp b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/main.wasp
index 6e0a63a5de..109925d543 100644
--- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/main.wasp
+++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/main.wasp
@@ -1,6 +1,6 @@
app waspCompile {
wasp: {
- version: "^0.14.1"
+ version: "^0.14.2"
},
title: "waspCompile"
}
diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/main.wasp b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/main.wasp
index 4148dd52a2..2a1cc49656 100644
--- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/main.wasp
+++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/main.wasp
@@ -1,6 +1,6 @@
app waspComplexTest {
wasp: {
- version: "^0.14.1"
+ version: "^0.14.2"
},
auth: {
userEntity: User,
diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/main.wasp b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/main.wasp
index 1deb5bca3a..cfde7303cb 100644
--- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/main.wasp
+++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/main.wasp
@@ -1,6 +1,6 @@
app waspJob {
wasp: {
- version: "^0.14.1"
+ version: "^0.14.2"
},
title: "waspJob"
}
diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/main.wasp b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/main.wasp
index d2692a3560..5b1bd22700 100644
--- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/main.wasp
+++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/main.wasp
@@ -1,6 +1,6 @@
app waspMigrate {
wasp: {
- version: "^0.14.1"
+ version: "^0.14.2"
},
title: "waspMigrate"
}
diff --git a/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/main.wasp b/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/main.wasp
index 5ea5f45250..e3555de634 100644
--- a/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/main.wasp
+++ b/waspc/e2e-test/test-outputs/waspNew-golden/waspNew/main.wasp
@@ -1,6 +1,6 @@
app waspNew {
wasp: {
- version: "^0.14.1"
+ version: "^0.14.2"
},
title: "waspNew"
}
diff --git a/waspc/src/Wasp/AI/GenerateNewProject/Common.hs b/waspc/src/Wasp/AI/GenerateNewProject/Common.hs
index b8345a2032..a003436a87 100644
--- a/waspc/src/Wasp/AI/GenerateNewProject/Common.hs
+++ b/waspc/src/Wasp/AI/GenerateNewProject/Common.hs
@@ -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 =
@@ -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}
diff --git a/waspc/src/Wasp/AI/GenerateNewProject/Plan.hs b/waspc/src/Wasp/AI/GenerateNewProject/Plan.hs
index 2ccafdf9c3..b202ee4eb0 100644
--- a/waspc/src/Wasp/AI/GenerateNewProject/Plan.hs
+++ b/waspc/src/Wasp/AI/GenerateNewProject/Plan.hs
@@ -44,7 +44,7 @@ type PlanRule = String
generatePlan :: NewProjectDetails -> [PlanRule] -> CodeAgent Plan
generatePlan newProjectDetails planRules = do
writeToLog $
- "\n" <> L.styled L.Generating "Generating" <> " plan (slowest step, usually takes 30 to 90 seconds)"
+ "\n" <> L.styled L.Generating "Generating" <> " plan (slowest step, can take up to 90 seconds for slower models)"
<> L.styled (L.Custom [Term.Blink]) "..."
initialPlan <- queryChatGPTForJSON (planningChatGPTParams newProjectDetails) chatMessages
writeToLog $ "Initial plan generated!\n" <> L.fromText (summarizePlan initialPlan)
diff --git a/waspc/src/Wasp/AI/GenerateNewProject/WaspFile.hs b/waspc/src/Wasp/AI/GenerateNewProject/WaspFile.hs
index 5149bcacf4..3d0ef8f76d 100644
--- a/waspc/src/Wasp/AI/GenerateNewProject/WaspFile.hs
+++ b/waspc/src/Wasp/AI/GenerateNewProject/WaspFile.hs
@@ -116,6 +116,7 @@ fixWaspFile newProjectDetails waspFilePath plan = do
Be careful not to do that.
- We are using SQLite as a database for Prisma, so we can't use scalar arrays in PSL, like `String[]`,
as those are not supported in SQLite. We can of course normally use arrays of other models, like `Task[]`.
+ - Wasp file should not contain any `entity` declarations! That was ok in older Wasp versions, but now entities are described in prisma.schema file, and not in wasp file.
With this in mind, generate a new, fixed wasp file.
Try not to do big changes like changing names, removing/adding declarations and similar, those are usually correct, focus more on obvious, smaller errors.
diff --git a/waspc/src/Wasp/AI/OpenAI/ChatGPT.hs b/waspc/src/Wasp/AI/OpenAI/ChatGPT.hs
index 9c21219f33..9acb2306ec 100644
--- a/waspc/src/Wasp/AI/OpenAI/ChatGPT.hs
+++ b/waspc/src/Wasp/AI/OpenAI/ChatGPT.hs
@@ -12,7 +12,6 @@ module Wasp.AI.OpenAI.ChatGPT
ChatMessage (..),
ChatRole (..),
getChatResponseContent,
- checkIfGpt4IsAvailable,
)
where
@@ -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)
@@ -87,20 +79,18 @@ 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
@@ -108,16 +98,14 @@ instance Show Model where
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 ->
diff --git a/waspc/waspc.cabal b/waspc/waspc.cabal
index 1560cc70c6..24feaa42d1 100644
--- a/waspc/waspc.cabal
+++ b/waspc/waspc.cabal
@@ -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
homepage: https://github.com/wasp-lang/wasp/waspc#readme
bug-reports: https://github.com/wasp-lang/wasp/issues
From 9c330298984dd6aa34b2d31fe3193ed679f16360 Mon Sep 17 00:00:00 2001
From: Martin Sosic
Date: Mon, 9 Sep 2024 19:00:33 +0200
Subject: [PATCH 2/2] Fixed e2e tests for jobs (parenthesses).
---
.../.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts | 4 ++--
.../.wasp/out/sdk/wasp/dist/server/jobs/returnHelloJob.d.ts | 4 ++--
.../.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts
index 0b1d0b120a..5bfe012bf8 100644
--- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts
+++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts
@@ -16,7 +16,7 @@ export declare const mySpecialJob: {
readonly pgBoss: {
readonly cancel: () => ReturnType;
readonly resume: () => ReturnType;
- readonly details: () => Promise, "output" | "state"> & {
+ readonly details: () => Promise, "output" | "state"> & ({
data: JSONObject;
} & ({
state: "failed";
@@ -35,7 +35,7 @@ export declare const mySpecialJob: {
} | {
value: true;
};
- })>;
+ }))>;
};
readonly job: import("./core/job").Job;
readonly jobId: string;
diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/returnHelloJob.d.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/returnHelloJob.d.ts
index 1cdfa14ed1..edd67b776c 100644
--- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/returnHelloJob.d.ts
+++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/server/jobs/returnHelloJob.d.ts
@@ -20,7 +20,7 @@ export declare const returnHelloJob: {
readonly pgBoss: {
readonly cancel: () => ReturnType;
readonly resume: () => ReturnType;
- readonly details: () => Promise, "output" | "state"> & {
+ readonly details: () => Promise, "output" | "state"> & ({
data: JSONObject;
} & ({
state: "failed";
@@ -39,7 +39,7 @@ export declare const returnHelloJob: {
} | {
value: true;
};
- })>;
+ }))>;
};
readonly job: import("./core/job").Job;
readonly jobId: string;
diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts
index 0b1d0b120a..5bfe012bf8 100644
--- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts
+++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/server/jobs/mySpecialJob.d.ts
@@ -16,7 +16,7 @@ export declare const mySpecialJob: {
readonly pgBoss: {
readonly cancel: () => ReturnType;
readonly resume: () => ReturnType;
- readonly details: () => Promise, "output" | "state"> & {
+ readonly details: () => Promise, "output" | "state"> & ({
data: JSONObject;
} & ({
state: "failed";
@@ -35,7 +35,7 @@ export declare const mySpecialJob: {
} | {
value: true;
};
- })>;
+ }))>;
};
readonly job: import("./core/job").Job;
readonly jobId: string;