Set usage limits on the research mode

This commit is contained in:
sabaimran 2024-11-01 10:29:33 -07:00
parent 3ea94ac972
commit 0145b2a366
2 changed files with 4 additions and 4 deletions

View file

@ -76,7 +76,7 @@ from khoj.utils.rawconfig import FileFilterRequest, FilesFilterRequest, Location
# Initialize Router # Initialize Router
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
conversation_command_rate_limiter = ConversationCommandRateLimiter( conversation_command_rate_limiter = ConversationCommandRateLimiter(
trial_rate_limit=100, subscribed_rate_limit=6000, slug="command" trial_rate_limit=20, subscribed_rate_limit=75, slug="command"
) )
@ -555,10 +555,10 @@ async def chat(
common: CommonQueryParams, common: CommonQueryParams,
body: ChatRequestBody, body: ChatRequestBody,
rate_limiter_per_minute=Depends( rate_limiter_per_minute=Depends(
ApiUserRateLimiter(requests=60, subscribed_requests=200, window=60, slug="chat_minute") ApiUserRateLimiter(requests=5, subscribed_requests=20, window=60, slug="chat_minute")
), ),
rate_limiter_per_day=Depends( rate_limiter_per_day=Depends(
ApiUserRateLimiter(requests=600, subscribed_requests=6000, window=60 * 60 * 24, slug="chat_day") ApiUserRateLimiter(requests=100, subscribed_requests=600, window=60 * 60 * 24, slug="chat_day")
), ),
image_rate_limiter=Depends(ApiImageRateLimiter(max_images=10, max_combined_size_mb=20)), image_rate_limiter=Depends(ApiImageRateLimiter(max_images=10, max_combined_size_mb=20)),
): ):

View file

@ -1372,7 +1372,7 @@ class ConversationCommandRateLimiter:
self.slug = slug self.slug = slug
self.trial_rate_limit = trial_rate_limit self.trial_rate_limit = trial_rate_limit
self.subscribed_rate_limit = subscribed_rate_limit self.subscribed_rate_limit = subscribed_rate_limit
self.restricted_commands = [ConversationCommand.Online, ConversationCommand.Image] self.restricted_commands = [ConversationCommand.Research]
async def update_and_check_if_valid(self, request: Request, conversation_command: ConversationCommand): async def update_and_check_if_valid(self, request: Request, conversation_command: ConversationCommand):
if state.billing_enabled is False: if state.billing_enabled is False: