From 1f4a6502bb9ceb86a676f6ebfab5d8f319ded10e Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 30 May 2024 12:34:09 -0700 Subject: [PATCH] fix: rate limit --- pipelines/examples/rate_limit_filter_pipeline.py | 7 ++++--- requirements.txt | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pipelines/examples/rate_limit_filter_pipeline.py b/pipelines/examples/rate_limit_filter_pipeline.py index eb40041..f875d23 100644 --- a/pipelines/examples/rate_limit_filter_pipeline.py +++ b/pipelines/examples/rate_limit_filter_pipeline.py @@ -108,9 +108,10 @@ class Pipeline: print(body) print(user) - user_id = user["id"] if user and "id" in user else "default_user" - if self.rate_limited(user_id): - raise Exception("Rate limit exceeded. Please try again later.") + if user["role"] == "user": + user_id = user["id"] if user and "id" in user else "default_user" + if self.rate_limited(user_id): + raise Exception("Rate limit exceeded. Please try again later.") self.log_request(user_id) return body diff --git a/requirements.txt b/requirements.txt index 02b9ed2..23d93fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,8 +13,11 @@ requests==2.32.2 aiohttp==3.9.5 httpx + +# AI libraries openai anthropic +google-generativeai # Database pymongo @@ -60,6 +63,7 @@ playwright beautifulsoup4 # Misc +APScheduler youtube_dl twilio streamlit \ No newline at end of file