litellm-proxy-extras 0.1.0__tar.gz → 0.1.2__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.

@@ -0,0 +1,26 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ * All content that resides under the "enterprise/" directory of this repository, if that directory exists, is licensed under the license defined in "enterprise/LICENSE".
4
+ * Content outside of the above mentioned directories or restrictions above is available under the MIT license as defined below.
5
+ ---
6
+ MIT License
7
+
8
+ Copyright (c) 2023 Berri AI
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: litellm-proxy-extras
3
- Version: 0.1.0
3
+ Version: 0.1.2
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,12 @@
1
+ import logging
2
+
3
+ # Set up package logger
4
+ logger = logging.getLogger("litellm_proxy_extras")
5
+ if not logger.handlers: # Only add handler if none exists
6
+ handler = logging.StreamHandler()
7
+ formatter = logging.Formatter(
8
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
9
+ )
10
+ handler.setFormatter(formatter)
11
+ logger.addHandler(handler)
12
+ logger.setLevel(logging.INFO)
@@ -0,0 +1,4 @@
1
+ -- AlterTable
2
+ ALTER TABLE "LiteLLM_DailyUserSpend" ADD COLUMN "failed_requests" INTEGER NOT NULL DEFAULT 0,
3
+ ADD COLUMN "successful_requests" INTEGER NOT NULL DEFAULT 0;
4
+
@@ -0,0 +1,80 @@
1
+ import os
2
+ import random
3
+ import subprocess
4
+ import time
5
+ from typing import Optional
6
+
7
+ from litellm_proxy_extras._logging import logger
8
+
9
+
10
+ def str_to_bool(value: Optional[str]) -> bool:
11
+ if value is None:
12
+ return False
13
+ return value.lower() in ("true", "1", "t", "y", "yes")
14
+
15
+
16
+ class ProxyExtrasDBManager:
17
+ @staticmethod
18
+ def setup_database(schema_path: str, use_migrate: bool = False) -> bool:
19
+ """
20
+ Set up the database using either prisma migrate or prisma db push
21
+ Uses migrations from litellm-proxy-extras package
22
+
23
+ Args:
24
+ schema_path (str): Path to the Prisma schema file
25
+ use_migrate (bool): Whether to use prisma migrate instead of db push
26
+
27
+ Returns:
28
+ bool: True if setup was successful, False otherwise
29
+ """
30
+ use_migrate = str_to_bool(os.getenv("USE_PRISMA_MIGRATE")) or use_migrate
31
+ for attempt in range(4):
32
+ original_dir = os.getcwd()
33
+ schema_dir = os.path.dirname(schema_path)
34
+ os.chdir(schema_dir)
35
+
36
+ try:
37
+ if use_migrate:
38
+ logger.info("Running prisma migrate deploy")
39
+ try:
40
+ # Set migrations directory for Prisma
41
+ subprocess.run(
42
+ ["prisma", "migrate", "deploy"],
43
+ timeout=60,
44
+ check=True,
45
+ capture_output=True,
46
+ text=True,
47
+ )
48
+ logger.info("prisma migrate deploy completed")
49
+ return True
50
+ except subprocess.CalledProcessError as e:
51
+ logger.info(f"prisma db error: {e.stderr}, e: {e.stdout}")
52
+ if (
53
+ "P3005" in e.stderr
54
+ and "database schema is not empty" in e.stderr
55
+ ):
56
+ logger.info("Error: Database schema is not empty")
57
+ return False
58
+ else:
59
+ # Use prisma db push with increased timeout
60
+ subprocess.run(
61
+ ["prisma", "db", "push", "--accept-data-loss"],
62
+ timeout=60,
63
+ check=True,
64
+ )
65
+ return True
66
+ except subprocess.TimeoutExpired:
67
+ logger.info(f"Attempt {attempt + 1} timed out")
68
+ time.sleep(random.randrange(5, 15))
69
+ except subprocess.CalledProcessError as e:
70
+ attempts_left = 3 - attempt
71
+ retry_msg = (
72
+ f" Retrying... ({attempts_left} attempts left)"
73
+ if attempts_left > 0
74
+ else ""
75
+ )
76
+ logger.info(f"The process failed to execute. Details: {e}.{retry_msg}")
77
+ time.sleep(random.randrange(5, 15))
78
+ finally:
79
+ os.chdir(original_dir)
80
+ return False
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "litellm-proxy-extras"
3
- version = "0.1.0"
3
+ version = "0.1.2"
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"
@@ -20,3 +20,11 @@ python = ">=3.8.1,<4.0, !=3.9.7"
20
20
  [build-system]
21
21
  requires = ["poetry-core"]
22
22
  build-backend = "poetry.core.masonry.api"
23
+
24
+ [tool.commitizen]
25
+ version = "0.1.2"
26
+ version_files = [
27
+ "pyproject.toml:version",
28
+ "../requirements.txt:litellm-proxy-extras==",
29
+ "../pyproject.toml:litellm-proxy-extras = {version = \""
30
+ ]