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

Allow Model switching based on User Tier #1151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

debanjum
Copy link
Member

@debanjum debanjum commented Apr 5, 2025

Overview

Enable free tier users to chat with any AI model made available on free tier
of production deployments like like Khoj cloud.

Previously model switching was completely disabled for users on free tier.

Details

  • Track price tier of each Chat, Speech, Image, Voice AI model in DB
  • Update API to allow free tier users to switch between free models
  • Update web app to allow model switching on agent creation, settings
    chat page (via right side pane), even for free tier users.

debanjum added 2 commits April 4, 2025 20:21
Enables users on free plan to choose AI models marked for free tier
- Update API to allow free tier users to switch between free models
- Update web app to allow model switching on agent creation, settings
  chat page (via right side pane), even for free tier users.

Previously the model switching APIs and UX fields on web app were
completely disabled for free tier users
@debanjum debanjum changed the title # Allow Model switching based on User Tier Allow Model switching based on User Tier Apr 5, 2025
@debanjum debanjum requested a review from sabaimran April 5, 2025 05:55
Copy link
Member

@sabaimran sabaimran left a comment

Choose a reason for hiding this comment

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

nice! will be awesome to extend model switching to unsubbed users.

>
{model.name}
{model.name} {model.tier === "standard" && <span className="text-green-500 ml-2">(Pro)</span>}
Copy link
Member

Choose a reason for hiding this comment

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

Let's be consistent in naming?

Suggested change
{model.name} {model.tier === "standard" && <span className="text-green-500 ml-2">(Pro)</span>}
{model.name} {model.tier === "standard" && <span className="text-green-500 ml-2">(Futurist)</span>}

{modelOption.name}{" "}
{modelOption.tier === "standard" && (
<span className="text-green-500 ml-2">
(Pro)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above

>
{item.name}
{item.name} {item.tier === "standard" && <span className="text-green-500 ml-2">(Pro)</span>}
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above

config = UserConversationConfig.objects.filter(user=user).first()
if config:
return config.setting
subscribed = is_user_subscribed(user)
if not subscribed:
return ConversationAdapters.get_default_chat_model(user)
Copy link
Member

Choose a reason for hiding this comment

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

This check should come before the config check, in case the user is not subscribed & had an older setting that's using an upgraded chat model. We can also use this function to opportunistically correct that mismatch.

@@ -202,11 +202,16 @@ class ModelType(models.TextChoices):
ANTHROPIC = "anthropic"
GOOGLE = "google"

class PriceTier(models.TextChoices):
Copy link
Member

Choose a reason for hiding this comment

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

We can define the PriceTier class outside of the data model class so that it can be reused across data models.

@@ -452,6 +462,17 @@ class ServerChatSettings(DbBaseModel):
WebScraper, on_delete=models.CASCADE, default=None, null=True, blank=True, related_name="web_scraper"
)

def clean(self):
error = {}
Copy link
Member

Choose a reason for hiding this comment

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

Rather than throwing an error, let's correct it automatically? If the admin ends up here, it's most likely a mistake on their part, so we can gracefully correct it imo.

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.

2 participants