Skip to main content

Prompt Pipeline

A modern, type-safe prompt pipeline for LLM interactions. This package provides a clean, intuitive API for building prompt pipelines with full type safety and modern Python features.

Features

  • 🔒 Full type safety with generics and Pydantic models
  • 🔗 Chain-style API for building pipelines
  • 🎨 Decorator support for clean prompt definitions
  • 📦 Context sharing between prompts
  • 🔄 Automatic dependency handling between prompts
  • ⚡ Modern Python features and best practices

Installation

pip install prompt-pipeline

Quick Start

Here's a simple example of using the pipeline:

from pydantic import BaseModel
from prompt_pipeline import PromptPipeline

# Define your models
class TranslatorContext(BaseModel):
    source_text: str
    target_language: str

class ContextModel(BaseModel):
    context: str

class TranslationModel(BaseModel):
    translation: str

# Chain-style API
pipeline = (
    PromptPipeline[TranslatorContext, TranslationModel]()
    .add_prompt(
        "Analyze the context of this text: {context.source_text}",
        output_model=ContextModel,
        name="context"
    )
    .add_prompt(
        "Translate this text to {context.target_language} using the context: {prev.context}",
        output_model=TranslationModel,
        name="translate",
        depends_on="context"
    )
)

# Execute the pipeline
result = pipeline.execute(TranslatorContext(
    source_text="Hello, world!",
    target_language="Spanish"
))

Decorator Style

You can also use decorators for a more declarative style:

from prompt_pipeline import PromptPipeline, prompt

class TranslationPipeline(PromptPipeline[TranslatorContext, TranslationModel]):
    @prompt(output_model=ContextModel)
    def get_context(self, context: TranslatorContext) -> ContextModel:
        """
        Analyze the context of this text: {context.source_text}
        Consider the target language: {context.target_language}
        """
        pass
    
    @prompt(output_model=TranslationModel, depends_on="get_context")
    def translate(self, context: TranslatorContext) -> TranslationModel:
        """
        Translate this text to {context.target_language}
        Using the context: {prev.context}
        """
        pass

# Use the pipeline
pipeline = TranslationPipeline()
result = pipeline.execute(context)

Advanced Features

Configuration

Configure prompts with specific parameters:

pipeline = (
    PromptPipeline()
    .add_prompt("Your prompt", output_model=YourModel)
    .model("gpt-4")
    .configure(
        temperature=0.7,
        max_tokens=100
    )
)

Context Variables

Share variables between prompts:

context = pipeline.context(
    text="Hello",
    language="Spanish"
)
context.set_var("style", "formal")

Single Prompt Execution

Execute a single prompt without building a pipeline:

result = pipeline.execute_single(
    "Translate {text} to {language}",
    output_model=TranslationModel
)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for prompt-pipeline 0.1.1

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-pipeline 0.1.1
File Size Uploaded Provenance Actions
prompt_pipeline-0.1.1.tar.gz 11.8 kB Without provenance Details for prompt_pipeline-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prompt-pipeline 0.1.1
File Interpreter ABI Platform Actions
prompt_pipeline-0.1.1-py3-none-any.whl Python 3 none any Details for prompt_pipeline-0.1.1-py3-none-any.whl

Total release size: 27.2 kB

Release files / prompt_pipeline-0.1.1.tar.gz

Download URL prompt_pipeline-0.1.1.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8f0355208f21d69aba8fde2f12dc39dd8272ccbd5be564a0f55683a6ec7d35bc
BLAKE2b-256 checksum
How to use checksums
86c31198df88fd5099844b1350306b3e3bdaa02184c371aa6d1c6e3f361b9a4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release files / prompt_pipeline-0.1.1-py3-none-any.whl

Download URL prompt_pipeline-0.1.1-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d866c815cd169bab261f8fcdbd26aa51b94b65b3719ed0c08641e29744dc4d4e
BLAKE2b-256 checksum
How to use checksums
59bd70a67035efba14959baaa269c7d3a25b8f38bc78be9504d85ff341b8f4d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Security for prompt-pipeline 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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