Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show free mode banner if an API key has been added (check settings.providers.length) #628

Merged
merged 3 commits into from
May 5, 2024

Conversation

rjwignar
Copy link
Collaborator

@rjwignar rjwignar commented May 4, 2024

This fixes #544.

Sorry for sitting on this for a while. There's one concern I have that I wasn't able to figure out.
More details below.

Background

We show a "You are using the free model..." banner when the user first comes to ChatCraft and we want to let them know about adding more providers for better features.
However, even after you add an OpenAI or OpenRouter provider, when you switch back to the free provider, we show the banner again.

Solution

If you run console.log(settings) you'll see that settings has a property called providers.
settings.providers is empty when no provider API keys are added (length 0):
image

...and is populated when you add an API key:
image

This PR does the following:

  • adds a useEffect that toggles the Free Banner based on the length of settings.provider:
    • length=0 (no API Keys added) - Show banner
    • length>0 (1+ API Key(s) added) - Don't show banner
  • defaults showAlert to false so banner doesn't appear temporarily when user opens ChatCraft after adding a provider/API key

My concern

The useMemo no longer checks the current provider when showing the Free Mode banner.
This means if a user has a paid provider (like OpenAI) as the current provider and removes their API key, the Free Mode banner will re-appear, but the currentProvider will still be OpenAI:
freeBannerIgnoreCurrentProvider

We can revert back to the original behaviour if that's preferred (don't show Free Mode if Current Provider is a Paid provider):
freeBannerCheckCurrentProvider.

I'd like some opinions on this.

@rjwignar rjwignar self-assigned this May 4, 2024
Copy link

cloudflare-workers-and-pages bot commented May 4, 2024

Deploying chatcraft-org with  Cloudflare Pages  Cloudflare Pages

Latest commit: aae8ffe
Status: ✅  Deploy successful!
Preview URL: https://65c73392.console-overthinker-dev.pages.dev
Branch Preview URL: https://issue-544.console-overthinker-dev.pages.dev

View logs

Copy link
Collaborator

@humphd humphd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the right behaviour. Once you've used the app for a bit, and played around with providers, we don't need to bother you any more with whether this is the free one or not.

@rjwignar rjwignar merged commit 54f7cce into main May 5, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't show "free mode" banner when multiple providers are set
2 participants