Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions litellm/proxy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,10 @@ def jsonify_team_object(self, db_data: dict):
db_data["members_with_roles"], list
):
db_data["members_with_roles"] = json.dumps(db_data["members_with_roles"])
if db_data.get("budget_limits", None) is not None and isinstance(
db_data["budget_limits"], list
):
db_data["budget_limits"] = json.dumps(db_data["budget_limits"])
return db_data

# Define a retrying strategy with exponential backoff
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,33 @@ def test_jsonify_team_object_converts_members_to_json_string(
}


def test_jsonify_team_object_converts_budget_limits_to_json_string(
prisma_client: PrismaClient,
) -> None:
data = {
"team_id": "t1",
"budget_limits": [
{
"budget_duration": "1d",
"max_budget": 10.0,
"reset_at": "2026-01-01T00:00:00Z",
},
{
"budget_duration": "7d",
"max_budget": 50.0,
"reset_at": "2026-01-07T00:00:00Z",
},
],
"models": ["gpt-4"],
}
result = prisma_client.jsonify_team_object(data)
assert result == {
"team_id": "t1",
"budget_limits": json.dumps(data["budget_limits"]),
"models": ["gpt-4"],
}


def test_jsonify_team_object_error_on_non_dict(prisma_client: PrismaClient) -> None:
with pytest.raises(AttributeError):
prisma_client.jsonify_team_object(None) # type: ignore[arg-type]
Expand Down
Loading