tars 平台命令行工具
Project description
tars-cli
tars 平台命令行工具,支持插件导入、数据集管理、评估执行和报告导出。
安装
pip install tars-cli
安装验证
$ tars --version
tars-cli 0.1.10
升级
pip install --upgrade tars-cli
环境要求
- Python >= 3.11
- 依赖:typer >= 0.12, httpx >= 0.27, rich >= 13.0, pyyaml >= 6.0, platformdirs >= 4.0
快速开始
# 登录
$ tars auth login -s <server_url>
# 导入插件
$ tars plugin import <git_url_or_file_path>
# 生成数据集
$ tars dataset generate <plugin_id> --agent-name <name> --conversation-type single_turn
# 发布数据集
$ tars dataset publish <version_id>
# 执行评估
$ tars eval run <plugin_id> --agent-name <name> --dataset-version <version_id>
# 导出报告
$ tars plugin export-report <plugin_id>
命令测试结果
认证
$ tars auth login -s <server_url>
登录 tars 平台
用户名: admin
密码: ********
✓ 登录成功
服务器: <server_url>
用户: admin
$ tars auth logout
✓ 已登出,本地凭证已清除
插件管理
Git 导入可选参数:
--branch(分支,默认 main)、--path(子目录路径)、--auth-type(认证方式:none/token/ssh-key)、--auth-token(认证凭证)。本地文件导入支持--overwrite覆盖。
$ tars plugin import <git_url>
✓ 插件验证通过
✓ Plugin 导入成功
$ tars plugin import <git_url> --branch <branch> --path <subpath> --auth-type token --auth-token <token>
✓ 插件验证通过
✓ Plugin 导入成功
$ tars plugin import /path/to/plugin.zip --overwrite
✓ 插件验证通过
✓ Plugin 导入成功(已覆盖)
$ tars plugin export-report <plugin_id>
message: 报告导出成功
path: /path/to/report_<plugin_id>_<timestamp>.html
模板下载
$ tars template download plan -f yaml
✓ 模板下载成功
文件: plan-template.yaml
$ tars template download testcase-single
✓ 模板下载成功
文件: testcase-single-template.yaml
$ tars template download testcase-multi
✓ 模板下载成功
文件: testcase-multi-template.yaml
数据集管理
--agent-name和--skill-name二选一,必须指定其中一个。publish仅需版本 ID,无需指定目标。
--conversation-type(简写-t)支持single_turn(默认)和multi_turn,用于指定会话类型。
按 Agent 生成 & 管理
$ tars dataset generate <plugin_id> --agent-name <name> --conversation-type single_turn
completed ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:03:56
completed ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:04:47
📎 Web 查看: <server_url>/plugins/<plugin_id>/golden-set/<version_id>
version_id: <version_id>
status: draft
case_count:
message: 数据集生成完成
👉 下一步: tars dataset publish <version_id>
$ tars dataset list <plugin_id> --agent-name <name> --conversation-type single_turn
数据集版本列表
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ 版本 ID ┃ 状态 ┃ 用例数 ┃ 创建时间 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ <version_id> │ published│ N │ <datetime> │
│ <version_id> │ draft │ N │ <datetime> │
└────────────────────────────────────┴──────────┴────────┴────────────────────┘
按 Skill 生成 & 管理
$ tars dataset generate <plugin_id> --skill-name <name> --conversation-type multi_turn
completed ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:03:56
completed ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:04:47
📎 Web 查看: <server_url>/plugins/<plugin_id>/golden-set/<version_id>
version_id: <version_id>
status: draft
case_count:
message: 数据集生成完成
👉 下一步: tars dataset publish <version_id>
$ tars dataset list <plugin_id> --skill-name <name> --conversation-type multi_turn
数据集版本列表
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┓
┃ 版本 ID ┃ 状态 ┃ 用例数 ┃ 创建时间 ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━┩
│ <version_id> │ published│ N │ <datetime> │
└────────────────────────────────────┴──────────┴────────┴────────────────────┘
发布数据集版本
$ tars dataset publish <version_id>
version_id: <version_id>
status: published
message: 发布成功
手动上传评估计划和测试用例
$ tars dataset upload <plugin_id> --agent-name <name> --conversation-type single_turn --plan plan.yaml --cases cases.yaml
成功导入 <N> 条用例
📎 Web 查看: <server_url>/plugins/<plugin_id>/golden-set/<version_id>
version_id: <version_id>
status: published
message: 数据集上传并发布成功
👉 下一步: tars eval run <plugin_id> --agent-name <name> --dataset-version <version_id>
评估
--agent-name和--skill-name二选一,可不传。eval status仅需任务 ID。
按 Agent 评估
$ tars eval run <plugin_id> --agent-name <name> --dataset-version <version_id>
任务已创建: <task_id>
completed ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:13
📎 Web 查看: <server_url>/plugins/<plugin_id>/evaluation/<task_id>
task_id: <task_id>
status: completed
score: <score>
pass_rate: <rate>
message: 评估完成
└─ 评估结论:
1. [P0][L1] 失败模式名称
缺陷表现: 缺陷表现描述
代表案例: case_id_1, case_id_2
根因分析: 根因分析描述
优化建议: 优化建议描述
2. [P1][L2] 失败模式名称
缺陷表现: 缺陷表现描述
代表案例: case_id_1, case_id_2
根因分析: 根因分析描述
优化建议: 优化建议描述
👉 完整报告: tars plugin export-report <plugin_id>
按 Skill 评估
$ tars eval run <plugin_id> --skill-name <name> --dataset-version <version_id>
任务已创建: <task_id>
completed ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:07:13
📎 Web 查看: <server_url>/plugins/<plugin_id>/evaluation/<task_id>
task_id: <task_id>
status: completed
score: <score>
pass_rate: <rate>
message: 评估完成
└─ 评估结论:
1. [P0][L1] 失败模式名称
缺陷表现: 缺陷表现描述
代表案例: case_id_1, case_id_2
根因分析: 根因分析描述
优化建议: 优化建议描述
2. [P1][L2] 失败模式名称
缺陷表现: 缺陷表现描述
代表案例: case_id_1, case_id_2
根因分析: 根因分析描述
优化建议: 优化建议描述
👉 完整报告: tars plugin export-report <plugin_id>
查看评估状态
$ tars eval status <task_id>
task_id: <task_id>
status: completed
overall_score: <score>
total_cases: <N>
passed_cases: <N>
failed_cases: <N>
全局选项
| 选项 | 说明 |
|---|---|
-o, --output FORMAT |
输出格式:table(默认)/ json / yaml |
-q, --quiet |
安静模式 |
--verbose |
打印 HTTP 请求日志 |
--server URL |
覆盖服务地址(优先级:--server > TARS_SERVER_URL 环境变量 > 默认 http://localhost:8001) |
-V, --version |
查看版本 |
CI/CD 集成
export TARS_ACCESS_TOKEN=<token>
export TARS_SERVER_URL=<server_url>
tars -o json -q eval run <plugin_id> \
--agent-name <name> \
--dataset-version <version_id>
注意: 全局选项(
-o、-q、--verbose、--server)必须放在子命令之前,否则会报错。TARS_ACCESS_TOKEN一旦设置,优先级高于本地凭证文件,token 过期后需手动更新环境变量或unset TARS_ACCESS_TOKEN回退到文件凭证。
退出码
| 退出码 | 含义 |
|---|---|
| 0 | 成功 |
| 2 | 执行错误(网络、参数、认证等) |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tars_cli-0.1.10.tar.gz.
File metadata
- Download URL: tars_cli-0.1.10.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c59227d148dde962369cc5a1a0c63fceb85fac8d4ac7c3b4c5f1225e37ad585
|
|
| MD5 |
c3a591f020f2941d9be8b6a05cb5a5a6
|
|
| BLAKE2b-256 |
8dab72fd0ab0e4c5e5a5bb745b3cb27b6cfb7352151eb0c1b4fe2814f866859b
|
File details
Details for the file tars_cli-0.1.10-py3-none-any.whl.
File metadata
- Download URL: tars_cli-0.1.10-py3-none-any.whl
- Upload date:
- Size: 21.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e591c025525ee25d96073d30242e8642ef5a25ebd3d7df0c0c1430e7f8209793
|
|
| MD5 |
3b7c03ad6496c8c75cf894ec219ce9d6
|
|
| BLAKE2b-256 |
ec2cc470c65708b884f78a84e54424b3e9cd3247de554737089070d68bd67119
|