mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
Merge pull request #23606 from BerriAI/litellm_tag_spend_fix
[Fix] Tag list endpoint 500 from invalid Prisma group_by kwargs
This commit is contained in:
commit
26d555f504
2 changed files with 7 additions and 10 deletions
|
|
@ -456,11 +456,8 @@ async def list_tags(
|
|||
dynamic_tag_rows = await prisma_client.db.litellm_dailytagspend.group_by(
|
||||
by=["tag"],
|
||||
where={"tag": {"not": None}},
|
||||
# The old find_many(distinct=...) returned arbitrary timestamps from
|
||||
# whichever row Prisma happened to pick. MIN/MAX give more meaningful
|
||||
# values: earliest appearance and most recent activity.
|
||||
_min={"created_at": True},
|
||||
_max={"updated_at": True},
|
||||
min={"created_at": True},
|
||||
max={"updated_at": True},
|
||||
)
|
||||
|
||||
dynamic_tag_config = [
|
||||
|
|
@ -468,8 +465,8 @@ async def list_tags(
|
|||
"name": row["tag"],
|
||||
"description": "This is just a spend tag that was passed dynamically in a request. It does not control any LLM models.",
|
||||
"models": None,
|
||||
"created_at": row["_min"]["created_at"].isoformat(),
|
||||
"updated_at": row["_max"]["updated_at"].isoformat(),
|
||||
"created_at": row["_min"]["created_at"],
|
||||
"updated_at": row["_max"]["updated_at"],
|
||||
}
|
||||
for row in dynamic_tag_rows
|
||||
if row["tag"] not in stored_tag_names
|
||||
|
|
|
|||
|
|
@ -282,9 +282,9 @@ async def test_list_tags_with_dynamic_tags():
|
|||
|
||||
# Setup dynamic tags via group_by — includes one that overlaps with stored
|
||||
mock_db.litellm_dailytagspend.group_by = AsyncMock(return_value=[
|
||||
{"tag": "dynamic-tag-1", "_min": {"created_at": datetime(2025, 2, 1)}, "_max": {"updated_at": datetime(2025, 3, 1)}},
|
||||
{"tag": "dynamic-tag-2", "_min": {"created_at": datetime(2025, 2, 2)}, "_max": {"updated_at": datetime(2025, 3, 2)}},
|
||||
{"tag": "stored-tag", "_min": {"created_at": datetime(2025, 1, 1)}, "_max": {"updated_at": datetime(2025, 1, 1)}}, # duplicate, should be excluded
|
||||
{"tag": "dynamic-tag-1", "_min": {"created_at": "2025-02-01T00:00:00Z"}, "_max": {"updated_at": "2025-03-01T00:00:00Z"}},
|
||||
{"tag": "dynamic-tag-2", "_min": {"created_at": "2025-02-02T00:00:00Z"}, "_max": {"updated_at": "2025-03-02T00:00:00Z"}},
|
||||
{"tag": "stored-tag", "_min": {"created_at": "2025-01-01T00:00:00Z"}, "_max": {"updated_at": "2025-01-01T00:00:00Z"}}, # duplicate, should be excluded
|
||||
])
|
||||
|
||||
headers = {"Authorization": "Bearer sk-1234"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue