mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
feat - get all unique end_users
This commit is contained in:
parent
9f29dbaed6
commit
f7f1ce9345
1 changed files with 32 additions and 0 deletions
|
@ -8917,6 +8917,38 @@ async def global_spend_per_team():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
"/global/all_end_users",
|
||||||
|
tags=["Budget & Spend Tracking"],
|
||||||
|
dependencies=[Depends(user_api_key_auth)],
|
||||||
|
include_in_schema=False,
|
||||||
|
)
|
||||||
|
async def global_view_all_end_users():
|
||||||
|
"""
|
||||||
|
[BETA] This is a beta endpoint. It will change.
|
||||||
|
|
||||||
|
Use this to just get all the unique `end_users`
|
||||||
|
"""
|
||||||
|
global prisma_client
|
||||||
|
|
||||||
|
if prisma_client is None:
|
||||||
|
raise HTTPException(status_code=500, detail={"error": "No db connected"})
|
||||||
|
|
||||||
|
sql_query = """
|
||||||
|
SELECT DISTINCT end_user FROM "LiteLLM_SpendLogs"
|
||||||
|
"""
|
||||||
|
|
||||||
|
db_response = await prisma_client.db.query_raw(query=sql_query)
|
||||||
|
if db_response is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
_end_users = []
|
||||||
|
for row in db_response:
|
||||||
|
_end_users.append(row["end_user"])
|
||||||
|
|
||||||
|
return {"end_users": _end_users}
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/global/spend/end_users",
|
"/global/spend/end_users",
|
||||||
tags=["Budget & Spend Tracking"],
|
tags=["Budget & Spend Tracking"],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue