Skip to content

PromptManager Documentation

⚠️ CAUTION ⚠️
Breaking Changes are Coming
See Roadmap for details
PromptManager - The Enchanted Librarian of AI Prompts

Like an enchanted librarian organizing floating books of knowledge, PromptManager helps you masterfully orchestrate and organize your AI prompts through wisdom and experience.

Each prompt becomes a living entity that can be categorized, parameterized, and interconnected with golden threads of relationships.

Key Features

What is PromptManager?

PromptManager is a Ruby gem designed for managing parameterized prompts used in generative AI applications. It provides a sophisticated system for organizing, templating, and processing prompts with support for multiple storage backends, directive processing, and advanced templating features.

Think of it as your personal AI prompt librarian - organizing your prompts, managing their parameters, processing their directives, and ensuring they're always ready when you need them.

Quick Start

Get up and running with PromptManager in minutes:

gem install prompt_manager
# or add to Gemfile
bundle add prompt_manager
require 'prompt_manager'

# Configure storage
PromptManager::Prompt.storage_adapter = 
  PromptManager::Storage::FileSystemAdapter.config do |config|
    config.prompts_dir = '~/.prompts'
  end.new

# Use a prompt
prompt = PromptManager::Prompt.new(id: 'greeting')
prompt.parameters = {
  "[NAME]" => "Alice",
  "[LANGUAGE]" => "English"
}

puts prompt.to_s
# ~/.prompts/greeting.txt
# Description: A friendly greeting prompt

Hello [NAME]! How can I assist you today?
Please respond in [LANGUAGE].

Architecture Overview

PromptManager follows a modular architecture designed for flexibility and extensibility:

graph TB
    subgraph "Application Layer"
        A[Your Application]
        P[PromptManager::Prompt]
    end

    subgraph "Processing Layer"
        D[Directive Processor]
        E[ERB Engine]
        K[Keyword Substitution]
    end

    subgraph "Storage Layer"
        FS[FileSystem Adapter]
        AR[ActiveRecord Adapter]
        CA[Custom Adapter]
    end

    A --> P
    P --> D
    P --> E
    P --> K
    P --> FS
    P --> AR
    P --> CA

    D --> |includes| FS
    E --> |templates| P
    K --> |substitutes| P

Core Concepts

Parameterized Prompts

Transform static prompts into dynamic templates:

# Template with parameters
prompt_text = "Translate '[TEXT]' from [SOURCE_LANG] to [TARGET_LANG]"

# Filled with values
prompt.parameters = {
  "[TEXT]" => "Hello world",
  "[SOURCE_LANG]" => "English", 
  "[TARGET_LANG]" => "Spanish"
}

# Result: "Translate 'Hello world' from English to Spanish"

Directive Processing

Use JCL-style directives for prompt composition:

# Common header for all customer service prompts
//include common/customer_service_header.txt

# Dynamic template inclusion
//include templates/[TEMPLATE_TYPE].txt

Handle this customer inquiry about [TOPIC].

Storage Adapters

Choose your preferred storage backend:

  • FileSystemAdapter: Store prompts as text files
  • ActiveRecordAdapter: Store prompts in a database
  • Custom Adapters: Build your own storage solution

Why PromptManager?

🎯 Organized Prompts

Keep your prompts organized in a structured, searchable format instead of scattered across your codebase.

🔄 Reusable Templates

Create parameterized templates that can be reused across different contexts and applications.

🛠️ Powerful Processing

Advanced features like directive processing, ERB templating, and environment variable substitution.

📈 Scalable Architecture

Modular design supports everything from simple scripts to enterprise applications.

🔍 Easy Management

Built-in search capabilities and parameter history make prompt management effortless.

Getting Started

Ready to dive in? Here are some great places to start:

  • Quick Start


    Get PromptManager running in your project within minutes

    Quick Start

  • Core Features


    Learn about parameterized prompts, directives, and more

    Core Features

  • Storage Adapters


    Choose the right storage solution for your needs

    Storage Options

  • API Reference


    Complete reference for all classes and methods

    API Docs

Community & Support

License

PromptManager is released under the MIT License.