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

FISH-9719 Implement Security filters to Suspend Usage When OpenAI API Max Count is Reached #83

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

Conversation

jGauravGupta
Copy link
Contributor

@jGauravGupta jGauravGupta commented Dec 20, 2024

Add IP Rate Limiting with Scheduled Cleanup

Description

  • Introduced IP rate limiting for specific REST endpoints using JAX-RS filters.
  • Configurable via MicroProfile Config (rate.limit (60), rate.time.window (1 Hour)).
  • Utilized ManagedScheduledExecutorService for periodic cleanup of stale log entries.

Key Changes

  1. Added IpRateLimitFilter to restrict Generative AI requests per IP.
  2. Implemented scheduled cleanup to optimize memory usage.

How It Works

  • Tracks API calls per IP in a ConcurrentHashMap.
  • Blocks requests exceeding the limit within the configured time window.
  • Periodic cleanup task removes outdated entries.

Copy link

@simonladen simonladen left a comment

Choose a reason for hiding this comment

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

Tested locally.
The limit applies only to the ER diagram (app generation is filtered separately and differently)
One minor issue raised: when the user has reached the limit, and they make a new request to modify the diagram via AI, the pop up appears but the loading bar is visible in the background. The issue will be raised separately as it would require to design and modify the pop up used.

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