diff --git a/pyproject.toml b/pyproject.toml index 28e1edc39..aab6cc16f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ dependencies = [ # Core Dependencies "pydantic>=2.4.2", "openai>=1.13.3", - "litellm>=1.65.1", + "litellm>=1.65.1,<2.0.0", "instructor>=1.3.3", # Text Processing "pdfplumber>=0.11.4", diff --git a/tests/test_dependency_compatibility.py b/tests/test_dependency_compatibility.py index 082f8d6bc..4150ae879 100644 --- a/tests/test_dependency_compatibility.py +++ b/tests/test_dependency_compatibility.py @@ -1,49 +1,85 @@ +""" +Dependency Compatibility Tests + +Tests to verify compatibility between litellm and other packages that depend on httpx. + +Known working versions: +- httpx >= 0.28.1 +- litellm >= 1.65.1 +- exa-py (optional) +- google-genai (optional) +""" import importlib.util import sys import pytest -def test_httpx_litellm_compatibility(): - """Test that litellm is compatible with the latest httpx""" +def _check_optional_dependency(package_name): + """Centralized handling of optional dependency checks""" + if importlib.util.find_spec(package_name) is None: + pytest.skip(f"{package_name} not installed. Skipping compatibility test.") + return True + + +@pytest.fixture(autouse=True) +def log_versions(): + """Log all relevant package versions before tests""" import httpx import litellm - assert hasattr(httpx, "__version__") - - print(f"Using httpx version: {httpx.__version__}") - print("Successfully imported litellm") + versions = { + "httpx": httpx.__version__, + } + print("\nRunning tests with versions:", versions) + return versions -def test_exa_py_compatibility(): - """Test that exa-py can be imported alongside litellm""" - if importlib.util.find_spec("exa") is None: - pytest.skip("exa-py not installed") +class TestDependencyCompatibility: + """Test suite for checking package dependency compatibility""" - import exa - import httpx - import litellm + def test_httpx_litellm_compatibility(self): + """Test that litellm is compatible with the latest httpx""" + import httpx + import litellm + + try: + assert hasattr(httpx, "__version__") + min_required_version = "0.28.1" # Minimum required version + from packaging import version + assert version.parse(httpx.__version__) >= version.parse(min_required_version) + except (AssertionError, ImportError) as e: + pytest.fail(f"httpx version {httpx.__version__} is not compatible. Minimum required: {min_required_version}. Error: {e}") + + print(f"Using httpx version: {httpx.__version__}") + print("Successfully imported litellm") - assert hasattr(exa, "__version__") - assert hasattr(httpx, "__version__") + def test_exa_py_compatibility(self): + """Test that exa-py can be imported alongside litellm""" + _check_optional_dependency("exa") + + import exa + import httpx + import litellm + + assert hasattr(exa, "__version__") + assert hasattr(httpx, "__version__") + + print(f"Using exa-py version: {exa.__version__}") + print("Successfully imported litellm") + print(f"Using httpx version: {httpx.__version__}") - print(f"Using exa-py version: {exa.__version__}") - print("Successfully imported litellm") - print(f"Using httpx version: {httpx.__version__}") - - -def test_google_genai_compatibility(): - """Test that google-genai can be imported alongside litellm""" - if importlib.util.find_spec("google.generativeai") is None: - pytest.skip("google-genai not installed") - - import httpx - import litellm - from google import generativeai - - assert hasattr(generativeai, "version") - assert hasattr(httpx, "__version__") - - print(f"Using google-genai version: {generativeai.version}") - print("Successfully imported litellm") - print(f"Using httpx version: {httpx.__version__}") + def test_google_genai_compatibility(self): + """Test that google-genai can be imported alongside litellm""" + _check_optional_dependency("google.generativeai") + + import httpx + import litellm + from google import generativeai + + assert hasattr(generativeai, "version") + assert hasattr(httpx, "__version__") + + print(f"Using google-genai version: {generativeai.version}") + print("Successfully imported litellm") + print(f"Using httpx version: {httpx.__version__}")