mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Update Khoj cloud trial period to a fortnight instead of a week
- Improve rate limit error message wording - Make the "too many requests" error message more robust. Should throw that exception fix self.request >= self.subscribed_requests because upgrading wouldn't fix this rate limiting
This commit is contained in:
@@ -219,7 +219,7 @@ def subscription_to_state(subscription: Subscription) -> str:
|
||||
return SubscriptionState.INVALID.value
|
||||
elif subscription.type == Subscription.Type.TRIAL:
|
||||
# Trial subscription is valid for 7 days
|
||||
if datetime.now(tz=timezone.utc) - subscription.created_at > timedelta(days=7):
|
||||
if datetime.now(tz=timezone.utc) - subscription.created_at > timedelta(days=14):
|
||||
return SubscriptionState.EXPIRED.value
|
||||
|
||||
return SubscriptionState.TRIAL.value
|
||||
|
||||
@@ -430,14 +430,14 @@ class ApiUserRateLimiter:
|
||||
if subscribed and count_requests >= self.subscribed_requests:
|
||||
raise HTTPException(status_code=429, detail="Slow down! Too Many Requests")
|
||||
if not subscribed and count_requests >= self.requests:
|
||||
if self.subscribed_requests == self.requests:
|
||||
if self.requests >= self.subscribed_requests:
|
||||
raise HTTPException(
|
||||
status_code=429,
|
||||
detail="Slow down! Too Many Requests",
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=429,
|
||||
detail="We're glad you're enjoying Khoj! You've exceeded your usage limit for today. Come back tomorrow or subscribe to increase your rate limit via [your settings](https://app.khoj.dev/config).",
|
||||
detail="We're glad you're enjoying Khoj! You've exceeded your usage limit for today. Come back tomorrow or subscribe to increase your usage limit via [your settings](https://app.khoj.dev/config).",
|
||||
)
|
||||
|
||||
# Add the current request to the cache
|
||||
@@ -476,7 +476,7 @@ class ConversationCommandRateLimiter:
|
||||
if not subscribed and count_requests >= self.trial_rate_limit:
|
||||
raise HTTPException(
|
||||
status_code=429,
|
||||
detail=f"We're glad you're enjoying Khoj! You've exceeded your `/{conversation_command.value}` command usage limit for today. You can increase your rate limit via [your settings](https://app.khoj.dev/config).",
|
||||
detail=f"We're glad you're enjoying Khoj! You've exceeded your `/{conversation_command.value}` command usage limit for today. Subscribe to increase your usage limit via [your settings](https://app.khoj.dev/config).",
|
||||
)
|
||||
await UserRequests.objects.acreate(user=user, slug=command_slug)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user