mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
fix - updating team
This commit is contained in:
parent
61bc6fae63
commit
8efa76f1a4
3 changed files with 34 additions and 5 deletions
|
@ -612,7 +612,6 @@ class UpdateTeamRequest(LiteLLMBase):
|
||||||
models: Optional[list] = None
|
models: Optional[list] = None
|
||||||
blocked: Optional[bool] = None
|
blocked: Optional[bool] = None
|
||||||
budget_duration: Optional[str] = None
|
budget_duration: Optional[str] = None
|
||||||
budget_reset_at: Optional[datetime] = None
|
|
||||||
|
|
||||||
|
|
||||||
class DeleteTeamRequest(LiteLLMBase):
|
class DeleteTeamRequest(LiteLLMBase):
|
||||||
|
|
|
@ -8121,16 +8121,16 @@ async def update_team(
|
||||||
detail={"error": f"Team not found, passed team_id={data.team_id}"},
|
detail={"error": f"Team not found, passed team_id={data.team_id}"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
updated_kv = data.json(exclude_none=True)
|
||||||
|
|
||||||
# Check budget_duration and budget_reset_at
|
# Check budget_duration and budget_reset_at
|
||||||
if data.budget_duration is not None:
|
if data.budget_duration is not None:
|
||||||
duration_s = _duration_in_seconds(duration=data.budget_duration)
|
duration_s = _duration_in_seconds(duration=data.budget_duration)
|
||||||
reset_at = datetime.now(timezone.utc) + timedelta(seconds=duration_s)
|
reset_at = datetime.now(timezone.utc) + timedelta(seconds=duration_s)
|
||||||
|
|
||||||
# set the budget duration and budget_reset_at in DB
|
# set the budget_reset_at in DB
|
||||||
data.budget_duration = duration_s
|
updated_kv["budget_reset_at"] = reset_at
|
||||||
data.budget_reset_at = reset_at
|
|
||||||
|
|
||||||
updated_kv = data.json(exclude_none=True)
|
|
||||||
team_row = await prisma_client.update_data(
|
team_row = await prisma_client.update_data(
|
||||||
update_key_values=updated_kv,
|
update_key_values=updated_kv,
|
||||||
data=updated_kv,
|
data=updated_kv,
|
||||||
|
|
|
@ -52,6 +52,7 @@ from litellm.proxy.proxy_server import (
|
||||||
user_info,
|
user_info,
|
||||||
info_key_fn,
|
info_key_fn,
|
||||||
new_team,
|
new_team,
|
||||||
|
update_team,
|
||||||
chat_completion,
|
chat_completion,
|
||||||
completion,
|
completion,
|
||||||
embeddings,
|
embeddings,
|
||||||
|
@ -73,6 +74,7 @@ from litellm.proxy._types import (
|
||||||
UpdateKeyRequest,
|
UpdateKeyRequest,
|
||||||
GenerateKeyRequest,
|
GenerateKeyRequest,
|
||||||
NewTeamRequest,
|
NewTeamRequest,
|
||||||
|
UpdateTeamRequest,
|
||||||
UserAPIKeyAuth,
|
UserAPIKeyAuth,
|
||||||
LiteLLM_UpperboundKeyGenerateParams,
|
LiteLLM_UpperboundKeyGenerateParams,
|
||||||
)
|
)
|
||||||
|
@ -2185,3 +2187,31 @@ async def test_create_update_team(prisma_client):
|
||||||
assert response["budget_reset_at"] is not None and isinstance(
|
assert response["budget_reset_at"] is not None and isinstance(
|
||||||
response["budget_reset_at"], datetime.datetime
|
response["budget_reset_at"], datetime.datetime
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# updating team budget duration and reset at
|
||||||
|
|
||||||
|
response = await update_team(
|
||||||
|
UpdateTeamRequest(
|
||||||
|
team_id=_team_id,
|
||||||
|
max_budget=30,
|
||||||
|
budget_duration="2d",
|
||||||
|
tpm_limit=30,
|
||||||
|
rpm_limit=30,
|
||||||
|
),
|
||||||
|
user_api_key_dict=UserAPIKeyAuth(
|
||||||
|
user_role="proxy_admin", api_key="sk-1234", user_id="1234"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
print("RESPONSE from update_team", response)
|
||||||
|
_updated_info = response["data"]
|
||||||
|
_updated_info = dict(_updated_info)
|
||||||
|
|
||||||
|
assert _updated_info["team_id"] == _team_id
|
||||||
|
assert _updated_info["max_budget"] == 30
|
||||||
|
assert _updated_info["tpm_limit"] == 30
|
||||||
|
assert _updated_info["rpm_limit"] == 30
|
||||||
|
assert _updated_info["budget_duration"] == "2d"
|
||||||
|
assert _updated_info["budget_reset_at"] is not None and isinstance(
|
||||||
|
_updated_info["budget_reset_at"], datetime.datetime
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue