litellm-proxy-extras 0.1.9__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of litellm-proxy-extras might be problematic. Click here for more details.

Files changed (21) hide show
  1. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/PKG-INFO +1 -1
  2. litellm_proxy_extras-0.1.11/litellm_proxy_extras/migrations/20250416115320_add_tag_table_to_db/migration.sql +45 -0
  3. litellm_proxy_extras-0.1.11/litellm_proxy_extras/migrations/20250416151339_drop_tag_uniqueness_requirement/migration.sql +3 -0
  4. litellm_proxy_extras-0.1.11/litellm_proxy_extras/migrations/20250416185146_add_allowed_routes_litellm_verification_token/migration.sql +3 -0
  5. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/schema.prisma +55 -0
  6. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/utils.py +72 -1
  7. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/pyproject.toml +2 -2
  8. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/LICENSE +0 -0
  9. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/README.md +0 -0
  10. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/__init__.py +0 -0
  11. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/_logging.py +0 -0
  12. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250326162113_baseline/migration.sql +0 -0
  13. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250326171002_add_daily_user_table/migration.sql +0 -0
  14. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250327180120_add_api_requests_to_daily_user_table/migration.sql +0 -0
  15. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250329084805_new_cron_job_table/migration.sql +0 -0
  16. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250331215456_track_success_and_failed_requests_daily_agg_table/migration.sql +0 -0
  17. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250411215431_add_managed_file_table/migration.sql +0 -0
  18. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250412081753_team_member_permissions/migration.sql +0 -0
  19. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250415151647_add_cache_read_write_tokens_daily_spend_transactions/migration.sql +0 -0
  20. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/20250415191926_add_daily_team_table/migration.sql +0 -0
  21. {litellm_proxy_extras-0.1.9 → litellm_proxy_extras-0.1.11}/litellm_proxy_extras/migrations/migration_lock.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: litellm-proxy-extras
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package.
5
5
  Author: BerriAI
6
6
  Requires-Python: >=3.8, !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*
