Skip to main content

prompt-config

PyPI version Python Versions License

prompt-config is a dynamic prompt building library designed for LLM applications. It allows you to define complex prompts in a structured YAML configuration, manage dynamic variables with Jinja2 templating, and construct prompts at runtime using a powerful tagging and filtering system.

Perfect for managing prompts as code, enabling environment-specific prompts, and ensuring reproducibility in your AI applications.


Features

  • YAML Configuration: Centralize your prompt definitions in a clean, readable YAML file.
  • Dynamic Variables: Use Jinja2 syntax ({{ variable }}) for dynamic content insertion.
  • Tag-Based Composition: conditionally include or exclude prompt parts based on tags (e.g., dev, prod, python, web).
  • Validation: Enforce required variables and provide default values.
  • CLI Tool: Built-in promptcfg CLI for easy integration into scripts and CI/CD pipelines.
  • Python API: seamless integration into your Python applications.

Installation

Requires Python 3.11 or higher.

pip install prompt-config

Quick Start

1. Initialize Configuration

Create a starter promptcfg.yaml file in your current directory:

promptcfg init

This will generate a file similar to:

version: "1.0"
prompts:
  - id: "system_intro"
    text: "You are a helpful AI assistant named {{ assistant_name }}."
    default: true
    variables:
      - name: "assistant_name"
        default: "Prompter"

  - id: "coding_capabilities"
    text: "You are an expert in {{ language }} programming."
    tags: ["coding"]
    variables:
      - name: "language"
        required: true

2. Build via CLI

Generate a prompt by activating specific tags and passing variables:

promptcfg build --tags coding --vars assistant_name=Jarvis,language=Python

Output:

--- Generated Prompt ---
You are a helpful AI assistant named Jarvis.
You are an expert in Python programming.
------------------------

3. Build via Python API

Integrate prompt-config directly into your application:

from promptcfg.config import PromptConfig
from promptcfg.builder import PromptBuilder

# Load the configuration
config = PromptConfig.load("promptcfg.yaml")

# Initialize the builder
builder = PromptBuilder(config)

# Build the prompt
prompt = builder.build(
    tags=["coding"],
    variables={
        "assistant_name": "Jarvis",
        "language": "Python"
    }
)

print(prompt)

CLI Usage

The promptcfg generic command line interface supports the following subcommands:

  • init: Create a generic configuration file.
  • build: Construct a prompt based on tags and variables.

Build Options

Option Description
--config Path to the YAML config file (default: promptcfg.yaml)
--tags Comma-separated list of tags to include (e.g., dev,test)
--vars Key-value pairs for variables (e.g., key=value,foo=bar)
--include-ids Explicitly include specific prompt blocks by ID
--exclude-ids Explicitly exclude specific prompt blocks by ID
--exclude-tags Exclude prompt blocks matching these tags
--list-prompts List all available prompt IDs and their status
# Example: Build with exclusions
promptcfg build --tags all --exclude-tags deprecated --vars user_id=123

Development

If you want to contribute or modify the library:

  1. Clone the repository:

    git clone https://github.com/AKSHILMY/prompter.git
    cd prompter
    
  2. Set up a virtual environment:

    python3.12 -m venv venv
    source venv/bin/activate
    
  3. Install in editable mode:

    pip install -e "."
    
  4. Run Tests:

    python -m unittest discover tests
    

License

This project is licensed under the terms of the Apache License 2.0.

Metadata

Release files for prompt-config 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prompt-config 0.1.7
File Size Uploaded Provenance Actions
prompt_config-0.1.7.tar.gz 19.0 kB Without provenance Details for prompt_config-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prompt-config 0.1.7
File Interpreter ABI Platform Actions
prompt_config-0.1.7-py3-none-any.whl Python 3 none any Details for prompt_config-0.1.7-py3-none-any.whl

Total release size: 37.9 kB

Release files / prompt_config-0.1.7.tar.gz

Download URL prompt_config-0.1.7.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
76477a3f763833111f06041fece710316a85efd890940e0ecfbd0f63885d3fd3
BLAKE2b-256 checksum
How to use checksums
cfae2c8d8f15645aef00474dafe284f185f329ea3cee9059d7b670f2f9962071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Release files / prompt_config-0.1.7-py3-none-any.whl

Download URL prompt_config-0.1.7-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d56e6f7f18da8ee8d1cccf0238e00674354d124ba00941f12043d389432c5fc2
BLAKE2b-256 checksum
How to use checksums
3a41339d69c98c5d510b11dfa276a8417ef466f1e58b381f3d7079e54cd71ee1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Security for prompt-config 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page