Skip to main content

Prompt version control and A/B testing for LLM applications

Project description

pguard-llm

Prompt version control and A/B testing for LLM applications.

pip install pguard-llm

The Problem

You tweak a prompt. It gets better. You tweak it again. Now you don't remember what changed, which version was best, or how much each version costs to run.

pguard-llm fixes this — version your prompts, run them, compare them.

Quick Start

from pguard import Prompt

p = Prompt("summarize")

# Save versions
p.save("v1", "Summarize this: {text}", description="Simple")
p.save("v2", "In 3 bullet points, summarize: {text}", description="Structured")

# Run against an LLM
result = p.run(
    "v1",
    provider="openai",
    model="gpt-4o",
    api_key="sk-...",
    input_vars={"text": "Your article text here..."}
)

print(result.output)
print(result.cost_usd)
print(result.latency_ms)

# Compare v1 vs v2
comparison = p.compare("v1", "v2")
print(comparison.summary())

Supported Providers

Provider Install Models
OpenAI pip install openai gpt-4o, gpt-4o-mini, ...
Anthropic pip install anthropic claude-sonnet-4, claude-haiku-4
Gemini pip install google-genai gemini-2.5-flash, gemini-1.5-pro

Install with Provider

pip install "pguard-llm[openai]"
pip install "pguard-llm[anthropic]"
pip install "pguard-llm[gemini]"
pip install "pguard-llm[all]"

Storage Backends

# File storage (default) — zero setup
p = Prompt("summarize", storage="file")

# SQLite — better for querying
p = Prompt("summarize", storage="sqlite")

A/B Comparison

comparison = p.compare("v1", "v2")
summary = comparison.summary()

# summary contains:
# - latency_ms: avg latency per version + winner
# - cost_usd: avg cost per version + winner
# - quality_score: avg quality per version + winner
# - tokens_avg: avg tokens per version

CLI

pguard list                        # list all prompts
pguard versions summarize          # list versions
pguard show summarize v1           # show template
pguard runs summarize v1           # show run history
pguard compare summarize v1 v2     # compare versions

RunResult

result.output        # LLM response text
result.cost_usd      # Cost in USD
result.latency_ms    # Latency in milliseconds
result.tokens_in     # Input tokens
result.tokens_out    # Output tokens
result.quality_score # Quality score (0-1)
result.provider      # Provider used
result.model         # Model used

License

MIT

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

pguard_llm-0.1.3.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

pguard_llm-0.1.3-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file pguard_llm-0.1.3.tar.gz.

File metadata

  • Download URL: pguard_llm-0.1.3.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pguard_llm-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f6b5e06414ffd7693c248338396358efe09ad38c0d535c8678d9c2ceb62658f9
MD5 c1a59e4337076e7e83fe340ab8a79289
BLAKE2b-256 2484ddef5fc27ba47cf83791cfe854adee4a9b3ab4b018b2a3388c546bc0f1b4

See more details on using hashes here.

File details

Details for the file pguard_llm-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pguard_llm-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pguard_llm-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9ceb52a2bb35a4caa6dd2890371a8740acc13d93f9aa76edfd30a3d6311004af
MD5 13614135e83cedbe2c59ebdd171fda66
BLAKE2b-256 9092fdd679ae946737d5dfae98138b2fb3052b93ff25a5ef52b34fce61d11ba3

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