mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-12 14:02:47 +00:00
fix: remove deprecated InitFrom import from qdrant-client
The InitFrom class has been removed from qdrant-client in newer versions (1.16.2+), causing ImportError when importing crewai.rag.qdrant modules. This commit: - Removes InitFrom import from qdrant_client.models - Removes init_from field from CommonCreateFields TypedDict - Removes init_from handling from _get_collection_params function - Updates docstrings to remove init_from parameter references - Adds tests to verify the import works correctly Fixes #4305 Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -80,7 +80,6 @@ class QdrantClient(BaseClient):
|
||||
optimizers_config: Optional optimizer configuration.
|
||||
wal_config: Optional write-ahead log configuration.
|
||||
quantization_config: Optional quantization configuration.
|
||||
init_from: Optional collection to initialize from.
|
||||
timeout: Optional timeout for the operation.
|
||||
|
||||
Raises:
|
||||
@@ -120,7 +119,6 @@ class QdrantClient(BaseClient):
|
||||
optimizers_config: Optional optimizer configuration.
|
||||
wal_config: Optional write-ahead log configuration.
|
||||
quantization_config: Optional quantization configuration.
|
||||
init_from: Optional collection to initialize from.
|
||||
timeout: Optional timeout for the operation.
|
||||
|
||||
Raises:
|
||||
@@ -160,7 +158,6 @@ class QdrantClient(BaseClient):
|
||||
optimizers_config: Optional optimizer configuration.
|
||||
wal_config: Optional write-ahead log configuration.
|
||||
quantization_config: Optional quantization configuration.
|
||||
init_from: Optional collection to initialize from.
|
||||
timeout: Optional timeout for the operation.
|
||||
|
||||
Returns:
|
||||
@@ -204,7 +201,6 @@ class QdrantClient(BaseClient):
|
||||
optimizers_config: Optional optimizer configuration.
|
||||
wal_config: Optional write-ahead log configuration.
|
||||
quantization_config: Optional quantization configuration.
|
||||
init_from: Optional collection to initialize from.
|
||||
timeout: Optional timeout for the operation.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -16,7 +16,6 @@ from qdrant_client.models import ( # type: ignore[import-not-found]
|
||||
HasIdCondition,
|
||||
HasVectorCondition,
|
||||
HnswConfigDiff,
|
||||
InitFrom,
|
||||
IsEmptyCondition,
|
||||
IsNullCondition,
|
||||
NestedCondition,
|
||||
@@ -129,7 +128,6 @@ class CommonCreateFields(TypedDict, total=False):
|
||||
optimizers_config: OptimizersConfigDiff
|
||||
wal_config: WalConfigDiff
|
||||
quantization_config: QuantizationConfig
|
||||
init_from: InitFrom | str
|
||||
timeout: Annotated[int, "Operation timeout in seconds"]
|
||||
|
||||
|
||||
|
||||
@@ -113,8 +113,6 @@ def _get_collection_params(
|
||||
params["wal_config"] = kwargs["wal_config"]
|
||||
if "quantization_config" in kwargs:
|
||||
params["quantization_config"] = kwargs["quantization_config"]
|
||||
if "init_from" in kwargs:
|
||||
params["init_from"] = kwargs["init_from"]
|
||||
if "timeout" in kwargs:
|
||||
params["timeout"] = kwargs["timeout"]
|
||||
|
||||
|
||||
51
lib/crewai/tests/rag/qdrant/test_types.py
Normal file
51
lib/crewai/tests/rag/qdrant/test_types.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Tests for Qdrant types module."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
class TestQdrantTypesImport:
|
||||
"""Test suite for Qdrant types module imports."""
|
||||
|
||||
def test_qdrant_types_import_succeeds(self):
|
||||
"""Test that qdrant types module can be imported without errors.
|
||||
|
||||
This test verifies that the types module is compatible with the
|
||||
installed version of qdrant-client, particularly ensuring that
|
||||
removed/deprecated imports like InitFrom don't cause ImportError.
|
||||
"""
|
||||
from crewai.rag.qdrant.types import (
|
||||
CommonCreateFields,
|
||||
CreateCollectionParams,
|
||||
EmbeddingFunction,
|
||||
QdrantClientParams,
|
||||
QdrantCollectionCreateParams,
|
||||
)
|
||||
|
||||
assert CommonCreateFields is not None
|
||||
assert CreateCollectionParams is not None
|
||||
assert EmbeddingFunction is not None
|
||||
assert QdrantClientParams is not None
|
||||
assert QdrantCollectionCreateParams is not None
|
||||
|
||||
def test_common_create_fields_does_not_have_init_from(self):
|
||||
"""Test that CommonCreateFields no longer has init_from field.
|
||||
|
||||
The init_from field was removed because InitFrom class was
|
||||
deprecated and removed from qdrant-client.
|
||||
"""
|
||||
from crewai.rag.qdrant.types import CommonCreateFields
|
||||
|
||||
annotations = CommonCreateFields.__annotations__
|
||||
assert "init_from" not in annotations
|
||||
|
||||
def test_qdrant_client_module_import_succeeds(self):
|
||||
"""Test that the qdrant client module can be imported without errors."""
|
||||
from crewai.rag.qdrant.client import QdrantClient
|
||||
|
||||
assert QdrantClient is not None
|
||||
|
||||
def test_qdrant_utils_module_import_succeeds(self):
|
||||
"""Test that the qdrant utils module can be imported without errors."""
|
||||
from crewai.rag.qdrant.utils import _get_collection_params
|
||||
|
||||
assert _get_collection_params is not None
|
||||
Reference in New Issue
Block a user