The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Revert "Fix: make `pondpond` as optional dependency for `proxy` extras, disab…" (#14880)
Ishaan Jaffd9bf6a8c53db
diff --git a/litellm/litellm_core_utils/object_pooling.py b/litellm/litellm_core_utils/object_pooling.pyindex 81c3ec2e133..846e6536f80 100644--- a/litellm/litellm_core_utils/object_pooling.py+++ b/litellm/litellm_core_utils/object_pooling.py@@ -16,35 +16,11 @@ Memory Management Strategy:from typing import Any, Callable, Optional, Type, TypeVar-try:- from pond import Pond, PooledObject, PooledObjectFactory # type: ignore- POND_AVAILABLE = True-except ImportError: # pragma: no cover- POND_AVAILABLE = False- class Pond: # type: ignore- def __init__(self, *args: Any, **kwargs: Any) -> None:- pass-- def register(self, *args: Any, **kwargs: Any) -> None:- pass-- def borrow(self, *args: Any, **kwargs: Any) -> Any:- pass-- def recycle(self, *args: Any, **kwargs: Any) -> None:- pass-- class PooledObject: # type: ignore- def __init__(self, keeped_object: Any = None) -> None:- self.keeped_object = keeped_object-- class PooledObjectFactory: # type: ignore- def __init__(self, *args: Any, **kwargs: Any) -> None:- pass+from pond import Pond, PooledObject, PooledObjectFactoryT = TypeVar('T')-class GenericPooledObjectFactory(PooledObjectFactory): # type: ignore[misc]+class GenericPooledObjectFactory(PooledObjectFactory):"""Generic factory class for creating pooled objects of any type."""def __init__(@@ -103,7 +79,7 @@ def get_object_pool(time_between_eviction_runs: int = 300, # Less frequent eviction to maintain high reuse ratioeviction_weight: float = 0.3, # Less aggressive eviction for better reuseprewarm_count: int = 5 # Lower pre-warm count to reduce initial memory usage-) -> Pond | None:+) -> Pond:"""Get or create a global object pool instance with balanced eviction-based memory control.Memory is controlled through moderate eviction to balance reuse ratio and memory usage:@@ -122,13 +98,9 @@ def get_object_pool(prewarm_count: Number of objects to pre-warm the pool with (default: 5)Returns:- Pond instance for the specified object type or None if pond is not available+ Pond instance for the specified object type"""- # If pond is not available, disable pooling gracefully- if not POND_AVAILABLE:- return None-if pool_name in _pools:return _pools[pool_name]@@ -162,4 +134,4 @@ def _prewarm_pool(pond: Pond, pool_name: str, prewarm_count: int = 20) -> None:pond.recycle(pooled_obj, name=f"{pool_name}Factory")except Exception:# If pre-warming fails, just continue- break+ break\ No newline at end of filediff --git a/poetry.lock b/poetry.lockindex 87599768db6..a8ef9ee79df 100644--- a/poetry.lock+++ b/poetry.lock@@ -2730,10 +2730,9 @@ files = [name = "madoka"version = "0.7.1"description = "Memory-efficient CountMin Sketch key-value structure (based on Madoka C++ library)"-optional = true+optional = falsepython-versions = "*"groups = ["main"]-markers = "extra == \"proxy\""files = [{file = "madoka-0.7.1-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:7521eee9ace30b376bb54fdcb2cb42bf6b7a0346b0d0b612f25f3299aa4a95af"},{file = "madoka-0.7.1.tar.gz", hash = "sha256:e258baa84fc0a3764365993b8bf5e1b065383a6ca8c9f862fb3e3e709843fae7"},@@ -4045,10 +4044,9 @@ xlsxwriter = ["xlsxwriter"]name = "pondpond"version = "1.4.1"description = "Pond is a high performance object-pooling library for Python."-optional = true+optional = falsepython-versions = ">=3.8"groups = ["main"]-markers = "extra == \"proxy\""files = [{file = "pondpond-1.4.1-py3-none-any.whl", hash = "sha256:641028ead4e8018ca6de1220c660ddd6d6fbf62a60e72f410655dd0451d82880"},{file = "pondpond-1.4.1.tar.gz", hash = "sha256:8afa34b869d1434d21dd2ec12644abc3b1733fcda8fcf355300338a13a79bb7b"},@@ -6749,11 +6747,11 @@ type = ["pytest-mypy"]caching = ["diskcache"]extra-proxy = ["azure-identity", "azure-keyvault-secrets", "google-cloud-iam", "google-cloud-kms", "prisma", "redisvl", "resend"]mlflow = ["mlflow"]-proxy = ["PyJWT", "apscheduler", "azure-identity", "azure-storage-blob", "backoff", "boto3", "cryptography", "fastapi", "fastapi-sso", "fastuuid", "gunicorn", "litellm-enterprise", "litellm-proxy-extras", "mcp", "orjson", "polars", "pondpond", "pynacl", "python-multipart", "pyyaml", "rich", "rq", "uvicorn", "uvloop", "websockets"]+proxy = ["PyJWT", "apscheduler", "azure-identity", "azure-storage-blob", "backoff", "boto3", "cryptography", "fastapi", "fastapi-sso", "fastuuid", "gunicorn", "litellm-enterprise", "litellm-proxy-extras", "mcp", "orjson", "polars", "pynacl", "python-multipart", "pyyaml", "rich", "rq", "uvicorn", "uvloop", "websockets"]semantic-router = ["semantic-router"]utils = ["numpydoc"][metadata]lock-version = "2.1"python-versions = ">=3.8.1,<4.0, !=3.9.7"-content-hash = "16fdc1044b4bb316803cbf1825bc970895526949a8bef93eab741777b7210ca8"+content-hash = "75004c6a23b70be86622fa417fd0d62fa3843e6e61c8dff8507ae5c967b7205d"diff --git a/pyproject.toml b/pyproject.tomlindex 4113714415c..b11b1a1c2e2 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -31,7 +31,7 @@ jinja2 = "^3.1.2"aiohttp = ">=3.10"pydantic = "^2.5.0"jsonschema = "^4.22.0"-pondpond = {version = "^1.4.1", optional = true}+pondpond = "^1.4.1"numpydoc = {version = "*", optional = true} # used in utils.pyfastuuid = {version = ">=0.12.0", optional = true}@@ -94,7 +94,6 @@ proxy = ["rich","polars","fastuuid",- "pondpond",]extra_proxy = [diff --git a/tests/litellm_utils_tests/test_object_pooling.py b/tests/litellm_utils_tests/test_object_pooling.pyindex 8d0272e92b9..5cdc38ee452 100644--- a/tests/litellm_utils_tests/test_object_pooling.py+++ b/tests/litellm_utils_tests/test_object_pooling.py@@ -3,7 +3,6 @@ Simplified tests for object pooling utilities in litellm."""import pytest-pytest.importorskip("pond")from litellm.litellm_core_utils.object_pooling import (get_object_pool,@@ -104,4 +103,4 @@ class TestObjectPooling:if __name__ == "__main__":- pytest.main([__file__])+ pytest.main([__file__])\ No newline at end of file