Adding manager llm

This commit is contained in:
João Moura
2024-04-16 16:50:37 -03:00
parent dd97a2674d
commit a391004432
4 changed files with 2865 additions and 6 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -912,3 +912,35 @@ def test_crew_log_file_output(tmp_path):
crew = Crew(agents=[researcher], tasks=tasks, output_log_file=str(test_file))
crew.kickoff()
assert test_file.exists()
@pytest.mark.vcr(filter_headers=["authorization"])
def test_manager_agent():
from unittest.mock import patch
from langchain_openai import ChatOpenAI
task = Task(
description="Come up with a list of 5 interesting ideas to explore for an article, then write one amazing paragraph highlight for each idea that showcases how good an article about this topic could be. Return the list of ideas with their paragraph and your notes.",
expected_output="5 bullet points with a paragraph for each idea.",
)
manager = Agent(
role="Manager",
goal="Manage the crew and ensure the tasks are completed efficiently.",
backstory="You're an experienced manager, skilled in overseeing complex projects and guiding teams to success. Your role is to coordinate the efforts of the crew members, ensuring that each task is completed on time and to the highest standard.",
allow_delegation=False,
llm=ChatOpenAI(temperature=0, model="gpt-4"),
)
crew = Crew(
agents=[researcher, writer],
process=Process.hierarchical,
manager_agent=manager,
tasks=[task],
)
with patch.object(Task, "execute") as execute:
crew.kickoff()
assert manager.allow_delegation == True
execute.assert_called()