mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
Update memory tests to handle optional ChromaDB dependency
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -2384,6 +2384,16 @@ def test_multiple_conditional_tasks(researcher, writer):
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_using_contextual_memory():
|
def test_using_contextual_memory():
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
# Check if ChromaDB is available
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
@@ -2412,6 +2422,16 @@ def test_using_contextual_memory():
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_using_contextual_memory_with_long_term_memory():
|
def test_using_contextual_memory_with_long_term_memory():
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
# Check if ChromaDB is available
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
@@ -2441,6 +2461,16 @@ def test_using_contextual_memory_with_long_term_memory():
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_warning_long_term_memory_without_entity_memory():
|
def test_warning_long_term_memory_without_entity_memory():
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
# Check if ChromaDB is available
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
@@ -2478,6 +2508,16 @@ def test_warning_long_term_memory_without_entity_memory():
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_long_term_memory_with_memory_flag():
|
def test_long_term_memory_with_memory_flag():
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
# Check if ChromaDB is available
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
@@ -2513,6 +2553,16 @@ def test_long_term_memory_with_memory_flag():
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_using_contextual_memory_with_short_term_memory():
|
def test_using_contextual_memory_with_short_term_memory():
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
# Check if ChromaDB is available
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
@@ -2542,6 +2592,16 @@ def test_using_contextual_memory_with_short_term_memory():
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_disabled_memory_using_contextual_memory():
|
def test_disabled_memory_using_contextual_memory():
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
# Check if ChromaDB is available
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
|
|||||||
@@ -7,10 +7,28 @@ from crewai.memory.long_term.long_term_memory_item import LongTermMemoryItem
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def long_term_memory():
|
def long_term_memory():
|
||||||
"""Fixture to create a LongTermMemory instance"""
|
"""Fixture to create a LongTermMemory instance"""
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
return LongTermMemory()
|
return LongTermMemory()
|
||||||
|
|
||||||
|
|
||||||
def test_save_and_search(long_term_memory):
|
def test_save_and_search(long_term_memory):
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
memory = LongTermMemoryItem(
|
memory = LongTermMemoryItem(
|
||||||
agent="test_agent",
|
agent="test_agent",
|
||||||
task="test_task",
|
task="test_task",
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ from crewai.task import Task
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def short_term_memory():
|
def short_term_memory():
|
||||||
"""Fixture to create a ShortTermMemory instance"""
|
"""Fixture to create a ShortTermMemory instance"""
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
role="Researcher",
|
role="Researcher",
|
||||||
goal="Search relevant data and provide results",
|
goal="Search relevant data and provide results",
|
||||||
@@ -29,6 +38,15 @@ def short_term_memory():
|
|||||||
|
|
||||||
|
|
||||||
def test_save_and_search(short_term_memory):
|
def test_save_and_search(short_term_memory):
|
||||||
|
try:
|
||||||
|
import chromadb
|
||||||
|
HAS_CHROMADB = True
|
||||||
|
except ImportError:
|
||||||
|
HAS_CHROMADB = False
|
||||||
|
|
||||||
|
if not HAS_CHROMADB:
|
||||||
|
pytest.skip("ChromaDB is required for this test")
|
||||||
|
|
||||||
memory = ShortTermMemoryItem(
|
memory = ShortTermMemoryItem(
|
||||||
data="""test value test value test value test value test value test value
|
data="""test value test value test value test value test value test value
|
||||||
test value test value test value test value test value test value
|
test value test value test value test value test value test value
|
||||||
|
|||||||
Reference in New Issue
Block a user