Skip to main content

Versioned prompt CRUD, A/B experiments, metrics, and LLM optimization API

Project description

prompt-manager

Versioned prompt CRUD, A/B experiments, metric collection, and LLM-driven optimization API.

Install

# Just the client SDK (for services that fetch prompts)
pip install prompt-manager[client]

# Full API server
pip install prompt-manager[api]

# Client + metric reporting
pip install prompt-manager[client,metric]

# Everything
pip install prompt-manager[all]

Quick start

Start the API

PM_DATABASE_URL=postgresql://user:pass@localhost:5432/prompts \
  prompt-manager serve

Use the client SDK

from prompt_manager.client import PromptManagerClient

client = PromptManagerClient(base_url="http://localhost:8910")

# Resolve a prompt (returns latest version, experiment-aware)
prompt = await client.resolve("welcome-email", session_id="user-123")
print(prompt.body)       # "Hi {name}, welcome to {company}!"
print(prompt.version)    # 2

# Report a quality metric
await client.report_metric("welcome-email", str(prompt.version_id), "quality", 8.5)

API endpoints

Method Path Description
POST /prompts Create prompt (auto-creates v1)
GET /prompts List all prompts
GET /prompts/{slug} Get prompt by slug
POST /prompts/{slug}/versions Create new version
GET /prompts/{slug}/versions List versions
GET /resolve/{slug} Resolve prompt (experiment-aware)
POST /experiments Create A/B experiment
PATCH /experiments/{id}/status Start/pause/conclude
POST /metrics Report metric signal
GET /metrics/aggregate Aggregated metrics per version
POST /optimize Trigger LLM optimization
GET /health Health check

Key features

  • Slug-based addressing -- resolve("welcome-email") not UUIDs
  • Immutable versions -- append-only, SHA-256 dedup, full audit trail
  • Experiment routing -- MurmurHash3 deterministic + Thompson Sampling (auto_optimize)
  • Sticky sessions -- same user always sees same variant
  • Metric collection -- quality signals per version, batch ingestion
  • MCP server -- expose all tools via Model Context Protocol
  • CLI -- prompt-manager serve, prompt-manager migrate, prompt-manager health

Database

Requires PostgreSQL 14+. Migrations run automatically on startup.

# Docker
docker compose up -d

# Or point to existing Postgres
PM_DATABASE_URL=postgresql://user:pass@host:5432/dbname prompt-manager migrate

Configuration

All settings via PM_-prefixed environment variables:

Variable Default Description
PM_DATABASE_URL postgresql://localhost:5432/prompt_manager PostgreSQL DSN
PM_HOST 0.0.0.0 Bind host
PM_PORT 8910 Bind port
PM_LLM_PROVIDER anthropic LLM for optimization
PM_LLM_MODEL claude-sonnet-4-20250514 Model ID
PM_LLM_API_KEY -- API key

Part of autoresearch-prompt-manager

autoresearch-prompt-manager  (this package -- API, client, metrics)
  -> autoresearcher-shonku   (optimization agents)
  -> shonku                  (agent framework)
  -> agno                    (runtime -- https://agno.com)

LLM-driven optimization is powered by agno and AgentOS.

Contributing

  1. Fork autoresearch-prompt-manager
  2. cd packages/prompt_manager && pip install -e '.[dev,api,client,metric]'
  3. Make changes, pytest, ruff check src/
  4. Integration tests: PM_DATABASE_URL=... python3 -m pytest tests/integration/
  5. Submit a PR

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

autoresearch_prompt_manager-0.1.0.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

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

autoresearch_prompt_manager-0.1.0-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

Details for the file autoresearch_prompt_manager-0.1.0.tar.gz.

File metadata

File hashes

Hashes for autoresearch_prompt_manager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02be95a0564583f2723e9d3a843c650f09c7c7c0e6f68e1c9403b52553acc729
MD5 10dc4872e6fcda25c5aab44c3148e45c
BLAKE2b-256 738422f67a1176f0807ab6f40a924373024f4922cfa04f9a343b1277176d4992

See more details on using hashes here.

File details

Details for the file autoresearch_prompt_manager-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for autoresearch_prompt_manager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c7e5085454c563de41f8ed7408d3c231660dd2bcb5e6fcab475d45f2c0aebe5
MD5 421df13de7ce270185da26b032517179
BLAKE2b-256 2b5441f098c22837bc89752e6cfcbe32aaf890e9ddde5043d324478ed2be64bd

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