mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 22:18:10 -05:00
fix: widen openai version constraint to allow >=1.90.0
This fixes the dependency version conflict between CrewAI and packages like mem0ai that require openai>=1.90.0. Changes: - Updated openai constraint from ~=1.83.0 to >=1.83.0,<2.0.0 - Added tests to verify the constraint allows mem0ai compatibility - Added tests to verify all OpenAI imports used by CrewAI are available Fixes #4098 Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -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.0.0",
|
||||
"instructor>=1.3.3",
|
||||
# Text Processing
|
||||
"pdfplumber~=0.11.4",
|
||||
|
||||
66
lib/crewai/tests/test_dependency_constraints.py
Normal file
66
lib/crewai/tests/test_dependency_constraints.py
Normal file
@@ -0,0 +1,66 @@
|
||||
"""Test that dependency constraints are properly configured to avoid conflicts."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import tomli
|
||||
|
||||
|
||||
def test_openai_version_constraint_allows_mem0ai_compatibility():
|
||||
"""Test that the openai version constraint allows versions >= 1.90.0.
|
||||
|
||||
This test ensures that the openai dependency constraint is flexible enough
|
||||
to allow installation alongside packages like mem0ai that require openai>=1.90.0.
|
||||
|
||||
See: https://github.com/crewAIInc/crewAI/issues/4098
|
||||
"""
|
||||
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
|
||||
|
||||
with open(pyproject_path, "rb") as f:
|
||||
pyproject = tomli.load(f)
|
||||
|
||||
dependencies = pyproject.get("project", {}).get("dependencies", [])
|
||||
|
||||
openai_dep = None
|
||||
for dep in dependencies:
|
||||
if dep.startswith("openai"):
|
||||
openai_dep = dep
|
||||
break
|
||||
|
||||
assert openai_dep is not None, "openai dependency not found in pyproject.toml"
|
||||
|
||||
assert "~=" not in openai_dep, (
|
||||
f"openai dependency uses ~= operator which is too restrictive: {openai_dep}. "
|
||||
"This causes conflicts with packages like mem0ai that require openai>=1.90.0"
|
||||
)
|
||||
|
||||
assert ">=" in openai_dep, (
|
||||
f"openai dependency should use >= operator for minimum version: {openai_dep}"
|
||||
)
|
||||
|
||||
assert "1.83.0" in openai_dep, (
|
||||
f"openai dependency should have minimum version 1.83.0: {openai_dep}"
|
||||
)
|
||||
|
||||
|
||||
def test_openai_imports_are_available():
|
||||
"""Test that all OpenAI imports used by CrewAI are available.
|
||||
|
||||
This test verifies that the OpenAI SDK version installed provides
|
||||
all the imports that CrewAI depends on.
|
||||
"""
|
||||
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
|
||||
|
||||
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 ChatCompletion is not None
|
||||
assert ChatCompletionChunk is not None
|
||||
assert ChatCompletionStream is not None
|
||||
assert Choice is not None
|
||||
assert ChoiceDelta is not None
|
||||
Reference in New Issue
Block a user