1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| from crewai import Agent, Task, Crew, Process
architect = Agent( role="软件架构师", goal="设计最佳系统架构", backstory="15 年经验的软件架构师,擅长微服务和 DDD", verbose=True )
developer = Agent( role="高级开发者", goal="实现高质量、可维护的代码", backstory="全栈开发者,精通 C# 和 Python", verbose=True )
qa = Agent( role="QA 工程师", goal="确保代码质量和测试覆盖", backstory="专注于自动化测试和代码审查", verbose=True )
design_task = Task( description="设计博客系统架构,包含用户、文章、评论模块", agent=architect, expected_output="技术栈和模块划分文档" )
implement_task = Task( description="实现博客系统的核心 CRUD API", agent=developer, expected_output="完整的 API 代码", context=[design_task] )
test_task = Task( description="为所有 API 端点编写集成测试", agent=qa, expected_output="测试代码和执行报告", context=[implement_task] )
crew = Crew( agents=[architect, developer, qa], tasks=[design_task, implement_task, test_task], process=Process.sequential )
result = crew.kickoff() print("最终输出:", result)
|