Testing

了解如何测试你的 CrewAI Crew 并评估其性能。

概述

测试是开发流程中的关键组成部分,它对于确保你的 crew 按预期运行至关重要。借助 crewAI,你可以使用内置测试能力,轻松测试你的 crew 并评估其性能。

使用测试功能

我们新增了 CLI 命令 crewai test,以便更方便地测试你的 crew。该命令会让你的 crew 按指定迭代次数运行,并提供详细的性能指标。参数包括 n_iterationsmodel,它们是可选的,默认值分别为 2 和 gpt-4o-mini。目前仅支持 OpenAI 作为 provider。

  1. crewai test

如果你想运行更多轮迭代,或者使用不同的模型,可以像下面这样指定参数:

  1. crewai test --n_iterations 5 --model gpt-4o

或者使用简写形式:

  1. crewai test -n 5 -m gpt-4o

当你运行 crewai test 命令时,crew 会按照指定的迭代次数执行,并在运行结束时显示性能指标。

最终会输出一个分数表,展示 crew 在以下指标上的表现:

任务评分( 1 - 10 分,越高越好 )
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 的平均总分。