Feature: Log files (#423)

* log_file

feature: added a new parameter for crew that creates a txt file to log agent execution

* unit tests and documentation

unit test if file is created but not what is inside the file
This commit is contained in:
GabeKoga
2024-04-05 19:44:50 -03:00
committed by GitHub
parent aebc443b62
commit 9db99befb6
7 changed files with 231 additions and 5 deletions

View File

@@ -894,3 +894,21 @@ def test_disabled_memory_using_contextual_memory():
with patch.object(ContextualMemory, "build_context_for_task") as contextual_mem:
crew.kickoff()
contextual_mem.assert_not_called()
@pytest.mark.vcr(filter_headers=["authorization"])
def test_crew_log_file_output(tmp_path):
test_file = tmp_path / "logs.txt"
tasks = [
Task(
description="Say Hi",
expected_output="The word: Hi",
agent=researcher,
)
]
test_message = {"agent": "Researcher", "task": "Say Hi"}
crew = Crew(agents=[researcher], tasks=tasks, output_log_file=str(test_file))
crew.kickoff()
assert test_file.exists()