测试
测试是开发流程中至关重要的一部分,确保你的 crew 的表现符合预期是必不可少的。使用 crewAI,你可以借助内置测试能力轻松测试 crew 并评估其表现。
使用测试功能
Section titled “使用测试功能”我们加入了 CLI 命令 crewai test,让测试 crew 变得更简单。这个命令会让你的 crew 运行指定次数,并提供详细的性能指标。参数是 n_iterations 和 model,它们都是可选的,默认值分别为 2 和 gpt-4o-mini。目前唯一可用的 provider 是 OpenAI。
crewai test如果你想运行更多轮次或使用不同模型,可以像这样指定参数:
crewai test --n_iterations 5 --model gpt-4o或者使用短参数形式:
crewai test -n 5 -m gpt-4o运行 crewai test 命令时,crew 会按指定轮次数执行,性能指标会在运行结束时展示。
最后会有一张分数表,展示 crew 在以下指标上的表现:
| Tasks/Crew/Agents | Run 1 | Run 2 | Avg. Total | Agents | Additional Info |
|---|---|---|---|---|---|
| Task 1 | 9.0 | 9.5 | 9.2 | Professional Insights | |
| Researcher | |||||
| Task 2 | 9.0 | 10.0 | 9.5 | Company Profile Investigator | |
| Task 3 | 9.0 | 9.0 | 9.0 | Automation Insights | |
| Specialist | |||||
| Task 4 | 9.0 | 9.0 | 9.0 | Final Report Compiler | Automation Insights Specialist |
| Crew | 9.00 | 9.38 | 9.2 | ||
| Execution Time (s) | 126 | 145 | 135 |
上面的示例展示了 crew 在两次运行中的测试结果,包含两个任务,以及每个任务和整个 crew 的平均总分。