PromptOps CLI 🐍
Python 实现的轻量级提示词工程运营工具 - 让提示词具备"可协作、可审查、可回滚、可监控"能力
为什么选择 Python?
PromptOps 的核心场景是提示词测试与评估,Python 在这方面有天然优势:
- ✅ LLM 生态最强:LangChain、DSPy、Langfuse SDK 均以 Python 为主
- ✅ AI 评估工具链:promptlayer、humanloop、deepeval 等
- ✅ 数据分析能力:pandas、numpy 处理测试数据
- ✅ Jupyter 集成:交互式开发和调试
核心能力
1️⃣ 版本管理(Git for Prompts)
# 初始化项目
promptops init my-project
# 创建新提示词
promptops new code-review --model deepseek-chat --author jack.zhu
# 查看版本历史
promptops history code-review
# 回滚版本
promptops rollback code-review v1.2.0
2️⃣ 真实 LLM 测试(集成 OpenAI / DeepSeek / Anthropic SDK)
# 运行测试套件(真实调用 API)
promptops test code-review --live
# 生成质量报告
promptops report code-review --output metrics.json
3️⃣ DSPy 风格评估
from promptops import Evaluator
evaluator = Evaluator()
result = evaluator.evaluate(
prompt_name="code-review",
test_cases=[...],
metrics=["accuracy", "latency", "cost"]
)
print(result.accuracy) # 0.97
print(result.latency_p95) # 340ms
4️⃣ 部署控制
# 推送到 staging
promptops deploy code-review --env staging
# 灰度发布
promptops rollout code-review --percentage 10
提示词结构规范
# prompts/code-review.yaml
name: code-review
version: 2.0.0
model: deepseek-chat
author: jack.zhu
created_at: 2026-05-25T12:00:00
tags: [production, security]
content: |
你是一位资深代码审查专家...
tests:
- input: "function foo() { return eval(userInput); }"
expected:
security: high
type: code-injection
- input: "const data = []; ..."
expected:
performance: medium
thresholds:
accuracy: 0.95
latency_ms: 500
cost_per_request: 0.01
技术架构
PromptOps CLI (Python)
│
├── Version Manager (Git-based)
│ ├── Semantic versioning (v1.0.0)
│ ├── Rollback mechanism
│ └── Diff visualization
│
├── LLM Tester (真实 API 调用)
│ ├── OpenAI SDK 集成
│ ├── DeepSeek SDK 集成 (OpenAI 兼容 API)
│ ├── Anthropic SDK 集成
│ └── Cost tracking
│
├── Evaluator (DSPy 风格)
│ ├── LLM-as-judge
│ ├── Heuristic evaluators
│ └── Custom metrics
│
└── Deployment System
├── Environment progression
├── Traffic shifting
└── A/B testing
快速开始
# 安装
pip install promptops-zhuyt
# 初始化
promptops init your-project
# 创建提示词
promptops new code-review --author jack.zhu
# 配置 API Key(按需选择)
export DEEPSEEK_API_KEY=sk-xxx # DeepSeek(默认模型)
export OPENAI_API_KEY=sk-xxx # OpenAI
export ANTHROPIC_API_KEY=sk-ant-xxx # Anthropic
# 运行测试
promptops test code-review --live
# 查看帮助
promptops --help
实战案例
# 电商推荐系统迭代
# 1. 创建初始版本
promptops init ecommerce-recommendation
promptops new product-suggest --model claude-3.7-opus
# 2. 编辑提示词
vim prompts/product-suggest.yaml
# 3. 运行真实 LLM 测试
promptops test product-suggest --live --sample 100
# ✅ 150/150 通过,准确率 97.3%
# 💰 总成本: $2.34
# 4. 审批变更
promptops approve product-suggest v2.0.0 --reviewer alice
# 5. 灰度发布
promptops rollout product-suggest --percentage 10 --monitor
# 6. 监控指标
promptops metrics product-suggest --watch
# 📊 转化率: +15%
# 响应时间: 320ms (p95)
# 用户满意度: 4.3/5
# 7. 全量发布
promptops deploy product-suggest --env production
与现有工具对比
| 特性 | promptops-zhuyt | Langfuse | PromptLayer | DSPy |
|---|---|---|---|---|
| 语言 | Python ✅ | Python/TS | Python/JS | Python ✅ |
| 真实 LLM 测试 | ✅ | ✅ | ❌ | ✅ |
| DSPy 风格评估 | ✅ | ❌ | ❌ | ✅ |
| 数据分析 | ✅ pandas | ❌ | ❌ | ❌ |
| CLI 体验 | ✅ | ❌ Web | ❌ | ❌ |
| 开源 | ✅ MIT | ✅ Apache | ❌ | ✅ MIT |
适用场景
- ✅ 小团队(2-10人)快速落地 PromptOps
- ✅ 需要真实 LLM API 测试
- ✅ 数据驱动的提示词优化
- ✅ Jupyter 交互式开发
贡献指南
欢迎提交 PR!
git clone https://github.com/YaBoom/promptops-zhuyt.git
cd promptops-zhuyt
pip install -e ".[dev]"
pytest tests/
License
MIT © 2026 jack.zhu
让提示词成为可追踪、可验证的工程资产 🚀
Metadata
Release files for promptops-zhuyt 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| promptops_zhuyt-1.2.0.tar.gz | 18.2 kB | Without provenance | Details for promptops_zhuyt-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| promptops_zhuyt-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for promptops_zhuyt-1.2.0-py3-none-any.whl |
Total release size: 36.4 kB
Release files / promptops_zhuyt-1.2.0.tar.gz
| Download URL | promptops_zhuyt-1.2.0.tar.gz |
|---|---|
| Size | 18.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26d09c0ea39d2e897e208467a46c6af9eacdf5960b46034bee01ca5d69c10507
|
|
BLAKE2b-256 checksum How to use checksums |
a13464a18913a26b869ec6fe151bac42fa30ccde62660d34f973a56cd94f2338
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / promptops_zhuyt-1.2.0-py3-none-any.whl
| Download URL | promptops_zhuyt-1.2.0-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
407a04d1a0fcf9369df0519af94f1f466fb9e49a9d43c94a69c1e6d4188b3a45
|
|
BLAKE2b-256 checksum How to use checksums |
bed25393210e2d2d52bf30f4ff117de72cc946a84e5648466bfa251292c630a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for promptops-zhuyt 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.