@@ -0,0 +1,45 @@
1
+ -- AlterTable
2
+ ALTER TABLE "LiteLLM_DailyTeamSpend" ADD COLUMN "cache_creation_input_tokens" INTEGER NOT NULL DEFAULT 0,
3
+ ADD COLUMN "cache_read_input_tokens" INTEGER NOT NULL DEFAULT 0;
4
+
5
+ -- CreateTable
6
+ CREATE TABLE "LiteLLM_DailyTagSpend" (
7
+ "id" TEXT NOT NULL,
8
+ "tag" TEXT NOT NULL,
9
+ "date" TEXT NOT NULL,
10
+ "api_key" TEXT NOT NULL,
11
+ "model" TEXT NOT NULL,
12
+ "model_group" TEXT,
13
+ "custom_llm_provider" TEXT,
14
+ "prompt_tokens" INTEGER NOT NULL DEFAULT 0,
15
+ "completion_tokens" INTEGER NOT NULL DEFAULT 0,
16
+ "cache_read_input_tokens" INTEGER NOT NULL DEFAULT 0,
17
+ "cache_creation_input_tokens" INTEGER NOT NULL DEFAULT 0,
18
+ "spend" DOUBLE PRECISION NOT NULL DEFAULT 0.0,
19
+ "api_requests" INTEGER NOT NULL DEFAULT 0,
20
+ "successful_requests" INTEGER NOT NULL DEFAULT 0,
21
+ "failed_requests" INTEGER NOT NULL DEFAULT 0,
22
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
23
+ "updated_at" TIMESTAMP(3) NOT NULL,
24
+
25
+ CONSTRAINT "LiteLLM_DailyTagSpend_pkey" PRIMARY KEY ("id")
26
+ );
27
+
28
+ -- CreateIndex
29
+ CREATE UNIQUE INDEX "LiteLLM_DailyTagSpend_tag_key" ON "LiteLLM_DailyTagSpend"("tag");
30
+
31
+ -- CreateIndex
32
+ CREATE INDEX "LiteLLM_DailyTagSpend_date_idx" ON "LiteLLM_DailyTagSpend"("date");
33
+
34
+ -- CreateIndex
35
+ CREATE INDEX "LiteLLM_DailyTagSpend_tag_idx" ON "LiteLLM_DailyTagSpend"("tag");
36
+
37
+ -- CreateIndex
38
+ CREATE INDEX "LiteLLM_DailyTagSpend_api_key_idx" ON "LiteLLM_DailyTagSpend"("api_key");
39
+
40
+ -- CreateIndex
41
+ CREATE INDEX "LiteLLM_DailyTagSpend_model_idx" ON "LiteLLM_DailyTagSpend"("model");
42
+
43
+ -- CreateIndex
44
+ CREATE UNIQUE INDEX "LiteLLM_DailyTagSpend_tag_date_api_key_model_custom_llm_pro_key" ON "LiteLLM_DailyTagSpend"("tag", "date", "api_key", "model", "custom_llm_provider");
45
+
@@ -0,0 +1,3 @@
1
+ -- DropIndex
2
+ DROP INDEX "LiteLLM_DailyTagSpend_tag_key";
3
+
@@ -0,0 +1,3 @@
1
+ -- AlterTable
2
+ ALTER TABLE "LiteLLM_VerificationToken" ADD COLUMN "allowed_routes" TEXT[] DEFAULT ARRAY[]::TEXT[];
3
+
@@ -169,6 +169,7 @@ model LiteLLM_VerificationToken {
169
169
  budget_duration String?
170
170
  budget_reset_at DateTime?
171
171
  allowed_cache_controls String[] @default([])
172
+ allowed_routes String[] @default([])
172
173
  model_spend Json @default("{}")
173
174
  model_max_budget Json @default("{}")
174
175
  budget_id String?
@@ -342,6 +343,60 @@ model LiteLLM_DailyUserSpend {
342
343
  @@index([model])
343
344
  }
344
345
 
346
+ // Track daily team spend metrics per model and key
347
+ model LiteLLM_DailyTeamSpend {
348
+ id String @id @default(uuid())
349
+ team_id String
350
+ date String
351
+ api_key String
352
+ model String
353
+ model_group String?
354
+ custom_llm_provider String?
355
+ prompt_tokens Int @default(0)
356
+ completion_tokens Int @default(0)
357
+ cache_read_input_tokens Int @default(0)
358
+ cache_creation_input_tokens Int @default(0)
359
+ spend Float @default(0.0)
360
+ api_requests Int @default(0)
361
+ successful_requests Int @default(0)
362
+ failed_requests Int @default(0)
363
+ created_at DateTime @default(now())
364
+ updated_at DateTime @updatedAt
365
+
366
+ @@unique([team_id, date, api_key, model, custom_llm_provider])
367
+ @@index([date])
368
+ @@index([team_id])
369
+ @@index([api_key])
370
+ @@index([model])
371
+ }
372
+
373
+ // Track daily team spend metrics per model and key
374
+ model LiteLLM_DailyTagSpend {
375
+ id String @id @default(uuid())
376
+ tag String
377
+ date String
378
+ api_key String
379
+ model String
380
+ model_group String?
381
+ custom_llm_provider String?
382
+ prompt_tokens Int @default(0)
383
+ completion_tokens Int @default(0)
384
+ cache_read_input_tokens Int @default(0)
385
+ cache_creation_input_tokens Int @default(0)
386
+ spend Float @default(0.0)
387
+ api_requests Int @default(0)
388
+ successful_requests Int @default(0)
389
+ failed_requests Int @default(0)
390
+ created_at DateTime @default(now())
391
+ updated_at DateTime @updatedAt
392
+
393
+ @@unique([tag, date, api_key, model, custom_llm_provider])
394
+ @@index([date])
395
+ @@index([tag])
396
+ @@index([api_key])
397
+ @@index([model])
398
+ }
399
+
345
400
 
346
401
  // Track the status of cron jobs running. Only allow one pod to run the job at a time
347
402
  model LiteLLM_CronJob {
@@ -1,6 +1,7 @@
1
1
  import glob
2
2
  import os
3
3
  import random
4
+ import re
4
5
  import subprocess
5
6
  import time
6
7
  from pathlib import Path
@@ -82,6 +83,26 @@ class ProxyExtrasDBManager:
82
83
  logger.info(f"Found {len(migration_paths)} migrations at {migrations_dir}")
83
84
  return [Path(p).parent.name for p in migration_paths]
84
85
 
86
+ @staticmethod
87
+ def _roll_back_migration(migration_name: str):
88
+ """Mark a specific migration as rolled back"""
89
+ subprocess.run(
90
+ ["prisma", "migrate", "resolve", "--rolled-back", migration_name],
91
+ timeout=60,
92
+ check=True,
93
+ capture_output=True,
94
+ )
95
+
96
+ @staticmethod
97
+ def _resolve_specific_migration(migration_name: str):
98
+ """Mark a specific migration as applied"""
99
+ subprocess.run(
100
+ ["prisma", "migrate", "resolve", "--applied", migration_name],
101
+ timeout=60,
102
+ check=True,
103
+ capture_output=True,
104
+ )
105
+
85
106
  @staticmethod
86
107
  def _resolve_all_migrations(migrations_dir: str):
87
108
  """Mark all existing migrations as applied"""
@@ -141,7 +162,34 @@ class ProxyExtrasDBManager:
141
162
  return True
142
163
  except subprocess.CalledProcessError as e:
143
164
  logger.info(f"prisma db error: {e.stderr}, e: {e.stdout}")
144
- if (
165
+ if "P3009" in e.stderr:
166
+ # Extract the failed migration name from the error message
167
+ migration_match = re.search(
168
+ r"`(\d+_.*)` migration", e.stderr
169
+ )
170
+ if migration_match:
171
+ failed_migration = migration_match.group(1)
172
+ logger.info(
173
+ f"Found failed migration: {failed_migration}, marking as rolled back"
174
+ )
175
+ # Mark the failed migration as rolled back
176
+ subprocess.run(
177
+ [
178
+ "prisma",
179
+ "migrate",
180
+ "resolve",
181
+ "--rolled-back",
182
+ failed_migration,
183
+ ],
184
+ timeout=60,
185
+ check=True,
186
+ capture_output=True,
187
+ text=True,
188
+ )
189
+ logger.info(
190
+ f"✅ Migration {failed_migration} marked as rolled back... retrying"
191
+ )
192
+ elif (
145
193
  "P3005" in e.stderr
146
194
  and "database schema is not empty" in e.stderr
147
195
  ):
@@ -155,6 +203,29 @@ class ProxyExtrasDBManager:
155
203
  ProxyExtrasDBManager._resolve_all_migrations(migrations_dir)
156
204
  logger.info("✅ All migrations resolved.")
157
205
  return True
206
+ elif (
207
+ "P3018" in e.stderr
208
+ ): # PostgreSQL error code for duplicate column
209
+ logger.info(
210
+ "Migration already exists, resolving specific migration"
211
+ )
212
+ # Extract the migration name from the error message
213
+ migration_match = re.search(
214
+ r"Migration name: (\d+_.*)", e.stderr
215
+ )
216
+ if migration_match:
217
+ migration_name = migration_match.group(1)
218
+ logger.info(f"Rolling back migration {migration_name}")
219
+ ProxyExtrasDBManager._roll_back_migration(
220
+ migration_name
221
+ )
222
+ logger.info(
223
+ f"Resolving migration {migration_name} that failed due to existing columns"
224
+ )
225
+ ProxyExtrasDBManager._resolve_specific_migration(
226
+ migration_name
227
+ )
228
+ logger.info("✅ Migration resolved.")
158
229
  else:
159
230
  # Use prisma db push with increased timeout
160
231
  subprocess.run(
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "litellm-proxy-extras"
3
- version = "0.1.9"
3
+ version = "0.1.11"
4
4
  description = "Additional files for the LiteLLM Proxy. Reduces the size of the main litellm package."
5
5
  authors = ["BerriAI"]
6
6
  readme = "README.md"
@@ -22,7 +22,7 @@ requires = ["poetry-core"]
22
22
  build-backend = "poetry.core.masonry.api"
23
23
 
24
24
  [tool.commitizen]
25
- version = "0.1.9"
25
+ version = "0.1.11"
26
26
  version_files = [
27
27
  "pyproject.toml:version",
28
28
  "../requirements.txt:litellm-proxy-extras==",