From 75b4e8445700782ded2c3ee3d4c49ff7a49f0da1 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 12:15:00 +0000 Subject: [PATCH] improve: address PR feedback for OpenAI 1.78 support - Add inline documentation for litellm version constraints - Improve test implementation with pytest markers and constants - Add clearer assertion messages for better error reporting Co-Authored-By: Joe Moura --- pyproject.toml | 2 ++ tests/test_openai_178_compatibility.py | 35 +++++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c86c1ecda..55b4a8807 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,8 @@ dependencies = [ # Core Dependencies "pydantic>=2.4.2", "openai>=1.13.3", + # litellm: v1.68.0+ required for OpenAI 1.78 compatibility + # Upper bound <1.72.0 to ensure stability and prevent issues with breaking changes "litellm>=1.68.0,<1.72.0", "instructor>=1.3.3", # Text Processing diff --git a/tests/test_openai_178_compatibility.py b/tests/test_openai_178_compatibility.py index fe431fe95..cf303b0b2 100644 --- a/tests/test_openai_178_compatibility.py +++ b/tests/test_openai_178_compatibility.py @@ -4,20 +4,22 @@ import pytest from crewai import LLM, Agent, Crew, Task, TaskOutput +TEST_IMAGES = { + "product_shoe": "https://www.us.maguireshoes.com/cdn/shop/files/FW24-Edito-Lucena-Distressed-01_1920x.jpg?v=1736371244", + "sample_image": "https://example.com/sample-image.jpg" +} + +@pytest.mark.requires_api_key @pytest.mark.skip(reason="Only run manually with valid API keys") def test_openai_178_compatibility_with_multimodal(): - """ - Test that CrewAI works with OpenAI 1.78.0 and multi-image input support. - This test verifies the fix for issue #2910. - """ - OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") - if not OPENAI_API_KEY: - pytest.skip("OPENAI_API_KEY environment variable not set") + """Test CrewAI compatibility with OpenAI 1.78.0 multi-image support.""" + if not os.getenv("OPENAI_API_KEY"): + pytest.skip("Test requires OPENAI_API_KEY environment variable") llm = LLM( model="openai/gpt-4o", # model with vision capabilities - api_key=OPENAI_API_KEY, + api_key=os.getenv("OPENAI_API_KEY"), temperature=0.7 ) @@ -34,11 +36,14 @@ def test_openai_178_compatibility_with_multimodal(): analysis_task = Task( description=""" Analyze these product images: - 1. https://www.us.maguireshoes.com/cdn/shop/files/FW24-Edito-Lucena-Distressed-01_1920x.jpg?v=1736371244 - 2. https://example.com/sample-image.jpg + 1. {product_shoe} + 2. {sample_image} Provide a comparative analysis focusing on design elements and quality indicators. - """, + """.format( + product_shoe=TEST_IMAGES["product_shoe"], + sample_image=TEST_IMAGES["sample_image"] + ), expected_output="A comparative analysis of the provided images", agent=visual_agent ) @@ -46,8 +51,8 @@ def test_openai_178_compatibility_with_multimodal(): crew = Crew(agents=[visual_agent], tasks=[analysis_task]) result = crew.kickoff() - assert result is not None - assert len(result.tasks_output) == 1 + assert result is not None, "Crew execution returned None" + assert len(result.tasks_output) == 1, "Expected exactly one task output" task_output = result.tasks_output[0] - assert isinstance(task_output, TaskOutput) - assert len(task_output.raw) > 0 + assert isinstance(task_output, TaskOutput), f"Expected TaskOutput, got {type(task_output)}" + assert len(task_output.raw) > 0, "Task output should contain content"