Skip to content

Conversation

@jcabrero
Copy link
Member

@jcabrero jcabrero commented Sep 10, 2025

This PR adds a new way of dealing with rate limits in a generic way that allows us to add more and new rate limits to the database without necessarily creating a new DB column always.

@jcabrero jcabrero force-pushed the feat/web_search_rate_limits branch 2 times, most recently from 53af8a7 to d799fca Compare September 10, 2025 16:17
@jcabrero jcabrero marked this pull request as ready for review September 11, 2025 08:01
@jcabrero jcabrero requested review from blefo and Copilot September 11, 2025 08:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a generic rate limiting system to replace the previous fixed database schema approach. The changes introduce a flexible JSON-based rate limits configuration that allows for easy addition of new rate limit types without requiring database schema changes.

  • Replaces individual rate limit columns with a single JSON column for flexible rate limit storage
  • Adds web search rate limiting functionality with time-based and for-good limits
  • Introduces comprehensive integration tests for the new rate limiting system

Reviewed Changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/nilai_api/test_rate_limiting.py Updates test fixtures to use new RateLimits model structure
tests/unit/nilai_api/routers/test_private.py Adds rate_limits mock data to user fixtures
tests/unit/nilai_api/routers/test_nildb_endpoints.py Updates mock users to include rate_limits configuration
tests/unit/nilai_api/auth/test_strategies.py Updates authentication strategy tests with new rate limits structure
tests/unit/nilai_api/auth/test_auth.py Adds rate limits to mock user models
tests/integration/nilai_api/test_users_db_integration.py Comprehensive integration tests for JSON-based rate limits CRUD operations
tests/integration/nilai_api/init.py Package initialization for integration tests
tests/integration/conftest.py Test configuration and fixtures for database integration tests
tests/integration/init.py Package initialization file
pyproject.toml Updates testcontainers dependency version
nilai-api/src/nilai_api/routers/private.py Adds web_search_calls parameter to query logging
nilai-api/src/nilai_api/rate_limiting.py Refactors rate limiting to use new RateLimits model and adds web search rate limiting
nilai-api/src/nilai_api/db/users.py Introduces RateLimits model and replaces individual rate limit columns with JSON storage
nilai-api/src/nilai_api/db/logs.py Adds web_search_calls tracking to query logs
nilai-api/src/nilai_api/config/rate_limiting.py Updates rate limiting configuration structure
nilai-api/src/nilai_api/config/config.yaml Adds for-good rate limit configuration options
nilai-api/src/nilai_api/commands/add_user.py Updates user creation command to use new rate limits structure
nilai-api/examples/users.py Updates example to include web_search_calls parameter
nilai-api/alembic/versions/9ddf28cf6b6f_feat_new_user_config_and_web_rate_limits.py Database migration to implement the new rate limits schema
.github/workflows/cicd.yml Adds integration test execution to CI/CD pipeline

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jcabrero jcabrero changed the base branch from feat/new_config to main September 12, 2025 14:04
@jcabrero jcabrero force-pushed the feat/web_search_rate_limits branch from 7227cc5 to 9ea6546 Compare September 12, 2025 14:11
@jcabrero jcabrero merged commit 5ad2ee4 into main Sep 12, 2025
8 checks passed
@jcabrero jcabrero linked an issue Oct 8, 2025 that may be closed by this pull request
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.

Add rate limit for web search feature

2 participants