mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(feat) proxy - save model access requests
This commit is contained in:
parent
54e9b5b99a
commit
a13565dd95
4 changed files with 82 additions and 1 deletions
|
@ -696,7 +696,9 @@ class PrismaClient:
|
|||
on_backoff=on_backoff, # specifying the function to call on backoff
|
||||
)
|
||||
async def insert_data(
|
||||
self, data: dict, table_name: Literal["user", "key", "config", "spend", "team"]
|
||||
self,
|
||||
data: dict,
|
||||
table_name: Literal["user", "key", "config", "spend", "team", "model_request"],
|
||||
):
|
||||
"""
|
||||
Add a key to the database. If it already exists, do nothing.
|
||||
|
@ -778,6 +780,17 @@ class PrismaClient:
|
|||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Spend Table")
|
||||
return new_spend_row
|
||||
elif table_name == "model_request":
|
||||
db_data = self.jsonify_object(data=data)
|
||||
new_model_request_row = await self.db.litellm_modelrequests.upsert(
|
||||
where={"request_id": data["request_id"]},
|
||||
data={
|
||||
"create": {**db_data}, # type: ignore
|
||||
"update": {}, # don't do anything if it already exists
|
||||
},
|
||||
)
|
||||
verbose_proxy_logger.info(f"Data Inserted into Model Request Table")
|
||||
return new_model_request_row
|
||||
|
||||
except Exception as e:
|
||||
print_verbose(f"LiteLLM Prisma Client Exception: {e}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue