litellm-proxy-extras 0.1.2__py3-none-any.whl → 0.1.3__py3-none-any.whl

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.

@@ -0,0 +1,356 @@
1
+ datasource client {
2
+ provider = "postgresql"
3
+ url = env("DATABASE_URL")
4
+ }
5
+
6
+ generator client {
7
+ provider = "prisma-client-py"
8
+ }
9
+
10
+ // Budget / Rate Limits for an org
11
+ model LiteLLM_BudgetTable {
12
+ budget_id String @id @default(uuid())
13
+ max_budget Float?
14
+ soft_budget Float?
15
+ max_parallel_requests Int?
16
+ tpm_limit BigInt?
17
+ rpm_limit BigInt?
18
+ model_max_budget Json?
19
+ budget_duration String?
20
+ budget_reset_at DateTime?
21
+ created_at DateTime @default(now()) @map("created_at")
22
+ created_by String
23
+ updated_at DateTime @default(now()) @updatedAt @map("updated_at")
24
+ updated_by String
25
+ organization LiteLLM_OrganizationTable[] // multiple orgs can have the same budget
26
+ keys LiteLLM_VerificationToken[] // multiple keys can have the same budget
27
+ end_users LiteLLM_EndUserTable[] // multiple end-users can have the same budget
28
+ team_membership LiteLLM_TeamMembership[] // budgets of Users within a Team
29
+ organization_membership LiteLLM_OrganizationMembership[] // budgets of Users within a Organization
30
+ }
31
+
32
+ // Models on proxy
33
+ model LiteLLM_CredentialsTable {
34
+ credential_id String @id @default(uuid())
35
+ credential_name String @unique
36
+ credential_values Json
37
+ credential_info Json?
38
+ created_at DateTime @default(now()) @map("created_at")
39
+ created_by String
40
+ updated_at DateTime @default(now()) @updatedAt @map("updated_at")
41
+ updated_by String
42
+ }
43
+
44
+ // Models on proxy
45
+ model LiteLLM_ProxyModelTable {
46
+ model_id String @id @default(uuid())
47
+ model_name String
48
+ litellm_params Json
49
+ model_info Json?
50
+ created_at DateTime @default(now()) @map("created_at")
51
+ created_by String
52
+ updated_at DateTime @default(now()) @updatedAt @map("updated_at")
53
+ updated_by String
54
+ }
55
+
56
+ model LiteLLM_OrganizationTable {
57
+ organization_id String @id @default(uuid())
58
+ organization_alias String
59
+ budget_id String
60
+ metadata Json @default("{}")
61
+ models String[]
62
+ spend Float @default(0.0)
63
+ model_spend Json @default("{}")
64
+ created_at DateTime @default(now()) @map("created_at")
65
+ created_by String
66
+ updated_at DateTime @default(now()) @updatedAt @map("updated_at")
67
+ updated_by String
68
+ litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
69
+ teams LiteLLM_TeamTable[]
70
+ users LiteLLM_UserTable[]
71
+ keys LiteLLM_VerificationToken[]
72
+ members LiteLLM_OrganizationMembership[] @relation("OrganizationToMembership")
73
+ }
74
+
75
+ // Model info for teams, just has model aliases for now.
76
+ model LiteLLM_ModelTable {
77
+ id Int @id @default(autoincrement())
78
+ model_aliases Json? @map("aliases")
79
+ created_at DateTime @default(now()) @map("created_at")
80
+ created_by String
81
+ updated_at DateTime @default(now()) @updatedAt @map("updated_at")
82
+ updated_by String
83
+ team LiteLLM_TeamTable?
84
+ }
85
+
86
+
87
+ // Assign prod keys to groups, not individuals
88
+ model LiteLLM_TeamTable {
89
+ team_id String @id @default(uuid())
90
+ team_alias String?
91
+ organization_id String?
92
+ admins String[]
93
+ members String[]
94
+ members_with_roles Json @default("{}")
95
+ metadata Json @default("{}")
96
+ max_budget Float?
97
+ spend Float @default(0.0)
98
+ models String[]
99
+ max_parallel_requests Int?
100
+ tpm_limit BigInt?
101
+ rpm_limit BigInt?
102
+ budget_duration String?
103
+ budget_reset_at DateTime?
104
+ blocked Boolean @default(false)
105
+ created_at DateTime @default(now()) @map("created_at")
106
+ updated_at DateTime @default(now()) @updatedAt @map("updated_at")
107
+ model_spend Json @default("{}")
108
+ model_max_budget Json @default("{}")
109
+ model_id Int? @unique // id for LiteLLM_ModelTable -> stores team-level model aliases
110
+ litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
111
+ litellm_model_table LiteLLM_ModelTable? @relation(fields: [model_id], references: [id])
112
+ }
113
+
114
+ // Track spend, rate limit, budget Users
115
+ model LiteLLM_UserTable {
116
+ user_id String @id
117
+ user_alias String?
118
+ team_id String?
119
+ sso_user_id String? @unique
120
+ organization_id String?
121
+ password String?
122
+ teams String[] @default([])
123
+ user_role String?
124
+ max_budget Float?
125
+ spend Float @default(0.0)
126
+ user_email String?
127
+ models String[]
128
+ metadata Json @default("{}")
129
+ max_parallel_requests Int?
130
+ tpm_limit BigInt?
131
+ rpm_limit BigInt?
132
+ budget_duration String?
133
+ budget_reset_at DateTime?
134
+ allowed_cache_controls String[] @default([])
135
+ model_spend Json @default("{}")
136
+ model_max_budget Json @default("{}")
137
+ created_at DateTime? @default(now()) @map("created_at")
138
+ updated_at DateTime? @default(now()) @updatedAt @map("updated_at")
139
+
140
+ // relations
141
+ litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
142
+ organization_memberships LiteLLM_OrganizationMembership[]
143
+ invitations_created LiteLLM_InvitationLink[] @relation("CreatedBy")
144
+ invitations_updated LiteLLM_InvitationLink[] @relation("UpdatedBy")
145
+ invitations_user LiteLLM_InvitationLink[] @relation("UserId")
146
+ }
147
+
148
+ // Generate Tokens for Proxy
149
+ model LiteLLM_VerificationToken {
150
+ token String @id
151
+ key_name String?
152
+ key_alias String?
153
+ soft_budget_cooldown Boolean @default(false) // key-level state on if budget alerts need to be cooled down
154
+ spend Float @default(0.0)
155
+ expires DateTime?
156
+ models String[]
157
+ aliases Json @default("{}")
158
+ config Json @default("{}")
159
+ user_id String?
160
+ team_id String?
161
+ permissions Json @default("{}")
162
+ max_parallel_requests Int?
163
+ metadata Json @default("{}")
164
+ blocked Boolean?
165
+ tpm_limit BigInt?
166
+ rpm_limit BigInt?
167
+ max_budget Float?
168
+ budget_duration String?
169
+ budget_reset_at DateTime?
170
+ allowed_cache_controls String[] @default([])
171
+ model_spend Json @default("{}")
172
+ model_max_budget Json @default("{}")
173
+ budget_id String?
174
+ organization_id String?
175
+ created_at DateTime? @default(now()) @map("created_at")
176
+ created_by String?
177
+ updated_at DateTime? @default(now()) @updatedAt @map("updated_at")
178
+ updated_by String?
179
+ litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
180
+ litellm_organization_table LiteLLM_OrganizationTable? @relation(fields: [organization_id], references: [organization_id])
181
+ }
182
+
183
+ model LiteLLM_EndUserTable {
184
+ user_id String @id
185
+ alias String? // admin-facing alias
186
+ spend Float @default(0.0)
187
+ allowed_model_region String? // require all user requests to use models in this specific region
188
+ default_model String? // use along with 'allowed_model_region'. if no available model in region, default to this model.
189
+ budget_id String?
190
+ litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
191
+ blocked Boolean @default(false)
192
+ }
193
+
194
+ // store proxy config.yaml
195
+ model LiteLLM_Config {
196
+ param_name String @id
197
+ param_value Json?
198
+ }
199
+
200
+ // View spend, model, api_key per request
201
+ model LiteLLM_SpendLogs {
202
+ request_id String @id
203
+ call_type String
204
+ api_key String @default ("") // Hashed API Token. Not the actual Virtual Key. Equivalent to 'token' column in LiteLLM_VerificationToken
205
+ spend Float @default(0.0)
206
+ total_tokens Int @default(0)
207
+ prompt_tokens Int @default(0)
208
+ completion_tokens Int @default(0)
209
+ startTime DateTime // Assuming start_time is a DateTime field
210
+ endTime DateTime // Assuming end_time is a DateTime field
211
+ completionStartTime DateTime? // Assuming completionStartTime is a DateTime field
212
+ model String @default("")
213
+ model_id String? @default("") // the model id stored in proxy model db
214
+ model_group String? @default("") // public model_name / model_group
215
+ custom_llm_provider String? @default("") // litellm used custom_llm_provider
216
+ api_base String? @default("")
217
+ user String? @default("")
218
+ metadata Json? @default("{}")
219
+ cache_hit String? @default("")
220
+ cache_key String? @default("")
221
+ request_tags Json? @default("[]")
222
+ team_id String?
223
+ end_user String?
224
+ requester_ip_address String?
225
+ messages Json? @default("{}")
226
+ response Json? @default("{}")
227
+ @@index([startTime])
228
+ @@index([end_user])
229
+ }
230
+
231
+ // View spend, model, api_key per request
232
+ model LiteLLM_ErrorLogs {
233
+ request_id String @id @default(uuid())
234
+ startTime DateTime // Assuming start_time is a DateTime field
235
+ endTime DateTime // Assuming end_time is a DateTime field
236
+ api_base String @default("")
237
+ model_group String @default("") // public model_name / model_group
238
+ litellm_model_name String @default("") // model passed to litellm
239
+ model_id String @default("") // ID of model in ProxyModelTable
240
+ request_kwargs Json @default("{}")
241
+ exception_type String @default("")
242
+ exception_string String @default("")
243
+ status_code String @default("")
244
+ }
245
+
246
+ // Beta - allow team members to request access to a model
247
+ model LiteLLM_UserNotifications {
248
+ request_id String @id
249
+ user_id String
250
+ models String[]
251
+ justification String
252
+ status String // approved, disapproved, pending
253
+ }
254
+
255
+ model LiteLLM_TeamMembership {
256
+ // Use this table to track the Internal User's Spend within a Team + Set Budgets, rpm limits for the user within the team
257
+ user_id String
258
+ team_id String
259
+ spend Float @default(0.0)
260
+ budget_id String?
261
+ litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
262
+ @@id([user_id, team_id])
263
+ }
264
+
265
+ model LiteLLM_OrganizationMembership {
266
+ // Use this table to track Internal User and Organization membership. Helps tracking a users role within an Organization
267
+ user_id String
268
+ organization_id String
269
+ user_role String?
270
+ spend Float? @default(0.0)
271
+ budget_id String?
272
+ created_at DateTime? @default(now()) @map("created_at")
273
+ updated_at DateTime? @default(now()) @updatedAt @map("updated_at")
274
+
275
+ // relations
276
+ user LiteLLM_UserTable @relation(fields: [user_id], references: [user_id])
277
+ organization LiteLLM_OrganizationTable @relation("OrganizationToMembership", fields: [organization_id], references: [organization_id])
278
+ litellm_budget_table LiteLLM_BudgetTable? @relation(fields: [budget_id], references: [budget_id])
279
+
280
+
281
+
282
+ @@id([user_id, organization_id])
283
+ @@unique([user_id, organization_id])
284
+ }
285
+
286
+ model LiteLLM_InvitationLink {
287
+ // use this table to track invite links sent by admin for people to join the proxy
288
+ id String @id @default(uuid())
289
+ user_id String
290
+ is_accepted Boolean @default(false)
291
+ accepted_at DateTime? // when link is claimed (user successfully onboards via link)
292
+ expires_at DateTime // till when is link valid
293
+ created_at DateTime // when did admin create the link
294
+ created_by String // who created the link
295
+ updated_at DateTime // when was invite status updated
296
+ updated_by String // who updated the status (admin/user who accepted invite)
297
+
298
+ // Relations
299
+ liteLLM_user_table_user LiteLLM_UserTable @relation("UserId", fields: [user_id], references: [user_id])
300
+ liteLLM_user_table_created LiteLLM_UserTable @relation("CreatedBy", fields: [created_by], references: [user_id])
301
+ liteLLM_user_table_updated LiteLLM_UserTable @relation("UpdatedBy", fields: [updated_by], references: [user_id])
302
+ }
303
+
304
+
305
+ model LiteLLM_AuditLog {
306
+ id String @id @default(uuid())
307
+ updated_at DateTime @default(now())
308
+ changed_by String @default("") // user or system that performed the action
309
+ changed_by_api_key String @default("") // api key hash that performed the action
310
+ action String // create, update, delete
311
+ table_name String // on of LitellmTableNames.TEAM_TABLE_NAME, LitellmTableNames.USER_TABLE_NAME, LitellmTableNames.PROXY_MODEL_TABLE_NAME,
312
+ object_id String // id of the object being audited. This can be the key id, team id, user id, model id
313
+ before_value Json? // value of the row
314
+ updated_values Json? // value of the row after change
315
+ }
316
+
317
+ // Track daily user spend metrics per model and key
318
+ model LiteLLM_DailyUserSpend {
319
+ id String @id @default(uuid())
320
+ user_id String
321
+ date String
322
+ api_key String
323
+ model String
324
+ model_group String?
325
+ custom_llm_provider String?
326
+ prompt_tokens Int @default(0)
327
+ completion_tokens Int @default(0)
328
+ spend Float @default(0.0)
329
+ api_requests Int @default(0)
330
+ successful_requests Int @default(0)
331
+ failed_requests Int @default(0)
332
+ created_at DateTime @default(now())
333
+ updated_at DateTime @updatedAt
334
+
335
+ @@unique([user_id, date, api_key, model, custom_llm_provider])
336
+ @@index([date])
337
+ @@index([user_id])
338
+ @@index([api_key])
339
+ @@index([model])
340
+ }
341
+
342
+
343
+ // Track the status of cron jobs running. Only allow one pod to run the job at a time
344
+ model LiteLLM_CronJob {
345
+ cronjob_id String @id @default(cuid()) // Unique ID for the record
346
+ pod_id String // Unique identifier for the pod acting as the leader
347
+ status JobStatus @default(INACTIVE) // Status of the cron job (active or inactive)
348
+ last_updated DateTime @default(now()) // Timestamp for the last update of the cron job record
349
+ ttl DateTime // Time when the leader's lease expires
350
+ }
351
+
352
+ enum JobStatus {
353
+ ACTIVE
354
+ INACTIVE
355
+ }
356
+
@@ -30,21 +30,23 @@ class ProxyExtrasDBManager:
30
30
  use_migrate = str_to_bool(os.getenv("USE_PRISMA_MIGRATE")) or use_migrate
31
31
  for attempt in range(4):
32
32
  original_dir = os.getcwd()
33
- schema_dir = os.path.dirname(schema_path)
34
- os.chdir(schema_dir)
33
+ migrations_dir = os.path.dirname(__file__)
34
+ os.chdir(migrations_dir)
35
35
 
36
36
  try:
37
37
  if use_migrate:
38
38
  logger.info("Running prisma migrate deploy")
39
39
  try:
40
40
  # Set migrations directory for Prisma
41
- subprocess.run(
41
+ result = subprocess.run(
42
42
  ["prisma", "migrate", "deploy"],
43
43
  timeout=60,
44
44
  check=True,
45
45
  capture_output=True,
46
46
  text=True,
47
47
  )
48
+ logger.info(f"prisma migrate deploy stdout: {result.stdout}")
49
+
48
50
  logger.info("prisma migrate deploy completed")
49
51
  return True
50
52
  except subprocess.CalledProcessError as e:
@@ -77,4 +79,5 @@ class ProxyExtrasDBManager:
77
79
  time.sleep(random.randrange(5, 15))
78
80
  finally:
79
81
  os.chdir(original_dir)
82
+ pass
80
83
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: litellm-proxy-extras
3
- Version: 0.1.2
3
+ Version: 0.1.3
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.*
@@ -6,8 +6,9 @@ litellm_proxy_extras/migrations/20250327180120_add_api_requests_to_daily_user_ta
6
6
  litellm_proxy_extras/migrations/20250329084805_new_cron_job_table/migration.sql,sha256=eZNDwrzKtWFXkTqOKb9JS4hzum1dI-VTXvMqzhryfxc,404
7
7
  litellm_proxy_extras/migrations/20250331215456_track_success_and_failed_requests_daily_agg_table/migration.sql,sha256=tyeLY6u8KFyw71osCBM-sdjhIgvHoFCK88cIx8dExNY,178
8
8
  litellm_proxy_extras/migrations/migration_lock.toml,sha256=HbF6jQUaoTYRBzZ1LF4fi37ZK26o6AMRL7viSXBHwhA,24
9
- litellm_proxy_extras/utils.py,sha256=09w_J9nsHS_GhPNs1tjJqVBYhGh6OUDI4p8Vld4Xv6w,3081
10
- litellm_proxy_extras-0.1.2.dist-info/LICENSE,sha256=sXDWv46INd01fgEWgdsCj01R4vsOqJIFj1bgH7ObgnM,1419
11
- litellm_proxy_extras-0.1.2.dist-info/METADATA,sha256=U2Pin4dmmX-JrndTt4RwWoCd7buX5Eg04pP90vS5iNE,1267
12
- litellm_proxy_extras-0.1.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
- litellm_proxy_extras-0.1.2.dist-info/RECORD,,
9
+ litellm_proxy_extras/schema.prisma,sha256=ohGQijs_BC0W-RHAr9UVT5sxhDkQfS58VN6K9aRu8rc,14162
10
+ litellm_proxy_extras/utils.py,sha256=G4FaWA01jwQ4482CWtFERKp0BosCwxsuqyv7bAIk7xg,3203
11
+ litellm_proxy_extras-0.1.3.dist-info/LICENSE,sha256=sXDWv46INd01fgEWgdsCj01R4vsOqJIFj1bgH7ObgnM,1419
12
+ litellm_proxy_extras-0.1.3.dist-info/METADATA,sha256=MpKnw9itqRCFPbMFFrA_0q2pIOcOaosKh-R5ZcWptR8,1267
13
+ litellm_proxy_extras-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
+ litellm_proxy_extras-0.1.3.dist-info/RECORD,,