mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
Merge pull request #1590 from BerriAI/litellm_spend_logs_by_key
feat(proxy_server.py): enable returning spend logs by api key
This commit is contained in:
commit
ed77f2d682
2 changed files with 44 additions and 10 deletions
|
@ -361,7 +361,7 @@ class PrismaClient:
|
|||
self,
|
||||
token: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
request_id: Optional[str] = None,
|
||||
key_val: Optional[dict] = None,
|
||||
table_name: Optional[Literal["user", "key", "config", "spend"]] = None,
|
||||
query_type: Literal["find_unique", "find_all"] = "find_unique",
|
||||
expires: Optional[datetime] = None,
|
||||
|
@ -441,12 +441,19 @@ class PrismaClient:
|
|||
verbose_proxy_logger.debug(
|
||||
f"PrismaClient: get_data: table_name == 'spend'"
|
||||
)
|
||||
if request_id is not None:
|
||||
response = await self.db.litellm_spendlogs.find_unique( # type: ignore
|
||||
where={
|
||||
"request_id": request_id,
|
||||
}
|
||||
)
|
||||
if key_val is not None:
|
||||
if query_type == "find_unique":
|
||||
response = await self.db.litellm_spendlogs.find_unique( # type: ignore
|
||||
where={ # type: ignore
|
||||
key_val["key"]: key_val["value"], # type: ignore
|
||||
}
|
||||
)
|
||||
elif query_type == "find_all":
|
||||
response = await self.db.litellm_spendlogs.find_many( # type: ignore
|
||||
where={
|
||||
key_val["key"]: key_val["value"], # type: ignore
|
||||
}
|
||||
)
|
||||
return response
|
||||
else:
|
||||
response = await self.db.litellm_spendlogs.find_many( # type: ignore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue