1====== DokuLLM Plugin - Prompt System and Namespace Documentation ====== 2 3This document explains how the DokuLLM plugin's prompt system works, including the namespace structure, prompt hierarchy, available placeholders, system prompt extensions, and how to customize prompts. 4 5===== Namespace Structure ===== 6 7The ''dokullm:'' namespace in DokuWiki serves as the central configuration and prompt management system for the DokuLLM plugin. This namespace contains all the prompt templates, profiles, and system configurations that control how the LLM processes content. 8 9==== System Prompts ===== 10 11=== Main System Prompt (''dokullm:profiles:default:system'') === 12 13The system prompt is the foundational instruction set that defines the LLM's role, behavior, and capabilities. It establishes: 14 15 * Role Definition: The LLM acts as a helpful assistant specialized in text processing tasks 16 * Content Guidelines: 17 * Use clear and professional language 18 * Maintain proper DokuWiki formatting 19 * Follow structured content organization 20 * Capabilities: 21 * Access to templates, examples, and previous content 22 * Ability to retrieve relevant information 23 * Context-aware processing 24 * Safety Constraints: 25 * Focus on factual content 26 * No personal opinions 27 * Maintain professional tone 28 29=== Command-Specific System Appendages === 30 31Each action can have an additional system prompt that extends the main system prompt: 32 33 * ''create:system'' - Additional instructions for content creation 34 * ''rewrite:system'' - Guidelines for text rewriting and improvement 35 * ''summarize:system'' - Focus areas for summarization 36 * ''analyze:system'' - Analysis framework and structure 37 * ''expand:system'' - Guidelines for content expansion 38 39===== Prompt Placeholders ===== 40 41The prompts use several special placeholders that are automatically populated: 42 43==== Core Placeholders ==== 44 45 * ''{text}'' - The main content being processed 46 * ''{template}'' - Template content for structure guidance 47 * ''{examples}'' - Style examples from previous content 48 * ''{snippets}'' - Relevant text snippets from similar content 49 * ''{previous}'' - Content from previous related documents 50 * ''{prompt}'' - Custom user prompt 51 52==== Metadata Placeholders ==== 53 54 * ''{current_date}'' - Current date 55 * ''{previous_date}'' - Date of previous document (if applicable) 56 * ''{action}'' - Current action being performed 57 * ''{think}'' - Thinking mode switch (/think or /no_think) 58 59===== Template Integration ===== 60 61==== Template Metadata ==== 62 63Templates are referenced using metadata directives: 64 * ''~~LLM_TEMPLATE:template_id~~'' 65 * ''~~LLM_EXAMPLES:example1,example2~~'' 66 * ''~~LLM_PREVIOUS:previous_page_id~~'' 67 68==== Automatic Template Discovery ==== 69 70When no template is specified, the system can automatically find relevant templates based on content similarity using ChromaDB vector search. 71 72===== Context Management ===== 73 74The system provides rich context through: 75 76 1. Template Context: Structural guidance from template documents 77 2. Style Context: Examples showing preferred writing style 78 3. Content Context: Relevant snippets from similar documents 79 4. Historical Context: Previous related documents for continuity 80 81===== Thinking Process ===== 82 83When enabled, the LLM can engage in deeper reasoning processes, with the thinking output optionally displayed to users. This is controlled by the ''{think}'' placeholder which resolves to ''/think'' or ''/no_think''. 84 85===== Prompt Hierarchy ===== 86 87The DokuLLM plugin uses a hierarchical prompt system that allows for flexible customization using DokuWiki pages: 88 89==== 1. Default Prompts ==== 90 * Located in the ''dokullm:profiles:default:'' namespace 91 * These are the base prompts that ship with the plugin 92 * Used when no custom prompts are defined 93 * Named according to their function (e.g., ''summarize'', ''expand'') 94 95==== 2. Profile Prompts ==== 96 * Located in the ''dokullm:profiles:[PROFILE_NAME]:'' namespace 97 * Allow for different prompt configurations for different use cases 98 * Can override default prompts selectively 99 * Activated through plugin configuration 100 101==== 3. Custom Prompts ==== 102 * Can be created in custom namespaces under ''dokullm:profiles:'' 103 * Completely override default and profile prompts 104 * Allow for organization-specific customizations 105 * Take precedence over all other prompt types 106 107===== Prompt Structure ===== 108 109Each prompt page follows a simple structure with placeholders: 110 111==== Simple Prompt Format ==== 112 * Contains direct instructions to the LLM 113 * Uses placeholders for dynamic content insertion 114 * Does not require complex sectioning 115 116===== Available Placeholders ===== 117 118The plugin provides several placeholders that can be used in prompts: 119 120==== Content Placeholders ==== 121 122**{text}** 123 * The main content being processed 124 * Could be the entire document or selected text 125 * Automatically populated by the plugin 126 127**{template}** 128 * Content of the template associated with this page 129 * Used when applying template-based structures 130 131**{examples}** 132 * Example content related to the current task 133 * Helps guide the LLM with specific examples 134 135**{snippets}** 136 * Relevant text snippets from similar documents 137 * Provides context from related content 138 139**{previous}** 140 * Content from a previous version or related page 141 * Useful for continuation or comparison tasks 142 143**{prompt}** 144 * Custom instructions provided by the user 145 * Allows for dynamic user input 146 147==== Context Placeholders ==== 148 149**{current_date}** 150 * Current date in ISO format 151 * Useful for time-sensitive operations 152 153**{previous_date}** 154 * Date of previous related document 155 * Useful for tracking changes over time 156 157**{action}** 158 * The current action being performed 159 * Can be used for action-specific instructions 160 161**{think}** 162 * Thinking mode indicator (/think or /no_think) 163 * Controls whether reasoning process is shown 164 165===== Creating Custom Prompts ===== 166 167==== Basic Process ==== 168 1691. **Identify the Action** 170 * Determine which action you want to customize 171 * Check existing prompt names in the ''dokullm:profiles:default:'' namespace 172 1732. **Create Prompt Page** 174 * Create a new page with the same name in your profile namespace 175 * Use the same structure as existing prompts 176 1773. **Add Placeholders** 178 * Incorporate relevant placeholders for dynamic content 179 * Ensure all required placeholders are included 180 1814. **Test and Refine** 182 * Test the prompt with various content types 183 * Refine based on the quality of results 184 185==== Example Prompt Structure ==== 186 187A typical prompt page might look like this: 188 189<code> 190Summarize the following text in a concise manner: 191 192{text} 193</code> 194 195===== System Prompt Extensions ===== 196 197The plugin supports a hierarchical system prompt architecture that allows for fine-grained control over LLM behavior for specific actions. This extension mechanism enables you to provide additional context and instructions that are specific to individual operations. 198 199==== Extension Mechanism ==== 200 201The system works by automatically checking for command-specific system prompt extensions when processing any action. The extension follows this page naming convention: 202 203 ''dokullm:profiles:[PROFILE_NAME]:[ACTION_NAME]:system'' 204 205For example: 206 * ''dokullm:profiles:default:summarize:system'' 207 * ''dokullm:profiles:default:create:system'' 208 * ''dokullm:profiles:medical:analyze:system'' 209 210==== How It Works ==== 211 2121. **Base System Prompt Loading**: When any action is initiated, the main system prompt is first loaded from: 213 ''dokullm:profiles:[PROFILE_NAME]:system'' 214 2152. **Command-Specific Extension Check**: The system then checks if a command-specific system prompt extension exists: 216 ''dokullm:profiles:[PROFILE_NAME]:[ACTION_NAME]:system'' 217 2183. **Automatic Appendage**: If the extension exists, its content is automatically appended to the base system prompt with a newline separator. 219 2204. **Fallback Behavior**: If the extension doesn't exist, the system simply uses the base system prompt without any additional instructions. 221 222==== Use Cases ==== 223 224=== Action-Specific Guidelines === 225 226Command extensions are ideal for providing action-specific guidance that supplements the general system instructions. For example: 227 228Base System Prompt (''dokullm:profiles:default:system''): 229 You are a helpful assistant specialized in text processing tasks... 230 231Summarize Extension (''dokullm:profiles:default:summarize:system''): 232 When summarizing content, focus on the key findings and conclusions. 233 Create a concise executive summary that captures the most important information. 234 Limit your summary to 3-5 bullet points. 235 236Combined Result: 237 You are a helpful assistant specialized in text processing tasks... 238 [base instructions...] 239 240 When summarizing content, focus on the key findings and conclusions. 241 Create a concise executive summary that captures the most important information. 242 Limit your summary to 3-5 bullet points. 243 244=== Specialized Processing Instructions === 245 246Extensions can provide detailed processing instructions that are unique to each action: 247 * Analysis Extension: Specify analytical frameworks and evaluation criteria 248 * Comparison Extension: Define comparison methodologies and focus areas 249 * Rewrite Extension: Provide style guidelines and content restructuring rules 250 * Create Extension: Outline content generation templates and required sections 251 252==== Best Practices ==== 253 2541. **Complementary Content**: Extensions should complement, not contradict, the base system prompt 2552. **Concise Instructions**: Keep extensions focused and specific to the action 2563. **Consistent Formatting**: Maintain consistent style with the base system prompt 2574. **Profile Awareness**: Create profile-specific extensions when using multiple profiles 2585. **Testing**: Test extensions thoroughly to ensure they produce desired behavior 259 260==== Example Structure ==== 261 262 dokullm:profiles:default: 263 ├── system # Base system prompt 264 ├── summarize # Summarize action prompt 265 ├── summarize:system # Summarize-specific system extension 266 ├── expand # Expand action prompt 267 ├── expand:system # Expand-specific system extension 268 ├── grammar # Grammar action prompt 269 └── grammar:system # Grammar-specific system extension 270 271This extension mechanism provides powerful flexibility in customizing LLM behavior for different actions while maintaining a consistent foundational set of instructions. 272 273===== Prompt Best Practices ===== 274 275==== Writing Effective Prompts ==== 276 277 * **Be Specific**: Clearly define the task and expected output 278 * **Provide Context**: Include relevant background information 279 * **Use Examples**: Show examples of desired output format 280 * **Set Constraints**: Define limitations on length, style, or content 281 * **Guide Formatting**: Specify output format requirements 282 283==== Placeholder Usage ==== 284 285 * **Always Include Required Placeholders**: Missing placeholders can cause errors 286 * **Use Contextual Placeholders**: Only include placeholders that add value 287 * **Test Placeholder Substitution**: Verify that placeholders are correctly replaced 288 * **Document Custom Placeholders**: If adding new placeholders, document their purpose 289 290==== Organization and Maintenance ==== 291 292 * **Consistent Naming**: Use consistent naming conventions for prompt pages 293 * **Version Control**: Keep prompts under version control 294 * **Documentation**: Document significant changes to prompts 295 * **Backup**: Keep backups of working prompt configurations 296 297===== Troubleshooting Prompts ===== 298 299Common issues and solutions: 300 301 * **Empty Responses**: Check that all required placeholders are provided 302 * **Irrelevant Content**: Improve context and constraints in the prompt 303 * **Formatting Issues**: Be more specific about output format requirements 304 * **Performance Problems**: Simplify prompts or reduce context length 305 * **Inconsistent Results**: Add more specific guidance and examples 306 307For debugging prompt issues, enable debug logging in the plugin configuration to see the actual prompts being sent to the LLM. 308 309===== Profile System ===== 310 311==== Default Profile ==== 312 313The ''default'' profile contains standard prompts for general use cases. Each prompt in this profile is designed for specific tasks: 314 315 * create: Generate new content from scratch 316 * rewrite: Improve existing text clarity and grammar 317 * summarize: Create concise summaries 318 * expand: Add more details to topics 319 * analyze: Provide detailed analysis 320 * grammar: Check grammar and spelling 321 322==== Custom Profiles ==== 323 324Additional profiles can be created under ''dokullm:profiles:'' for specialized use cases: 325 326 * Different content types 327 * Various writing styles 328 * Organization-specific requirements 329 * Language variations 330 331===== Best Practices ===== 332 333 1. Prompt Design: Keep prompts clear and specific 334 2. Template Structure: Use consistent formatting in templates 335 3. Example Selection: Choose representative examples 336 4. Metadata Usage: Properly tag pages with relevant metadata 337 5. Profile Organization: Group related prompts in appropriate profiles 338 339The ''dokullm:'' namespace provides a flexible, extensible framework for managing LLM interactions within DokuWiki, enabling sophisticated AI-assisted content creation while maintaining consistency and quality control. 340