prompt-decorators
by: synaptiai
A standardized framework for enhancing how LLMs process and respond to prompts through composable decorators, featuring an official open standard specification and Python reference implementation with MCP server integration.
πOverview
Purpose: The framework aims to standardize the enhancement and transformation of prompts for Large Language Models (LLMs) through a composable annotation system.
Overview: Prompt Decorators introduces a formal and systematic method for modifying LLM behavior using simple, composable decorators. By utilizing a standardized syntax, it streamlines how developers interact with AI models, reducing complexity and enhancing consistency in prompt engineering across various platforms.
Key Features:
-
Standardized Decorator Syntax: A formal specification that defines the syntax and behavior of decorators, ensuring uniformity across LLM interactions.
-
Comprehensive Library: A wide array of over 140 pre-built decorators that facilitate various functionalities such as reasoning and output formatting.
-
Robust Implementation: A Python implementation that includes a registry for managing decorators, parameter validation, dynamic loading, and automated documentation generation.
-
Model Context Protocol (MCP) Integration: Enables functionality of prompt decorators in applications like Claude Desktop, broadening the usability of the framework.
Prompt Decorators
Prompt Decorators is a framework that standardizes how prompts for Large Language Models (LLMs) are enhanced, structured, and transformed. This repository contains both the official Prompt Decorators Specification and its complete Python reference implementation.
Documentation β’ Prompt Decorators Specification
π Table of Contents
π Overview
What Are Prompt Decorators?
Prompt Decorators introduces a standardized annotation system that allows users to modify LLM behavior through simple, composable "decorators." By prefixing prompts with annotations like +++Reasoning
, users can consistently control how AI models process their requests.
Key Components
- Specification: Defines the standard for decorators.
- Core Framework: A Python implementation with registry-based decorator management.
- Decorators: A comprehensive library of pre-built decorators.
- MCP Server: Integration with the Model Context Protocol for desktop applications.
- Documentation: API references and guides for users and developers.
Background & Motivation
As LLMs become more integrated into various workflows, the need for standardized interaction methods has become clear. Current prompt engineering approaches are often inconsistent and inefficient. Prompt Decorators address this by providing systematic modifications to AI behavior through annotations inspired by programming design patterns.
Challenges in Prompt Engineering
Current limitations include:
- Inconsistency across platforms
- Verbosity in instructions
- High cognitive overhead
- Difficulty in composability
- Undocumented model behavior
Benefits of Prompt Decorators
Prompt Decorators offers solutions to these challenges by standardizing notation, reducing verbosity, simplifying cognitive load, enabling composability, and clarifying expected behaviors.
Key Features
- Registry-based decorator management.
- Parameter validation and type checking.
- Decorator versioning.
- Compatibility checking.
- Documentation generation.
- Dynamic loading and discovery of decorators.
π‘ Implementation Status
The Prompt Decorators project is in active development. You can test functionality through a demo or an MCP server implementation.
Implemented Functionality
Key implemented features include:
- Core Decorator Registry
- Parameter validation and type checking
- Support for multiple input formats
- Extension framework for domain-specific decorators
- Automated documentation generation
π Getting Started
Installation
Install the package from PyPI:
pip install prompt-decorators
For optional dependencies, use:
pip install "prompt-decorators[mcp]"
pip install "prompt-decorators[dev,test]"
pip install "prompt-decorators[docs]"
pip install "prompt-decorators[all]"
Basic Usage
import prompt_decorators as pd
pd.load_decorator_definitions()
reasoning = pd.create_decorator_instance("Reasoning", depth="comprehensive")
prompt = "Explain the concept of prompt engineering."
decorated_prompt = reasoning.apply(prompt)
print(decorated_prompt)
For more examples, refer to the official documentation.
π License
This project is licensed under the Apache License, Version 2.0. See the LICENSE
file for more information.
π€ Contributing
Contributions are welcome! Please read the 1 file for guidelines.
π€ Acknowledgments
Thanks to individuals and organizations that contributed to this project:
- Mostapha Kalami Heris: For his article on Prompt Decorators.
- Synaptiai: Creators and maintainers of this framework.
- Contributors: Everyone who has participated in this project.