Skip to main content

Lightweight Prompt Engineering Operations CLI - Version control, real LLM testing, and deployment for AI prompts

Project description

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 gpt-4o --author jack.zhu

# 查看版本历史
promptops history code-review

# 回滚版本
promptops rollback code-review v1.2.0

2️⃣ 真实 LLM 测试(集成 OpenAI 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: gpt-4o
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 集成
│   ├── 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 OPENAI_API_KEY=sk-xxx

# 运行测试
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


让提示词成为可追踪、可验证的工程资产 🚀

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

promptops_zhuyt-1.0.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptops_zhuyt-1.0.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file promptops_zhuyt-1.0.0.tar.gz.

File metadata

  • Download URL: promptops_zhuyt-1.0.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for promptops_zhuyt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 68f924d1cd395b221f4efb6dac815407f2ab88594e97528d3e5400cb20b62a94
MD5 e0ab570bb0a9cf645fcfa2f40cb6d305
BLAKE2b-256 194bba88258912c4514ecb6e6f27a7b356b6477a3e67cdafae6fd7e1ba377fd2

See more details on using hashes here.

File details

Details for the file promptops_zhuyt-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for promptops_zhuyt-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6a388d96e57fa37a91c3629eb52cf0b36f586398afa097a0a568f1a4f32e48b
MD5 e6ad7b50a70906705eb54c2aee79b682
BLAKE2b-256 2006e4268070ebbbf6f9a8e432646d39e28caa71620144cc50df794978f895d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page