[Fix proxy perf] Use correct cache key when reading from redis cache (#5928)

* fix parallel request limiter use correct user id

* async def get_user_object(
fix

* use safe get_internal_user_object

* fix store internal users in redis correctly
This commit is contained in:
Ishaan Jaff 2024-09-26 18:13:35 -07:00 committed by GitHub
parent 8b6eec1951
commit 58171f35ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 51 additions and 7 deletions

View file

@ -295,7 +295,13 @@ async def test_pre_call_hook_user_tpm_limits():
local_cache = DualCache()
# create user with tpm/rpm limits
user_id = "test-user"
user_obj = {"tpm_limit": 9, "rpm_limit": 10}
user_obj = {
"tpm_limit": 9,
"rpm_limit": 10,
"user_id": user_id,
"user_email": "user_email",
"max_budget": None,
}
local_cache.set_cache(key=user_id, value=user_obj)
@ -331,6 +337,7 @@ async def test_pre_call_hook_user_tpm_limits():
## Expected cache val: {"current_requests": 0, "current_tpm": 0, "current_rpm": 1}
try:
print("cache=local_cache", local_cache.in_memory_cache.cache_dict)
await parallel_request_handler.async_pre_call_hook(
user_api_key_dict=user_api_key_dict,
cache=local_cache,