mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-13 10:08:29 +00:00
feat: Add validation and improve documentation for embedder_config
- Add validation for embedder_config in Agent class - Add test cases for invalid embedder configurations - Improve docstrings with examples and error cases Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -36,6 +36,26 @@ def mock_vector_db():
|
||||
instance.reset.return_value = None
|
||||
yield instance
|
||||
|
||||
def test_agent_invalid_embedder_config():
|
||||
"""Test that an invalid embedder configuration raises a ValueError."""
|
||||
with pytest.raises(ValueError, match="embedder_config must contain 'provider' key"):
|
||||
Agent(
|
||||
role="test role",
|
||||
goal="test goal",
|
||||
backstory="test backstory",
|
||||
knowledge_sources=[StringKnowledgeSource(content="test content")],
|
||||
embedder_config={"invalid": "config"}
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="embedder_config must contain 'config' key"):
|
||||
Agent(
|
||||
role="test role",
|
||||
goal="test goal",
|
||||
backstory="test backstory",
|
||||
knowledge_sources=[StringKnowledgeSource(content="test content")],
|
||||
embedder_config={"provider": "custom"}
|
||||
)
|
||||
|
||||
def test_agent_knowledge_with_custom_embedder(mock_vector_db):
|
||||
agent = Agent(
|
||||
role="test role",
|
||||
|
||||
Reference in New Issue
Block a user