This commit is contained in:
Lorenze Jay
2024-11-27 11:27:27 -08:00
parent 3eb52dad9f
commit 61fe1c69d9
2 changed files with 528 additions and 17 deletions

View File

@@ -1599,6 +1599,7 @@ def test_agent_with_knowledge_sources():
goal="Provide information based on knowledge sources",
backstory="You have access to specific knowledge sources.",
llm=LLM(model="gpt-4o-mini"),
knowledge_sources=[string_source],
)
# Create a task that requires the agent to use the knowledge
@@ -1613,20 +1614,3 @@ def test_agent_with_knowledge_sources():
# Assert that the agent provides the correct information
assert "blue" in result.raw.lower()
def test_agent_with_knowledge_sources_context():
content = "Brandon's favorite color is blue and he likes Mexican food."
string_source = StringKnowledgeSource(
content=content, metadata={"preference": "personal"}
)
agent = Agent(
role="Information Agent",
goal="Provide information based on knowledge sources",
backstory="You have access to specific knowledge sources.",
knowledge_sources=[string_source],
)
assert isinstance(agent.knowledge_sources, list)
assert len(agent.knowledge_sources) == 1
assert isinstance(agent.knowledge_sources[0], BaseKnowledgeSource)
assert agent.knowledge_sources[0].metadata == {"preference": "personal"}