mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-25 08:08:14 +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:
@@ -2,6 +2,10 @@ import os
|
||||
import tempfile
|
||||
import pytest
|
||||
from crewai.memory import ShortTermMemory, LongTermMemory, EntityMemory
|
||||
from crewai.utilities.exceptions.embedding_exceptions import (
|
||||
EmbeddingConfigurationError,
|
||||
EmbeddingProviderError
|
||||
)
|
||||
from crewai.utilities import EmbeddingConfigurator
|
||||
|
||||
@pytest.fixture
|
||||
@@ -32,3 +36,26 @@ def test_memory_reset_with_openai(temp_db_dir):
|
||||
]
|
||||
for memory in memories:
|
||||
memory.reset()
|
||||
|
||||
def test_memory_reset_with_invalid_provider(temp_db_dir):
|
||||
os.environ["CREWAI_EMBEDDING_PROVIDER"] = "invalid_provider"
|
||||
with pytest.raises(EmbeddingProviderError):
|
||||
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)
|
||||
# Should use default URL when CREWAI_OLLAMA_URL is not set
|
||||
memories = [
|
||||
ShortTermMemory(path=temp_db_dir),
|
||||
LongTermMemory(path=temp_db_dir),
|
||||
EntityMemory(path=temp_db_dir)
|
||||
]
|
||||
for memory in memories:
|
||||
memory.reset()
|
||||
|
||||
Reference in New Issue
Block a user