A lightweight library for LLM prompt management, observability/tracing, and optimization
Project description
promptly
A lightweight, developer-friendly library for LLM prompt management, observability/tracing, and optimization. Currently with support for Python.
Features
- Prompt Templates: Jinja2-based templating system for dynamic prompts
- Multi-Provider Support: OpenAI, Anthropic, Google AI (Gemini), and extensible client architecture
- Built-in Tracing: Comprehensive observability for prompt execution
- Genetic Optimization: LLM-powered genetic algorithms for automated prompt improvement
- Async Support: Full async/await support for high-performance applications
- CLI Interface: Command-line tools for prompt management
- Type Safety: Full type hints and Pydantic models
Installation
# Install UV if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install promptly
uv pip install promptly
# With development dependencies
uv pip install promptly[dev]
# With CLI tools
uv pip install promptly[cli]
# With UI components
uv pip install promptly[ui]
Quick Start
import asyncio
from promptly import PromptRunner, OpenAIClient, PromptTemplate
async def main():
# Initialize client
client = OpenAIClient(api_key="your-api-key")
# Create a prompt template
template = PromptTemplate(
name="greeting",
template="Hello {{ name }}, how are you today?",
variables=["name"]
)
# Create runner with tracing
runner = PromptRunner(client)
# Execute prompt
response = await runner.run(
template=template,
variables={"name": "Alice"},
model="gpt-3.5-turbo"
)
print(response.content)
asyncio.run(main())
Prompt Optimization
Promptly includes an advanced genetic algorithm optimizer that uses LLMs to automatically improve your prompts through iterative evaluation and mutation. The optimizer can work with test cases for accuracy-based optimization or without test cases for general quality improvement.
Quick Example:
# Optimize with test cases
promptly optimize \
--base-prompt "Answer this question: {{question}}" \
--test-cases my_tests.json \
--population-size 10 \
--generations 5
# Quality-based optimization (no test cases needed)
promptly optimize \
--base-prompt "Write a {{genre}} story about {{character}}" \
--population-size 8 \
--generations 4
For complete documentation on optimization features, configuration options, and examples, see OPTIMIZER_README.md.
CLI Usage
# Run a simple prompt
promptly run "What is the capital of France?" --model="gpt-3.5-turbo"
# Run with tracing
promptly run "Explain quantum computing" --trace
# View traces
promptly trace
Development
For developers who want to contribute to or extend promptly:
- Developer Quick Start.md - Complete development guide
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file promptly_llm-0.2.0.tar.gz.
File metadata
- Download URL: promptly_llm-0.2.0.tar.gz
- Upload date:
- Size: 34.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60d97845dccb382a995df45c162fb1553a502abaa9921186921ad5a6c8a1ce9e
|
|
| MD5 |
9c02fb10ba4eac1b1d83dd9e621befa5
|
|
| BLAKE2b-256 |
4e330d27cd6bffdc234b2329c096da2b7bef07e0286de01b20adc66e85c236b6
|
Provenance
The following attestation bundles were made for promptly_llm-0.2.0.tar.gz:
Publisher:
release.yml on orgpromptly/promptly
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptly_llm-0.2.0.tar.gz -
Subject digest:
60d97845dccb382a995df45c162fb1553a502abaa9921186921ad5a6c8a1ce9e - Sigstore transparency entry: 636403420
- Sigstore integration time:
-
Permalink:
orgpromptly/promptly@9d68ae9f23858071999384d0f0784f6b5f43b3da -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/orgpromptly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d68ae9f23858071999384d0f0784f6b5f43b3da -
Trigger Event:
push
-
Statement type:
File details
Details for the file promptly_llm-0.2.0-py3-none-any.whl.
File metadata
- Download URL: promptly_llm-0.2.0-py3-none-any.whl
- Upload date:
- Size: 34.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
716c6cf8ea23b5072a110f20bae3d2ef77def51e2252b1591f35abb4a158f261
|
|
| MD5 |
afe0ba53ce60cf3ab8b6101f28564fc1
|
|
| BLAKE2b-256 |
33478a22a7d585fbd9fdbda00d061170bc4e4a9e5b33d24c8d3f7b872636a8c7
|
Provenance
The following attestation bundles were made for promptly_llm-0.2.0-py3-none-any.whl:
Publisher:
release.yml on orgpromptly/promptly
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
promptly_llm-0.2.0-py3-none-any.whl -
Subject digest:
716c6cf8ea23b5072a110f20bae3d2ef77def51e2252b1591f35abb4a158f261 - Sigstore transparency entry: 636403440
- Sigstore integration time:
-
Permalink:
orgpromptly/promptly@9d68ae9f23858071999384d0f0784f6b5f43b3da -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/orgpromptly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9d68ae9f23858071999384d0f0784f6b5f43b3da -
Trigger Event:
push
-
Statement type: