mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
use jsonify_team_object for updating teams
This commit is contained in:
parent
a9088a958a
commit
834db4447c
1 changed files with 20 additions and 15 deletions
|
@ -32,7 +32,13 @@ from fastapi import HTTPException, status
|
||||||
import litellm
|
import litellm
|
||||||
import litellm.litellm_core_utils
|
import litellm.litellm_core_utils
|
||||||
import litellm.litellm_core_utils.litellm_logging
|
import litellm.litellm_core_utils.litellm_logging
|
||||||
from litellm import EmbeddingResponse, ImageResponse, ModelResponse, Router, ModelResponseStream
|
from litellm import (
|
||||||
|
EmbeddingResponse,
|
||||||
|
ImageResponse,
|
||||||
|
ModelResponse,
|
||||||
|
ModelResponseStream,
|
||||||
|
Router,
|
||||||
|
)
|
||||||
from litellm._logging import verbose_proxy_logger
|
from litellm._logging import verbose_proxy_logger
|
||||||
from litellm._service_logger import ServiceLogging, ServiceTypes
|
from litellm._service_logger import ServiceLogging, ServiceTypes
|
||||||
from litellm.caching.caching import DualCache, RedisCache
|
from litellm.caching.caching import DualCache, RedisCache
|
||||||
|
@ -1009,19 +1015,24 @@ class ProxyLogging:
|
||||||
for callback in litellm.callbacks:
|
for callback in litellm.callbacks:
|
||||||
_callback: Optional[CustomLogger] = None
|
_callback: Optional[CustomLogger] = None
|
||||||
if isinstance(callback, str):
|
if isinstance(callback, str):
|
||||||
_callback = litellm.litellm_core_utils.litellm_logging.get_custom_logger_compatible_class(callback)
|
_callback = litellm.litellm_core_utils.litellm_logging.get_custom_logger_compatible_class(
|
||||||
|
callback
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
_callback = callback # type: ignore
|
_callback = callback # type: ignore
|
||||||
if _callback is not None and isinstance(_callback, CustomLogger):
|
if _callback is not None and isinstance(_callback, CustomLogger):
|
||||||
if not isinstance(_callback, CustomGuardrail) or _callback.should_run_guardrail(
|
if not isinstance(
|
||||||
data=request_data, event_type=GuardrailEventHooks.post_call
|
_callback, CustomGuardrail
|
||||||
|
) or _callback.should_run_guardrail(
|
||||||
|
data=request_data, event_type=GuardrailEventHooks.post_call
|
||||||
):
|
):
|
||||||
response = _callback.async_post_call_streaming_iterator_hook(
|
response = _callback.async_post_call_streaming_iterator_hook(
|
||||||
user_api_key_dict=user_api_key_dict, response=response, request_data=request_data
|
user_api_key_dict=user_api_key_dict,
|
||||||
|
response=response,
|
||||||
|
request_data=request_data,
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
async def post_call_streaming_hook(
|
async def post_call_streaming_hook(
|
||||||
self,
|
self,
|
||||||
response: str,
|
response: str,
|
||||||
|
@ -1733,13 +1744,7 @@ class PrismaClient:
|
||||||
verbose_proxy_logger.info("Data Inserted into User Table")
|
verbose_proxy_logger.info("Data Inserted into User Table")
|
||||||
return new_user_row
|
return new_user_row
|
||||||
elif table_name == "team":
|
elif table_name == "team":
|
||||||
db_data = self.jsonify_object(data=data)
|
db_data = self.jsonify_team_object(db_data=data)
|
||||||
if db_data.get("members_with_roles", None) is not None and isinstance(
|
|
||||||
db_data["members_with_roles"], list
|
|
||||||
):
|
|
||||||
db_data["members_with_roles"] = json.dumps(
|
|
||||||
db_data["members_with_roles"]
|
|
||||||
)
|
|
||||||
new_team_row = await self.db.litellm_teamtable.upsert(
|
new_team_row = await self.db.litellm_teamtable.upsert(
|
||||||
where={"team_id": data["team_id"]},
|
where={"team_id": data["team_id"]},
|
||||||
data={
|
data={
|
||||||
|
@ -2010,8 +2015,8 @@ class PrismaClient:
|
||||||
batcher = self.db.batch_()
|
batcher = self.db.batch_()
|
||||||
for idx, team in enumerate(data_list):
|
for idx, team in enumerate(data_list):
|
||||||
try:
|
try:
|
||||||
data_json = self.jsonify_object(
|
data_json = self.jsonify_team_object(
|
||||||
data=team.model_dump(exclude_none=True)
|
db_data=team.model_dump(exclude_none=True)
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
data_json = self.jsonify_object(
|
data_json = self.jsonify_object(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue