用途
cli-eval 是 OmniRoute 命令行工具(CLI)中的评测(Evals)能力。Evals 是自动化测试套件,用于按照预期答案或评分规则(rubric)对 LLM 输出打分。OmniRoute 将评测套件和运行结果保存在本地数据库中。其定位是:在终端里完成评测套件的创建与运行、观察实时基准进度、查看评分卡、比较模型表现,并将评测运行接入 CI 工作流。
安装与前置条件
需要使用 omniroute CLI。安装命令:
npm install -g omniroute # 或: npx omniroute
omniroute --version
官方说明中提到,安装方式与全局参数参见 CLI 入口相关的技能说明。
主要能力
- 评测套件管理:列出、查看和创建评测套件。
omniroute eval suites list(支持--json)omniroute eval suites get <suiteId>:查看完整套件定义omniroute eval suites create --name "code-quality" --rubric "exact-match" --samples-file ./samples.jsonl
- 评分规则(rubric):可选 exact-match、contains、llm-judge、regex。
- 样本文件:
--samples-file采用 JSONL 格式,每行一个 JSON 对象,包含input和expected_output,例如:{"input": "What is 2+2?", "expected_output": "4"} {"input": "Translate 'hello' to Spanish", "expected_output": "hola"} - 运行评测:
omniroute eval suites run <suiteId> --model <id>,可将同一套件对指定模型运行;加--watch可显示实时 TUI 进度(EvalWatch)。运行是异步的,可用--watch观察,也可手动轮询。 - 运行管理:
omniroute eval list(支持--json,以及--suite、--status、--since、--limit等标志)、omniroute eval get <runId>(状态、模型、分数)、omniroute eval results <runId>(支持--failed,查看逐样本结果)、omniroute eval cancel <runId>(支持--yes)、omniroute eval scorecard <runId>(完整评分卡,含逐样本通过/失败)。 - 评分卡输出:
omniroute eval scorecard <runId> --output json,每个样本的响应字段包括id、score、passed、input、output、expected。 - 模型比较:对同一套件依次以不同模型运行并对比结果,例如:
for MODEL in claude-sonnet-4-6 gpt-4o gemini-2.0-flash; do omniroute eval suites run $SUITE_ID --model $MODEL --output json | jq '{model: .model, score: .score}' done - CI 集成:运行评测后,若分数低于阈值则使 CI 失败,例如:
SCORE=$(omniroute eval suites run $SUITE_ID --model claude-sonnet-4-6 --output json | jq -r '.score') python3 -c "import sys; score=float('$SCORE'); sys.exit(0 if score >= 0.90 else 1)" - simulate 子命令:
omniroute simulate [prompt],支持--file、-m/--model、--combo、--reasoning-effort、--thinking-budget、--explain。
使用方式
典型流程:先安装 omniroute CLI,用 eval suites create 创建套件并指定评分规则与样本文件;再用 eval suites run 对目标模型运行;运行中可用 --watch 观察,或通过 eval get 轮询状态;完成后用 eval results 或 eval scorecard 查看结果;最后可在 CI 中根据分数阈值决定通过或失败。
子命令示例还包括 omniroute eval、omniroute eval suites、omniroute eval list、omniroute eval get <suiteId>、omniroute eval create(--file <path>)等。
适用场景
- 在终端中对 LLM 输出做自动化评分与回归测试;
- 对同一套件比较多个模型的表现;
- 在 CI 中设置分数门槛,防止模型效果下降;
- 查看逐样本的通过/失败评分卡,定位失败样本。
限制与排错
- 需要先具备 omniroute CLI,并依赖本地数据库存储套件与运行结果。
- 评分规则只支持 exact-match、contains、llm-judge、regex。
- 若
suites create报无效 rubric,需改用上述四种之一。 - 若
suites run返回 model not found,用omniroute models --search <name>核实模型 ID。 - 若
eval get显示status: failed,可用omniroute logs --search eval查看错误详情。 - 若 scorecard 返回空结果,运行可能仍在进行,需轮询
omniroute eval get <runId>直到状态为 completed。 - 资料未提供计费、价格、支持的模型清单或额外平台信息。