Skip to content

Commit

Permalink
free trial logic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RomneyDa committed Jan 20, 2025
1 parent 709e597 commit 442b863
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion core/config/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const LOCAL_ONBOARDING_CHAT_MODEL = "llama3.1:8b";
export const LOCAL_ONBOARDING_CHAT_TITLE = "Llama 3.1 8B";

/**
* We set the "best" chat + autocopmlete models by default
* We set the "best" chat + autocomplete models by default
* whenever a user doesn't have a config.json
*/
export function setupBestConfig(
Expand Down
4 changes: 2 additions & 2 deletions extensions/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions gui/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,7 @@ const Layout = () => {
"incrementFtc",
async () => {
const u = getLocalStorage("ftc");
if (u) {
setLocalStorage("ftc", u + 1);
} else {
setLocalStorage("ftc", 1);
}
setLocalStorage("ftc", (u ?? 0) + 1);
},
[],
);
Expand Down
27 changes: 12 additions & 15 deletions gui/src/pages/gui/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,18 @@ export function Chat() {
editorToClearOnSend?: Editor,
) => {
if (defaultModel?.provider === "free-trial") {
const u = getLocalStorage("ftc");
if (u) {
setLocalStorage("ftc", u + 1);

if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
onboardingCard.open("Best");
posthog?.capture("ftc_reached");
ideMessenger.ide.showToast(
"info",
"You've reached the free trial limit. Please configure a model to continue.",
);
return;
}
} else {
setLocalStorage("ftc", 1);
const u = getLocalStorage("ftc") ?? 0;
setLocalStorage("ftc", u + 1);
if (u === FREE_TRIAL_LIMIT_REQUESTS) {
posthog?.capture("ftc_reached");
}
if (u >= FREE_TRIAL_LIMIT_REQUESTS) {
onboardingCard.open("Best");
ideMessenger.ide.showToast(
"info",
"You've reached the free trial limit. Please configure a model to continue.",
);
return;
}
}

Expand Down

0 comments on commit 442b863

Please sign in to comment.