====== DokuLLM Plugin - Prompt System ====== This document explains how the DokuLLM plugin's prompt system works, including prompt hierarchy, available placeholders, and how to customize prompts. ===== Prompt Hierarchy ===== The DokuLLM plugin uses a hierarchical prompt system that allows for flexible customization using DokuWiki pages: ==== 1. Default Prompts ==== * Located in the ''dokullm:profiles:default:'' namespace * These are the base prompts that ship with the plugin * Used when no custom prompts are defined * Named according to their function (e.g., ''summarize'', ''expand'') ==== 2. Profile Prompts ==== * Located in the ''dokullm:profiles:[PROFILE_NAME]:'' namespace * Allow for different prompt configurations for different use cases * Can override default prompts selectively * Activated through plugin configuration ==== 3. Custom Prompts ==== * Can be created in custom namespaces under ''dokullm:profiles:'' * Completely override default and profile prompts * Allow for organization-specific customizations * Take precedence over all other prompt types ===== Prompt Structure ===== Each prompt page follows a simple structure with placeholders: ==== Simple Prompt Format ==== * Contains direct instructions to the LLM * Uses placeholders for dynamic content insertion * Does not require complex sectioning ===== Available Placeholders ===== The plugin provides several placeholders that can be used in prompts: ==== Content Placeholders ==== **{text}** * The main content being processed * Could be the entire document or selected text * Automatically populated by the plugin **{template}** * Content of the template associated with this page * Used when applying template-based structures **{examples}** * Example content related to the current task * Helps guide the LLM with specific examples **{snippets}** * Relevant text snippets from similar documents * Provides context from related content **{previous}** * Content from a previous version or related page * Useful for continuation or comparison tasks **{prompt}** * Custom instructions provided by the user * Allows for dynamic user input ==== Context Placeholders ==== **{current_date}** * Current date in ISO format * Useful for time-sensitive operations **{previous_date}** * Date of previous related document * Useful for tracking changes over time **{action}** * The current action being performed * Can be used for action-specific instructions **{think}** * Thinking mode indicator (/think or /no_think) * Controls whether reasoning process is shown ===== Creating Custom Prompts ===== ==== Basic Process ==== 1. **Identify the Action** * Determine which action you want to customize * Check existing prompt names in the ''dokullm:profiles:default:'' namespace 2. **Create Prompt Page** * Create a new page with the same name in your profile namespace * Use the same structure as existing prompts 3. **Add Placeholders** * Incorporate relevant placeholders for dynamic content * Ensure all required placeholders are included 4. **Test and Refine** * Test the prompt with various content types * Refine based on the quality of results ==== Example Prompt Structure ==== A typical prompt page might look like this: Summarize the following text in a concise manner: {text} ===== System Prompt Extensions ===== The plugin supports a hierarchical system prompt architecture: ==== Base System Prompt ==== * Located at ''dokullm:profiles:[PROFILE_NAME]:system'' * Provides the foundational instructions for the LLM ==== Action-Specific Extensions ==== * Located at ''dokullm:profiles:[PROFILE_NAME]:[ACTION_NAME]:system'' * Automatically appended to the base system prompt * Provides action-specific guidance ===== Prompt Best Practices ===== ==== Writing Effective Prompts ==== * **Be Specific**: Clearly define the task and expected output * **Provide Context**: Include relevant background information * **Use Examples**: Show examples of desired output format * **Set Constraints**: Define limitations on length, style, or content * **Guide Formatting**: Specify output format requirements ==== Placeholder Usage ==== * **Always Include Required Placeholders**: Missing placeholders can cause errors * **Use Contextual Placeholders**: Only include placeholders that add value * **Test Placeholder Substitution**: Verify that placeholders are correctly replaced * **Document Custom Placeholders**: If adding new placeholders, document their purpose ==== Organization and Maintenance ==== * **Consistent Naming**: Use consistent naming conventions for prompt pages * **Version Control**: Keep prompts under version control * **Documentation**: Document significant changes to prompts * **Backup**: Keep backups of working prompt configurations ===== Troubleshooting Prompts ===== Common issues and solutions: * **Empty Responses**: Check that all required placeholders are provided * **Irrelevant Content**: Improve context and constraints in the prompt * **Formatting Issues**: Be more specific about output format requirements * **Performance Problems**: Simplify prompts or reduce context length * **Inconsistent Results**: Add more specific guidance and examples For debugging prompt issues, enable debug logging in the plugin configuration to see the actual prompts being sent to the LLM.