mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Litellm user daily activity allow non admin usage (#9695)
* feat(internal_user_endpoints.py): allow non-admin to view their own usage via `/user/daily/activity` route * fix(leftnav.tsx): allow users to view their own usage via new_usage.tsx allows internal users to see their usage via new api Handles 1m+ spend logs scenario * fix(leftnav.tsx): allow all users to see new usage tab
This commit is contained in:
parent
4f9805c9aa
commit
5a3eab0247
3 changed files with 68 additions and 46 deletions
|
@ -1480,6 +1480,14 @@ async def get_user_daily_activity(
|
|||
if api_key:
|
||||
where_conditions["api_key"] = api_key
|
||||
|
||||
if (
|
||||
user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN
|
||||
and user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY
|
||||
):
|
||||
where_conditions[
|
||||
"user_id"
|
||||
] = user_api_key_dict.user_id # only allow access to own data
|
||||
|
||||
# Get total count for pagination
|
||||
total_count = await prisma_client.db.litellm_dailyuserspend.count(
|
||||
where=where_conditions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue