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.1.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.1-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for autoresearch_prompt_manager-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1e004c126254b5e46a7c3eaed82dfc3d8775e94cae9d6cdef8723a03a372a455
MD5 c93b9e3aada0adff7b7fb909be436e19
BLAKE2b-256 0e4fefcbb1a31d60cf978ca3dfd6e1a7259e8414a993bd6571e71b2cabad6bee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autoresearch_prompt_manager-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4687abbd010a88b4857c3d899287e8be3455ab09667cc689adc2c31dfddf5e1
MD5 0399e1c5482cc98643c90797d5d856b5
BLAKE2b-256 60a3081bb1626754515096a36af5b9b23f75e8ce217325f149deea8abcc55794

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