"""CrewAI backend — uses crewai for task-oriented multi-agent discussion.""" def check_installed(): try: import crewai # noqa return True except ImportError: return False def run(scenario_path: str, config: dict): if not check_installed(): print("CrewAI is not installed. Run:\n pip install meeting-room[crewai]") return [] import yaml from crewai import Agent, Task, Crew, Process from meeting_room.scenario_loader import load_scenario scenario = load_scenario(scenario_path) roles = config["roles"] participants = scenario.get("participants", list(roles.keys())) agents = [] for role_id in participants: role = roles[role_id] agent = Agent( role=role["name"], goal=role["system_prompt"].split(".")[0] + ".", backstory=role["system_prompt"].strip(), llm=f"{role['provider']}/{role['model']}", verbose=True, ) agents.append(agent) discuss_task = Task( description=f"Discuss this problem as a group:\n\n{scenario['problem']}", agent=agents[0], expected_output="Final solution with arguments from each participant", ) crew = Crew( agents=agents, tasks=[discuss_task], process=Process.sequential, verbose=True, ) result = crew.kickoff() print(f"\n{'='*60}\nCREWAI RESULT:\n{'='*60}\n") print(result) return str(result)