Compare commits

...

1 Commits

Author SHA1 Message Date
Devin AI
78de2038d7 fix: relax openai version constraint to allow newer SDK versions
- Change openai dependency from ~=1.83.0 to >=1.83.0,<2
- Add tests to verify OpenAI SDK imports compatibility
- Add test to verify OpenAI client instantiation

Fixes #4300

Co-Authored-By: João <joao@crewai.com>
2026-01-29 08:46:53 +00:00
2 changed files with 54 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ requires-python = ">=3.10, <3.14"
dependencies = [
# Core Dependencies
"pydantic~=2.11.9",
"openai~=1.83.0",
"openai>=1.83.0,<2",
"instructor>=1.3.3",
# Text Processing
"pdfplumber~=0.11.4",

View File

@@ -1397,3 +1397,56 @@ def test_openai_responses_api_both_auto_chains_work_together():
assert params.get("previous_response_id") == "resp_123"
assert "reasoning.encrypted_content" in params["include"]
assert len(params["input"]) == 2 # Reasoning item + message
def test_openai_sdk_imports_compatibility():
"""
Test that all OpenAI SDK imports used by CrewAI are available.
This test verifies that the OpenAI SDK version installed provides all the
types and classes that CrewAI depends on. If this test fails after updating
the OpenAI SDK, it indicates a breaking change in the SDK that needs to be
addressed.
Related to issue #4300: Dependency constraints in pyproject.toml are overly strict
"""
from openai import APIConnectionError, AsyncOpenAI, NotFoundError, OpenAI, Stream
from openai.lib.streaming.chat import ChatCompletionStream
from openai.types.chat import ChatCompletion, ChatCompletionChunk
from openai.types.chat.chat_completion import Choice
from openai.types.chat.chat_completion_chunk import ChoiceDelta
from openai.types.responses import Response
assert OpenAI is not None
assert AsyncOpenAI is not None
assert Stream is not None
assert APIConnectionError is not None
assert NotFoundError is not None
assert ChatCompletionStream is not None
assert ChatCompletion is not None
assert ChatCompletionChunk is not None
assert Choice is not None
assert ChoiceDelta is not None
assert Response is not None
def test_openai_sdk_client_instantiation():
"""
Test that OpenAI client can be instantiated with the current SDK version.
This test verifies that the OpenAI client initialization works correctly
with the installed SDK version, ensuring compatibility with newer versions.
Related to issue #4300: Dependency constraints in pyproject.toml are overly strict
"""
from openai import AsyncOpenAI, OpenAI
client = OpenAI(api_key="test-key")
async_client = AsyncOpenAI(api_key="test-key")
assert client is not None
assert async_client is not None
assert hasattr(client, "chat")
assert hasattr(client.chat, "completions")
assert hasattr(async_client, "chat")
assert hasattr(async_client.chat, "completions")