mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 09:08:31 +00:00
fix: Remove OpenAI dependency for memory reset when using alternative LLMs
- Add environment variables for default embedding provider - Support Ollama as default embedding provider - Add tests for memory reset with different providers - Update documentation Fixes #2023 Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -48,6 +48,19 @@ def test_memory_reset_with_invalid_provider(temp_db_dir):
|
||||
for memory in memories:
|
||||
memory.reset()
|
||||
|
||||
def test_memory_reset_with_invalid_configuration(temp_db_dir):
|
||||
os.environ["CREWAI_EMBEDDING_PROVIDER"] = "openai"
|
||||
os.environ.pop("OPENAI_API_KEY", None)
|
||||
|
||||
with pytest.raises(EmbeddingConfigurationError):
|
||||
memories = [
|
||||
ShortTermMemory(path=temp_db_dir),
|
||||
LongTermMemory(path=temp_db_dir),
|
||||
EntityMemory(path=temp_db_dir)
|
||||
]
|
||||
for memory in memories:
|
||||
memory.reset()
|
||||
|
||||
def test_memory_reset_with_missing_ollama_url(temp_db_dir):
|
||||
os.environ["CREWAI_EMBEDDING_PROVIDER"] = "ollama"
|
||||
os.environ.pop("CREWAI_OLLAMA_URL", None)
|
||||
@@ -59,3 +72,20 @@ def test_memory_reset_with_missing_ollama_url(temp_db_dir):
|
||||
]
|
||||
for memory in memories:
|
||||
memory.reset()
|
||||
|
||||
def test_memory_reset_with_custom_path(temp_db_dir):
|
||||
os.environ["CREWAI_EMBEDDING_PROVIDER"] = "ollama"
|
||||
custom_path = os.path.join(temp_db_dir, "custom")
|
||||
os.makedirs(custom_path, exist_ok=True)
|
||||
|
||||
memories = [
|
||||
ShortTermMemory(path=custom_path),
|
||||
LongTermMemory(path=custom_path),
|
||||
EntityMemory(path=custom_path)
|
||||
]
|
||||
for memory in memories:
|
||||
memory.reset()
|
||||
|
||||
assert not os.path.exists(os.path.join(custom_path, "short_term"))
|
||||
assert not os.path.exists(os.path.join(custom_path, "long_term"))
|
||||
assert not os.path.exists(os.path.join(custom_path, "entity"))
|
||||
|
||||
Reference in New Issue
Block a user