mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01: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:
parent
05c1903784
commit
6283d9fe83
2 changed files with 4 additions and 4 deletions
|
@ -219,7 +219,7 @@ def subscription_to_state(subscription: Subscription) -> str:
|
||||||
return SubscriptionState.INVALID.value
|
return SubscriptionState.INVALID.value
|
||||||
elif subscription.type == Subscription.Type.TRIAL:
|
elif subscription.type == Subscription.Type.TRIAL:
|
||||||
# Trial subscription is valid for 7 days
|
# 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.EXPIRED.value
|
||||||
|
|
||||||
return SubscriptionState.TRIAL.value
|
return SubscriptionState.TRIAL.value
|
||||||
|
|
|
@ -430,14 +430,14 @@ class ApiUserRateLimiter:
|
||||||
if subscribed and count_requests >= self.subscribed_requests:
|
if subscribed and count_requests >= self.subscribed_requests:
|
||||||
raise HTTPException(status_code=429, detail="Slow down! Too Many Requests")
|
raise HTTPException(status_code=429, detail="Slow down! Too Many Requests")
|
||||||
if not subscribed and count_requests >= self.requests:
|
if not subscribed and count_requests >= self.requests:
|
||||||
if self.subscribed_requests == self.requests:
|
if self.requests >= self.subscribed_requests:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=429,
|
status_code=429,
|
||||||
detail="Slow down! Too Many Requests",
|
detail="Slow down! Too Many Requests",
|
||||||
)
|
)
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=429,
|
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
|
# Add the current request to the cache
|
||||||
|
@ -476,7 +476,7 @@ class ConversationCommandRateLimiter:
|
||||||
if not subscribed and count_requests >= self.trial_rate_limit:
|
if not subscribed and count_requests >= self.trial_rate_limit:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=429,
|
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)
|
await UserRequests.objects.acreate(user=user, slug=command_slug)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue