1====== DokuLLM Plugin - Prompt System ====== 2 3This document explains how the DokuLLM plugin's prompt system works, including prompt hierarchy, available placeholders, and how to customize prompts. 4 5===== Prompt Hierarchy ===== 6 7The DokuLLM plugin uses a hierarchical prompt system that allows for flexible customization: 8 9==== 1. Default Prompts ==== 10 * Located in ''lib/plugins/dokullm/doc/default/'' 11 * These are the base prompts that ship with the plugin 12 * Used when no custom prompts are defined 13 * Named according to their function (e.g., ''write.txt'', ''analyze.txt'') 14 15==== 2. Profile Prompts ==== 16 * Located in ''lib/plugins/dokullm/doc/profiles/'' 17 * Allow for different prompt configurations for different use cases 18 * Can override default prompts selectively 19 * Activated through plugin configuration 20 21==== 3. Custom Prompts ==== 22 * Can be placed in ''lib/plugins/dokullm/doc/custom/'' 23 * Completely override default and profile prompts 24 * Allow for organization-specific customizations 25 * Take precedence over all other prompt types 26 27===== Prompt Structure ===== 28 29Each prompt file follows a specific structure: 30 31==== System Section ==== 32 * Defines the role and behavior of the LLM 33 * Provides context about the task 34 * Sets expectations for the response format 35 36==== User Section ==== 37 * Contains the actual instruction 38 * Incorporates user content and context 39 * Uses placeholders for dynamic content 40 41==== Output Format ==== 42 * Specifies how the response should be structured 43 * May include examples of expected output 44 * Helps ensure consistent results 45 46===== Available Placeholders ===== 47 48The plugin provides several placeholders that can be used in prompts: 49 50==== Content Placeholders ==== 51 52**{{content}}** 53 * The main content being processed 54 * Could be the entire document or selected text 55 * Automatically populated by the plugin 56 57**{{selected_text}}** 58 * Specifically the text selected by the user 59 * Empty if no text was selected 60 * Useful for targeted operations 61 62==== Context Placeholders ==== 63 64**{{page_title}}** 65 * The title of the current wiki page 66 * Helps provide context to the LLM 67 68**{{page_id}}** 69 * The internal ID of the current page 70 * Useful for referencing or tracking 71 72**{{namespace}}** 73 * The namespace/category of the current page 74 * Can be used for domain-specific processing 75 76==== Metadata Placeholders ==== 77 78**{{template}}** 79 * Content of the template associated with this page 80 * Used when applying template-based structures 81 82**{{examples}}** 83 * Example content related to the current task 84 * Helps guide the LLM with specific examples 85 86**{{previous_content}}** 87 * Content from a previous version or related page 88 * Useful for continuation or comparison tasks 89 90==== Configuration Placeholders ==== 91 92**{{model}}** 93 * The LLM model being used 94 * Can be referenced in model-specific instructions 95 96**{{language}}** 97 * The language setting of the wiki 98 * Useful for language-specific processing 99 100**{{date}}** 101 * Current date in ISO format 102 * Useful for time-sensitive operations 103 104===== Creating Custom Prompts ===== 105 106==== Basic Process ==== 107 1081. **Identify the Action** 109 * Determine which action you want to customize 110 * Check existing prompt names in ''doc/default/'' 111 1122. **Create Prompt File** 113 * Create a new file with the same name in your custom directory 114 * Use the same structure as existing prompts 115 1163. **Add Placeholders** 117 * Incorporate relevant placeholders for dynamic content 118 * Ensure all required placeholders are included 119 1204. **Test and Refine** 121 * Test the prompt with various content types 122 * Refine based on the quality of results 123 124==== Example Prompt Structure ==== 125 126A typical prompt file might look like this: 127 128``` 129You are an expert content assistant helping with {{page_title}}. 130 131Your task is to {{action_description}}. 132 133Use the following content as your source: 134{{content}} 135 136When responding: 1371. Be concise but thorough 1382. Use clear, professional language 1393. Format your response in DokuWiki syntax 1404. Focus specifically on the selected text if provided 141 142Provide your response below: 143``` 144 145===== Prompt Variables ===== 146 147The plugin supports dynamic variables in prompts: 148 149==== Action-Specific Variables ==== 150 * **{{action}}** - The current action being performed 151 * **{{action_description}}** - Description of the action 152 * **{{expected_output}}** - Description of expected output format 153 154==== User Variables ==== 155 * **{{user_prompt}}** - Custom instructions provided by the user 156 * **{{user_role}}** - Role of the user (if configured) 157 * **{{user_preferences}}** - User-specific preferences 158 159===== Prompt Best Practices ===== 160 161==== Writing Effective Prompts ==== 162 163 * **Be Specific**: Clearly define the task and expected output 164 * **Provide Context**: Include relevant background information 165 * **Use Examples**: Show examples of desired output format 166 * **Set Constraints**: Define limitations on length, style, or content 167 * **Guide Formatting**: Specify output format requirements 168 169==== Placeholder Usage ==== 170 171 * **Always Include Required Placeholders**: Missing placeholders can cause errors 172 * **Use Contextual Placeholders**: Only include placeholders that add value 173 * **Test Placeholder Substitution**: Verify that placeholders are correctly replaced 174 * **Document Custom Placeholders**: If adding new placeholders, document their purpose 175 176==== Organization and Maintenance ==== 177 178 * **Consistent Naming**: Use consistent naming conventions for prompt files 179 * **Version Control**: Keep prompts under version control 180 * **Documentation**: Document significant changes to prompts 181 * **Backup**: Keep backups of working prompt configurations 182 183===== Troubleshooting Prompts ===== 184 185Common issues and solutions: 186 187 * **Empty Responses**: Check that all required placeholders are provided 188 * **Irrelevant Content**: Improve context and constraints in the prompt 189 * **Formatting Issues**: Be more specific about output format requirements 190 * **Performance Problems**: Simplify prompts or reduce context length 191 * **Inconsistent Results**: Add more specific guidance and examples 192 193For debugging prompt issues, enable debug logging in the plugin configuration to see the actual prompts being sent to the LLM. 194